public void Save(FlowInfo flowInfo) { Type flowType = flowInfo.Flow.GetType(); FlowStorageAttribute flowStorage = flowType.GetCustomAttribute <FlowStorageAttribute>(); try { if (string.IsNullOrEmpty(flowInfo.Path) || !File.Exists(flowInfo.Path)) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = string.Format("{0} ({1})|{1}", flowStorage.Description, string.Join(";", flowStorage.Extensions.Select(e => "*" + e))); saveFileDialog.FilterIndex = 1; if (saveFileDialog.ShowDialog() != true) { return; } flowInfo.Path = saveFileDialog.FileName; } flowInfo.Flow.Save(flowInfo.Path); Log.Info("Saved flow to \"{0}\"", flowInfo.Path); flowInfo.History.Clear(); } catch (Exception e) { Error.Show(e, "An error occurred while saving your flow", App.Name); } }
private void NewFlowCommandCallback(object parameter) { XFlow flow = new XFlow(); FlowInfo flowInfo = new FlowInfo(flow, null); Flows.Add(flowInfo); CurrentFlow = flowInfo; }
public static VariableInfo From(FlowInfo flowInfo, Variable variable) { VariableInfo variableInfo; if (!variableInfos.TryGetValue(variable, out variableInfo)) { variableInfos.Add(variable, variableInfo = new VariableInfo(flowInfo, variable)); } return(variableInfo); }
public static NodeInfo From(FlowInfo flowInfo, Node node) { NodeInfo nodeInfo; if (!nodeInfos.TryGetValue(node, out nodeInfo)) { nodeInfos.Add(node, nodeInfo = new NodeInfo(flowInfo, node)); } return(nodeInfo); }
public override void Undo() { // Add the node FlowInfo.Flow.Nodes.Add(Node); // Restore all links to this node foreach (Slot slot in slots) { slot.Nodes.Add(Node); } FlowInfo.Update(); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { FlowInfo flowInfo = item as FlowInfo; Type flowType = flowInfo.Type; Type editorType = Assembly.GetExecutingAssembly().GetTypes() .Where(t => t.GetCustomAttribute <FlowEditorAttribute>() != null) .FirstOrDefault(t => t.GetCustomAttribute <FlowEditorAttribute>().Types.Contains(flowType)); DataTemplate dataTemplate = new DataTemplate(); dataTemplate.VisualTree = new FrameworkElementFactory(editorType); return(dataTemplate); }
private void XFlowEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { FlowInfo oldFlow = e.OldValue as FlowInfo; if (oldFlow != null) { oldFlow.PropertyChanged -= FlowInfo_PropertyChanged; } FlowInfo newFlow = e.NewValue as FlowInfo; if (newFlow != null) { newFlow.PropertyChanged += FlowInfo_PropertyChanged; } }
public void Open(string path) { Log.Info("Opening \"{0}\"", path); FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Exists) { MessageBox.Show("Could not find specified file " + path, "FlowTomator", MessageBoxButton.OK, MessageBoxImage.Error); return; } FlowInfo flowInfo = null; string error = ""; try { EditableFlow flow = EditableFlow.Load(fileInfo.FullName); flowInfo = new FlowInfo(flow, fileInfo.FullName); } catch (Exception e) { error = e.Message; if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } } if (flowInfo == null || flowInfo.Flow == null) { MessageBox.Show("Could not open specified file " + path + "." + Environment.NewLine + error, "FlowTomator", MessageBoxButton.OK, MessageBoxImage.Error); return; } Flows.Add(flowInfo); NotifyPropertyChanged(nameof(Flows)); }
public override void Do() { slots.Clear(); // Remove the node FlowInfo.Flow.Nodes.Remove(Node); // Remove all links to this node foreach (Node node in FlowInfo.Flow.Nodes) { foreach (Slot slot in node.Slots) { while (slot.Nodes.Contains(Node)) { slot.Nodes.Remove(Node); slots.Add(slot); } } } FlowInfo.Update(); }
private VariableInfo(FlowInfo flowInfo, Variable variable) { Variable = variable; FlowInfo = flowInfo; }
private NodeInfo(FlowInfo flowInfo, Node node) { FlowInfo = flowInfo; Node = node; NodeAnchorBinder.PropertyChanged += NodeAnchorBinder_PropertyChanged; }
public override void Undo() { FlowInfo.Flow.Nodes.Remove(Node); FlowInfo.Update(); }
public override void Do() { FlowInfo.Flow.Nodes.Add(Node); FlowInfo.Update(); }
public AddNodeAction(FlowInfo flow, Node node) { FlowInfo = flow; Node = node; }
public FlowDebugger(FlowInfo flowInfo) { FlowInfo = flowInfo; }