Пример #1
0
        public void CreateTextPostAt(Point position)
        {
            DesignerItem newItem = null;

            UserControl content = new PostEditor();
            content.Margin = new Thickness(2, 10, 2, 2);

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

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

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

                newItem.SaveMethod = ((PostEditor)content).SavePost;
            }
        }
Пример #2
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;
            }
        }
Пример #3
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;
            }
        }
Пример #4
0
        public void DeletePost(PostEditor postEditor)
        {
            DesignerItem toBeDeleted = null;

            foreach (DesignerItem item in this.Children.OfType <DesignerItem>())
            {
                if (item.Content == postEditor)
                {
                    toBeDeleted = item;
                }
            }

            this.Children.Remove(toBeDeleted);
        }
Пример #5
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;
            }
        }
Пример #6
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;
            }
        }
Пример #7
0
        private void CreateTextPostAt(Point position, double width, double height, DateTime creationTime, string postFile, Color background)
        {
            DesignerItem newItem = null;

            UserControl content = new PostEditor();

            content.Margin = new Thickness(2, 10, 2, 2);

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

                newItem.Content = content;
                ((PostEditor)content).BackgroundColor = background;
                ((PostEditor)content).SetCreationTime(newItem.CreationTime);
                ((PostEditor)content).LoadPost(postFile);

                newItem.Width = width;
                //newItem.Height = height;

                DesignerCanvas.SetLeft(newItem, position.X);
                DesignerCanvas.SetTop(newItem, position.Y);
                this.Children.Add(newItem);

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

                newItem.SaveMethod = ((PostEditor)content).SavePost;
            }
        }
Пример #8
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;

            }
        }
Пример #9
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;
            }
        }