Example #1
0
        /// <summary>
        /// Add Guide-lines
        /// </summary>
        public void AddHorizGuideLineHandler(object obj)
        {
            if (GuideType == GuideType.Global || _page == null || _pageView == null)
            {
                return;
            }

            var values = (object[])obj;

            Ruler ruler = values[0] as Ruler;
            PageEditorViewModel editor = values[1] as PageEditorViewModel;

            System.Windows.Point point = Mouse.GetPosition(ruler);
            IGuide guide = _pageView.CreateGuide(Orientation.Horizontal, 0, (point.X + ruler.CountShift) / Scale);
            HorizontalGuideLine hLine = new HorizontalGuideLine(guide, GuideType.Local, editor.EditorScale);

            GuideItems.Add(hLine);
            _document.IsDirty = true;
            editor.EditorCanvas.Focus();

            List <IGuide> guides = new List <IGuide>();

            guides.Add(guide);
            CreatePageGuideCommand cmd = new CreatePageGuideCommand(_pageView, guides);

            CurrentUndoManager.Push(cmd);

            ShowGuide(editor);
        }
Example #2
0
        private void MoveThumb_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            this.guideItem.IsSelected = false;
            if (this.adorner != null)
            {
                AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this);
                if (adornerLayer != null)
                {
                    adornerLayer.Remove(this.adorner);
                }
                this.adorner = null;
            }

            // redo/undo
            if (pageUndoManager == null)
            {
                return;
            }
            if (this.guideItem is HorizontalGuideLine)
            {
                HorizontalGuideLine        hGuide = this.guideItem as HorizontalGuideLine;
                GuidePropertyChangeCommand cmd    = new GuidePropertyChangeCommand(hGuide.Guide, "Y", oldPos, guideItem.Guide.Y);
                pageUndoManager.Push(cmd);
            }
            else
            {
                VerticalGuideLine          hGuide = this.guideItem as VerticalGuideLine;
                GuidePropertyChangeCommand cmd    = new GuidePropertyChangeCommand(hGuide.Guide, "X", oldPos, guideItem.Guide.X);
                pageUndoManager.Push(cmd);
            }
        }