資源簡介
private void SetPopupPosition()
{
if (colorBoard != null && Application.Current != null && Application.Current.Host != null && Application.Current.Host.Content != null)
{
double contentheight = Application.Current.Host.Content.ActualHeight;
double contentwidth = Application.Current.Host.Content.ActualWidth;
double colorboardheight = colorBoard.ActualHeight;
double colorboardwidth = colorBoard.ActualWidth;
double pickerheight = ActualHeight;
double pickerwidth = ActualWidth;
if (rootElement != null)
{
GeneralTransform transform = rootElement.TransformToVisual(null);
if (transform != null)
{
Point point00 = transform.Transform( new Point(0.0, 0.0));
Point point10 = transform.Transform( new Point(1.0, 0.0));
Point point01 = transform.Transform( new Point(0.0, 1.0));
double x00 = point00.X;
double y00 = point00.Y;
double x = x00;
double y = y00 pickerheight;
if (contentheight < (y colorboardheight))
{
y = y00 - colorboardheight;
}
if (contentwidth < (x colorboardwidth))
{
x = x00 pickerwidth - colorboardwidth;
}
popupDropDown.HorizontalOffset = 0.0;
popupDropDown.VerticalOffset = 0.0;
canvasOutsidePopup.Width = contentwidth;
canvasOutsidePopup.Height = contentheight;
colorBoard.HorizontalAlignment = HorizontalAlignment.Left;
colorBoard.VerticalAlignment = VerticalAlignment.Top;
Canvas.SetLeft(colorBoard, x - x00);
Canvas.SetTop(colorBoard, y - y00);
Matrix identity = Matrix.Identity;
identity.M11 = point10.X - point00.X;
identity.M12 = point10.Y - point00.Y;
identity.M21 = point01.X - point00.X;
identity.M22 = point01.Y - point00.Y;
identity.OffsetX = point00.X;
identity.OffsetY = point00.Y;
MatrixTransform matrixtransform = new MatrixTransform();
InvertMatrix(ref identity);
matrixtransform.Matrix = identity;
canvasOutsidePopup.RenderTransform = matrixtransform;
}
}
}
}
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Net;
using?System.Windows;
using?System.Windows.Controls;
using?System.Windows.Documents;
using?System.Windows.Input;
using?System.Windows.Media;
using?System.Windows.Media.Animation;
using?System.Windows.Shapes;
namespace?SilverlightControls
{
????public?partial?class?App?:?Application
????{
????????public?App()
????????{
????????????this.Startup?+=?this.Application_Startup;
????????????this.Exit?+=?this.Application_Exit;
????????????this.UnhandledException?+=?this.Application_UnhandledException;
????????????InitializeComponent();
????????}
????????private?void?Application_Startup(object?sender?StartupEventArgs?e)
????????{
????????????this.RootVisual?=?new?MainPage();
????????}
????????private?void?Application_Exit(object?sender?EventArgs?e)
????????{
????????}
????????private?void?Application_UnhandledException(object?sender?ApplicationUnhandledExceptionEvent
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2010-12-30?14:06??SilverlightControls\
?????文件?????????302??2010-12-08?14:17??SilverlightControls\App.xaml
?????文件????????2409??2010-12-08?14:17??SilverlightControls\App.xaml.cs
?????目錄???????????0??2010-12-30?11:06??SilverlightControls\ColorPicker\
?????文件???????18520??2010-12-16?15:45??SilverlightControls\ColorPicker\ColorBoard.cs
?????文件????????6093??2010-12-10?10:35??SilverlightControls\ColorPicker\ColorHelper.cs
?????文件????????9126??2010-12-16?15:42??SilverlightControls\ColorPicker\ColorPicker.cs
?????文件???????28497??2010-12-13?17:30??SilverlightControls\ColorPicker\PredefinedColor.cs
?????文件????????4639??2010-12-14?16:09??SilverlightControls\ColorPicker\PredefinedColorItem.cs
?????文件????????3773??2010-12-18?14:52??SilverlightControls\MainPage.xaml
?????文件?????????846??2010-12-25?13:57??SilverlightControls\MainPage.xaml.cs
?????目錄???????????0??2010-12-30?14:05??SilverlightControls\Properties\
?????文件?????????207??2010-12-08?14:17??SilverlightControls\Properties\AppManifest.xm
?????文件????????1427??2010-12-08?14:17??SilverlightControls\Properties\AssemblyInfo.cs
?????文件????????5449??2010-12-25?13:49??SilverlightControls\SilverlightControls.csproj
?????文件?????????927??2010-12-08?14:17??SilverlightControls\SilverlightControls.sln
?????文件???????16896??2010-12-30?14:06??SilverlightControls\SilverlightControls.suo
?????目錄???????????0??2010-12-30?11:06??SilverlightControls\Themes\
?????文件???????45979??2010-12-16?15:54??SilverlightControls\Themes\Generic.xaml
?????文件?????????191??2010-12-12?14:02??SilverlightControls\Themes\Transparent.PNG
評論
共有 條評論