예제 #1
13
        /// <summary>
        /// Handles the select/de-select of a row.
        /// </summary>
        /// <param name="rowNumber">The row number.</param>
        /// <param name="selectionSource">Selection source.</param>
        /// <param name="e">Routed event arguments.</param>
        private void HandleSelect(int rowNumber, SelectionSource selectionSource, RoutedEventArgs e)
        {
            bool controlKeyDown;
            bool shiftKeyDown;          

            if (this.mainView.View.Rows.Count < 1 || rowNumber >= this.mainView.View.Rows.Count || rowNumber < 0)
            {
                return;
            }

            DataBoundRow hitRow = this.mainView.View.Rows[rowNumber];
            List<DataBoundRow> removedItems = new List<DataBoundRow>();
            List<DataBoundRow> addedItems = new List<DataBoundRow>();
            removedItems = new List<DataBoundRow>();
            addedItems = new List<DataBoundRow>();

            KeyboardHelper.GetMetaKeyState(out controlKeyDown, out shiftKeyDown);

            this.selectedIndex = rowNumber;
            if (shiftKeyDown == false)
            {
                this.AnchorRowIndex = rowNumber;
            }

            bool multiSelectAllowed = (this.SelectionMode == SelectionMode.MultipleExtended || this.SelectionMode == SelectionMode.MultipleSimple);

            // Multi-select?
            if ((controlKeyDown && multiSelectAllowed && selectionSource != SelectionSource.Keyboard) || (this.forceSelect && multiSelectAllowed))
            {
                if (this.spacebarKeyDown)
                {
                    return;
                }

                //// De-select via Control Key and mouse
                if (this.SelectedItems.Contains(hitRow) == true)
                {
                    removedItems.Add(hitRow);                    
                    this.SelectedItems.Remove(hitRow);                                    
                    this.SelectedItem = this.SelectedItems.Count > 0 ? this.SelectedItems[this.SelectedItems.Count - 1] : null;
                    hitRow.Select(false);
                    hitRow.Highlight(true);  
                    hitRow.RowFocus = true;
                    hitRow.RowSelected = false;
                }
                else
                {
                    //// Select via Control Key and mouse
                    addedItems.Add(hitRow);
                    this.SelectedItems.Add(hitRow);
                    this.SelectedItem = hitRow;
                    hitRow.RowFocus = true;
                    hitRow.RowSelected = false;
                }

                if (this.lastRowHavingFocusIndex != -1 && hitRow.Index != this.lastRowHavingFocusIndex)
                {
                    this.MainView.Rows[this.lastRowHavingFocusIndex].Highlight(false);
                }               
            }           
            else if (controlKeyDown && multiSelectAllowed && selectionSource == SelectionSource.Keyboard)
            {
                hitRow.Highlight(true);
                hitRow.RowFocus = true;
                this.handlingControlMultiSelection = true;
                if (this.spacebarKeyDown)
                {
                    //// Select via Control Key and space-bar
                    if (this.SelectedItems.IndexOf(hitRow) == -1)
                    {
                        this.SelectedItems.Add(hitRow);
                        hitRow.Highlight(false);
                        hitRow.Select(true);                       
                        hitRow.RowSelected = true;
                        hitRow.RowFocus = true;
                    }
                    else
                    {
                        //// De-select via Control Key and space-bar
                        this.SelectedItems.Remove(hitRow);
                        hitRow.Select(false);
                        hitRow.Highlight(true);
                        hitRow.RowSelected = false;
                        hitRow.RowFocus = true;
                    }
                }
                else if (this.SelectedItems.IndexOf(hitRow) != -1)
                {
                    hitRow.Select(true);
                    hitRow.RowFocus = true;
                }
               
                if (this.lastHitRow != null)
                {
                    if (this.lastHitRow != hitRow)
                    {
                        this.lastHitRow.Highlight(false);
                        this.lastHitRow.RowFocus = false;
                    }

                    if (this.SelectedItems.IndexOf(this.lastHitRow) != -1)
                    {
                        this.lastHitRow.Select(true);
                    }
                }

                this.lastHitRow = hitRow;
            }
            else if ((shiftKeyDown && multiSelectAllowed))
            {
                //// Handle shift based selected
                int startRow = this.anchorRowIndex <= rowNumber ? this.anchorRowIndex : rowNumber;
                int endRow = this.anchorRowIndex <= rowNumber ? rowNumber : this.anchorRowIndex;
                DataBoundRow unselectingRow;
               
                // Items before selection range...
                for (int beforeRowIndex = 0; beforeRowIndex < startRow; beforeRowIndex++)
                {
                    unselectingRow = this.mainView.View.Rows[beforeRowIndex];
                    if (this.SelectedItems.Contains(unselectingRow) == true)
                    {                        
                        this.SelectedItems.Remove(unselectingRow);
                        removedItems.Add(unselectingRow);
                        unselectingRow.Select(false);
                        unselectingRow.RowSelected = false;
                        unselectingRow.RowFocus = false;
                    }
                }

                // Items in selection range...
                for (int selectRowIndex = startRow; selectRowIndex <= endRow; selectRowIndex++)
                {
                    DataBoundRow selectingRow = this.mainView.View.Rows[selectRowIndex];
                    if (this.SelectedItems.Contains(selectingRow) == false)
                    {
                        this.SelectedItems.Add(selectingRow);
                        addedItems.Add(selectingRow);
                        selectingRow.RowSelected = true;
                        selectingRow.RowFocus = false;
                    }

                    this.SelectedItem = selectingRow;
                }

                // Items after selection range...
                for (int afterRowIndex = endRow + 1; afterRowIndex < this.mainView.View.Rows.Count - 1; afterRowIndex++)
                {
                    unselectingRow = this.mainView.View.Rows[afterRowIndex];
                    if (this.SelectedItems.Contains(unselectingRow) == true)
                    {                        
                        this.SelectedItems.Remove(unselectingRow);
                        removedItems.Add(unselectingRow);
                        unselectingRow.Select(false);
                        unselectingRow.RowSelected = false;
                        unselectingRow.RowFocus = false;
                    }
                }

                if (e.GetType() == typeof(System.Windows.Input.KeyEventArgs))
                {
                    if (endRow + 2 == this.mainView.View.Rows.Count && ((KeyEventArgs)e).Key == Key.Up)
                    {
                        unselectingRow = this.mainView.View.Rows[endRow + 1];
                        if (this.SelectedItems.Contains(unselectingRow) == true)
                        {                           
                            this.SelectedItems.Remove(unselectingRow);
                            removedItems.Add(unselectingRow);
                            unselectingRow.Select(false);
                            unselectingRow.RowSelected = false;
                            unselectingRow.RowFocus = false;
                        }
                    }
                }
                else if (e.GetType() == typeof(System.Windows.Input.MouseButtonEventArgs))
                {
                    if (endRow + 1 != this.mainView.View.Rows.Count)
                    {
                        unselectingRow = this.mainView.View.Rows[this.mainView.View.Rows.Count - 1];
                        if (this.SelectedItems.Contains(unselectingRow) == true)
                        {                           
                            this.SelectedItems.Remove(unselectingRow);
                            removedItems.Add(unselectingRow);
                            unselectingRow.Select(false);
                            unselectingRow.RowSelected = false;
                            unselectingRow.RowFocus = false;
                        }
                    }
                }
            }            
            else
            {
                if (this.lastHitRow != null)
                {
                    if (this.lastHitRow != hitRow)
                    {
                        this.lastHitRow.Highlight(false);
                        this.lastHitRow.RowSelected = false;
                        this.lastHitRow.RowFocus = false;
                    }
                }

                this.ClearSelections();
                removedItems.AddRange(this.selectedItems);
                this.SelectedItems.Clear();
                removedItems.Remove(hitRow);
                addedItems.Add(hitRow);
                this.SelectedItems.Add(hitRow);
                this.SelectedItem = hitRow;
                hitRow.RowFocus = true;
                hitRow.RowSelected = true;
            }

            if (!this.handlingControlMultiSelection)
            {
                this.EnsureSelections();
            }

            this.spacebarKeyDown = false;
            this.handlingControlMultiSelection = false;
            this.EnsureRowVisible(rowNumber);
            this.lastRowHavingFocusIndex = rowNumber;          
            this.HandleSelectedRowCollection();
            if (this.OnSelectionChanged != null)
            {
#if SILVERLIGHT
                SelectionChangedEventArgs newSelectionChangedEventArgs = new SelectionChangedEventArgs(removedItems, addedItems);
#else
                // TODO: Check whether this implementation is correct
                SelectionChangedEventArgs newSelectionChangedEventArgs = new SelectionChangedEventArgs(e.RoutedEvent, removedItems, addedItems);
#endif
                this.OnSelectionChanged(this, newSelectionChangedEventArgs);
            }
        }
