本文整理汇总了C#中Dynamo.Models.FunctionNamePromptEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# FunctionNamePromptEventArgs类的具体用法?C# FunctionNamePromptEventArgs怎么用?C# FunctionNamePromptEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionNamePromptEventArgs类属于Dynamo.Models命名空间,在下文中一共展示了FunctionNamePromptEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRequestsFunctionNamePrompt
public void OnRequestsFunctionNamePrompt(Object sender, FunctionNamePromptEventArgs e)
{
if (RequestsFunctionNamePrompt != null)
{
RequestsFunctionNamePrompt(this, e);
}
}
示例2: ShowNewFunctionDialogAndMakeFunction
/// <summary>
/// Present the new function dialogue and create a custom function.
/// </summary>
/// <param name="parameter"></param>
private void ShowNewFunctionDialogAndMakeFunction(object parameter)
{
var args = new FunctionNamePromptEventArgs();
this.Model.OnRequestsFunctionNamePrompt(this, args);
if (args.Success)
{
this.ExecuteCommand(new DynamoModel.CreateCustomNodeCommand(Guid.NewGuid(),
args.Name, args.Category, args.Description, true));
this.ShowStartPage = false;
}
}
示例3: ShowNewFunctionDialog
/// <summary>
/// Presents the function name dialogue. Returns true if the user enters
/// a function name and category.
/// </summary>
/// <param name="name"></param>
/// <param name="category"></param>
/// <returns></returns>
internal void ShowNewFunctionDialog(FunctionNamePromptEventArgs e)
{
var categorized =
SearchCategoryUtil.CategorizeSearchEntries(
dynamoViewModel.Model.SearchModel.SearchEntries,
entry => entry.Categories);
var allCategories =
categorized.SubCategories.SelectMany(sub => sub.GetAllCategoryNames());
var dialog = new FunctionNamePrompt(allCategories)
{
categoryBox = { Text = e.Category },
DescriptionInput = { Text = e.Description },
nameView = { Text = e.Name },
nameBox = { Text = e.Name },
// center the prompt
Owner = this,
WindowStartupLocation = WindowStartupLocation.CenterOwner
};
if (e.CanEditName)
{
dialog.nameBox.Visibility = Visibility.Visible;
dialog.nameView.Visibility = Visibility.Collapsed;
}
else
{
dialog.nameView.Visibility = Visibility.Visible;
dialog.nameBox.Visibility = Visibility.Collapsed;
}
if (dialog.ShowDialog() != true)
{
e.Success = false;
return;
}
e.Name = dialog.Text;
e.Category = dialog.Category;
e.Description = dialog.Description;
e.Success = true;
}
示例4: DynamoViewModelRequestsFunctionNamePrompt
/// <summary>
/// Handles the request for the presentation of the function name prompt
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void DynamoViewModelRequestsFunctionNamePrompt(object sender, FunctionNamePromptEventArgs e)
{
ShowNewFunctionDialog(e);
}
示例5: CollapsedNodeWOrkspaceIsAddedToDynamoWithUnsavedChanges
public void CollapsedNodeWOrkspaceIsAddedToDynamoWithUnsavedChanges()
{
NodeModel node;
if (!CurrentDynamoModel.NodeFactory.CreateNodeFromTypeName("CoreNodeModels.Input.DoubleInput", out node))
{
throw new Exception("Failed to create node!");
}
var selectionSet = new[] { node };
DynamoModel.FunctionNamePromptRequestHandler del = (sender, args) =>
{
args.Category = "Testing";
args.Description = "";
args.Name = "__CollapseTest__";
args.Success = true;
};
CurrentDynamoModel.RequestsFunctionNamePrompt += del;
var arg = new FunctionNamePromptEventArgs();
CurrentDynamoModel.OnRequestsFunctionNamePrompt(null, arg);
Assert.IsTrue(arg.Success);
CurrentDynamoModel.AddCustomNodeWorkspace(
CurrentDynamoModel.CustomNodeManager.Collapse(
selectionSet, Enumerable.Empty<NoteModel>(),
CurrentDynamoModel.CurrentWorkspace, DynamoModel.IsTestMode, arg));
Assert.IsNotNull(CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace<Function>());
Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
Assert.AreEqual(2, CurrentDynamoModel.Workspaces.Count());
var customWorkspace = CurrentDynamoModel.Workspaces.ElementAt(1);
Assert.AreEqual("__CollapseTest__", customWorkspace.Name);
Assert.IsTrue(customWorkspace.HasUnsavedChanges);
}
示例6: ShowNewFunctionDialog
/// <summary>
/// Presents the function name dialogue. Returns true if the user enters
/// a function name and category.
/// </summary>
/// <param name="name"></param>
/// <param name="category"></param>
/// <returns></returns>
public void ShowNewFunctionDialog(FunctionNamePromptEventArgs e)
{
string error = "";
do
{
var dialog = new FunctionNamePrompt(dynSettings.Controller.SearchViewModel.Categories)
{
categoryBox = { Text = e.Category },
DescriptionInput = { Text = e.Description },
nameView = { Text = e.Name },
nameBox = { Text = e.Name }
};
if (e.CanEditName)
{
dialog.nameBox.Visibility = Visibility.Visible;
dialog.nameView.Visibility = Visibility.Collapsed;
}
else
{
dialog.nameView.Visibility = Visibility.Visible;
dialog.nameBox.Visibility = Visibility.Collapsed;
}
if (dialog.ShowDialog() != true)
{
e.Success = false;
return;
}
if (String.IsNullOrEmpty(dialog.Text))
{
error = "You must supply a name.";
MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
MessageBoxImage.Error);
}
else if (e.Name != dialog.Text && dynSettings.Controller.BuiltInTypesByNickname.ContainsKey(dialog.Text))
{
error = "A built-in node with the given name already exists.";
MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
MessageBoxImage.Error);
}
else if (dialog.Category.Equals(""))
{
error = "You must enter a new category or choose one from the existing categories.";
MessageBox.Show(error, "Custom Node Property Error", MessageBoxButton.OK,
MessageBoxImage.Error);
}
else
{
error = "";
}
e.Name = dialog.Text;
e.Category = dialog.Category;
e.Description = dialog.Description;
} while (!error.Equals(""));
e.Success = true;
}
示例7: _vm_RequestsFunctionNamePrompt
/// <summary>
/// Handles the request for the presentation of the function name prompt
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _vm_RequestsFunctionNamePrompt(object sender, FunctionNamePromptEventArgs e)
{
ShowNewFunctionDialog(e);
}
示例8: ShowNewFunctionDialogAndMakeFunction
/// <summary>
/// Present the new function dialogue and create a custom function.
/// </summary>
/// <param name="parameter"></param>
public void ShowNewFunctionDialogAndMakeFunction(object parameter)
{
//trigger the event to request the display
//of the function name dialogue
var args = new FunctionNamePromptEventArgs();
OnRequestsFunctionNamePrompt(this, args);
if (args.Success)
{
NewCustomNodeWorkspace(Guid.NewGuid(), args.Name, args.Category, args.Description, true);
}
}
示例9: ShowNewFunctionDialogAndMakeFunction
/// <summary>
/// Present the new function dialogue and create a custom function.
/// </summary>
/// <param name="parameter"></param>
private void ShowNewFunctionDialogAndMakeFunction(object parameter)
{
//trigger the event to request the display
//of the function name dialogue
var args = new FunctionNamePromptEventArgs();
this.Model.OnRequestsFunctionNamePrompt(this, args);
if (args.Success)
{
this.ExecuteCommand(new CreateCustomNodeCommand(Guid.NewGuid(),
args.Name, args.Category, args.Description, true));
}
}
示例10: VmOnWorkspacePropertyEditRequested
private void VmOnWorkspacePropertyEditRequested(WorkspaceModel workspace)
{
// copy these strings
var newName = workspace.Name.Substring(0);
var newCategory = workspace.Category.Substring(0);
var newDescription = workspace.Description.Substring(0);
var args = new FunctionNamePromptEventArgs
{
Name = newName,
Description = newDescription,
Category = newCategory,
CanEditName = false
};
dynSettings.Controller.DynamoModel.OnRequestsFunctionNamePrompt(this, args);
if (args.Success)
{
if (workspace is CustomNodeWorkspaceModel)
{
var def = (workspace as CustomNodeWorkspaceModel).FunctionDefinition;
dynSettings.CustomNodeManager.Refactor(def.FunctionId, args.CanEditName ? args.Name : workspace.Name, args.Category, args.Description);
}
if (args.CanEditName) workspace.Name = args.Name;
workspace.Description = args.Description;
workspace.Category = args.Category;
// workspace.Author = "";
}
}
示例11: CollapseNodes
/// <summary>
/// Collapse a set of nodes in this workspace
/// </summary>
/// <param name="selectedNodes"> The function definition for the user-defined node </param>
internal void CollapseNodes(IEnumerable<NodeModel> selectedNodes)
{
var args = new FunctionNamePromptEventArgs();
DynamoViewModel.Model.OnRequestsFunctionNamePrompt(null, args);
if (!args.Success)
return;
DynamoViewModel.Model.AddCustomNodeWorkspace(
DynamoViewModel.Model.CustomNodeManager.Collapse(
selectedNodes, Model, DynamoModel.IsTestMode, args));
}
示例12: Collapse
/// <summary>
/// Collapse a set of nodes in a given workspace.
/// </summary>
/// <param name="dynamoModel">The current DynamoModel</param>
/// <param name="selectedNodes"> The function definition for the user-defined node </param>
/// <param name="currentWorkspace"> The workspace where</param>
/// <param name="args"></param>
public static void Collapse(DynamoModel dynamoModel, IEnumerable<NodeModel> selectedNodes, WorkspaceModel currentWorkspace, FunctionNamePromptEventArgs args = null)
{
var selectedNodeSet = new HashSet<NodeModel>(selectedNodes);
if (args == null || !args.Success)
{
args = new FunctionNamePromptEventArgs();
dynamoModel.OnRequestsFunctionNamePrompt(null, args);
if (!args.Success)
{
return;
}
}
// Note that undoable actions are only recorded for the "currentWorkspace",
// the nodes which get moved into "newNodeWorkspace" are not recorded for undo,
// even in the new workspace. Their creations will simply be treated as part of
// the opening of that new workspace (i.e. when a user opens a file, she will
// not expect the nodes that show up to be undoable).
//
// After local nodes are moved into "newNodeWorkspace" as the result of
// conversion, if user performs an undo, new set of nodes will be created in
// "currentWorkspace" (not moving those nodes in the "newNodeWorkspace" back
// into "currentWorkspace"). In another word, undo recording is on a per-
// workspace basis, it does not work across different workspaces.
//
UndoRedoRecorder undoRecorder = currentWorkspace.UndoRecorder;
using (undoRecorder.BeginActionGroup())
{
var newNodeWorkspace = new CustomNodeWorkspaceModel(
dynamoModel,
args.Name,
args.Category,
args.Description,
0,
0) { WatchChanges = false, HasUnsavedChanges = true };
var newNodeDefinition = new CustomNodeDefinition(Guid.NewGuid())
{
WorkspaceModel = newNodeWorkspace
};
currentWorkspace.DisableReporting();
#region Determine Inputs and Outputs
//Step 1: determine which nodes will be inputs to the new node
var inputs =
new HashSet<Tuple<NodeModel, int, Tuple<int, NodeModel>>>(
selectedNodeSet.SelectMany(
node =>
Enumerable.Range(0, node.InPortData.Count)
.Where(node.HasConnectedInput)
.Select(data => Tuple.Create(node, data, node.Inputs[data]))
.Where(input => !selectedNodeSet.Contains(input.Item3.Item2))));
var outputs =
new HashSet<Tuple<NodeModel, int, Tuple<int, NodeModel>>>(
selectedNodeSet.SelectMany(
node =>
Enumerable.Range(0, node.OutPortData.Count)
.Where(node.HasOutput)
.SelectMany(
data =>
node.Outputs[data].Where(
output => !selectedNodeSet.Contains(output.Item2))
.Select(output => Tuple.Create(node, data, output)))));
#endregion
#region Detect 1-node holes (higher-order function extraction)
var curriedNodeArgs =
new HashSet<NodeModel>(
inputs.Select(x => x.Item3.Item2)
.Intersect(outputs.Select(x => x.Item3.Item2))).Select(
outerNode =>
{
//var node = new Apply1();
var node = newNodeWorkspace.AddNode<Apply1>();
node.SetNickNameFromAttribute();
node.DisableReporting();
node.X = outerNode.X;
node.Y = outerNode.Y;
//Fetch all input ports
// in order
// that have inputs
//.........这里部分代码省略.........
示例13: Collapse
/// <summary>
/// Collapse a set of nodes in a given workspace. Has the side effects of prompting the user
/// first in order to obtain the name and category for the new node,
/// writes the function to a dyf file, adds it to the FunctionDict, adds it to search, and compiles and
/// places the newly created symbol (defining a lambda) in the Controller's FScheme Environment.
/// </summary>
/// <param name="selectedNodes"> The function definition for the user-defined node </param>
/// <param name="currentWorkspace"> The workspace where</param>
public static void Collapse(IEnumerable<NodeModel> selectedNodes, WorkspaceModel currentWorkspace, FunctionNamePromptEventArgs args=null)
{
var selectedNodeSet = new HashSet<NodeModel>(selectedNodes);
if (args == null || !args.Success)
{
args = new FunctionNamePromptEventArgs();
dynSettings.Controller.DynamoModel.OnRequestsFunctionNamePrompt(null, args);
//if (!dynSettings.Controller.DynamoViewModel.ShowNewFunctionDialog(ref newNodeName, ref newNodeCategory))
if (!args.Success)
{
return;
}
}
var newNodeWorkspace = new CustomNodeWorkspaceModel(args.Name, args.Category, args.Description, 0, 0)
{
WatchChanges = false,
HasUnsavedChanges = true
};
var newNodeDefinition = new FunctionDefinition(Guid.NewGuid())
{
WorkspaceModel = newNodeWorkspace
};
currentWorkspace.DisableReporting();
#region Determine Inputs and Outputs
//Step 1: determine which nodes will be inputs to the new node
var inputs = new HashSet<Tuple<NodeModel, int, Tuple<int, NodeModel>>>(
selectedNodeSet.SelectMany(
node => Enumerable.Range(0, node.InPortData.Count).Where(node.HasConnectedInput)
.Select(data => Tuple.Create(node, data, node.Inputs[data]))
.Where(input => !selectedNodeSet.Contains(input.Item3.Item2))));
var outputs = new HashSet<Tuple<NodeModel, int, Tuple<int, NodeModel>>>(
selectedNodeSet.SelectMany(
node => Enumerable.Range(0, node.OutPortData.Count).Where(node.HasOutput).SelectMany(
data => node.Outputs[data]
.Where(output => !selectedNodeSet.Contains(output.Item2))
.Select(output => Tuple.Create(node, data, output)))));
#endregion
#region Detect 1-node holes (higher-order function extraction)
var curriedNodeArgs =
new HashSet<NodeModel>(
inputs
.Select(x => x.Item3.Item2)
.Intersect(outputs.Select(x => x.Item3.Item2)))
.Select(
outerNode =>
{
var node = new Apply1();
//MVVM : Don't make direct reference to view here
//MVVM: no reference to view here
//dynNodeView nodeUI = node.NodeUI;
var elNameAttrib =
node.GetType().GetCustomAttributes(typeof(NodeNameAttribute), true)[0] as
NodeNameAttribute;
if (elNameAttrib != null)
{
node.NickName = elNameAttrib.Name;
}
node.GUID = Guid.NewGuid();
//store the element in the elements list
newNodeWorkspace.Nodes.Add(node);
node.WorkSpace = newNodeWorkspace;
node.DisableReporting();
//MVVM : Can't set view location here
//dynSettings.Bench.WorkBench.Children.Add(nodeUI);
//Place it in an appropriate spot
//Canvas.SetLeft(nodeUI, Canvas.GetLeft(outerNode.NodeUI));
//Canvas.SetTop(nodeUI, Canvas.GetTop(outerNode.NodeUI));
node.X = outerNode.X;
node.Y = outerNode.Y;
//Fetch all input ports
// in order
// that have inputs
//.........这里部分代码省略.........
示例14: OnRequestsFunctionNamePrompt
internal void OnRequestsFunctionNamePrompt(Object sender, FunctionNamePromptEventArgs e)
{
if (RequestsFunctionNamePrompt != null)
RequestsFunctionNamePrompt(this, e);
}
示例15: VmOnWorkspacePropertyEditRequested
private void VmOnWorkspacePropertyEditRequested(WorkspaceModel workspace)
{
var customNodeWs = workspace as CustomNodeWorkspaceModel;
if (customNodeWs != null)
{
// copy these strings
var newName = customNodeWs.Name.Substring(0);
var newCategory = customNodeWs.Category.Substring(0);
var newDescription = customNodeWs.Description.Substring(0);
var args = new FunctionNamePromptEventArgs
{
Name = newName,
Description = newDescription,
Category = newCategory,
CanEditName = false
};
this.ViewModel.DynamoViewModel.Model.OnRequestsFunctionNamePrompt(this, args);
if (args.Success)
{
customNodeWs.SetInfo(
args.CanEditName ? args.Name : workspace.Name,
args.Category,
args.Description);
}
}
}