PositionGotoDialog.Result Command_Position_Goto_Dialog(GotoType gotoType)
        {
            int line = 1, column = 1, index = 1, position = 0;
            var range = Selections.FirstOrDefault();

            if (range != null)
            {
                line     = Data.GetOffsetLine(range.Start) + 1;
                index    = Data.GetOffsetIndex(range.Start, line - 1) + 1;
                column   = Data.GetColumnFromIndex(line - 1, index - 1) + 1;
                position = range.Start;
            }
            int startValue;

            switch (gotoType)
            {
            case GotoType.Line: startValue = Data.GetDiffLine(line - 1) + 1; break;

            case GotoType.Column: startValue = column; break;

            case GotoType.Index: startValue = index; break;

            case GotoType.Position: startValue = position; break;

            default: throw new ArgumentException("GotoType invalid");
            }
            return(PositionGotoDialog.Run(WindowParent, gotoType, startValue, GetVariables()));
        }
Ejemplo n.º 2
0
        protected override void StopMove(bool moved)
        {
            Selection sel = Selections.FirstOrDefault();

            if (inZooming)
            {
                widget.SetCursorForTool(DrawTool.CanMove);
            }

            if (sel != null)
            {
                (sel.Drawable as ICanvasDrawableObject).IDrawableObject.Reorder();
            }
            if (inObjectCreation)
            {
                if (Tool != DrawTool.Counter)
                {
                    Tool = DrawTool.Selection;
                }
                else
                {
                    UpdateSelection(null);
                }
                inObjectCreation = false;
            }
            handdrawing = false;
            inZooming   = false;
        }
Ejemplo n.º 3
0
        protected override void ShowMenu(Point coords)
        {
            Selection sel = Selections.FirstOrDefault();

            if (sel != null && ShowMenuEvent != null)
            {
                ShowMenuEvent((sel.Drawable as ICanvasDrawableObject).IDrawableObject);
            }
        }
Ejemplo n.º 4
0
 public void DeleteCurrentSelection()
 {
     Selections.Remove(CurrentSelection);
     CurrentSelection = Selections.FirstOrDefault();
     if (!Selections.Contains(_currentlySaved))
     {
         _currentlySaved = null;
     }
     SaveSelection();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the current selection. If <paramref name="sel"/> is <c>null</c>,
        /// it clears the current selection. If <paramref name="sel"/> wasn't previously
        /// selected, it's added to the list of selected objects, otherwise it's removed
        /// from the list.
        /// </summary>
        /// <param name="sel">The selection.</param>
        /// <param name="notify">If set to <c>true</c>, notifies about the changes.</param>
        internal protected virtual void UpdateSelection(Selection sel, bool notify = true)
        {
            ICanvasSelectableObject so;
            Selection seldup;

            if (sel == null)
            {
                ClearSelection();
                if (notify)
                {
                    SelectionChanged(Selections);
                }
                return;
            }

            so = sel.Drawable as ICanvasSelectableObject;

            if (so == null)
            {
                return;
            }


            if (Selections.Count > 0)
            {
                if (SingleSelectionObjects.Contains(so.GetType()) ||
                    SingleSelectionObjects.Contains(Selections [0].Drawable.GetType()))
                {
                    return;
                }
            }

            seldup = Selections.FirstOrDefault(s => s.Drawable == sel.Drawable);

            if (seldup != null)
            {
                so.Selected = false;
                Selections.Remove(seldup);
            }
            else
            {
                so.Selected = true;
                Selections.Add(sel);
            }
            if (notify)
            {
                SelectionChanged(Selections);
            }
        }
Ejemplo n.º 6
0
 public void Update()
 {
     InitializeIfNeeded();
     if (builderWindow == null)
     {
         builderInspector = null;
         return;
     }
     CurrentSelection = Selections.FirstOrDefault();
     if (prevSelection != CurrentSelection)
     {
         prevSelection = CurrentSelection;
         OnSelectionChanged(CurrentSelection);
     }
 }
Ejemplo n.º 7
0
        protected override void StopMove(bool moved)
        {
            Selection sel = Selections.FirstOrDefault();

            if (movingLink != null)
            {
                if (destAnchor != null)
                {
                    ActionLinkVM link = movingLink.Link;
                    link.DestinationButton = destAnchor.Button.ButtonVM;
                    link.DestinationTags.ViewModels.AddRange(destAnchor.Tags);
                    link.SourceButton.ActionLinks.ViewModels.Add(link);
                    movingLink.Destination = destAnchor;
                    destAnchor.Highlighted = false;
                    if (ActionLinkCreatedEvent != null)
                    {
                        ActionLinkCreatedEvent(link);
                    }
                    linksDict.Add(link, movingLink);
                }
                else
                {
                    RemoveObject(movingLink);
                    widget.ReDraw();
                }
                ClearSelection();
                movingLink = null;
                destAnchor = null;
                return;
            }

            if (sel != null && moved)
            {
                if (sel.Drawable is DashboardButtonView)
                {
                    /* Round the position of the button to match a corner in the grid */
                    int             i  = VASDrawing.Constants.CATEGORY_TPL_GRID;
                    DashboardButton tb = (sel.Drawable as DashboardButtonView).Button;
                    tb.Position.X = VASDrawing.Utils.Round(tb.Position.X, i);
                    tb.Position.Y = VASDrawing.Utils.Round(tb.Position.Y, i);
                    tb.Width      = (int)VASDrawing.Utils.Round(tb.Width, i);
                    tb.Height     = (int)VASDrawing.Utils.Round(tb.Height, i);
                    (sel.Drawable as DashboardButtonView).ResetDrawArea();
                    widget.ReDraw();
                }
            }
            base.StopMove(moved);
        }
Ejemplo n.º 8
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            var senderLabel = btn?.TemplatedParent as Label;

            if (senderLabel == null)
            {
                return;
            }

            ResultPanel.Children.Remove(senderLabel);

            var deletedItem = Selections.FirstOrDefault((selectedItem) => selectedItem.DisplayName == senderLabel.ToolTip.ToString());

            if (deletedItem != null)
            {
                Selections.Remove(deletedItem);
            }
        }