Exemplo n.º 1
0
        private void UpdateSelection()
        {
            selectionService.AllowWdgPropertyNotify(false);
            Rect rubberBand = new Rect(this.startPoint.Value, this.endPoint.Value);

            foreach (ContentPresenter item in this.designerCanvas.Children)
            {
                if (item == null)
                {
                    continue;
                }
                //Rect itemRect = new Rect(item.RenderSize);
                //Rect itemBounds = item.TransformToAncestor(designerCanvas).TransformBounds(itemRect);

                BaseWidgetItem widget = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(item, 0), 0) as BaseWidgetItem;

                if (widget == null || widget.Visibility != Visibility.Visible)
                {
                    continue;
                }

                if (rubberBand.Contains(widget.GetBoundingRect())) // Select Contained Mode
                //if (rubberBand.IntersectsWith(itemBounds)) // Select Intersected Mode
                {
                    if (widget.ParentID != Guid.Empty)
                    {
                        continue;
                    }
                    if (widget.IsGroup == true)
                    {
                        GroupViewModel  groupVM = widget.DataContext as GroupViewModel;
                        IGroupOperation pageVM  = designerCanvas.DataContext as IGroupOperation;
                        Guid            groupID = groupVM.widgetGID;
                        pageVM.SetGroupStatus(groupID, GroupStatus.Selected);
                    }
                    else
                    {
                        widget.IsSelected = true;
                    }
                }
                else
                {
                    if (widget.IsGroup == true)
                    {
                        GroupViewModel  groupVM = widget.DataContext as GroupViewModel;
                        IGroupOperation pageVM  = designerCanvas.DataContext as IGroupOperation;
                        Guid            groupID = groupVM.widgetGID;
                        pageVM.SetGroupStatus(groupID, GroupStatus.UnSelect);
                    }
                    else
                    {
                        widget.IsSelected = false;
                    }
                }
            }
            selectionService.AllowWdgPropertyNotify(true);
        }
Exemplo n.º 2
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            if ((e.Key == Key.F2 || e.Key == Key.Space) &&
                Keyboard.Modifiers == ModifierKeys.None &&
                SelectedItems.Count() == 1)
            {
                BaseWidgetItem item = SelectedItems.First();

                if (item != e.Source && item.IsInEditModel != true)
                {
                    item.IsInEditModel = true;
                }
            }

            base.OnKeyUp(e);
        }
Exemplo n.º 3
0
        private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.designerItem = DataContext as BaseWidgetItem;
            _infoItems.Clear();
            _groups.Clear();
            bIsMousePressMove   = false;
            bIsMouseClicked     = true;
            _totalHorizonOffset = 0;
            _totaVerticalOffset = 0;

            if (this.designerItem != null)
            {
                this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
                this.designerCanvas  = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this.designerItem))) as DesignerCanvas;
                _page = (designerCanvas.DataContext as IPagePropertyData).ActivePage;
            }
        }
Exemplo n.º 4
0
        protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseUp(e);

            e.Handled = false;
            BaseWidgetItem wdg = e.Source as BaseWidgetItem;

            if (wdg == null || wdg != this)
            {
                return;
            }
            if (IsAfterDraged == false)
            {
                SelectCurrentWidget();
            }
            IsAfterDraged = false;
        }
Exemplo n.º 5
0
        protected void OnPreviewMouseDown2222(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseDown(e);
            _isSelectedDone = false;
            e.Handled       = false;

            if (IsInEditModel == false)
            {
                Focus();
            }
            //return;

            BaseWidgetItem wdg = e.Source as BaseWidgetItem;

            if (wdg == null)
            {
                return;
            }

            if (wdg.ParentID == Guid.Empty)
            {
                ClickPageWidget();
            }
            else
            {
                DesignerCanvas  designer    = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;
                IGroupOperation pageVM      = designer.DataContext as IGroupOperation;
                GroupStatus     groupStatus = pageVM.GetGroupStatus(this.ParentID);
                if (groupStatus == GroupStatus.UnSelect)
                {
                    ClickGroupChildInUnselected();
                }
                else if (groupStatus == GroupStatus.Selected)
                {
                    ClickGroupChildInSelected();
                }
                else if (groupStatus == GroupStatus.Edit)
                {
                    ClickGroupChildInEdited();
                }
            }
        }
Exemplo n.º 6
0
        public void SelectCurrentWidget()
        {
            _isSelectedDone = false;


            if (IsInEditModel == false)
            {
                Focus();
            }
            //return;


            BaseWidgetItem wdg = this as  BaseWidgetItem;

            if (wdg.ParentID == Guid.Empty)
            {
                ClickPageWidget();
            }
            else
            {
                DesignerCanvas  designer    = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;
                IGroupOperation pageVM      = designer.DataContext as IGroupOperation;
                GroupStatus     groupStatus = pageVM.GetGroupStatus(this.ParentID);
                if (groupStatus == GroupStatus.UnSelect)
                {
                    ClickGroupChildInUnselected();
                }
                else if (groupStatus == GroupStatus.Selected)
                {
                    ClickGroupChildInSelected();
                }
                else if (groupStatus == GroupStatus.Edit)
                {
                    ClickGroupChildInEdited();
                }
            }
        }
Exemplo n.º 7
0
        public ResizeRotateAdorner(ContentControl designerItem)
            : base(designerItem)
        {
            SnapsToDevicePixels = true;
            BaseWidgetItem item = designerItem as BaseWidgetItem;

            if (item == null)
            {
                this.chrome             = new ResizeChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
                return;
            }

            if (item.DecoChrome == DecoChromeType.HlineDecorator)
            {
                this.chrome             = new HLineChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }
            else if (item.DecoChrome == DecoChromeType.VlineDecorator)
            {
                this.chrome             = new VLineChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }
            else if (item.DecoChrome == DecoChromeType.RounedRotateDecorator)
            {
                //if (item.CanRotate==true)
                this.chrome             = new RounedRotatChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }
            else if (item.DecoChrome == DecoChromeType.RotateDecorator)
            {
                //if (item.CanRotate==true)
                this.chrome             = new ResizeRotateChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }
            else if (item.DecoChrome == DecoChromeType.NoRotateDecorator)
            {
                this.chrome             = new ResizeChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }
            else if (item.DecoChrome == DecoChromeType.HorRiszeDecorator)
            {
                this.chrome             = new HorResizeChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }
            else if (item.DecoChrome == DecoChromeType.MasterDecorator)
            {
                this.chrome             = new MasterChrome();
                this.chrome.DataContext = designerItem;
                this.visuals            = new VisualCollection(this);
                this.visuals.Add(this.chrome);
            }

            this.Loaded += (loads, loade) =>
            {
                if (timer == null)
                {
                    timer          = new DispatcherTimer();
                    timer.Interval = TimeSpan.FromMilliseconds(1);
                    timer.Tick    += (ticks, ticke) =>
                    {
                        System.Diagnostics.Debug.WriteLine("timer ticked.");
                        timer.Stop();
                        timer = null;
                        System.Threading.ThreadPool.QueueUserWorkItem(obj =>
                        {
                            System.Threading.Thread.Sleep(5);
                            this.Dispatcher.BeginInvoke((Action)(() =>
                            {
                                var ador = FindVisualParent <AdornerLayer>(this);
                                if (ador != null)
                                {
                                    ador.InvalidateMeasure();
                                    ador.InvalidateArrange();
                                }
                            }),
                                                        null);
                        });
                    };

                    timer.Start();
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            };
        }