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); } } }
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); } } }