public void Export(IProject2 project, ConfigParameterString exportPath, Func <Id <LocalizedStringType>, Id <LocalizedText>, Tuple <string, DateTime> > localize, IErrorCheckerUtilities <IConversationNode> util) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (exportPath == null) { throw new ArgumentNullException(nameof(exportPath)); } using (var sfd = new SaveFileDialog()) { sfd.DefaultExt = "*.ssv"; sfd.AddExtension = true; sfd.CreatePrompt = false; sfd.InitialDirectory = exportPath.Value; sfd.OverwritePrompt = true; sfd.ValidateNames = true; sfd.Title = "Export to C# source file"; sfd.DefaultExt = ".ssv"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { exportPath.Value = Path.GetDirectoryName(sfd.FileName); FileStream stream = null; try { stream = new FileStream(sfd.FileName, FileMode.OpenOrCreate, FileAccess.Write); stream.SetLength(0); using (var sw = new StreamWriter(stream)) { stream = null; ExportAsSsv ssv = new ExportAsSsv((type, textId) => localize(type, textId).Item1); CsvData.WriteTitle(";", sw, true); foreach (var con in project.ConversationFilesCollection) { ssv.WriteConversation(con, sw, true, util); } } } finally { if (stream != null) { stream.Dispose(); } } } } }
public void Export(IProject2 project, ConfigParameterString exportPath, Func <Id <LocalizedStringType>, Id <LocalizedText>, Tuple <string, DateTime> > localize, IErrorCheckerUtilities <IConversationNode> util) { DomainData builtIn = new DomainData(); builtIn.Connectors.Add(SpecialConnectors.Input); builtIn.Connectors.Add(SpecialConnectors.Output); var data = project.DomainFilesCollection.Select(d => d.Data).Concat(builtIn.Only()); using (var sfd = new SaveFileDialog()) { sfd.DefaultExt = "*.cs"; sfd.AddExtension = true; sfd.CreatePrompt = false; sfd.InitialDirectory = exportPath.Value; sfd.OverwritePrompt = true; sfd.ValidateNames = true; sfd.Title = "Export to C# source file"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { exportPath.Value = Path.GetDirectoryName(sfd.FileName); string @namespace = project.File.File.Name; @namespace = Path.ChangeExtension(@namespace, null); @namespace = new string(@namespace.Where(c => char.IsLetterOrDigit(c) || c == '_').ToArray()); if (@namespace.Length == 0) { @namespace = "MyNamespace"; } while (char.IsDigit(@namespace.First())) { @namespace = @namespace.Substring(1); if (@namespace.Length == 0) { @namespace = "MyNamespace"; } } CSDomainSerializer <INodeGui, NodeUIData, ConversationEditorData> s = new CSDomainSerializer <INodeGui, NodeUIData, ConversationEditorData>(BasicTypeMap(), @namespace); using (var stream = new FileStream(sfd.FileName, FileMode.OpenOrCreate, FileAccess.Write)) { stream.SetLength(0); s.Write(data, stream); } } } }
public IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer) { yield return(new MenuAction <ConversationNode>("Reset Zoom", (n, p) => null, null, null, (p) => { control.GraphScale = 1; })); //yield return new MenuAction2<ConversationNode>("Delete", (n, p) => () => { Delete(n); }, null, null, null); //yield return new MenuAction2<ConversationNode>("Remove Links", (n, p) => null, (i, p) => { control.CurrentFile.RemoveLinks(i); }, null, null); }
public virtual IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer) { MenuAction <ConversationNode> addNodes = new MenuAction <ConversationNode>("Add Node", (n, p) => null, null, null, p => { }); AddNodeMenuItem(addNodes, control.DataSource.Nodes, control); yield return(addNodes); yield return(new MenuAction <ConversationNode>("Reset Zoom", (n, p) => null, null, null, (p) => { control.GraphScale = 1; })); yield return(new MenuAction <ConversationNode>("Paste", (n, p) => null, null, null, (p) => { control.Paste(p); })); yield return(new MenuAction <ConversationNode>("Delete", (n, p) => () => { control.CurrentFile.Remove(n.Only(), Enumerable.Empty <NodeGroup>(), localizer); }, null, null, null)); yield return(new MenuAction <ConversationNode>("Remove Links", (n, p) => () => { foreach (var c in n.Data.Connectors) { control.CurrentFile.RemoveLinks(c); } }, (i, p) => { control.CurrentFile.RemoveLinks(i); }, null, null)); yield return(new MenuAction <ConversationNode>("Copy ID", (n, p) => control.ShowIds ? () => Clipboard.SetText(n.Data.NodeId.Serialized()) : (Action)null, null, null, null)); }
public override IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer) { foreach (var action in base.GetMenuActions(control, project, log, localizer)) { yield return(action); } yield return(new MenuAction <ConversationNode>("Find References", (n, p) => () => FileReferences(n), null, null, null)); }
public IEnumerable <MenuAction <ConversationNode <INodeGui> > > GetMenuActions(IGraphEditorControl <ConversationNode <INodeGui> > control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer) { //XmlGraphData<NodeUIData, ConversationEditorData> data; //Assembly assembly = Assembly.GetExecutingAssembly(); //using (Stream stream = assembly.GetManifestResourceStream("PluginPack.Templates.Basic Conversation.xml")) //{ // data = SerializationUtils.ConversationDeserializer(control.DataSource).Read(stream); //} yield return(new MenuAction <ConversationNode>("Find Nodes of Type", (a, b) => () => { var nodesofType = project.ConversationFilesCollection.SelectMany(f => f.Nodes.Where(n => n.Data.NodeTypeId == a.Data.NodeTypeId).Select(n => new { Node = n, File = f })); log(nodesofType.Select(n => new LogElement(n.File, n.Node, localizer))); } , null, null, null)); }
public IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer) { XmlGraphData <NodeUIData, ConversationEditorData> data; Assembly assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream("Clandestine.Templates.Basic Conversation.xml")) { data = SerializationUtils.ConversationDeserializer(control.DataSource).Read(stream); } yield return(new MenuAction <ConversationNode>("Basic Conversation", (a, b) => null, null, null, p => { control.Insert(p, Tuple.Create(data.Nodes, data.EditorData.Groups, new object(), true)); })); }
public IEnumerable <MenuAction <ConversationNode> > GetMenuActions(IGraphEditorControl <ConversationNode> control, IProject2 project, Action <IEnumerable <IErrorListElement> > log, ILocalizationEngine localizer) { Action <ConversationNode, Point> jump = (n, p) => { if (n.Data.NodeTypeId == SpecialNodes.JumpTo) { var targetnodes = control.CurrentFile.Nodes.Where(a => a.Data.NodeTypeId == SpecialNodes.JumpTarget); var target = targetnodes.FirstOrDefault(t => GetId(t) == GetTarget(n)); if (target != null) { control.SelectNode(target); } } else if (n.Data.NodeTypeId == SpecialNodes.JumpTarget) { var sourceNodes = control.CurrentFile.Nodes.Where(a => a.Data.NodeTypeId == SpecialNodes.JumpTo); var source = sourceNodes.FirstOrDefault(t => GetTarget(t) == GetId(n)); if (source != null) { control.SelectNode(source); } } }; yield return(new MenuAction <ConversationNode>("Jump", (n, p) => (n.Data.NodeTypeId == SpecialNodes.JumpTo || n.Data.NodeTypeId == SpecialNodes.JumpTarget ? () => jump(n, p) : (Action)null), null, null, null)); }