예제 #2
0
        public override void LoadParameters(System.IO.BinaryReader reader)
        {
            base.LoadParameters(reader);

            source        = (SelectionSource)reader.ReadInt32();
            source_string = reader.ReadString();
        }
예제 #3
0
        public override void CopyFrom(Action copy)
        {
            base.CopyFrom(copy);

            source        = (copy as ActionConditionIsValid).source;
            source_string = (copy as ActionConditionIsValid).source_string;
        }
예제 #4
0
        public override void CopyFrom(Action copy)
        {
            base.CopyFrom(copy);

            Selection  = (copy as ActionBufferSave).Selection;
            typestring = (copy as ActionBufferSave).typestring;
        }
예제 #5
0
        public override void CopyFrom(Action copy)
        {
            base.CopyFrom(copy);

            source        = (copy as ActionDestroyObject).source;
            source_string = (copy as ActionDestroyObject).source_string;
        }
예제 #6
0
        private void listView1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                ListViewItem item = listView1.GetItemAt(e.X, e.Y);

                if (item != null)
                {
                    if (e.Location.X >= item.Bounds.X - (item.ListView.SmallImageList.ImageSize.Width + 5) &&
                        e.Location.X <= item.Bounds.Right + 1)
                    {
                        ((mainForm)this.DockPanel.Parent).timeSlider1_Scroll(sender, e);

                        SavedItemCollection si = doc.SelectionSets.Value;

                        SelectionSource ss = doc.SelectionSets.CreateSelectionSource(si[item.Index]);
                        Search          s  = new Search(); s.Selection.SelectionSources.Add(ss);

                        modelSelection = new ModelItemCollection(s.Selection.GetSelectedItems(doc));

                        System.Drawing.Color c = System.Drawing.Color.Blue;

                        doc.Models.OverridePermanentColor(modelSelection, new Autodesk.Navisworks.Api.Color(c.R / 255, c.G / 255, c.B / 255));

                        i = modelSelection[0].PropertyCategories.ElementAt(modelSelection[0].PropertyCategories.Count() - 1).Properties[4].Value.ToInt32();
                        j = -1;
                        contextMenuStrip1.Items.Clear();
                        contextMenuStrip1.Items.Add(changePropertiesToolStripMenuItem);
                        contextMenuStrip1.Size = new Size(164, 26);
                        contextMenuStrip1.Show(msTreeView1, e.Location);
                    }
                }
            }
        }
        public ActionTransferObject() : base("Transfer Object")
        {
            source      = SelectionSource.Original;
            destination = SelectionSource.Selected;

            source_string = "Object Type";
            dest_string   = "Destination Type";
        }
