private void InitializeXPathDocumentContent(XPathDocumentContent xpathDocumentContent) { xpathDocumentContent.TreeView.FontFamily = new FontFamily(Properties.Settings.Default.FontFamilyName); xpathDocumentContent.TreeView.FontSize = Properties.Settings.Default.FontSize; this.dockingManager.MainDocumentPane.Items.Add(xpathDocumentContent); this.dockingManager.ActiveDocument = xpathDocumentContent; }
private void ExpandAll() { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } xpathDocumentContent.TreeView.ExpandAll(); }
private void CopyOuterXml() { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } xpathDocumentContent.TreeView.CopyOuterXml(); }
private void CopyXPath() { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } this.textBoxXPath.Text = xpathDocumentContent.TreeView.CopyXPath(); }
private void SaveAs(bool formatting) { // get the selected tab XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } xpathDocumentContent.TreeView.SaveAs(formatting); }
private void LoadErrorList() { IEnumerable items = null; XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent != null) { items = xpathDocumentContent.TreeView.Errors; } this.ErrorListDockableContent.DataGridErrorList.ItemsSource = items; }
private void Refresh() { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } xpathDocumentContent.Close(); this.Open(xpathDocumentContent.FileInfo); }
private void ChooseFont() { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } FontChooserLite fontChooser = new FontChooserLite(); fontChooser.Owner = this; fontChooser.WindowStartupLocation = WindowStartupLocation.CenterOwner; TreeView xpathDocumentContentTreeView = xpathDocumentContent.TreeView; fontChooser.SetPropertiesFromObject(xpathDocumentContentTreeView); if (!fontChooser.ShowDialog().Value) { return; } fontChooser.ApplyPropertiesToObject(xpathDocumentContentTreeView); // save the new font settings XmlExplorer.Properties.Settings settings = Properties.Settings.Default; settings.FontFamilyName = xpathDocumentContentTreeView.FontFamily.ToString(); settings.FontSize = xpathDocumentContentTreeView.FontSize; settings.Save(); foreach (object item in this.dockingManager.Documents) { XPathDocumentContent otherXPathDocumentContent = item as XPathDocumentContent; if (otherXPathDocumentContent == null) { continue; } if (otherXPathDocumentContent == xpathDocumentContent) { continue; } fontChooser.ApplyPropertiesToObject(otherXPathDocumentContent.TreeView); } }
private void OpenContainingFolderCommand_Executed(object sender, ExecutedRoutedEventArgs e) { try { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } xpathDocumentContent.OpenContainingFolder(); } catch (Exception ex) { App.HandleException(ex); } }
private void CloseCommand_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { try { // get the selected tab XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent != null) { xpathDocumentContent.Close(); } } catch (Exception ex) { App.HandleException(ex); } }
public void Open(FileInfo fileInfo) { XPathDocumentContent xpathDocumentContent = new XPathDocumentContent(fileInfo); xpathDocumentContent.TreeView.BeginOpen(fileInfo, this.OnDocumentLoaded, null); this.InitializeXPathDocumentContent(xpathDocumentContent); if (xpathDocumentContent.TreeView.DefaultNamespaceCount > 0) { this.dockingManager.Show(this.NamespaceListDockableContent); } if (xpathDocumentContent.TreeView.Errors != null && xpathDocumentContent.TreeView.Errors.Count > 0) { this.dockingManager.Show(this.ErrorListDockableContent); } }
private void SelectXPath(string xpath) { try { XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent == null) { return; } object result = xpathDocumentContent.TreeView.EvaluateXPath(xpath); if (result == null) { throw new XPathException("No matches found. Please check the XPath expression, and make sure you're using namespace prefixes, if required."); } // did the expression evaluate to a node set? XPathNodeIterator iterator = result as XPathNodeIterator; if (iterator != null) { if (iterator.Count < 1) { throw new XPathException("No matches found. Please check the XPath expression, and make sure you're using namespace prefixes, if required."); } // the expression evaluated to a node set xpathDocumentContent.TreeView.SelectFirstResult(iterator); } else { // the expression evaluated to something else, most likely a count() or another function // show the result in a new window this.DisplayXPathResult(result); } } catch (XPathException ex) { this.textBoxXPath.Background = Brushes.LightPink; this.statusBarItemMain.Background = Brushes.LightPink; this.statusBarItemMain.Text = ex.Message; } }
private void LoadNamespaceList() { ObservableCollection <NamespaceDefinition> items = null; XPathDocumentContent xpathDocumentContent = this.GetSelectedXPathDocumentContent(); if (xpathDocumentContent != null) { items = xpathDocumentContent.TreeView.NamespaceDefinitions; } this.NamespaceList.NamespaceDefinitions = items; //foreach (NamespaceDefinition definition in treeView.NamespaceDefinitions) //{ // treeView.XmlNamespaceManager.RemoveNamespace(definition.OldPrefix, definition.Namespace); // treeView.XmlNamespaceManager.AddNamespace(definition.NewPrefix, definition.Namespace); //} }
private void Open(string name, object document) { XPathDocumentContent xpathDocumentContent = new XPathDocumentContent(name, document); this.InitializeXPathDocumentContent(xpathDocumentContent); }