Exemplo n.º 1
0
        public void OnPageChildMouseUp()
        {
            DesignerCanvas designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;

            //object cc = VisualTreeHelper.GetParent(this);
            if (designer == null || IsInEditModel == true)
            {
                return;
            }

            IGroupOperation pageVM = designer.DataContext as IGroupOperation;

            //this is option for the common widget
            if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
            {
                return;
            }
            else
            {
                if (_isSelectedDone == false)
                {
                    if (IsSelected == true &&
                        designer.SelectedItems.Count() == 1)
                    {
                        return;
                    }
                    designer.DeselectAll();
                    pageVM.DeselectAllGroups();
                    this.IsSelected = true;
                }
            }
        }
Exemplo n.º 2
0
        private void ClickGroupChildInUnselected()
        {
            ClickInitialStatus = GroupStatus.UnSelect;
            DesignerCanvas  designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;
            IGroupOperation pageVM   = designer.DataContext as IGroupOperation;

            //this is option for the common widget
            if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
            {
                foreach (BaseWidgetItem item in designer.SelectedItems)
                {
                    if (item.IsSelected == true &&
                        item.ParentID != Guid.Empty)
                    {
                        return;
                    }
                }
                pageVM.SetGroupStatus(ParentID, GroupStatus.Selected);
            }
            else
            {
                designer.DeselectAll();
                pageVM.DeselectAllGroups();
                pageVM.SetGroupStatus(ParentID, GroupStatus.Selected);
            }
        }
Exemplo n.º 3
0
 protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
 {
     base.OnMouseDoubleClick(e);
     IsInEditModel = true;
     if (this.IsGroup != true)
     {
         IsSelected = true;
         DesignerCanvas  designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;
         IGroupOperation pageVM   = designer.DataContext as IGroupOperation;
         if (this.ParentID != Guid.Empty)
         {
             if (pageVM != null)
             {
                 pageVM.SetGroupStatus(ParentID, GroupStatus.Edit);
             }
         }
         else
         {
             if (pageVM != null)
             {
                 pageVM.DeselectAllGroups();
             }
         }
     }
     //Event should can continue it's route to let canvas DeSelect all other widgets selected
     e.Handled = false;
 }
Exemplo n.º 4
0
        //Old Solution, Called many times in widgets moving process
        private void MoveSelectedWidgets(object sender, DragDeltaEventArgs e)
        {
            //Get X/Y  Move Offset
            double deltaHorizontal = 0;
            double deltaVertical   = 0;

            GetMoveOffset(e, ref deltaHorizontal, ref deltaVertical);

            if (this.designerItem.ParentID == Guid.Empty)
            {
                MoveExternalElements(deltaHorizontal, deltaVertical);
            }
            else
            {
                IGroupOperation pageVM      = designerCanvas.DataContext as IGroupOperation;
                GroupStatus     groupStatus = pageVM.GetGroupStatus(this.designerItem.ParentID);
                if (groupStatus == GroupStatus.Edit)
                {
                    MoveEditedGroup(pageVM, deltaHorizontal, deltaVertical);
                }
                else if (groupStatus == GroupStatus.Selected)
                {
                    MoveSelectedGroup(pageVM, deltaHorizontal, deltaVertical);
                }
            }
        }