예제 #8
0
        public override void LoadParameters(System.IO.BinaryReader reader)
        {
            base.LoadParameters(reader);

            source = (SelectionSource)reader.ReadInt32();

            source_string = reader.ReadString();

            //trigger = (CGME.InterfaceEvent)Enum.Parse(typeof(InterfaceEvent),reader.ReadString());
        }
예제 #9
0
        public override void CopyFrom(Action copy)
        {
            base.CopyFrom(copy);

            selection_source = (copy as ActionSelect).selection_source;
            selection_mode   = (copy as ActionSelect).selection_mode;

            SourceCGType = (copy as ActionSelect).SourceCGType;
            TargetCGType = (copy as ActionSelect).TargetCGType;
            TargetIndex  = (copy as ActionSelect).TargetIndex;
        }
예제 #10
0
        public override void CopyFrom(Action copy)
        {
            base.CopyFrom(copy);

            source      = (copy as ActionTransferObject).source;
            destination = (copy as ActionTransferObject).destination;

            source_string = (copy as ActionTransferObject).source_string;
            dest_string   = (copy as ActionTransferObject).dest_string;

            //GameManager.DebugLog("Copying " + this.cgtype);
        }
예제 #11
0
        public override void LoadParameters(System.IO.BinaryReader reader)
        {
            base.LoadParameters(reader);

            selection_source = (SelectionSource)reader.ReadInt32();
            selection_mode   = (SelectionMode)reader.ReadInt32();

            SourceCGType = reader.ReadString();
            TargetCGType = reader.ReadString();
            TargetIndex  = reader.ReadInt32();

            //trigger = (CGME.InterfaceEvent)Enum.Parse(typeof(InterfaceEvent),reader.ReadString());
        }
