private void duplicateToolStripMenuItem_Click(object sender, EventArgs e) { if (listViewGraph.SelectedItems.Count != 1) { MessageBox.Show("no graph is selected"); return; } var graphUri = (string)listViewGraph.SelectedItems[0].Tag; var g = new Graph(); fuseki.LoadGraph(g, graphUri); var form = new SingleForm { Title = "Set New Graph URI", Label = "URI", Content = graphUri }; if (form.ShowDialog() != DialogResult.OK) { return; } var srcUri = graphUri; var srcGraphBase64 = GraphEditor.Base64Encode(srcUri); var dstUri = form.Content; var dstGraphLabel = dstUri.Split(new[] { '/', '#' }).Last(); var dstGraphBase64 = GraphEditor.Base64Encode(dstUri); var newg = new Graph { BaseUri = new Uri(dstUri) }; var nLabel = newg.CreateUriNode(UriFactory.Create("http://www.w3.org/2000/01/rdf-schema#label")); newg.Assert(new Triple(newg.CreateUriNode(UriFactory.Create(dstUri)), nLabel, newg.CreateLiteralNode(dstGraphLabel))); var cnt = 0; foreach (var triple in g.Triples) { INode news = newg.CreateUriNode(UriFactory.Create(triple.Subject.ToString().Replace(srcUri, dstUri))); INode newp = newg.CreateUriNode(UriFactory.Create(triple.Predicate.ToString().Replace(srcUri, dstUri))); INode newo = null; if (triple.Object.NodeType == NodeType.Uri) { newo = newg.CreateUriNode(UriFactory.Create(triple.Object.ToString().Replace(srcUri, dstUri))); } else if (triple.Object.NodeType == NodeType.Literal) { newo = newg.CreateLiteralNode(triple.Object.ToString().Replace(srcUri, dstUri)); } var asserted = newg.Assert(new Triple(news, newp, newo)); if (asserted) { cnt++; } } var srcPath = string.Format(@"{0}\{1}.txt", DocumentRoot, srcGraphBase64); var dstPath = string.Format(@"{0}\{1}.txt", DocumentRoot, dstGraphBase64); File.Copy(srcPath, dstPath); fuseki.SaveGraph(newg); UpdateListViewGraph(); MessageBox.Show(string.Format("total {0} triples cloned", cnt)); }
private void listViewGraph_SelectedIndexChanged(object sender, EventArgs e) { if (listViewGraph.SelectedItems.Count != 1) return; var uri = (string) listViewGraph.SelectedItems[0].Tag; UpdateListViewGraphColor(uri); var tabpage = GetTabPage(uri); if (tabpage == null) { tabpage = new TabPage(uri); var graphEditor = new GraphEditor(); graphEditor.SetGraph(uri); graphEditor.Dock = DockStyle.Fill; tabpage.Controls.Add(graphEditor); tabpage.Tag = graphEditor; tabControlGraph.TabPages.Add(tabpage); closeGraphToolStripMenuItem.Enabled = true; } tabControlGraph.SelectedTab = tabpage; }
public DynamicCollection(AutocompleteMenu menu, FastColoredTextBox tb, GraphEditor editor) { this.menu = menu; this.tb = tb; this.editor = editor; }