Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="c">UserControl</param>
        /// <param name="location"></param>
        void AddDesignerItem(object c, Point location)
        {
            DesignerItem designerItem = new DesignerItem(c);

            this.Children.Add(designerItem);

            IDesigner             idr = designerItem.Content as IDesigner;
            DesignerVisualElement dc  = idr.GetDesignerModel() as DesignerVisualElement;


            Binding canvasLeft = new Binding("Position.Location.X")
            {
                Source = dc
            };

            designerItem.SetBinding(Canvas.LeftProperty, canvasLeft);
            Binding canvasTop = new Binding("Position.Location.Y")
            {
                Source = dc
            };

            designerItem.SetBinding(Canvas.TopProperty, canvasTop);
            Binding canvasZIndex = new Binding("Position.ZIndex")
            {
                Source = dc
            };

            designerItem.SetBinding(Canvas.ZIndexProperty, canvasZIndex);
            Binding widthBind = new Binding("Size.Width")
            {
                Source = dc, Mode = BindingMode.TwoWay
            };

            designerItem.SetBinding(WidthProperty, widthBind);
            Binding heightBind = new Binding("Size.Height")
            {
                Source = dc, Mode = BindingMode.TwoWay
            };

            designerItem.SetBinding(HeightProperty, heightBind);

            dc.Position.MoveTo(location.X, location.Y);


            this.DeselectAll();
            designerItem.IsSelected = true;
            this.SelectItem         = designerItem;
        }
Пример #2
0
 private void  OnLoaded(object sender, RoutedEventArgs e)
 {
     this.designerItem = DataContext as DesignerItem;
     this.OriginPoint  = this.designerItem.TranslatePoint(
         new Point(this.designerItem.ActualWidth * this.designerItem.RenderTransformOrigin.X,
                   this.designerItem.ActualHeight * this.designerItem.RenderTransformOrigin.Y),
         this._parent);
     //Binding bd = new Binding()
     //{
     //    Path = new PropertyPath("RenderTransformOrigin"),
     //    Source = this.designerItem,
     //    Converter = (IValueConverter)(new PointMarginConverter()),
     //    ConverterParameter = new Size((designerItem.Content as FrameworkElement).ActualWidth, (designerItem.Content as FrameworkElement).ActualHeight)
     //};
     //BindingOperations.SetBinding(this, Thumb.MarginProperty, bd);
 }
Пример #3
0
        /// <summary>
        /// 已经开始拖放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this._beMovedItem = DataContext as DesignerItem;
            sp = Mouse.GetPosition(this._parent);
            if (this._beMovedItem != null)
            {
                this._parent    = VisualTreeHelper.GetParent(this._beMovedItem) as DesignerCanvas;
                this._transform = this._beMovedItem.RenderTransform as RotateTransform;

                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this._parent);
                if (adornerLayer != null)
                {
                    this._infoAdorner = new LocationInfoAdorner(this._beMovedItem);
                    adornerLayer.Add(this._infoAdorner);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 已经开始拖放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LineThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this._parentItem = DataContext as DesignerItem;

            if (this._parentItem != null)
            {
                this._line = _parentItem.Content as Line;
                //初始化起点终点

                this._parentCanvas = VisualTreeHelper.GetParent(this._parentItem) as DesignerCanvas;

                this._transform = this._line.RenderTransform as RotateTransform;

                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this._parentCanvas);
                if (adornerLayer != null)
                {
                    //TODO
                    //this._infoAdorner = new LineAdorner(this._line);
                    //adornerLayer.Add(this._infoAdorner);
                }
            }
        }