예제 #12
0
        CGObject GetFromSource(SelectionSource source, string t, CGObject s, Actor p1, Actor p2)
        {
            switch (source)
            {
            case (SelectionSource.Original):
                return(s);

            case (SelectionSource.Selected):
                return(p1);

            case (SelectionSource.Type):
                return(manager.CommandFindObject(t));
            }

            return(null);
        }
        public void ToString_WhenCaptionSourceReturnsNull_ReturnsEmptyString()
        {
            var source = new SelectionSource {
                Caption = null
            };
            var vm = new ParentVM {
                AllItemsSource     = new[] { source },
                SelectedItemSource = source
            };

            string caption = vm
                             .GetValue(x => x.Selection)
                             .SelectedItem
                             .ToString();

            Assert.AreEqual(String.Empty, caption);
        }
예제 #14
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ((mainForm)this.DockPanel.Parent).timeSlider1_Scroll(sender, e);
            //doc.Models.ResetPermanentMaterials(modelSelection);
            modelSelection.Clear(); listView1.HideSelection = false;

            SavedItemCollection si = doc.SelectionSets.Value;

            System.Windows.Forms.ListView.SelectedIndexCollection indicies = listView1.SelectedIndices;

            for (int i = 0; i < indicies.Count; i++)
            {
                SelectionSource ss = doc.SelectionSets.CreateSelectionSource(si[indicies[i]]);
                Search          s  = new Search(); s.Selection.SelectionSources.Add(ss);

                modelSelection.AddRange(s.Selection.GetSelectedItems(doc));
            }

            msTreeView1.CollapseAll();

            if (modelSelection.Count > 0)
            {
                System.Drawing.Color c = System.Drawing.Color.Blue;

                doc.Models.OverridePermanentColor(modelSelection, new Autodesk.Navisworks.Api.Color(c.R / 255, c.G / 255, c.B / 255));

                List <MSTreeView.MSTreeNode> selectedNodes = new List <MSTreeView.MSTreeNode>();

                int j = 0;
                foreach (ModelItem m in doc.Models.RootItems)
                {
                    if (modelSelection.IsSelected(m))
                    {
                        selectedNodes.Add((MSTreeView.MSTreeNode)msTreeView1.Nodes[j]);
                    }
                    else
                    {
                        if (treeSelect(m.Children, msTreeView1.Nodes[j], selectedNodes))
                        {
                            msTreeView1.Nodes[j].Expand();
                        }
                    }
                    j++;
                }

                msTreeView1.SelectedNodes = selectedNodes;
            }
            else
            {
                msTreeView1.SelectedNodes = new List <MSTreeView.MSTreeNode>();
            }

            if (modelSelection.Count == 1)
            {
                prop.displayProperties(modelSelection[0].PropertyCategories);
            }
            else
            {
                prop.displayLabel(modelSelection.Count + " items selected");
            }
        }
 public OutputPortViewSelectionEventArgs(bool isSelected, SelectionSource source, IOutputPortView portView)
     : base(isSelected, source)
 {
     _PortView = portView;
 }
