コード例 #1
0
        private void CreateSprite()
        {
            //contentPanel
            contentPanel = new Grid();
            contentPanel.VerticalAlignment   = VerticalAlignment.Center;
            contentPanel.HorizontalAlignment = HorizontalAlignment.Center;
            EnsureTransform(contentPanel);

            //LTPoint
            LTPoint                     = new Ellipse();
            LTPoint.Fill                = new SolidColorBrush(Colors.Red);
            LTPoint.Width               = 1d;
            LTPoint.Height              = 1d;
            LTPoint.VerticalAlignment   = VerticalAlignment.Top;
            LTPoint.HorizontalAlignment = HorizontalAlignment.Left;
            EnsureTransform(LTPoint);

            //RBPoint
            RBPoint                     = new Ellipse();
            RBPoint.Fill                = new SolidColorBrush(Colors.Red);
            RBPoint.Width               = 1d;
            RBPoint.Height              = 1d;
            RBPoint.VerticalAlignment   = VerticalAlignment.Bottom;
            RBPoint.HorizontalAlignment = HorizontalAlignment.Right;
            EnsureTransform(RBPoint);

            //centerPoint
            centerPoint                     = new Ellipse();
            centerPoint.Fill                = new SolidColorBrush(Colors.Red);
            centerPoint.Width               = 1d;
            centerPoint.Height              = 1d;
            centerPoint.VerticalAlignment   = VerticalAlignment.Center;
            centerPoint.HorizontalAlignment = HorizontalAlignment.Center;
            EnsureTransform(centerPoint);

            contentPanel.Children.Add(LTPoint);
            contentPanel.Children.Add(RBPoint);
            contentPanel.Children.Add(centerPoint);

            if (this.SpriteType == SpriteType.Image)
            {
                ////borderWhite
                //borderWhite = new Rectangle();
                //borderWhite.IsHitTestVisible = false;
                //borderWhite.Fill = new SolidColorBrush(Colors.White);
                //borderWhite.Margin = new Thickness(-BORDER_WHITE_THICKNESS);
                //contentPanel.Children.Add(borderWhite);

                //spriteFrame
                spriteFrame        = new SpriteFrame();
                spriteFrame.Margin = new Thickness(FRAME_MARGIN);
                contentPanel.Children.Add(spriteFrame);

                //image
                image           = new Image();
                image.Stretch   = Stretch.Uniform;
                image.CacheMode = new BitmapCache();
                contentPanel.Children.Add(image);
                contentPanel.MaxWidth  = 150d;
                contentPanel.MaxHeight = 200d;
            }
            else if (this.SpriteType == SpriteType.Text)
            {
                spriteText                 = new SpriteTextBox();
                spriteText.TextChanged    += spriteText_TextChanged;
                spriteText.EditingStarted += spriteText_EditingStarted;
                spriteText.EditingEnded   += spriteText_EditingEnded;
                contentPanel.Children.Add(spriteText);
                contentPanel.MaxWidth  = 300d;
                contentPanel.MinHeight = 80d;
            }

            //AttachManipulationEvents();
        }
コード例 #2
0
        private void CreateSprite()
        {
            //contentPanel
            contentPanel = new Grid();
            contentPanel.VerticalAlignment   = VerticalAlignment.Center;
            contentPanel.HorizontalAlignment = HorizontalAlignment.Center;
            contentPanel.Margin = new Thickness(-99999);
            EnsureTransform(contentPanel);

            //LTPoint
            LTPoint                     = new Ellipse();
            LTPoint.Fill                = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            LTPoint.Width               = 1d;
            LTPoint.Height              = 1d;
            LTPoint.VerticalAlignment   = VerticalAlignment.Top;
            LTPoint.HorizontalAlignment = HorizontalAlignment.Left;
            EnsureTransform(LTPoint);

            //RTPoint
            RTPoint                     = new Ellipse();
            RTPoint.Fill                = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            RTPoint.Width               = 1d;
            RTPoint.Height              = 1d;
            RTPoint.VerticalAlignment   = VerticalAlignment.Top;
            RTPoint.HorizontalAlignment = HorizontalAlignment.Right;
            EnsureTransform(RTPoint);

            //LBPoint
            LBPoint                     = new Ellipse();
            LBPoint.Fill                = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            LBPoint.Width               = 1d;
            LBPoint.Height              = 1d;
            LBPoint.VerticalAlignment   = VerticalAlignment.Bottom;
            LBPoint.HorizontalAlignment = HorizontalAlignment.Left;
            EnsureTransform(LBPoint);

            //RBPoint
            RBPoint                     = new Ellipse();
            RBPoint.Fill                = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            RBPoint.Width               = 1d;
            RBPoint.Height              = 1d;
            RBPoint.VerticalAlignment   = VerticalAlignment.Bottom;
            RBPoint.HorizontalAlignment = HorizontalAlignment.Right;
            EnsureTransform(RBPoint);

            //centerPoint
            centerPoint                     = new Ellipse();
            centerPoint.Fill                = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            centerPoint.Width               = 1d;
            centerPoint.Height              = 1d;
            centerPoint.VerticalAlignment   = VerticalAlignment.Center;
            centerPoint.HorizontalAlignment = HorizontalAlignment.Center;
            EnsureTransform(centerPoint);

            contentPanel.Children.Add(LTPoint);
            contentPanel.Children.Add(RTPoint);
            contentPanel.Children.Add(LBPoint);
            contentPanel.Children.Add(RBPoint);
            contentPanel.Children.Add(centerPoint);

            if (this.SpriteType == SpriteType.Photo)
            {
                //spriteFrame
                if (EdgeEnabled || ShadowEnabled)
                {
                    spriteFrame = new SpriteFrame();
                    contentPanel.Children.Add(spriteFrame);
                }

                //image
                image           = new Image();
                image.Stretch   = Stretch.Uniform;
                image.CacheMode = new BitmapCache();
                contentPanel.Children.Add(image);
            }
            else if (this.SpriteType == SpriteType.Material)
            {
                //image
                image           = new Image();
                image.Stretch   = Stretch.Uniform;
                image.CacheMode = new BitmapCache();
                contentPanel.Children.Add(image);
            }
            else if (this.SpriteType == SpriteType.Text)
            {
                spriteText = new SpriteTextBox()
                {
                    ContainerSpriteControl = this
                };
                spriteText.TextChanged    += spriteText_TextChanged;
                spriteText.EditingStarted += spriteText_EditingStarted;
                spriteText.EditingEnded   += spriteText_EditingEnded;
                contentPanel.Children.Add(spriteText);
                contentPanel.MaxWidth  = 300d;
                contentPanel.MinHeight = 80d;
                //contentPanel.Background = new SolidColorBrush(Colors.Yellow);
            }

            //AttachManipulationEvents();
        }