private double _baseGuidelineY; // the Y guideline of the text line. /// <summary> /// Construct drawing state for full text /// </summary> internal DrawingState( DrawingContext drawingContext, Point lineOrigin, MatrixTransform antiInversion, TextMetrics.FullTextLine currentLine ) { _drawingContext = drawingContext; _antiInversion = antiInversion; _currentLine = currentLine; if (antiInversion == null) { _lineOrigin = lineOrigin; } else { _vectorToLineOrigin = lineOrigin; } if (_drawingContext != null) { // LineServices draws GlyphRun and TextDecorations in multiple // callbacks and GlyphRuns may have different baselines. Pushing guideline // for each DrawGlyphRun are too costly. We optimize for the common case where // GlyphRuns and TextDecorations in the TextLine share the same baseline. _baseGuidelineY = lineOrigin.Y + currentLine.Baseline; _drawingContext.PushGuidelineY1(_baseGuidelineY); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.lWin = ((Animation.views.left)(target)); return; case 2: this.leftGrid = ((System.Windows.Controls.Grid)(target)); return; case 3: this.LeftArrowPath = ((System.Windows.Shapes.Path)(target)); return; case 4: this.mBrush = ((System.Windows.Media.SolidColorBrush)(target)); return; case 5: this.LeftArrow = ((System.Windows.Media.MatrixTransform)(target)); return; } this._contentLoaded = true; }
public void ResetTransformations() { _ImageTransform = new MatrixTransform(); _ImageControl.RenderTransform = ImageTransform; CenterImage(); }
public static StreamGeometry StreamGeometryFromCurve(Curve curve, MatrixTransform graphToCanvas) { double[] tempX; double[] tempY; if (graphToCanvas != null) { tempX = curve.xTransformed.MultiplyBy(graphToCanvas.Matrix.M11).SumWith(graphToCanvas.Matrix.OffsetX); tempY = curve.yTransformed.MultiplyBy(graphToCanvas.Matrix.M22).SumWith(graphToCanvas.Matrix.OffsetY); } else { tempX = curve.xTransformed; tempY = curve.yTransformed; } StreamGeometry streamGeometry = new StreamGeometry(); StreamGeometryContext context = streamGeometry.Open(); int lines = 0; for (int i = 0; i < curve.x.Count(); ++i) { if (i == 0) { context.BeginFigure(new Point(tempX[i], tempY[i]), false, false); } else { if (curve.includeLinePoint[i]) { context.LineTo(new Point(tempX[i], tempY[i]), true, false); lines++; } } } context.Close(); return streamGeometry; }
public CanvasEx() :base() { ClipToBounds = true; _transform = (MatrixTransform)MatrixTransform.Identity; _translate = new TranslateTransform(-Offset.X, -Offset.Y); }
public void Set () { MatrixTransform mt = new MatrixTransform (); mt.Matrix = new Matrix (1, 2, 3, 4, 5, 6); MatrixTest.CheckMatrix (mt.Matrix, 1, 2, 3, 4, 5, 6, "custom"); Assert.IsFalse (mt.Matrix.IsIdentity, "IsNotIdentity"); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Animations = ((System.Windows.Controls.TabControl)(target)); return; case 2: this.KeyFrames = ((System.Windows.Controls.TabControl)(target)); return; case 3: this.MyPath = ((System.Windows.Shapes.Path)(target)); return; case 4: this.MyBrush = ((System.Windows.Media.SolidColorBrush)(target)); return; case 5: this.MyMatrixTransform = ((System.Windows.Media.MatrixTransform)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.tbM11 = ((System.Windows.Controls.TextBox)(target)); return; case 2: this.tbM12 = ((System.Windows.Controls.TextBox)(target)); return; case 3: this.tbM21 = ((System.Windows.Controls.TextBox)(target)); return; case 4: this.tbM22 = ((System.Windows.Controls.TextBox)(target)); return; case 5: this.tbOffsetX = ((System.Windows.Controls.TextBox)(target)); return; case 6: this.tbOffsetY = ((System.Windows.Controls.TextBox)(target)); return; case 7: #line 47 "..\..\ObjectMatrixTransforms.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.BtnApply_Click); #line default #line hidden return; case 8: #line 49 "..\..\ObjectMatrixTransforms.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.BtnClose_Click); #line default #line hidden return; case 9: this.canvas1 = ((System.Windows.Controls.Canvas)(target)); return; case 10: this.rect = ((System.Windows.Shapes.Rectangle)(target)); return; case 11: this.matrixTransform = ((System.Windows.Media.MatrixTransform)(target)); return; } this._contentLoaded = true; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.fWin = ((Animation.views.forward)(target)); #line 10 "..\..\..\views\forward.xaml" this.fWin.Loaded += new System.Windows.RoutedEventHandler(this.fWin_Loaded); #line default #line hidden return; case 2: this.ForwardGrid = ((System.Windows.Controls.Grid)(target)); return; case 3: this.ForwardArrowPath = ((System.Windows.Shapes.Path)(target)); return; case 4: this.mBrush = ((System.Windows.Media.SolidColorBrush)(target)); return; case 5: this.ForwardArrow = ((System.Windows.Media.MatrixTransform)(target)); return; } this._contentLoaded = true; }
public void Value_Matrix (bool refresh) { MatrixTransform mt = new MatrixTransform (); TransformGroup tg = new TransformGroup (); tg.Children.Add (mt); Assert.AreEqual (1, tg.Children.Count, "Children-1"); Assert.IsTrue (tg.Value.IsIdentity, "IsIdentity-1"); mt.Matrix = new Matrix (2.0, 0.0, 0.0, 0.5, 0.0, 0.0); Assert.AreEqual (1, tg.Children.Count, "Children-2"); // update was made inside TransformGroup... Assert.IsFalse ((tg.Children [0] as MatrixTransform).Matrix.IsIdentity, "IsIdentity-2"); if (refresh) { // ... but Value is not refreshed if changed "indirectly" ... Assert.IsTrue (tg.Value.IsIdentity, "IsIdentity-3"); Assert.IsFalse (mt.Matrix.Equals (tg.Value), "Matrix-3"); } // ... unless the collection is changed tg.Children.Add (new MatrixTransform ()); Assert.AreEqual (2, tg.Children.Count, "Children-4"); Assert.IsTrue (mt.Matrix.Equals (tg.Value), "Matrix-4"); }
// ******************************************************************** // Public Methods // ******************************************************************** #region Public Methods /// <summary> /// Constructor. Initializes class fields. /// </summary> public AdornerCursorCoordinateDrawer(XYLineChart xyLineChart, UIElement adornedElement, MatrixTransform shapeTransform) : base(adornedElement) { elementTransform = shapeTransform; IsHitTestVisible = false; this.xyLineChart = xyLineChart; }
public static List<Point> Generate(int n = 1000, double width = 1.0, double height = 1.0) { // Probabilities double[] p = {0.85, .92, .99, 1.00}; // Transformations var a1 = new MatrixTransform(new Matrix(0.85, -0.04, 0.04, 0.85, 0, 1.6)); var a2 = new MatrixTransform(new Matrix(0.20, 0.23, -0.26, 0.22, 0, 1.6)); var a3 = new MatrixTransform(new Matrix(-0.15, 0.26, 0.28, 0.24, 0, 0.44)); var a4 = new MatrixTransform(new Matrix(0, 0, 0, 0.16, 0, 0)); var random = new Random(); var point = new Point(0.5, 0.5); var points = new List<Point>(); // Transformation for [-3,3,0,10] => output coordinates var T = new MatrixTransform(new Matrix(width/6.0, 0, 0, -height/10.1, width/2.0, height)); for (int i = 0; i < n; i++) { var r = random.NextDouble(); if (r < p[0]) point = a1.Transform(point); else if (r < p[1]) point = a2.Transform(point); else if (r < p[2]) point = a3.Transform(point); else point = a4.Transform(point); points.Add(T.Transform(point)); } return points; }
public WpfMultiChart() { InitializeComponent(); LoadImages(); //do not show no data label by default ShowNoDataLabel(false); dataSeries = new List<TimeSeriesData>(); plotSeries = new TimeSeriesData(); shapeTransform = new MatrixTransform(); chartClip = new PathGeometry(); optimalGridLineSpacing = new Point(100, 50); adorner = new AdornerCursor2(ChartInteractiveCanvas, shapeTransform); adorner.CanvasSize = new Size(ChartInteractiveCanvas.ActualWidth, ChartInteractiveCanvas.ActualHeight); adorner.PanCursorImage = panCursor; panZoomCalculator = new PanZoomCalculator(); ChartCanvas.SizeChanged += new SizeChangedEventHandler(ChartCanvas_SizeChanged); ChartCanvas.IsVisibleChanged += new DependencyPropertyChangedEventHandler(ChartCanvas_IsVisibleChanged); NoDataLabel.MouseMove += new MouseEventHandler(NoDataLabel_MouseMove); AttachEventsToCanvas(ChartInteractiveCanvas); ResizeChart(); }
internal override PathFigureCollection GetTransformedFigureCollection(Transform transform) { // Combine the transform argument with the internal transform Transform combined = new MatrixTransform(GetCombinedMatrix(transform)); PathFigureCollection result = new PathFigureCollection(); GeometryCollection children = Children; if (children != null) { for (int i = 0; i < children.Count; i++) { PathFigureCollection pathFigures = children.Internal_GetItem(i).GetTransformedFigureCollection(combined); if (pathFigures != null) { int count = pathFigures.Count; for (int j = 0; j < count; ++j) { result.Add(pathFigures[j]); } } } } return result; }
public VisualHost(MatrixTransform graphToCanvas) { this.graphToCanvas = graphToCanvas; curveList = new List<Curve>(); _children = new VisualCollection(this); //curveGeometry = curve.ToStreamGeometry(); //_children.Add(drawingVisual); }
/// <summary> /// 取得水平翻转的视频捕获 /// </summary> /// <param name="with"></param> /// <param name="height"></param> /// <returns></returns> public Rectangle GetVideoWithFlipHorizontal(int with, int height) { Rectangle rctg = GetVideo(with, height); MatrixTransform mTransform = new MatrixTransform(); mTransform.Matrix = new Matrix(-1, 0, 0, 1, with, 0); rctg.RenderTransform = mTransform; return rctg; }
public static void PositionGeometry(XamlShapes.Shape renderedGeometry, IViewport viewport) { CounterScaleLineWidth(renderedGeometry, viewport.Resolution); var matrixTransform = new XamlMedia.MatrixTransform {Matrix = CreateTransformMatrix1(viewport)}; renderedGeometry.RenderTransform = matrixTransform; if (renderedGeometry.Fill != null) renderedGeometry.Fill.Transform = matrixTransform.Inverse as XamlMedia.MatrixTransform; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 8 "..\..\..\..\src\views\MainWindow.xaml" ((WinMaths.MainWindow)(target)).Closed += new System.EventHandler(this.Window_Closed); #line default #line hidden return; case 2: this.GridOfCanvas = ((System.Windows.Controls.Grid)(target)); return; case 3: this.XCoordLabel = ((System.Windows.Controls.Label)(target)); return; case 4: this.YCoordLabel = ((System.Windows.Controls.Label)(target)); return; case 5: this.SettingsButton = ((System.Windows.Controls.Button)(target)); return; case 6: this.ButtonPopUpLogout = ((System.Windows.Controls.Button)(target)); #line 27 "..\..\..\..\src\views\MainWindow.xaml" this.ButtonPopUpLogout.Click += new System.Windows.RoutedEventHandler(this.Window_Closed); #line default #line hidden return; case 7: this.clipBorder = ((System.Windows.Controls.Border)(target)); return; case 8: this.RepresentationCanvas = ((System.Windows.Controls.Canvas)(target)); return; case 9: this.mt = ((System.Windows.Media.MatrixTransform)(target)); return; case 10: this.ExportMenuOption = ((System.Windows.Controls.MenuItem)(target)); return; } this._contentLoaded = true; }
protected void Create(UIElement element, bool wantsCache, bool wantsTransform) { if(wantsTransform) element.RenderTransform = transform = new SWM.MatrixTransform(); if(wantsCache) element.CacheMode = new SWM.BitmapCache(); canvas.Children.Add(element); }
public void Transform(Transform transform) { var matrixTransform = new System.Windows.Media.MatrixTransform(transform.A, transform.B, transform.C, transform.D, transform.E, transform.F); dc.PushTransform(matrixTransform); if (stackDepths.Count > 0) { stackDepths[stackDepths.Count - 1]++; } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.ButtonMatrixTransform = ((System.Windows.Media.MatrixTransform)(target)); return; } this._contentLoaded = true; }
/// <summary> /// The constructor takes the geometry to hit test with. /// </summary> public GeometryHitTestParameters(Geometry geometry) : base() { // This ctor guarantees that we are initialized in the following way: // // 1. The geometry provided by the user is unmodified // 2. _hitGeometryInternal is a PathGeometry equivilent to the supplied geometry // 3. _hitGeometryInternal.Tranform is a MatrixTransform equivilent to the supplied // geometry.Transform // 4. _origBounds is the untransformed bounds of the _hitGeometryInternal (inner space). // 5. _bounds is the transformed bounds of the _hitGeometryInternal (outer space). // 6. _matrixStack is an empty stack. if (geometry == null) { throw new ArgumentNullException("geometry"); } // Convert the Geometry to an equivilent PathGeometry up front to prevent // conversion on every call to DoesContainWithDetail. If the geometry is // animate this also has the side effect of eliminating animation interplay. _hitGeometryInternal = geometry.GetAsPathGeometry(); // If GetAsPathGeometry was a no-op, force the copy because we do not // went to modify the user's Geometry. if (object.ReferenceEquals(_hitGeometryInternal, geometry)) { _hitGeometryInternal = _hitGeometryInternal.Clone(); } // Convert _hitGeometryInternal.Transform to an equivilent MatrixTransform // so that we can aggregate in PushMatrix/PopMatrix without building a // TransformCollection. Transform origTransform = _hitGeometryInternal.Transform; MatrixTransform newTransform = new MatrixTransform(); _hitGeometryInternal.Transform = newTransform; // Before we initialize MatrixTransform.Matrix, cache the bounds of this // geometry without any transforms. _origBounds = _hitGeometryInternal.Bounds; // If we had a non-Identity transform, update our MatrixTransform.Matrix // with its Value. (Note that when GetAsPathGeometry *isn't* a no-op // it applies the transform to the figures and returns with a Geometry // with an identity Transform.) if (origTransform != null && !origTransform.IsIdentity) { newTransform.Matrix = origTransform.Value; } // Initialize the current transformed bounds of this Geometry _bounds = _hitGeometryInternal.Bounds; _matrixStack = new MatrixStack(); }
public TechnoControl() { this.InitializeComponent(); tableTransform = new MatrixTransform(Matrix.Identity); this.RenderTransform = tableTransform; this.RenderTransformOrigin = new Point(0.5, 0.5); Activated = false; LayoutRoot.IsVisibleChanged += LayoutRootIsVisibleChanged; }
void Manipulation(ManipulationDeltaEventArgs e) { var mt = new MatrixTransform(ShapeUtils.GetTransform(e)); var Point1 = mt.Transform(new Point(line.X1, line.Y1)); var Point2 = mt.Transform(new Point(line.X2, line.Y2)); line.X1 = Point1.X; line.Y1 = Point1.Y; line.X2 = Point2.X; line.Y2 = Point2.Y; }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; System.Windows.Application.LoadComponent(this, new System.Uri("/Invista.Game2;component/Sprite.xaml", System.UriKind.Relative)); this.MatrixElement = ((System.Windows.Media.MatrixTransform)(this.FindName("MatrixElement"))); this.RotationElement = ((System.Windows.Media.RotateTransform)(this.FindName("RotationElement"))); this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot"))); this.ContentElement = ((System.Windows.Controls.ContentPresenter)(this.FindName("ContentElement"))); }
public MainWindow() { InitializeComponent(); this.DataContext = dataContainer; shapeContainer = new CanvasShapeContainer(); transform = new MatrixTransform(); tempForm = new Path(); newShapeIndex = 0; composite = new ShapeComposite(); }
public static void PositionGeometry(XamlShapes.Shape renderedGeometry, IViewport viewport) { CounterScaleLineWidth(renderedGeometry, viewport.Resolution); var matrixTransform = new XamlMedia.MatrixTransform { Matrix = CreateTransformMatrix1(viewport) }; renderedGeometry.RenderTransform = matrixTransform; if (renderedGeometry.Fill != null) { renderedGeometry.Fill.Transform = matrixTransform.Inverse as XamlMedia.MatrixTransform; } }
// Results from Benchmarking: // // Animated Colour Changes: // - No Cache // (Silverlight will *automatically* uncache image if it has an effect, can use no-colour-change path. yay!) // - Transform on image // - Image on canvas // - Effect on canvas // // No Colour Changes: // - Optional Cache Image (will depend on if this will split an intermediate layer) // (have an option to block caching, or disable it automatically in (pre-?)render pass based on surrounding objects) // - Tranform on Image (could be on canvas, as long as layout and transform are on the same object, no difference) // - Image on canvas (may have tiny framerate impact, negligble and lets me have identical codepath) // // Fix Colour // - Same as No Colour Changes // - Set image source to writable bitmap copy of image // - Requires hint call // // Insulating the element from the parent canvas with another canvas // seems to result in a *significant* performance boost (perhaps to do with layout) #region Options For Benchmarking // Some of these are no longer in use - for documentation only // //internal protected UIElement ApplyTransformTo { get { return element; } } //internal protected UIElement ApplyLayoutOffsetTo { get { return element; } } //internal protected UIElement ApplyEffectTo { get { return canvas; } } //internal protected UIElement ApplyCacheTo { get { return element; } } //internal protected UIElement ApplyOpacityTo { get { return element; } } //internal protected UIElement AddToRoot { get { return canvas; } } // #endregion protected void Create(UIElement element, bool wantsCache, bool wantsTransform) { if (wantsTransform) { element.RenderTransform = transform = new SWM.MatrixTransform(); } if (wantsCache) { element.CacheMode = new SWM.BitmapCache(); } canvas.Children.Add(element); }
public DLMatrixAnimation(Matrix fromValue, Matrix toValue, Duration duration, Action<object> frameCallback, IEasingFunction easingFunction = null) { FrameCallback = frameCallback; _matrixTransform = new MatrixTransform(); _matrixAnimation = new MatrixAnimation(fromValue, toValue, duration); if(easingFunction != null) { _matrixAnimation.EasingFunction = easingFunction; } _matrixAnimation.Completed += (sender, args) => { FrameCallback(_matrixAnimation.To); _matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, null); }; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.path1 = ((System.Windows.Shapes.Path)(target)); return; case 2: this.e1 = ((System.Windows.Media.EllipseGeometry)(target)); return; case 3: this.ellipse2 = ((System.Windows.Shapes.Ellipse)(target)); return; case 4: this.mt2 = ((System.Windows.Media.MatrixTransform)(target)); return; case 5: this.ellipse1 = ((System.Windows.Shapes.Ellipse)(target)); return; case 6: this.mt1 = ((System.Windows.Media.MatrixTransform)(target)); return; case 7: this.sb1 = ((System.Windows.Media.Animation.Storyboard)(target)); return; case 8: this.ma1 = ((System.Windows.Media.Animation.MatrixAnimationUsingPath)(target)); return; case 9: this.button1 = ((System.Windows.Controls.Button)(target)); #line 56 "..\..\Window1.xaml" this.button1.Click += new System.Windows.RoutedEventHandler(this.button1_Click); #line default #line hidden return; } this._contentLoaded = true; }
public MainWindow() { InitializeComponent(); this.tx = new MatrixTransform() { Matrix = Matrix.Identity }; this.Content.RenderTransform = tx; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { var t = new Tile(); Canvas.SetLeft(t, x * 256d); Canvas.SetTop(t, y * 256d); this.Content.Children.Add(t); } } }
// ------------------------------------------------------------------ // // Visual Helpers // // ------------------------------------------------------------------ #region Visual Helpers // ------------------------------------------------------------------ // Update mirroring transform. // ------------------------------------------------------------------ internal static void UpdateMirroringTransform(FlowDirection parentFD, FlowDirection childFD, ContainerVisual visualChild, double width) { // Set mirroring transform if necessary, or clear it just in case it was set in the previous // format process. if (parentFD != childFD) { MatrixTransform transform = new MatrixTransform(-1.0, 0.0, 0.0, 1.0, width, 0.0); visualChild.Transform = transform; visualChild.SetValue(FrameworkElement.FlowDirectionProperty, childFD); } else { visualChild.Transform = null; visualChild.ClearValue(FrameworkElement.FlowDirectionProperty); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.RectangleA = ((System.Windows.Shapes.Rectangle)(target)); return; case 2: this.RectangleB = ((System.Windows.Shapes.Rectangle)(target)); return; case 3: this.RectangleC = ((System.Windows.Shapes.Rectangle)(target)); return; case 4: this.RectangleD = ((System.Windows.Shapes.Rectangle)(target)); return; case 5: this.RectangleE = ((System.Windows.Shapes.Rectangle)(target)); return; case 6: this.RectangleF = ((System.Windows.Shapes.Rectangle)(target)); return; case 7: this.RectangleG = ((System.Windows.Shapes.Rectangle)(target)); return; case 8: this.RectangleA2 = ((System.Windows.Shapes.Rectangle)(target)); return; case 9: this.RectangleB2 = ((System.Windows.Shapes.Rectangle)(target)); return; case 10: this.MatrixTransform = ((System.Windows.Media.MatrixTransform)(target)); return; } this._contentLoaded = true; }
// Check for a Moonlight issue which freeze the Matrix (throwing an UnautorizedException) public static bool CheckFreezer (MatrixTransform mt) { bool result = false; Matrix m = mt.Matrix; try { // NOTE: ML DO is frozen and can't be updated mt.Matrix = m; result = true; } catch (UnauthorizedAccessException) { // Moonlight known issue } finally { mt.Matrix = Matrix.Identity; } return result; }
/// <summary> /// Default constructor. /// </summary> public MainWindow() { InitializeComponent(); // Add handlers for window availability events AddWindowAvailabilityHandlers(); // Plug our item data into our visualizations itemData = new Items.ItemData(itemDataFile); ComparedItem1.ItemData = itemData; ComparedItem2.ItemData = itemData; ComparedItem1.GotTag += OnComparedItemGotTag; ComparedItem2.GotTag += OnComparedItemGotTag; // Set up our visualization axis to track the visualizations // Use "RootGrid" as a reference container for the coordinate space to work // with visualizationAxis = new VisualizationAxis(this.RootGrid); visualizationAxis.SetVisualization1(ComparedItem1); visualizationAxis.SetVisualization2(ComparedItem2); visualizationAxis.SetMinimumLength(Table.MinWidth - 2 * tableHorizontalMargin); visualizationAxis.Show += OnShowTable; visualizationAxis.Hide += OnHideTable; visualizationAxis.Moved += OnMoveTable; // Set up a render transform to use with our comparison table tableTransform = new MatrixTransform(Matrix.Identity); Table.RenderTransform = tableTransform; Table.RenderTransformOrigin = new Point(0.5, 0.5); // Prepare a timer to hide our table when needed hideTableTimer = new DispatcherTimer(); hideTableTimer.Interval = TimeSpan.FromMilliseconds(300); hideTableTimer.Tick += OnHideTableTick; ComparisonCanvas.Loaded += OnComparisonCanvasLoaded; // Check the hardware, and modify the UI based on the supported capabilities. bool areTagsSupported = InteractiveSurface.PrimarySurfaceDevice.IsTagRecognitionSupported; if (!areTagsSupported) { TagsNotSupportedText.Visibility = Visibility.Visible; TagInfoText.Visibility = Visibility.Collapsed; } }
public bool TryGetBitmapTransform(string optionValue, IEnumerable<KeyValuePair<string, string>> settings, out Func<BitmapSource, BitmapSource> bitmapTransformerFunc) { if (optionValue.ToLower() == "x") { var matrixTransform = new MatrixTransform(-1, 0, 0, 1, 0, 0); bitmapTransformerFunc = sourceBitmap => new TransformedBitmap(sourceBitmap, matrixTransform); return true; } if(optionValue.ToLower() == "y") { var matrixTransform = new MatrixTransform(1, 0, 0, -1, 0, 0); bitmapTransformerFunc = sourceBitmap => new TransformedBitmap(sourceBitmap, matrixTransform); return true; } bitmapTransformerFunc = null; return false; }
public void Begin(GraphicsDevice device, SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Local.Matrix transformMatrix) { //transformMatrix = Matrix.Identity; Rect rect = new Rect( (device.Viewport.X), (device.Viewport.Y), device.Viewport.Width, device.Viewport.Height); if (rect != lastRect || !MatricesAreEqual(transformMatrix, lastMatrix)) { transformMatrix.M41 += device.Viewport.X; transformMatrix.M42 += device.Viewport.Y; MatrixTransform matrixTransform = new MatrixTransform(); System.Windows.Media.Matrix matrix = new System.Windows.Media.Matrix( transformMatrix.M11, transformMatrix.M12, transformMatrix.M21, transformMatrix.M22, transformMatrix.M41, transformMatrix.M42); matrixTransform.Matrix = matrix; System.Windows.Media.RectangleGeometry rectangleGeometry = new System.Windows.Media.RectangleGeometry(); rectangleGeometry.Rect = rect; MatrixTransform inverse = matrixTransform.Inverse as MatrixTransform; rectangleGeometry.Transform = inverse; Canvas.Clip = rectangleGeometry; matrixTransform.Matrix = matrix; TransformMatrix = transformMatrix; lastRect = rect; lastMatrix = transformMatrix; Canvas.Width = rect.Width; Canvas.Height = rect.Height; } InUse = true; Begin(); }
public void ApplyMatrix(double OriginX, double OriginY, double M11, double M12, double M21, double M22, double Dx, double Dy) { //var g = new TransformGroup(); //// http://social.msdn.microsoft.com/Forums/en-US/vswpfdesigner/thread/578a058e-75ac-4550-b4be-18cf9569cf5e //g.Children.Add( // new TranslateTransform( // offsetX: OriginX, // offsetY:OriginY // )); //g.Children.Add( // new MatrixTransform // { // Matrix = new Matrix // { // M11 = M11, // M12 = M12, // M21 = M21, // M22 = M22, // OffsetX = Dx - OriginX, // OffsetY = Dy - OriginY, // } // } //); var g = new MatrixTransform( m11: M11, m12: M12, m21: M21, m22: M22, offsetX: Dx - OriginX, offsetY: Dy - OriginY ); this.Element.RenderTransform = g; }
public static PathGeometry PathGeometryFromCurve(Curve curve, MatrixTransform graphToCanvas) { double xScale, xOffset, yScale, yOffset; if (graphToCanvas != null) { xScale = graphToCanvas.Matrix.M11; xOffset = graphToCanvas.Matrix.OffsetX; yScale = graphToCanvas.Matrix.M22; yOffset = graphToCanvas.Matrix.OffsetY; } else { xScale = 1; xOffset = 0; yScale = 1; yOffset = 0; } PathGeometry pathGeometry = new PathGeometry(); if (curve.x.Count() == 0) return pathGeometry; PathFigure pathFigure = new PathFigure(); LineSegment lineSegment; double xCanvas = curve.xTransformed[0] * xScale + xOffset; double yCanvas = curve.yTransformed[0] * yScale + yOffset; pathFigure.StartPoint = new Point(xCanvas, yCanvas); for (int i = 1; i < curve.x.Count(); ++i) { if (curve.includeLinePoint[i]) { lineSegment = new LineSegment(); xCanvas = curve.xTransformed[i] * xScale + xOffset; yCanvas = curve.yTransformed[i] * yScale + yOffset; lineSegment.Point = new Point(xCanvas, yCanvas); pathFigure.Segments.Add(lineSegment); } } pathFigure.IsClosed = false; pathGeometry.Figures.Add(pathFigure); return pathGeometry; }
public void PageLoaded (object sender, EventArgs e) { Rectangle reflected = FindName ("Reflected") as Rectangle; Canvas c = FindName ("Normal") as Canvas; VisualBrush vb = new VisualBrush (); TransformGroup tg = new TransformGroup (); MatrixTransform mt = new MatrixTransform (); mt.Matrix = new Matrix (1, 0, 0, -1, 0, 0); tg.Children.Add (mt); TranslateTransform tt = new TranslateTransform (); tt.Y = c.Height; tg.Children.Add (tt); vb.Transform = tg; vb.Visual = c; reflected.Fill = vb; }
public override void OnApplyTemplate() { _matrixTransform = GetTemplateChild(MatrixTransformPartName) as MatrixTransform; _rotateTransform = GetTemplateChild(RotateTransformPartName) as RotateTransform; _scaleTransform = GetTemplateChild(ScaleTransformPartName) as ScaleTransform; _skewTransform = GetTemplateChild(SkewTransformPartName) as SkewTransform; _translateTransform = GetTemplateChild(TranslateTransformPartName) as TranslateTransform; UnregisterNames(MatrixTransformPartName, RotateTransformPartName, ScaleTransformPartName, SkewTransformPartName, TranslateTransformPartName); if (_matrixTransform != null) RegisterName(MatrixTransformPartName, _matrixTransform); if (_rotateTransform != null) RegisterName(RotateTransformPartName, _rotateTransform); if (_scaleTransform != null) RegisterName(ScaleTransformPartName, _scaleTransform); if (_skewTransform != null) RegisterName(SkewTransformPartName, _skewTransform); if (_translateTransform != null) RegisterName(TranslateTransformPartName, _translateTransform); base.OnApplyTemplate(); }
public static XamlShapes.Path RenderMultiPolygon(MultiPolygon geometry, IStyle style, IViewport viewport) { if (!(style is VectorStyle)) { throw new ArgumentException("Style is not of type VectorStyle"); } var vectorStyle = style as VectorStyle; var path = CreatePolygonPath(vectorStyle, viewport.Resolution); path.Data = geometry.ToXaml(); var matrixTransform = new XamlMedia.MatrixTransform { Matrix = CreateTransformMatrix1(viewport) }; path.RenderTransform = matrixTransform; if (path.Fill != null) { path.Fill.Transform = matrixTransform.Inverse as XamlMedia.MatrixTransform; } return(path); }
public static XamlShapes.Shape RenderPolygon(Polygon polygon, IStyle style, IViewport viewport, BrushCache brushCache = null) { if (!(style is VectorStyle)) { throw new ArgumentException("Style is not of type VectorStyle"); } var vectorStyle = style as VectorStyle; XamlShapes.Path path = CreatePolygonPath(vectorStyle, viewport.Resolution, brushCache); path.Data = polygon.ToXaml(); var matrixTransform = new XamlMedia.MatrixTransform { Matrix = CreateTransformMatrix1(viewport) }; path.RenderTransform = matrixTransform; if (path.Fill != null) { path.Fill.Transform = matrixTransform.Inverse as XamlMedia.MatrixTransform; } path.UseLayoutRounding = true; return(path); }
static internal void Render( IntPtr pRenderTarget, DUCE.Channel channel, Visual visual, int width, int height, double dpiX, double dpiY, Matrix worldTransform, Rect windowClip ) { DUCE.Resource target = new DUCE.Resource(); DUCE.Resource root = new DUCE.Resource(); DUCE.ResourceHandle targetHandle = DUCE.ResourceHandle.Null; DUCE.ResourceHandle rootHandle = DUCE.ResourceHandle.Null; Matrix deviceTransform = new Matrix( dpiX * (1.0 / 96.0), 0, 0, dpiY * (1.0 / 96.0), 0, 0); deviceTransform = worldTransform * deviceTransform; MatrixTransform mtDeviceTransform = new MatrixTransform(deviceTransform); DUCE.ResourceHandle deviceTransformHandle = ((DUCE.IResource)mtDeviceTransform).AddRefOnChannel(channel); try { // ------------------------------------------------------------ // Create the composition target and root visual resources. target.CreateOrAddRefOnChannel(target, channel, DUCE.ResourceType.TYPE_GENERICRENDERTARGET); targetHandle = target.Handle; DUCE.CompositionTarget.PrintInitialize( targetHandle, pRenderTarget, width, height, channel); root.CreateOrAddRefOnChannel(root, channel, DUCE.ResourceType.TYPE_VISUAL); rootHandle = root.Handle; DUCE.CompositionNode.SetTransform( rootHandle, deviceTransformHandle, channel); DUCE.CompositionTarget.SetRoot( targetHandle, rootHandle, channel); channel.CloseBatch(); channel.Commit(); // ------------------------------------------------------------ // Render the freshly created target. RenderContext renderContext = new RenderContext(); renderContext.Initialize(channel, rootHandle); visual.Precompute(); visual.Render(renderContext, 0); // ------------------------------------------------------------ // Flush the channel and present the composition target. channel.CloseBatch(); channel.Commit(); channel.Present(); MediaContext mediaContext = MediaContext.CurrentMediaContext; mediaContext.NotifySyncChannelMessage(channel); } finally { // ------------------------------------------------------------ // Clean up and release the root visual. if (!rootHandle.IsNull) { DUCE.CompositionNode.RemoveAllChildren( rootHandle, channel); ((DUCE.IResource)visual).ReleaseOnChannel(channel); root.ReleaseOnChannel(channel); } // ------------------------------------------------------------ // Release the world transform. if (!deviceTransformHandle.IsNull) { ((DUCE.IResource)mtDeviceTransform).ReleaseOnChannel(channel); } // ------------------------------------------------------------ // Clean up and release the composition target. if (!targetHandle.IsNull) { DUCE.CompositionTarget.SetRoot( targetHandle, DUCE.ResourceHandle.Null, channel); target.ReleaseOnChannel(channel); } // ------------------------------------------------------------ // Flush the channel and present the composition target. channel.CloseBatch(); channel.Commit(); channel.Present(); MediaContext mediaContext = MediaContext.CurrentMediaContext; mediaContext.NotifySyncChannelMessage(channel); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: #line 19 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnOpenJob_Click); #line default #line hidden return; case 2: this.rdoBBOX = ((System.Windows.Controls.RadioButton)(target)); #line 32 "..\..\MainWindow.xaml" this.rdoBBOX.Click += new System.Windows.RoutedEventHandler(this.rdoBBOX_Click); #line default #line hidden return; case 3: this.rdoConvexHull = ((System.Windows.Controls.RadioButton)(target)); #line 33 "..\..\MainWindow.xaml" this.rdoConvexHull.Click += new System.Windows.RoutedEventHandler(this.rdoBBOX_Click); #line default #line hidden return; case 4: this.rdoCombineIntersect = ((System.Windows.Controls.RadioButton)(target)); #line 34 "..\..\MainWindow.xaml" this.rdoCombineIntersect.Click += new System.Windows.RoutedEventHandler(this.rdoBBOX_Click); #line default #line hidden return; case 5: this.rdoTriangulation = ((System.Windows.Controls.RadioButton)(target)); #line 35 "..\..\MainWindow.xaml" this.rdoTriangulation.Click += new System.Windows.RoutedEventHandler(this.rdoBBOX_Click); #line default #line hidden return; case 6: this.rdoEnvelopIntersection = ((System.Windows.Controls.RadioButton)(target)); #line 36 "..\..\MainWindow.xaml" this.rdoEnvelopIntersection.Click += new System.Windows.RoutedEventHandler(this.rdoBBOX_Click); #line default #line hidden return; case 7: #line 37 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.RedrawMap_Click); #line default #line hidden return; case 8: this.grdTriangulationOption = ((System.Windows.Controls.Grid)(target)); return; case 9: this.chkDrawTriangulation = ((System.Windows.Controls.CheckBox)(target)); return; case 10: this.chkIntersectTriangles = ((System.Windows.Controls.CheckBox)(target)); return; case 11: #line 57 "..\..\MainWindow.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnTypeToogle_Click); #line default #line hidden return; case 12: this.CompList = ((System.Windows.Controls.ListView)(target)); #line 58 "..\..\MainWindow.xaml" this.CompList.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.CompList_SelectionChanged); #line default #line hidden return; case 13: this.ImageView = ((System.Windows.Controls.Canvas)(target)); #line 61 "..\..\MainWindow.xaml" this.ImageView.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Canvas_MouseWheel); #line default #line hidden #line 61 "..\..\MainWindow.xaml" this.ImageView.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.ImageView_MouseLeftButtonUp); #line default #line hidden #line 62 "..\..\MainWindow.xaml" this.ImageView.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.ImageView_MouseLeftButtonDown); #line default #line hidden #line 62 "..\..\MainWindow.xaml" this.ImageView.MouseMove += new System.Windows.Input.MouseEventHandler(this.ImageView_MouseMove); #line default #line hidden return; case 14: this.mt = ((System.Windows.Media.MatrixTransform)(target)); return; case 15: this.st = ((System.Windows.Media.ScaleTransform)(target)); return; case 16: this.tt = ((System.Windows.Media.TranslateTransform)(target)); return; case 17: this.prgStatus = ((System.Windows.Controls.ProgressBar)(target)); return; case 18: this.txtProccess = ((System.Windows.Controls.TextBlock)(target)); return; } this._contentLoaded = true; }
public void Transform(Transform transform) { var matrixTransform = new System.Windows.Media.MatrixTransform(transform.A, transform.B, transform.C, transform.D, transform.E, transform.F); dc.PushTransform(matrixTransform); }
//public void PushEffect(BitmapEffect effect, BitmapEffectInput effectInput); //public void PushGuidelineSet(GuidelineSet guidelines); //public void PushOpacity(double opacity); //public void PushOpacity(double opacity, AnimationClock opacityAnimations); //public void PushOpacityMask(Brush opacityMask); public void PushTransform(MatrixTransform transform) { XMatrix matrix = _matrixStack.Peek(); matrix.Append(transform.Matrix); }
/// <summary> /// /// </summary> /// <param name="visual"></param> /// <param name="parentNode"></param> public void InternalXmlDump(DependencyObject visual, XmlNode parentNode) { if (AncestorWindow == null) { AncestorWindow = FindAncestorWindow(visual) as Window; } //Add support for BlockUIContainer if (visual is BlockUIContainer) { visual = ((BlockUIContainer)visual).Child; } //Add support for InlineUIContainer if (visual is InlineUIContainer) { visual = ((InlineUIContainer)visual).Child; } // Dump only information for UIElement (or class deriving from UIElement) if (!(visual is UIElement)) { return; } XmlNode ownerNode = PropertyDumpCore.xmldoc.CreateElement(visual.GetType().ToString()); //Get the position of the visual with respect to rootvisual and dump it as properties of the tag. GeneralTransform gt = new System.Windows.Media.MatrixTransform(); if (AncestorWindow != null && AncestorWindow is Window) { UIElement root = (UIElement)AncestorWindow.Content; gt = ((UIElement)visual).TransformToAncestor((Visual)root); } else { GlobalLog.LogEvidence(new Exception("Ancestor Window is null")); } Point origin = new Point(0, 0); Point myPoint; if (gt.TryTransform(origin, out myPoint) == false) { //A point may not always be transformable GlobalLog.LogEvidence(new ApplicationException("//TODO: Handle GeneralTransform Case - introduced by Transforms Breaking Change")); } XmlAttribute attr1 = PropertyDumpCore.xmldoc.CreateAttribute("XPos"); attr1.Value = myPoint.X.ToString("F", CultureInfo.InvariantCulture); ownerNode.Attributes.Append(attr1); XmlAttribute attr2 = PropertyDumpCore.xmldoc.CreateAttribute("YPos"); attr2.Value = myPoint.Y.ToString("F", CultureInfo.InvariantCulture); ownerNode.Attributes.Append(attr2); foreach (Package package in Filter.AllProperties) { XmlNode node = PropertyDumpCore.xmldoc.CreateElement(package.name); DumpMethodProperty(visual, package, node); if (node.InnerText != string.Empty) { ownerNode.AppendChild(node); } } FrameworkElements.Init(this); DumpCustomUIElement dumpElement = elementToDumpHandler[((UIElement)visual).GetType()] as DumpCustomUIElement; if (dumpElement != null) { dumpElement(ownerNode, (UIElement)visual); } int count = VisualTreeHelper.GetChildrenCount(visual); for (int i = 0; i < count; i++) { DependencyObject visualChild = VisualTreeHelper.GetChild(visual, i); if (visual is Viewbox) { GlobalLog.LogStatus(string.Format("ViewBox.Child is {0}", (visualChild != null) ? visualChild.GetType().ToString() : "null")); } InternalXmlDump(visualChild, ownerNode); } if (ownerNode.InnerText != string.Empty) { parentNode.AppendChild(ownerNode); } }