Exemplo n.º 1
0
        private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.designerItem = DataContext as DesignerItem;

            if (this.designerItem != null)
            {
                this.designerCanvas = VisualTreeHelper.GetParent(this.designerItem) as DesignerCanvas;
                this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
            }
        }
Exemplo n.º 2
0
        private void CreatePostAt(Point position)
        {
            DesignerItem newItem = null;
            //FrameworkElement content = new RichTextBox();
            string imageFile = SelectImageFromDisk();

            if (imageFile == string.Empty)
            {
                return;
            }

            Image       content = new Image();
            BitmapImage bmImage = new BitmapImage();

            bmImage.BeginInit();
            bmImage.UriSource = new Uri(imageFile, UriKind.Absolute);
            bmImage.EndInit();
            content.Source = bmImage;

            //content.IsHitTestVisible = false;

            if (content != null)
            {
                newItem         = new DesignerItem();
                newItem.Content = content;

                if (content.MinHeight != 0 && content.MinWidth != 0)
                {
                    newItem.Width  = content.MinWidth * 2;;
                    newItem.Height = content.MinHeight * 2;
                }
                else
                {
                    newItem.Width  = 65;
                    newItem.Height = 65;
                }
                DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
                DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));
                this.Children.Add(newItem);

                this.DeselectAll();
                newItem.IsSelected = true;
            }
        }
Exemplo n.º 3
0
        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            string xamlString = e.Data.GetData("DESIGNER_ITEM") as string;

            if (!String.IsNullOrEmpty(xamlString))
            {
                DesignerItem     newItem = null;
                FrameworkElement content = XamlReader.Load(XmlReader.Create(new StringReader(xamlString))) as FrameworkElement;

                if (content != null)
                {
                    newItem         = new DesignerItem();
                    newItem.Content = content;

                    Point position = e.GetPosition(this);
                    if (content.MinHeight != 0 && content.MinWidth != 0)
                    {
                        newItem.Width  = content.MinWidth * 2;;
                        newItem.Height = content.MinHeight * 2;
                    }
                    else
                    {
                        newItem.Width  = 65;
                        newItem.Height = 65;
                    }
                    DesignerCanvas.SetLeft(newItem, Math.Max(0, position.X - newItem.Width / 2));
                    DesignerCanvas.SetTop(newItem, Math.Max(0, position.Y - newItem.Height / 2));
                    this.Children.Add(newItem);

                    this.DeselectAll();
                    newItem.IsSelected = true;
                }

                e.Handled = true;
            }
        }
Exemplo n.º 4
0
        private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.designerItem = DataContext as DesignerItem;

            if (this.designerItem != null)
            {
                this.designerCanvas = VisualTreeHelper.GetParent(this.designerItem) as DesignerCanvas;
            }
        }