/// <summary> /// Determines of the tree tool is enabled for the specified selection of items. /// </summary> /// <param name="selection">The selection.</param> /// <returns> /// Returns bitwise flag combination of the <see cref="mmToolState" /> to specify if enabled. /// </returns> protected virtual int InternalEnabled(IMMTreeViewSelection selection) { if (selection == null) { return(0); } if (selection.Count != 1) { return(0); } selection.Reset(); IMMPxNode node = (IMMPxNode)selection.Next; IMMPxTask task = ((IMMPxNode3)node).GetTaskByName(this.Name); if (task == null) { return(0); } if (task.get_Enabled(node)) { return(3); } return(0); }
/// <summary> /// Called when the user clicks a command. /// </summary> /// <remarks> /// Note to inheritors: override OnClick and use this method to /// perform the actual work of the custom command. /// </remarks> public override void OnClick() { try { IMMPxApplication pxApp = this.Application.GetPxApplication(); IMMPxNode node = pxApp.GetCurrentNode(); IMMPxTask task = node.GetTask(this.TaskName, true); task.Execute(node); } catch (Exception ex) { Log.Error(this.Caption, ex); } }
/// <summary> /// Creates an <see cref="IEnumerable{T}" /> from an <see cref="IMMEnumPxTasks" /> /// </summary> /// <param name="source">An <see cref="IMMEnumPxTasks" /> to create an <see cref="IEnumerable{T}" /> from.</param> /// <returns> /// An <see cref="IEnumerable{T}" /> that contains the fields from the input source. /// </returns> public static IEnumerable <IMMPxTask> AsEnumerable(this IMMEnumPxTasks source) { if (source != null) { source.Reset(); IMMPxTask task = source.Next(); while (task != null) { yield return(task); task = source.Next(); } } }
/// <summary> /// Executes the tree tool within error handling. /// </summary> /// <param name="selection">The selection.</param> protected virtual void InternalExecute(IMMTreeViewSelection selection) { // Only enable if 1 item is selected. if (selection == null || selection.Count != 1) { return; } // Execute the Task for the specified node. selection.Reset(); IMMPxNode node = (IMMPxNode)selection.Next; IMMPxTask task = ((IMMPxNode3)node).GetTaskByName(this.Name); if (task == null) { return; } task.Execute(node); }