예제 #16
0
 public InputPortSelectionEventArgs(bool isSelected, SelectionSource source)
     : this(isSelected, source, null)
 {
 }
예제 #17
0
 public void SetIsSelected(bool isSelected, SelectionSource source, SelectionOrigin origin)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #18
0
 public SelectedModelObjectChanged(object selectedObject, IEnumerable <Message> predecessorMessages, SelectionSource selectionSource)
     : base(predecessorMessages)
 {
     SelectedObject  = selectedObject;
     SelectionSource = selectionSource;
 }
예제 #19
0
 public InputPortSelectionEventArgs(bool isSelected, SelectionSource source, IInputPort port)
     : base(isSelected, source)
 {
     _Port = port;
 }
예제 #20
0
 public void SetIsSelected(bool isSelected, SelectionSource source, SelectionOrigin origin)
 {
     throw new NotImplementedException();
 }
예제 #21
0
 public SelectedModelObjectChanged(object selectedObject, Message predecessorMessage, SelectionSource selectionSource)
     : base(predecessorMessage)
 {
     SelectedObject  = selectedObject;
     SelectionSource = selectionSource;
 }
예제 #22
0
 public SelectionEventArgs(bool isSelected, SelectionSource source)
     : this(isSelected, source, SelectionOrigin.None)
 {
 }
예제 #23
0
 public SelectionEventArgs(bool isSelected, SelectionSource source, SelectionOrigin origin)
 {
     IsSelected = isSelected;
     Source = source;
     Origin = origin;
 }
예제 #24
0
 public ActionConditionIsValid() : base("Test Validity")
 {
     source        = SelectionSource.Original;
     source_string = "object type";
 }
예제 #25
0
 internal void SelectionChangedFromView(bool isSelected, SelectionSource source, SelectionOrigin origin)
 {
     // the change originated at the UI level and has already been applied at the UI level.
     if (Pipe.IsSelected != isSelected)
     {
         // propagate the selection change to the model if the Source is a UI source:  Mouse, Keyboard, UserInput
         if (source == SelectionSource.Mouse)
         {
             Pipe.SetIsSelected(isSelected, source, origin);
             VerifySelectionStates(View, Pipe);
         }
         else if (source == SelectionSource.KeyBoard)
         {
             Pipe.SetIsSelected(isSelected, source, origin);
             VerifySelectionStates(View, Pipe);
         }
         else if (source == SelectionSource.UserInput)
         {
             Pipe.SetIsSelected(isSelected, source, origin);
             VerifySelectionStates(View, Pipe);
         }
     }
 }
예제 #26
0
 public ActionBufferSave() : base("Save to Buffer")
 {
     Selection  = SelectionSource.Original;
     typestring = "Type Name";
 }
예제 #27
0
 public PortViewSelectionEventArgs(bool isSelected, SelectionSource source)
     : base(isSelected, source)
 {
 }
 public OutputPortViewSelectionEventArgs(bool isSelected, SelectionSource source)
     : this(isSelected, source, null)
 {
 }
예제 #29
0
파일: WorkSpace.cs 프로젝트: BgRva/Blob1
        /// <summary>
        /// See <see cref="IIsSelected"/>.
        /// </summary>
        public virtual void SetIsSelected(bool isSelected, SelectionSource source, SelectionOrigin origin)
        {
            // if selection changes
            if (IsSelected != isSelected)
            {
                // Update IsSelected
                IsSelected = isSelected;

                // if the origin of the selecion change is the biz tier (this tier), then propagate it up to
                // the presenter.  Otherwise just change the IsSelected property.
                if (origin == SelectionOrigin.Business)
                {
                    // fire the event signaling the IsSelected value has changed
                    OnSelectionChanged(new SelectionEventArgs(IsSelected, source, origin));
                }
            }
        }
예제 #30
0
 public ActionDestroyObject() : base("Destroy Object")
 {
     source        = SelectionSource.Original;
     source_string = "Object Type";
 }