private void LoadFile_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); //ofd.Filter = ""; ofd.InitialDirectory = Helper.GetSettingsPath(); ofd.ValidateNames = true; ofd.CheckFileExists = true; if (ofd.ShowDialog() == true) { // load snippets data SnippetsDataSet sd = new SnippetsDataSet(); try { // sd.ReadXmlSchema("Snippets\\SnippetsDataSet.xsd"); sd.ReadXml(ofd.FileName); snippetList.Clear(); txtImportedFile.Clear(); foreach (SnippetsDataSet.SnippetsTableRow r in sd.SnippetsTable) snippetList.Add(new CodeSnippet(r)); FindDuplicates(); txtImportedFile.Text = ofd.FileName; } catch (Exception ex) { MessageBox.Show("Could not read snippet data from file \"" + ofd.FileName + "\"." + Environment.NewLine + ex.Message, "Error loading snippets file.", MessageBoxButton.OK, MessageBoxImage.Error); } } }
SnippetsDataSet.SnippetsTableDataTable SnippTable; // the current snippet database, before importing anything public SnippetImporter(SnippetsDataSet.SnippetsTableDataTable st) { snippetList = new ObservableCollection<CodeSnippet>(); InitializeComponent(); DataContext = this; SnippTable = st; }
private void Window_Loaded(object sender, RoutedEventArgs e) { /* if (!File.Exists(Helper.GetSettingsPath() + Consts.cSyntaxFile)) * { * MessageBox.Show("Syntax definitions not found"); * } * else * { * XmlReader r = new XmlTextReader(Helper.GetSettingsPath() + Consts.cSyntaxFile); * txtSnippetCode.SyntaxHighlighting = HighlightingLoader.Load(r, null); //HighlightingManager.Instance..GetDefinition("C#"); * txtSampleCode.SyntaxHighlighting = txtSnippetCode.SyntaxHighlighting; //HighlightingManager.Instance..GetDefinition("C#"); * r.Close(); * }*/ snippetsDataSet = ((SnippetsDataSet)(this.FindResource("snippetsDataSet"))); snippetsTable = snippetsDataSet.Tables["SnippetsTable"] as SnippetsDataSet.SnippetsTableDataTable; snippetsTableViewSource = (CollectionViewSource)this.FindResource("snippetsTableViewSource"); if (File.Exists(Helper.GetSettingsPath() + Consts.cSnippetsFile)) { snippetsDataSet.ReadXml(Helper.GetSettingsPath() + Consts.cSnippetsFile); // TODO: Program stops here...very strange ... due to images??? snippetsTableViewSource.View.Refresh(); } }
private void LoadFile_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); //ofd.Filter = ""; ofd.InitialDirectory = Helper.GetSettingsPath(); ofd.ValidateNames = true; ofd.CheckFileExists = true; if (ofd.ShowDialog() == true) { // load snippets data SnippetsDataSet sd = new SnippetsDataSet(); try { // sd.ReadXmlSchema("Snippets\\SnippetsDataSet.xsd"); sd.ReadXml(ofd.FileName); snippetList.Clear(); txtImportedFile.Clear(); foreach (SnippetsDataSet.SnippetsTableRow r in sd.SnippetsTable) { snippetList.Add(new CodeSnippet(r)); } FindDuplicates(); txtImportedFile.Text = ofd.FileName; } catch (Exception ex) { MessageBox.Show("Could not read snippet data from file \"" + ofd.FileName + "\"." + Environment.NewLine + ex.Message, "Error loading snippets file.", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public SnippetListModel(ISnippetListView TheView) { this.TheView = TheView; snippetsDataSet = new SnippetsDataSet(); }
public void HandleUseStyleButtonClick(SnippetsDataSet.SnippetsTableRow r) { UseStylesEventArgs args = new UseStylesEventArgs(); if (!r.IsNull(snippetsTable.NodeStyleColumn)) args.nodestyle = r.NodeStyle; if (!r.IsNull(snippetsTable.EdgeStyleColumn)) args.edgestyle = r.EdgeStyle; if (!r.IsNull(snippetsTable.DependenciesColumn)) args.dependencies = r.Dependencies; args.InAddition = System.Windows.Forms.Control.ModifierKeys.HasFlag(Keys.Control); TheView.RaiseOnUseStyle(args); }
public void HandleInsertAsTikzStyleClick(SnippetsDataSet.SnippetsTableRow r) { string toinsert = "", dependencies = ""; if (!r.IsNull(snippetsTable.NodeStyleColumn) && !(r.NodeStyle.Trim() == "")) toinsert += "\\tikzstyle{mynodestyle} = [" + r.NodeStyle + "]" + Environment.NewLine; if (!r.IsNull(snippetsTable.EdgeStyleColumn) && !(r.EdgeStyle.Trim() == "")) toinsert += "\\tikzstyle{myedgestyle} = [" + r.EdgeStyle + "]" + Environment.NewLine; if (!r.IsNull(snippetsTable.DependenciesColumn)) dependencies = r.Dependencies; TheView.RaiseOnInsert(new InsertEventArgs() { code = toinsert, dependencies = dependencies }); }
public void HandleInsertDependenciesClick(SnippetsDataSet.SnippetsTableRow r) { string d = ""; if (!r.IsNull(snippetsTable.DependenciesColumn)) d = r.Dependencies; TheView.RaiseOnInsert(new InsertEventArgs() { code = @"\usetikzlibrary{" + d + "}" + Environment.NewLine, dependencies = d }); }
public void HandleInsertFullCodeClick(SnippetsDataSet.SnippetsTableRow r) { string c = "", d = ""; if (!r.IsNull(snippetsTable.SampleCodeColumn)) c = r.SampleCode; if (!r.IsNull(snippetsTable.DependenciesColumn)) d = r.Dependencies; TheView.RaiseOnInsert(new InsertEventArgs() { code = c, dependencies = d }); }
public void FillRow(SnippetsDataSet.SnippetsTableRow r) { r.Name = Name; r.Category = Category; r.Description = Description; r.SampleCode = SampleCode; r.SnippetCode = SnippetCode; r.EdgeStyle = EdgeStyle; r.NodeStyle = NodeStyle; r.Dependencies = Dependencies; }
public SnippetsDataSet.SnippetsTableRow tag; // used to remember the datatable row to be changed, if applicable public CodeSnippet( SnippetsDataSet.SnippetsTableRow r ) { Name = r.Name; Category = r.Category; Description = r.Description; SampleCode = r.SampleCode; SnippetCode = r.SnippetCode; EdgeStyle = r.IsEdgeStyleNull()?"":r.EdgeStyle; NodeStyle = r.IsNodeStyleNull() ? "" : r.NodeStyle; Dependencies = r.Dependencies; IsSelected = false; IsAlreadyThere = false; IsChanged = false; }