private void GatherRomsComplete(AsyncTaskData taskData) { var args = (RomDiscoveryData)taskData; var discoveredRoms = args.NewRoms; var addedRoms = Model.AddNewItemsFromList(discoveredRoms, args.InsertLocation); if (addedRoms.Any()) { var collectionChanged = CollectionChanged; if (collectionChanged != null) { collectionChanged(this, new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Add, addedRoms as System.Collections.IList)); } if (args.SelectNewRoms) { CurrentSelection.Clear(); var addedItemIndexes = addedRoms.Select(r => Programs.ModelCollection.IndexOf(r)); foreach (var addedRomIndex in addedItemIndexes) { var programViewModel = Programs[addedRomIndex]; CurrentSelection.Add(programViewModel); } } SaveRomList(true); } Model.EndAddRomsFromFiles(args.DuplicateRomPaths); if (taskData.Error != null) { OSMessageBox.Show(Resources.Strings.AddRomsErrorMessage, Resources.Strings.AddRomsErrorTitle, taskData.Error, null); } }
/// <summary> /// Selects multiple items. /// </summary> /// <param name="itemsToSelect">Items to select.</param> public void SelectItems(System.Collections.ObjectModel.Collection <ISelectable> itemsToSelect) { ClearSelection(false); foreach (ISelectable item in itemsToSelect) { CurrentSelection.Add(item); item.IsSelected = true; } Notify(); }
/// <summary> /// Adds an item to selection. /// </summary> /// <param name="item">Item to add to selection.</param> /// <param name="bNotify">True to notify of this selection change. False otherwise.</param> public void AddToSelection(ISelectable item, bool bNotify) { if (item is ISelectable) { if (!ContainsInSelection(item)) { CurrentSelection.Add(item); } item.IsSelected = true; } if (bNotify) { Notify(); } }
internal void AddToSelection(ISelectable item) { if (item is IGroupable) { List <IGroupable> groupItems = GetGroupMembers(item as IGroupable); foreach (ISelectable groupItem in groupItems) { groupItem.IsSelected = true; CurrentSelection.Add(groupItem); CurrentComponentParam = ((DesignerItem)item).ThisComponent; } } else { item.IsSelected = true; CurrentSelection.Add(item); } }
private void MouseServiceOnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { MouseRightDownMoveTranslationPositionLast = e.Location; } if (e.Button == MouseButtons.Left) { StartSelectionRectangle = false; MouseLeftDownMovePositionLast = RenderingEngine.TranslatedMousePosition; MouseLeftDownPositionLast = RenderingEngine.TranslatedMousePosition; if (!StartDrag) { Input = null; Output = null; var mouseOverItems = RenderingEngine.CurrentProject.Items.Where(x => x.IsMouseOver).ToList(); var mouseOverConnections = RenderingEngine.CurrentProject.Connections.Where(x => x.IsMouseOver).ToList(); if (mouseOverItems.Count == 0 && mouseOverConnections.Count == 0) { DeselectAll(); } if (mouseOverItems.Count > 0) { foreach (var selectedItem in mouseOverItems) { if (!CurrentSelection.Contains(selectedItem)) { DeselectAll(); CurrentSelection.Add(selectedItem); } selectedItem.IsSelected = true; List <InputOutputBase> inputOutputs = new List <InputOutputBase>(); inputOutputs.AddRange(selectedItem.Inputs); inputOutputs.AddRange(selectedItem.Outputs); var mouseOverInputOutput = inputOutputs.FirstOrDefault(x => x.IsMouseOver); if (mouseOverInputOutput != null) { if (mouseOverInputOutput is InputBase) { Input = new InputOutputSelector(selectedItem, mouseOverInputOutput); } if (mouseOverInputOutput is OutputBase) { Output = new InputOutputSelector(selectedItem, mouseOverInputOutput); } } } } if (mouseOverConnections.Count > 0) { foreach (var selectedItem in mouseOverConnections) { if (!CurrentSelectionConnection.Contains(selectedItem)) { DeselectAll(); CurrentSelectionConnection.Add(selectedItem); } selectedItem.IsSelected = true; } } } if (!SelectedItemsAvailable) { StartSelectionRectangle = true; SelectionRectangleStart = e.Location; } StartDrag = true; } if (e.Button == MouseButtons.Middle) { MouseMiddleDownMovePositionLast = e.Location; } }
private void MouseServiceOnMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (!StartSelectionRectangle) { var mouseOverItems = RenderingEngine.CurrentProject.Items.Where(x => x.IsMouseOver); InputOutputSelector selector = null; foreach (var selectedItem in mouseOverItems) { selectedItem.IsSelected = true; List <InputOutputBase> inputOutputs = new List <InputOutputBase>(); inputOutputs.AddRange(selectedItem.Inputs); inputOutputs.AddRange(selectedItem.Outputs); var mouseOverInputOutput = inputOutputs.FirstOrDefault(x => x.IsMouseOver); if (mouseOverInputOutput != null) { selector = SetSelector(selectedItem, mouseOverInputOutput); break; } } if (NotComplete || !SignatureMatching) { if (InputOutputAvailable && !SelectorEquals(SelectedInputOutput, selector)) { _lastDestinationPoint = RenderingEngine.TranslatedMousePosition; _currentActionArgs = new ContextActionEventArgs { Selector = SelectedInputOutput, Location = e.Location }; OnContextAction(_currentActionArgs); _actionActive = true; } else { OnInComplete(); FinishContextActionIntern(); } } else { OnCompleted(); FinishContextActionIntern(); } } else { var selectedItems = RenderingEngine.CurrentProject.Items.Where(x => RectangleF.Intersect(x.Rectangle, SelectionRectangleTranslated) != RectangleF.Empty); foreach (var selectedItem in selectedItems) { selectedItem.IsSelected = true; CurrentSelection.Add(selectedItem); } } StartDrag = false; } }
public void Select(File track) { CurrentSelection.Add(track); }