상속: Transform, IMatrixTransform
예제 #1
0
        private void InitManipulationTransforms()
        {
            _transformGroup = new TransformGroup();
            _compositeTransform = new CompositeTransform();
            _previousTransform = new MatrixTransform() { Matrix = Matrix.Identity };

            _transformGroup.Children.Add(_previousTransform);
            _transformGroup.Children.Add(_compositeTransform);

            ManipulateMe.RenderTransform = _transformGroup;
        }
        private void InitManipulationTransforms()
        {
            transforms = new TransformGroup();
            previousTransform = new MatrixTransform() { Matrix = Matrix.Identity };
            deltaTransform = new CompositeTransform();

            transforms.Children.Add(previousTransform);
            transforms.Children.Add(deltaTransform);

            // Set the render transform on the rect
            manipulateMe.RenderTransform = transforms;
        }
예제 #3
0
        public MainPage()
        {
            this.InitializeComponent();

            //	this.ManipulationMode = ManipulationModes.Rotate | ManipulationModes.Scale | ManipulationModes.TranslateX | ManipulationModes.TranslateY;
            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 TileUC();
                    Canvas.SetLeft(t, x * 256d);
                    Canvas.SetTop(t, y * 256d);
                    this.Content.Children.Add(t);
                }
            }
        }
        /// <summary>
        /// Called whenever the control's template changes.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            // Save existing content and remove it from the visual tree
            FrameworkElement savedContent = Child;
            Child = null;

            // Apply new template
            base.OnApplyTemplate();

            // Find template parts
            _layoutRoot = GetTemplateChild("LayoutRoot") as Panel;
            _matrixTransform = GetTemplateChild("MatrixTransform") as MatrixTransform;

            // Restore saved content
            Child = savedContent;

            // Apply the current transform
            TransformUpdated();
        } 