Exemplo n.º 5
0
 private void DeselectAllWidgets()
 {
     if (_pageVM != null)
     {
         foreach (IWidgetPropertyData widget in _pageVM.GetSelectedwidgets())
         {
             WidgetViewModBase widgetVM = widget as WidgetViewModBase;
             if (widgetVM != null)
             {
                 if (widgetVM.IsGroup)
                 {
                     // Group VM has IsSelected and GroupStatus.UnSelect property, set GroupStatus will also set IsSelected, but set
                     // set IsSelected will not set status, they are not synchronized. We use status to set group selection in undo/redo.
                     // See SelectCommand.
                     IGroupOperation pageVM = _pageVM as IGroupOperation;
                     if (pageVM != null)
                     {
                         pageVM.SetGroupStatus(widgetVM.widgetGID, GroupStatus.UnSelect);
                     }
                 }
                 else
                 {
                     widgetVM.Raw_IsSelected = false;
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
        private void MoveEditedGroup(IGroupOperation pageVM, double deltaHorizontal, double deltaVertical)
        {
            if (this.designerItem.IsSelected == false)
            {
                return;
            }

            foreach (WidgetViewModBase item in _infoItems)
            {
                if (item == _infoItems.Last())
                {
                    SendFirePositionEvent(true);
                }

                if (item.IsLocked == true)
                {
                    continue;
                }

                item.Raw_Left = item.Left + deltaHorizontal;
                item.Raw_Top  = item.Top + deltaVertical;
            }

            pageVM.UpdateGroup(this.designerItem.ParentID);
        }
Exemplo n.º 7
0
        private void MoveSelectedGroup(IGroupOperation pageVM, double deltaHorizontal, double deltaVertical)
        {
            if (_groups.Count <= 0)
            {
                this.designerCanvas.InvalidateMeasure();
                return;
            }

            //TODO:
            if (this.designerItem.IsSelected == true)
            {
                return;
            }

            foreach (WidgetViewModBase item in _infoItems)
            {
                if (item == _infoItems.Last())
                {
                    SendFirePositionEvent(true);
                }

                if (item.IsLocked == true)
                {
                    continue;
                }

                item.Raw_Left = item.Left + deltaHorizontal;
                item.Raw_Top  = item.Top + deltaVertical;
            }

            foreach (GroupViewModel it in _groups)
            {
                pageVM.UpdateGroup(it.WidgetID);
            }
        }
Exemplo n.º 8
0
        public SelectCommand(IGroupOperation pageVM, WidgetViewModBase selectedWidget)
        {
            List <WidgetViewModBase> selectedWidgetList = new List <WidgetViewModBase>();

            selectedWidgetList.Add(selectedWidget);
            CheckGroupHelper(selectedWidgetList);
            _pageVM = pageVM;
        }
Exemplo n.º 9
0
        private void PushUndoStack()
        {
            // Undo/Redo
            ISupportUndo    pageVMUndo  = designerCanvas.DataContext as ISupportUndo;
            IGroupOperation pageVMGroup = designerCanvas.DataContext as IGroupOperation;

            if (pageVMUndo == null)
            {
                return;
            }

            CompositeCommand cmds = new CompositeCommand();

            IPagePropertyData Page = designerCanvas.DataContext as IPagePropertyData;
            bool bHasGroup         = Page.GetSelectedwidgets().Any(a => a.IsGroup);

            // Create undoable command for widgets
            foreach (WidgetViewModBase item in _infoItems)
            {
                item.PropertyMementos.SetPropertyNewValue("Left", item.Raw_Left);
                item.PropertyMementos.SetPropertyNewValue("Top", item.Raw_Top);

                if (item.WidgetType == WidgetType.Toast && item.Top != 0)
                {
                    item.PropertyMementos.SetPropertyNewValue("DisplayPosition", ToastDisplayPosition.UserSetting);
                }

                PropertyChangeCommand cmd = new PropertyChangeCommand(item, item.PropertyMementos);
                cmds.AddCommand(cmd);
            }

            // Create undoable command for groups
            if (pageVMGroup != null)
            {
                List <Guid> groupGuids = _groups.Select(x => x.WidgetID).ToList();

                if (designerItem.ParentID != Guid.Empty)
                {
                    groupGuids.Add(designerItem.ParentID);
                }

                if (groupGuids.Count > 0)
                {
                    UpdateGroupCommand cmd = new UpdateGroupCommand(pageVMGroup, groupGuids);
                    cmds.AddCommand(cmd);
                }
            }

            // Push to undo stack
            if (cmds.Count > 0)
            {
                List <IWidgetPropertyData> allSelects = _selectionService.GetSelectedWidgets();
                cmds.AddCommand(new SelectCommand(pageVMGroup, allSelects));

                cmds.DeselectAllWidgetsFirst();
                pageVMUndo.UndoManager.Push(cmds);
            }
        }
Exemplo n.º 10
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.º 11
0
        public void DeselectAll()
        {
            ISelectionService _selectionSrv = ServiceLocator.Current.GetInstance <SelectionServiceProvider>();

            _selectionSrv.RemoveAllWidgets();


            foreach (BaseWidgetItem item in this.SelectedItems)
            {
                item.IsSelected = false;
            }
            IGroupOperation pageVM = DataContext as IGroupOperation;

            pageVM.DeselectAllGroups();
        }
Exemplo n.º 12
0
        private void ClickPageWidget()
        {
            DesignerCanvas designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;

            //object cc = VisualTreeHelper.GetParent(this);
            if (designer == null)
            {
                return;
            }

            IGroupOperation pageVM = designer.DataContext as IGroupOperation;

            //this is option for the common widget
            if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
            {
                int count = designer.SelectedItems.Count();

                foreach (BaseWidgetItem item in designer.SelectedItems)
                {
                    if (item.IsSelected == true &&
                        item.ParentID != Guid.Empty)
                    {
                        return;
                    }
                    if (count == 1)
                    {
                        item.IsTarget = true;
                    }
                }

                this.IsSelected = !this.IsSelected;
                if (count == 0 && IsSelected)
                {
                    this.IsTarget = true;
                }
            }
            else
            {
                if (!this.IsSelected)
                {
                    designer.DeselectAll();
                    pageVM.DeselectAllGroups();
                    this.IsSelected = true;
                    _isSelectedDone = true;
                }
            }
        }
Exemplo n.º 13
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.º 14
0
        private void ClickGroupChildInEdited()
        {
            ClickInitialStatus = GroupStatus.Edit;
            DesignerCanvas  designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;
            IGroupOperation pageVM   = designer.DataContext as IGroupOperation;

            if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
            {
                this.IsSelected = !this.IsSelected;
            }
            else
            {
                if (!this.IsSelected)
                {
                    pageVM.DeselectAllChildren(ParentID);
                    this.IsSelected = true;
                    _isSelectedDone = true;
                }
            }
        }
Exemplo n.º 15
0
 //New Solution, Called only one time after adorner moving is over
 private void MoveSeleteedWidgets()
 {
     if (this.designerItem.ParentID == Guid.Empty)
     {
         MoveExternalElements(_totalHorizonOffset, _totaVerticalOffset);
     }
     else
     {
         IGroupOperation pageVM      = designerCanvas.DataContext as IGroupOperation;
         GroupStatus     groupStatus = pageVM.GetGroupStatus(this.designerItem.ParentID);
         if (groupStatus == GroupStatus.Edit)
         {
             MoveEditedGroup(pageVM, _totalHorizonOffset, _totaVerticalOffset);
         }
         else if (groupStatus == GroupStatus.Selected)
         {
             MoveSelectedGroup(pageVM, _totalHorizonOffset, _totaVerticalOffset);
         }
     }
 }
Exemplo n.º 16
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.º 17
0
        private void MoveExternalElements(double deltaHorizontal, double deltaVertical)
        {
            if (this.designerItem.IsSelected == false)
            {
                return;
            }

            foreach (WidgetViewModBase item in _infoItems)
            {
                if (item == _infoItems.Last())
                {
                    SendFirePositionEvent(true);
                }

                if (item.IsLocked == true)
                {
                    continue;
                }

                item.Raw_Top  = item.Top + deltaVertical;;
                item.Raw_Left = item.Left + deltaHorizontal;
            }

            IGroupOperation pageVM    = designerCanvas.DataContext as IGroupOperation;
            List <Guid>     GroupGIDs = pageVM.GetAllSelectedGroups();

            if (GroupGIDs.Count <= 0)
            {
                return;
            }

            foreach (GroupViewModel it in _groups)
            {
                pageVM.UpdateGroup(it.WidgetID);
            }
        }
Exemplo n.º 18
0
 public virtual IGroupOperation TransformGroupOperation(IGroupOperation value)
 {
     value.Item = this.TransformExpression(value.Item);
     value.Key = this.TransformExpression(value.Key);
     return value;
 }
 private void WriteGroupOperation(IGroupOperation value, IFormatter formatter)
 {
     formatter.WriteKeyword("group");
     formatter.Write(" ");
     this.WriteExpression(value.Item, formatter);
     formatter.Write(" ");
     formatter.WriteKeyword("by");
     formatter.Write(" ");
     this.WriteExpression(value.Key, formatter);
 }
Exemplo n.º 20
0
 public UpdateGroupCommand(IGroupOperation pageVM, List <Guid> groupGuids)
 {
     _pageVM     = pageVM;
     _groupGuids = groupGuids;
 }
Exemplo n.º 21
0
        //protected override void OnMouseUp(MouseButtonEventArgs e)
        //{
        //    base.OnMouseUp(e);
        //}
        //protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
        //{
        //    base.OnPreviewMouseLeftButtonUp(e);
        //}

        #region Public function called bye Move Thumb
        public void OnGroupChildMouseUp()
        {
            DesignerCanvas designer = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(this))) as DesignerCanvas;

            if (designer == null)
            {
                return;
            }
            //e.Handled = false;
            IGroupOperation pageVM      = designer.DataContext as IGroupOperation;
            GroupStatus     groupStatus = pageVM.GetGroupStatus(ParentID);

            if (ClickInitialStatus == GroupStatus.UnSelect && groupStatus == GroupStatus.Selected)
            {
                return;
            }

            //this is option for the group's child widget
            if (groupStatus == GroupStatus.UnSelect)
            {
                //if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
                //{
                //    pageVM.SetGroupStatus(ParentID, GroupStatus.Selected);
                //}
                //else
                //{
                //    designer.DeselectAll();
                //    pageVM.DeselectAllGroups();
                //    pageVM.SetGroupStatus(ParentID, GroupStatus.Selected);
                //}
            }
            else if (groupStatus == GroupStatus.Selected)
            {
                if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
                {
                    pageVM.SetGroupStatus(ParentID, GroupStatus.UnSelect);
                }
                else
                {
                    designer.DeselectAll();
                    pageVM.DeselectAllGroups();
                    pageVM.SetGroupStatus(ParentID, GroupStatus.Edit);
                    this.IsSelected = true;
                }
            }
            else
            {
                //this is option for the common widget
                if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None)
                {
                    return;
                }
                else
                {
                    if (_isSelectedDone == false)
                    {
                        if (IsSelected == true &&
                            designer.SelectedItems.Count() == 1)
                        {
                            return;
                        }
                        pageVM.DeselectAllChildren(ParentID);
                        this.IsSelected = true;
                    }
                }
            }
        }
Exemplo n.º 22
0
 public SelectCommand(IGroupOperation pageVM, List <IWidgetPropertyData> selectedWidgetList)
 {
     CheckGroupHelper(selectedWidgetList);
     _pageVM = pageVM;
 }
Exemplo n.º 23
0
 public SelectCommand(IGroupOperation pageVM, List <WidgetViewModBase> selectedWidgetList)
 {
     CheckGroupHelper(selectedWidgetList);
     _pageVM = pageVM;
 }
Exemplo n.º 24
0
 public virtual void VisitGroupOperation(IGroupOperation value)
 {
     VisitExpression(value.Item);
     VisitExpression(value.Key);
 }
Exemplo n.º 25
0
        private void RotateThumb_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            if (_infoItems.Count <= 0)
            {
                return;
            }

            // Undo/Redo
            ISupportUndo    pageVMUndo  = canvas.DataContext as ISupportUndo;
            IGroupOperation pageVMGroup = canvas.DataContext as IGroupOperation;

            if (pageVMUndo == null)
            {
                return;
            }

            CompositeCommand cmds = new CompositeCommand();

            // Create undoable command for widgets
            foreach (WidgetViewModBase item in _infoItems)
            {
                item.PropertyMementos.SetPropertyNewValue("RotateAngle", item.RotateAngle);

                if (this.designerItem.IsGroup)
                {
                    item.PropertyMementos.SetPropertyNewValue("Left", item.Raw_Left);
                    item.PropertyMementos.SetPropertyNewValue("Top", item.Raw_Top);
                }
                PropertyChangeCommand cmd = new PropertyChangeCommand(item, item.PropertyMementos);
                cmds.AddCommand(cmd);
            }

            // Create undoable command for groups
            if (pageVMGroup != null)
            {
                List <Guid> groupGuids = new List <Guid>();

                if (designerItem.ParentID != Guid.Empty)
                {
                    groupGuids.Add(designerItem.ParentID);

                    UpdateGroupCommand cmd = new UpdateGroupCommand(pageVMGroup, groupGuids);
                    cmds.AddCommand(cmd);
                }

                if (this.designerItem.IsGroup)
                {
                    groupGuids.Add((designerItem.DataContext as GroupViewModel).WidgetID);

                    UpdateGroupCommand cmd = new UpdateGroupCommand(pageVMGroup, groupGuids);
                    cmds.AddCommand(cmd);
                }
            }

            // Push to undo stack
            if (cmds.Count > 0)
            {
                List <IWidgetPropertyData> allSelects = _selectionService.GetSelectedWidgets();
                cmds.AddCommand(new SelectCommand(pageVMGroup, allSelects));

                cmds.DeselectAllWidgetsFirst();
                pageVMUndo.UndoManager.Push(cmds);
            }
        }
Exemplo n.º 26
0
        private void RotateThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            //Initialize the selected widgets' context when first rotate
            if (_infoItems.Count <= 0)
            {
                WidgetViewModBase wdg = designerItem.DataContext as WidgetViewModBase;
                if (wdg.IsGroup == false)
                {
                    wdg.CreateNewPropertyMementos();
                    wdg.PropertyMementos.AddPropertyMemento(new PropertyMemento("RotateAngle", wdg.RotateAngle, wdg.RotateAngle));
                    _infoItems.Add(wdg);
                }
                else
                {
                    foreach (WidgetViewModBase item in (wdg as GroupViewModel).WidgetChildren)
                    {
                        item.CreateNewPropertyMementos();

                        item.CreateNewPropertyMementos();

                        item.PropertyMementos.AddPropertyMemento(new PropertyMemento("RotateAngle", item.RotateAngle, item.RotateAngle));
                        item.PropertyMementos.AddPropertyMemento(new PropertyMemento("Left", item.Raw_Left, item.Raw_Left));
                        item.PropertyMementos.AddPropertyMemento(new PropertyMemento("Top", item.Raw_Top, item.Raw_Top));
                        _infoItems.Add(item);
                    }
                }
            }

            //Rotate the current widget
            if (this.designerItem != null && this.canvas != null)
            {
                ContentPresenter wrapper = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(designerItem)) as ContentPresenter;

                Point  currentPoint = Mouse.GetPosition(this.canvas);
                Vector deltaVector  = Point.Subtract(currentPoint, this.centerPoint);

                double angle = Vector.AngleBetween(this.startVector, deltaVector);

                RotateTransform rotateTransform = designerItem.RenderTransform as RotateTransform;
                angle = this.initialAngle + Math.Round(angle, 0);



                if (angle < 0)
                {
                    angle += 360;
                }
                else if (angle >= 360)
                {
                    angle -= 360;
                }


                wrapper.InvalidateMeasure();

                if (this.designerItem.IsGroup == true)
                {
                    GroupViewModel group = this.designerItem.DataContext as GroupViewModel;

                    DesignerCanvas dc = canvas as DesignerCanvas;

                    foreach (WidgetViewModBase item in group.WidgetChildren)
                    {
                        RotateTransform rt = new RotateTransform(); // bw.RenderTransform as RotateTransform;
                        rt.Angle   = angle - groupIntialAngle;
                        rt.CenterX = groupCenterX;
                        rt.CenterY = groupCenterY;

                        double oldAngle = item.RotateAngle;
                        item.RotateAngle = Convert.ToInt16(angle - groupIntialAngle);
                        Rect rect1 = rt.TransformBounds(new Rect(item.Left, item.Top, item.ItemWidth, item.ItemHeight));
                        Rect rect2 = item.RevertBoundingRectangle(rect1);

                        //item.IsActual = true;
                        item.Raw_Left = rect2.Left;
                        item.Raw_Top  = rect2.Top;

                        //only widget can rotate
                        if (item is WidgetRotateViewModBase)
                        {
                            int newAngle = Convert.ToInt16(oldAngle + (angle - groupIntialAngle)) % 360;
                            if (newAngle < 0)
                            {
                                newAngle += 360;
                            }
                            else if (angle >= 360)
                            {
                                newAngle -= 360;
                            }
                            item.RotateAngle = newAngle;
                        }
                        else
                        {
                            item.RotateAngle = 0;
                        }
                    }

                    group.Refresh();
                    groupIntialAngle = angle;
                }
                else
                {
                    rotateTransform.Angle = angle;
                }


                if (this.designerItem.ParentID != Guid.Empty)
                {
                    IGroupOperation pageVM = canvas.DataContext as IGroupOperation;
                    pageVM.UpdateGroup(this.designerItem.ParentID);
                }

                if (this.designerItem.IsGroup)
                {
                    IGroupOperation pageVM = canvas.DataContext as IGroupOperation;
                    pageVM.UpdateGroup((this.designerItem.DataContext as GroupViewModel).WidgetID);
                }
            }
        }
Exemplo n.º 27
0
 public virtual void VisitGroupOperation(IGroupOperation value)
 {
     this.VisitExpression(value.Item);
     this.VisitExpression(value.Key);
 }