private void ModelItemSelectionChanged(Selection selection)
 {
     // AutoExpand only when designerTreeView didn't handle the selection change in modelItem
     if (this.IsSelectionChangeHandledByTreeView)
     {
         this.IsSelectionChangeHandledByTreeView = false;
     }
     else
     {
         if (selection.PrimarySelection != null)
         {
             TreeViewItemViewModel itemToBeSelected = DesignerTreeAutoExpandHelper.Expand(this.rootModelItemViewModel, selection.PrimarySelection);
             // itemToBeSelected == null means needn't AutoExpand.
             if (itemToBeSelected != null)
             {
                 this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
                 {
                     // TreeViewItemViewModel may got removed before Idle.
                     if (itemToBeSelected.IsAlive && itemToBeSelected.TreeViewItem != null)
                     {
                         itemToBeSelected.TreeViewItem.Select();
                     }
                     // reset this flag to false, because the operation is done.
                     // The flag will be used for next operation.
                     this.IsSelectionChangeHandledByTreeView = false;
                 }));
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Show what the selected text would look like with the specified style
        /// </summary>
        /// <param Name="selection">The current selection</param>
        /// <param Name="arguments">The arguments provided to the command</param>
        /// <returns>A PText containing the selection text, styled in the specified manner</returns>
        public override PText Preview(Selection selection, string[] arguments)
        {
            string styleName = arguments[0];
            //If the selection doesn't exist, abort
            if (selection == null) { return new PText("Error: Text must be selected for this command to work"); }
            //If no arguments were provided, abort
            if (arguments.Length == 0) { return new PText("Please specify a style"); }
            //If the style specified doesn't exist, abort
            if (!Styles.ContainsKey(styleName)) { return new PText(String.Format(@"Error: {0} is not a valid style", styleName)); }

            //Create and return a PText with the specified style
            return PTextForPreview(Styles[styleName], selection);
        }
Ejemplo n.º 3
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     var group = value as ReadOnlyObservableCollection<object>;
     if (group == null)
         return string.Empty;
     var tracks = new List<ITrack>();
     AddTracks(tracks, group);
     var summary = new Selection(tracks);
     var trackCount = tracks.Count;
     return string.Format(
         " ({0} {1}, {2}, {3})",
         trackCount,
         trackCount == 1 ? "track" : "tracks",
         summary.FileSize.AsString(false),
         summary.Duration.AsString(false));
 }
Ejemplo n.º 4
0
 protected override void StartMove(Selection sel)
 {
     if (sel != null && sel.Drawable is LinkAnchorObject) {
         LinkAnchorObject anchor = sel.Drawable as LinkAnchorObject;
         ActionLink link = new ActionLink {
             SourceButton = anchor.Button.Button,
             SourceTags = new ObservableCollection<Tag> (anchor.Tags)
         };
         movingLink = new ActionLinkObject (anchor, null, link);
         AddObject (movingLink);
         ClearSelection ();
         UpdateSelection (new Selection (movingLink, SelectionPosition.LineStop, 0), false);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// The constructor of RoofsManager class.
        /// </summary>
        /// <param name="commandData">The ExternalCommandData</param>
        public RoofsManager(ExternalCommandData commandData)
        {
            m_commandData = commandData;
            m_levels = new List<Level>();
            m_roofTypes = new List<RoofType>();
            m_referencePlanes = new List<ReferencePlane>();

            m_footPrint = new CurveArray();
            m_profile = new CurveArray();

            m_footPrintRoofManager = new FootPrintRoofManager(commandData);
            m_extrusionRoofManager = new ExtrusionRoofManager(commandData);
            m_selection = commandData.Application.ActiveUIDocument.Selection;

            m_transaction = new Transaction(commandData.Application.ActiveUIDocument.Document, "Document");

            RoofKind = CreateRoofKind.FootPrintRoof;
            Initialize();
        }
Ejemplo n.º 6
0
 public void Move(Selection s, Point p, Point start)
 {
     throw new NotImplementedException ("Unsupported move for PlayersTaggerObject:  " + s.Position);
 }
Ejemplo n.º 7
0
        public Selection GetSelection(Point point, double precision, bool inMotion = false)
        {
            Selection sel = null;

            if (!inMotion) {
                if (point.X < Position.X || point.X > Position.X + Width ||
                    point.Y < Position.Y || point.Y > Position.Y + Height) {
                    sel = null;
                } else {
                    sel = new Selection (this, SelectionPosition.All, 0);
                }
            } else {
                point = VASDrawing.Utils.ToUserCoords (point, offset, scaleX, scaleY);
                sel = homeBench.GetSelection (point, 0, false);
                if (sel == null) {
                    sel = awayBench.GetSelection (point, 0, false);
                    if (sel == null) {
                        sel = field.GetSelection (point, 0, false);
                    }
                }
            }
            return sel;
        }
Ejemplo n.º 8
0
 public void Select(int pressedRow, int row, int pressedColumn, int column)
 {
     SelectedItems = new Selection(pressedRow, row, pressedColumn, column);
 }
Ejemplo n.º 9
0
        public void Paste()
        {
            if (_selectedItems.HasValue)
            {
                int clickedColumn = _selectedItems.Value.BeginColumn;
                int clickedRow = _selectedItems.Value.EndRow;

                if (_clipboard != null)
                {
                    int endColumn = clickedColumn + _clipboardSelection.Value.ColumnSpan - 1;
                    int beginRow = clickedRow - _clipboardSelection.Value.RowSpan + 1;

                    int rightColumn = Math.Min(endColumn, _steps.Count - 1);
                    int bottomRow = Math.Max(beginRow, 0);

                    int newUpperRow = bottomRow + _clipboardSelection.Value.RowSpan - 1;

                    // remove old gates
                    for (int i = clickedColumn; i <= rightColumn; i++)
                    {
                        Gate beginGate = _steps[i].Gates[bottomRow];
                        if (beginGate.Begin < bottomRow)
                        {
                            for (int j = beginGate.Begin; j <= beginGate.End; j++)
                            {
                                RegisterRefModel gateRef = GetRefFromOffset(j);
                                Gate newGate = new EmptyGate(gateRef);
                                _steps[i].SetGate(newGate);
                            }
                        }
                        Gate endGate = _steps[i].Gates[clickedRow];
                        if (endGate.End > clickedRow)
                        {
                            for (int j = endGate.Begin; j <= endGate.End; j++)
                            {
                                RegisterRefModel gateRef = GetRefFromOffset(j);
                                Gate newGate = new EmptyGate(gateRef);
                                _steps[i].SetGate(newGate);
                            }
                        }
                    }

                    // make place, if it was too little
                    for (int i = rightColumn; i < endColumn; i++)
                    {
                        InsertStepRight(i);
                    }
                    for (int i = bottomRow; i > beginRow; i--)
                    {
                        InsertQubitBelow(_registers.Count - 1, 0);
                    }

                    // paste
                    for (int i = 0; i < _clipboard.Count; i++)
                    {
                        foreach (Gate oldGate in _clipboard[i])
                        {
                            Gate newGate = PasteGate(oldGate, bottomRow);
                            _steps[i + clickedColumn].SetGate(newGate);
                        }
                    }

                    // and move selection
                    SelectedItems = new Selection
                        (bottomRow,
                        newUpperRow,
                        clickedColumn,
                        endColumn);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="commandData">Revit's external commandData</param>
        public CircuitOperationData(ExternalCommandData commandData)
        {
            m_revitDoc = commandData.Application.ActiveUIDocument;
            m_selection = m_revitDoc.Selection;

            m_electricalSystemSet = new ElectricalSystemSet();
            m_electricalSystemItems = new List<ElectricalSystemItem>();

            CollectConnectorInfo();
            CollectCircuitInfo();
        }