예제 #5
0
        private void DivideGrid(int countGamers)
        {
            try
            {
                double angle = 360.0 / countGamers;
                double transformAngleLine = -90;
                double transformAngleNumber = 0;
                for (int i = 0; i < countGamers; i++)
                {
                    Line myLine = new Line();
                    transformAngleLine += angle;
                    transformAngleNumber = transformAngleLine - angle / 2;
                    string nameLine = "myLine" + i.ToString();
                    myLine.Stroke = new SolidColorBrush(colorLine);
                    myLine.X1 = LayoutRoot.ActualWidth / 2;
                    myLine.X2 = LayoutRoot.ActualWidth;
                    myLine.Y1 = LayoutRoot.ActualHeight / 2;
                    myLine.Y2 = LayoutRoot.ActualHeight / 2;
                    myLine.StrokeThickness = 3;
                    myLine.SetValue(Grid.RowProperty, 0);
                    myLine.SetValue(Grid.RowSpanProperty, 2);
                    myLine.Name = nameLine;
                    RotateTransform MyTransform = new RotateTransform();
                    myLine.RenderTransform = MyTransform;
                    myLine.RenderTransformOrigin = new Point(0.5, 0.5);
                    MyTransform.Angle = transformAngleLine;
                    LayoutRoot.Children.Add(myLine);

                    TextBlock numberGamer = new TextBlock();
                    numberGamer.Name = "number" + i.ToString();
                    numberGamer.Text = (i + 1).ToString();
                    numberGamer.HorizontalAlignment = HorizontalAlignment.Center;
                    numberGamer.VerticalAlignment = VerticalAlignment.Center;
                    numberGamer.FontSize = GridNumberGamer.ActualHeight * 80 / 100;
                    numberGamer.TextWrapping = TextWrapping.NoWrap;
                    numberGamer.FontFamily = new FontFamily("Comic Sans MS");

                    Border b = new Border();
                    Border b2 = new Border();
                    b.BorderThickness = b2.BorderThickness = new Thickness(3);
                    b.CornerRadius = b2.CornerRadius = new CornerRadius(20);
                    b.BorderBrush = b2.BorderBrush = new SolidColorBrush(colorLine);
                    b.Child = numberGamer;
                    b.Height = b.Width = b2.Height = b2.Width = GridNumberGamer.ActualHeight;

                    if (GridNumberGamer.ActualHeight > GridNumberGamer.ColumnDefinitions[1].ActualWidth)
                    {
                        b.Margin = b2.Margin = new Thickness(0, 0, -GridNumberGamer.ActualHeight + GridNumberGamer.ColumnDefinitions[1].ActualWidth, 0);
                    }
                    b2.Background = new SolidColorBrush(Colors.Black);
                    b2.Opacity = 0.4;
                    var radius = LayoutRoot.ActualHeight / 2 * 84 / 100;

                    var y0 = LayoutRoot.ActualHeight / 2 * 84 / 100;
                    var х1 = (Math.Cos(Math.PI * transformAngleNumber / 180) * radius);
                    var у1 = y0 + (Math.Sin(Math.PI * transformAngleNumber / 180) * radius);
                    MatrixTransform matrixTransform = new MatrixTransform();
                    b.RenderTransform = b2.RenderTransform = matrixTransform;
                    matrixTransform.Matrix = new Matrix(1, 0, 0, 1, х1, у1);

                    b2.SetValue(Grid.ColumnProperty, 1);
                    b.SetValue(Grid.ColumnProperty, 1);
                    GridNumberGamer.Children.Add(b2);
                    GridNumberGamer.Children.Add(b);
                    backButton.Height = GridNumberGamer.ActualHeight;
                }

                BottleImage = new Image();
                BottleImage.Name = "bottleImage";
                BottleImage.Source = new BitmapImage(new Uri(bottleRepository.GetBottle(numberBottle).Path, UriKind.RelativeOrAbsolute));
                BottleImage.RenderTransformOrigin = new Point(0.5, 0.5);
                RotateTransform rotateBottle = new RotateTransform();
                rotateBottle.Angle = 10;
                BottleImage.RenderTransform = rotateBottle;
                BottleImage.SetValue(Grid.RowProperty, 0);
                BottleImage.SetValue(Grid.RowSpanProperty, 2);
                BottleImage.Tapped += bottleImage_Start;
                BottleImage.PointerPressed += bottleImage_PointerPressed;
                BottleImage.Height = GridBottle.ActualHeight;
                BottleImage.HorizontalAlignment = HorizontalAlignment.Center;
                BottleImage.VerticalAlignment = VerticalAlignment.Center;
                LayoutRoot.Children.Add(BottleImage);
            }
            catch (Exception ex)
            {
                var a = ex.Message;
            }
        }
예제 #6
0
        private void InitManipulationTransforms()
        {
            //Initialize the transforms
            transformGroup = new TransformGroup();
            compositeTransform = new CompositeTransform();
            previousTransform = new MatrixTransform() { Matrix = Matrix.Identity };

            transformGroup.Children.Add(previousTransform);
            transformGroup.Children.Add(compositeTransform);

            ManipulateMe.RenderTransform = transformGroup;
        }
예제 #7
0
        protected override void OnApplyTemplate()
        {
            // Apply new template
            base.OnApplyTemplate();
            // Find template parts
            _transformRoot = GetTemplateChild(TransformRootName) as Grid;
            _contentPresenter = GetTemplateChild(PresenterName) as ContentPresenter;
            _matrixTransform = new MatrixTransform();
            if (null != _transformRoot)
            {
                _transformRoot.RenderTransform = _matrixTransform;
            }

            // Apply the current transform
            ApplyLayoutTransform();
        }
        public void InitializeTransforms()
        {
            cumulativeTransform = new TransformGroup();
            deltaTransform = new CompositeTransform();
            previousTransform = new MatrixTransform() { Matrix = Matrix.Identity };

            cumulativeTransform.Children.Add(previousTransform);
            cumulativeTransform.Children.Add(deltaTransform);

            element.RenderTransform = cumulativeTransform;
        }