/// <summary> /// 对选中歌曲项进行操作 /// </summary> /// <param name="operation">操作内容</param> public void OperateSelectedItems(SelectionOperation operation) { Action <SongModel> action = null; switch (operation) { case SelectionOperation.Delete: while (Songlist.SelectedIndex >= 0) { (Songlist.ItemsSource as IList <SongModel>).RemoveAt(Songlist.SelectedIndex); } return; case SelectionOperation.Love: action = model => model.IsLoved = true; // TODO: 在这更改设置的时候会抛出错误 break; case SelectionOperation.SelectAll: Songlist.SelectAll(); return; case SelectionOperation.SelectOther: OperateAllItems((item) => item.IsSelected = !item.IsSelected); return; } foreach (var item in Songlist.SelectedItems) { action?.Invoke(item as SongModel); } }
public static IEnumerator ApplySelectionOperation(SelectionOperation operation, IMetaSelectable selectable, IEnumerable <VisualPayload> selected) { var selectMode = new MetaSelectionMode(operation) { Selectable = selectable }; var iterator = selectMode.ApplyMode(selected); while (iterator.MoveNext()) { yield return(null); } }
/// <summary> /// 判断是否允许对歌曲项进行操作 /// </summary> /// <param name="operation">操作内容</param> public bool CanOperateItem(SelectionOperation operation) { if (operation == SelectionOperation.SelectAll || operation == SelectionOperation.SelectOther) { return(true); } if (Songlist.SelectedIndex < 0) { return(false); } switch (operation) { //case SelectionOperation.Delete: // return Songlist.SelectedIndex > 0; //case SelectionOperation.Love: // return true; default: return(true); } }
public IActionResult ProcessSelections(SelectionOperation operation, string targetFolderPath, [FromBody] PEngineResourceSelectionModel selections) { if (!IsRestrictedPath(targetFolderPath)) { var targetFolder = new PEngineFolderModel(targetFolderPath); if (targetFolder.Valid && selections != null) { bool valid = false; if (selections.FilePaths != null && selections.FilePaths.Any()) { foreach (var filePath in selections.FilePaths) { if (!IsRestrictedPath(filePath)) { var file = new PEngineFileModel(filePath); var targetFullPath = $"{targetFolder.FullPath}{System.IO.Path.DirectorySeparatorChar}{file.Name}"; if (file.Valid) { switch (operation) { case SelectionOperation.Copy: System.IO.File.Copy(file.FullPath, targetFullPath); break; case SelectionOperation.Move: System.IO.File.Move(file.FullPath, targetFullPath); break; case SelectionOperation.Delete: System.IO.File.Delete(file.FullPath); break; } valid = true; } } } } if (selections.FolderPaths != null && selections.FolderPaths.Any()) { foreach (var folderPath in selections.FolderPaths) { if (!IsRestrictedPath(folderPath)) { var folder = new PEngineFolderModel(folderPath); var targetFullPath = $"{targetFolder.FullPath}{System.IO.Path.DirectorySeparatorChar}{folder.Name}"; if (folder.Valid) { switch (operation) { case SelectionOperation.Copy: CopyFolder(folder.FullPath, targetFullPath); break; case SelectionOperation.Move: System.IO.Directory.Move(folder.FullPath, targetFullPath); break; case SelectionOperation.Delete: System.IO.Directory.Delete(folder.FullPath, true); break; } valid = true; } } } } if (valid) { return(Get(targetFolderPath)); } } } return(this.BadRequest()); }
public TreeGridRow SelectNode(TreeGridNodeReference node, SelectionOperation op) { int nodeIndex; using (new SelectionChangeSuppressor(this)) { if (!node.TryGetFlatIndex(out nodeIndex)) { Debug.Fail("Selected node must be exposed (can't be in a collapsed parent)!"); return null; } if (op == SelectionOperation.SelectOne) { ClearSelection(false); AddNodeToSelection(node); this.selectionAnchorIndex = nodeIndex; } else if (op == SelectionOperation.Toggle) { if (!this.selectedNodeReferences.ContainsKey(node)) { AddNodeToSelection(node); } else { RemoveNodeFromSelection(node); } if (this.selectionAnchorIndex == -1) { this.selectionAnchorIndex = nodeIndex; } } else if (op == SelectionOperation.Add) { if (!this.selectedNodeReferences.ContainsKey(node)) { AddNodeToSelection(node); if (this.selectionAnchorIndex == -1) { this.selectionAnchorIndex = nodeIndex; } } } else if (op == SelectionOperation.ExtendTo) { if (this.selectionAnchorIndex != -1) { int min = Math.Min(this.selectionAnchorIndex, nodeIndex); int max = Math.Max(this.selectionAnchorIndex, nodeIndex); ClearSelection(false); using (var nodeToSelect = this.rootNode.CreateNodeReference(min)) { while (nodeToSelect != null && (min <= max)) { AddNodeToSelection(nodeToSelect); if (!nodeToSelect.MoveToNextFlatNode()) { break; } min += 1; } } } } TreeGridRow newCurrentRow = null; foreach (var row in this.visibleRows) { row.IsSelected = this.selectedNodeReferences.ContainsKey(row.NodeReference); if (row.NodeReference.Equals(this.currentNode)) { newCurrentRow = row; } } if (newCurrentRow != null) { newCurrentRow.IsCurrent = true; } return newCurrentRow; } }
/// <summary> /// 判断是否允许对歌曲项进行操作 /// </summary> /// <param name="operation">操作内容</param> public bool CanOperateItem(SelectionOperation operation) { if (operation == SelectionOperation.SelectAll || operation == SelectionOperation.SelectOther) return true; if (Songlist.SelectedIndex < 0) return false; switch (operation) { //case SelectionOperation.Delete: // return Songlist.SelectedIndex > 0; //case SelectionOperation.Love: // return true; default: return true; } }
/// <summary> /// 对选中歌曲项进行操作 /// </summary> /// <param name="operation">操作内容</param> public void OperateSelectedItems(SelectionOperation operation) { Action<SongModel> action = null; switch (operation) { case SelectionOperation.Delete: while (Songlist.SelectedIndex >= 0) (Songlist.ItemsSource as IList<SongModel>).RemoveAt(Songlist.SelectedIndex); return; case SelectionOperation.Love: action = model => model.IsLoved = true; // TODO: 在这更改设置的时候会抛出错误 break; case SelectionOperation.SelectAll: Songlist.SelectAll(); return; case SelectionOperation.SelectOther: OperateAllItems((item) => item.IsSelected = !item.IsSelected); return; } foreach (var item in Songlist.SelectedItems) action?.Invoke(item as SongModel); }
/// <summary> /// Changes selection of the feature set adding new shapes using the specified mode /// </summary> public static void UpdateSelection(this IFeatureSet fs, IEnumerable <int> indices, SelectionOperation mode) { if (fs == null || indices == null) { return; } if (mode == SelectionOperation.New) { fs.ClearSelection(); } var sf = fs.GetInternal(); switch (mode) { case SelectionOperation.New: foreach (var item in indices) { sf.ShapeSelected[item] = true; } break; case SelectionOperation.Add: foreach (var item in indices) { sf.ShapeSelected[item] = true; } break; case SelectionOperation.Exclude: foreach (var item in indices) { sf.ShapeSelected[item] = false; } break; case SelectionOperation.Invert: foreach (var item in indices) { sf.ShapeSelected[item] = !sf.ShapeSelected[item]; } break; } }
/// <summary> /// Changes selection of the shapefile adding new shapes using the specified mode /// </summary> public void UpdateSelection(IEnumerable <int> indices, SelectionOperation mode) { FeatureSet.UpdateSelection(indices, mode); MapControl.FireSelectionChanged(MapControl, new SelectionChangedEventArgs(Handle, true)); }
public void UpdateSelection(IEnumerable <int> indices, SelectionOperation mode, Color selectionColor) { FeatureSet.SelectionColor = selectionColor; UpdateSelection(indices, mode); }
public MetaSelectionMode(SelectionOperation operationToPerform = SelectionOperation.SelectOnly) { OperationToPerform = operationToPerform; }