Example #1
0
        protected override void Execute(EditorFrame ef, TreeViewItem parameter, ViewerNode selectedNode, XmlDocument xmldoc, XmlNode node, XmlNode parentNode)
        {
            var comment = xmldoc.CreateComment(node.OuterXml);

            parentNode.ReplaceChild(comment, node);
            ef.XmlEditor.Text = xmldoc.ToUTF8String();
        }
Example #2
0
        protected override void Execute(EditorFrame ef)
        {
            SaveFileDialog dlgSaveFile = new SaveFileDialog();

            dlgSaveFile.Filter   = "Xml Files|*.xml|Xsd Files|*.xsd|Xslt Files|*.xslt|All Files|*.*";
            dlgSaveFile.Title    = "Select a file to save";
            dlgSaveFile.FileName = ef.XSDocument.Filename;

            if (dlgSaveFile.ShowDialog() == true)
            {
                if (ef.XSDocument.Filename == dlgSaveFile.FileName)
                {
                    MessageBox.Show("Cannot save document to same file as opened");
                    return;
                }
                try
                {
                    MainWindow mainWnd = (MainWindow)Application.Current.MainWindow;
                    mainWnd.SaveFile(dlgSaveFile.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Application.Current.MainWindow, ex.Message, "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }
Example #3
0
        protected override bool CanExecute(EditorFrame ef)
        {
            if (ef.XmlEditor == null)
            {
                return(false);
            }

            TreeViewItem selected = ((TreeViewItem)ef._editorTree.tree.SelectedItem);

            if (selected == null)
            {
                return(false);
            }
            if (selected.Tag == null)
            {
                return(false);
            }

            ViewerNode selectedNode = (ViewerNode)selected.Tag;
            XmlNode    node         = selectedNode.OriginalNode;

            if (node == null)
            {
                return(false);
            }
            if (node.OwnerDocument == null)
            {
                return(false);
            }

            return(true);
        }
        protected override void Execute(EditorFrame ef)
        {
            try
            {
                Encoding enc = ef.XmlEditor.Encoding;
                if (enc == null)
                {
                    enc = XSConfiguration.Instance.Config.Encoding;
                }

                if (ef.XmlEditor.SelectionLength != 0)
                {
                    byte[] encodedBytes = enc.GetBytes(ef.XmlEditor.SelectedText);
                    ef.XmlEditor.SelectedText = Convert.ToBase64String(encodedBytes);
                }
                else
                {
                    byte[] encodedBytes = enc.GetBytes(ef.XmlEditor.Text);
                    ef.XmlEditor.Text = Convert.ToBase64String(encodedBytes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.MainWindow, ex.Message, "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Example #5
0
        protected override void Execute(EditorFrame ef)
        {
            try
            {
                var encoding = XSConfiguration.Instance.Config.Encoding;

                XmlDocument xml;
                string      xslt;

                if (ef.Data.XsltData.XmlInEditor)
                {
                    xml  = ef.XmlEditor.Text.ToXmlDocument();
                    xslt = File.ReadAllText(ef.Data.XsltData.File);
                }
                else
                {
                    string x = File.ReadAllText(ef.Data.XsltData.File);
                    xml  = x.ToXmlDocument();
                    xslt = ef.XmlEditor.Text;
                }

                var result = new XsltTransformer().Transform(xml, xslt, encoding);
                SetResult(result);
            }
            catch (Exception ex)
            {
                string exc = ex.Message;
                if (ex.InnerException != null)
                {
                    exc += ex.InnerException.Message;
                }
                MessageBox.Show(Application.Current.MainWindow, "Error: " + exc, "Error", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Example #6
0
        protected override void Execute(EditorFrame ef)
        {
            TreeViewItem selected = ((TreeViewItem)ef._editorTree.tree.SelectedItem);
            ViewerNode   node     = (ViewerNode)selected.Tag;

            ef.SetSchemaInfo(node.SchemaInfo);
        }
Example #7
0
        private void Execute(EditorFrame ef, XmlDocument xmldoc, XmlNode node)
        {
            if (node.NodeType == XmlNodeType.Element)
            {
                XmlElement oldElement = (XmlElement)node;

                if (oldElement.ParentNode != null)
                {
                    oldElement.ParentNode.RemoveChild(oldElement);
                }
            }
            else if (node.NodeType == XmlNodeType.Attribute)
            {
                XmlAttribute attr = (XmlAttribute)node;

                XmlNode owner = attr.OwnerElement;
                if (owner != null && owner.Attributes != null)
                {
                    owner.Attributes.Remove(attr);
                }
            }
            else
            {
                return;
            }
            ef.XmlEditor.Text = xmldoc.ToUTF8String();
        }
Example #8
0
 protected override bool CanExecute(EditorFrame ef)
 {
     if (ef.XmlEditor == null)
     {
         return(false);
     }
     return(true);
 }
        protected override void Execute(EditorFrame ef)
        {
            try
            {
                XmlReader reader = XmlReader.Create(ef.XmlEditor.Text.ToStream());

                SaveFileDialog dlgOpenFile = new SaveFileDialog();
                dlgOpenFile.Filter           = "Xsd Files (*.xsd)|*.xsd";
                dlgOpenFile.Title            = "Select an Xsd File to generate";
                dlgOpenFile.FileName         = Path.ChangeExtension(Path.GetFileName(ef.XSDocument.Filename), "xsd");
                dlgOpenFile.InitialDirectory = Path.GetDirectoryName(ef.XSDocument.Filename);

                if (dlgOpenFile.ShowDialog() == true)
                {
                    XmlSchemaInference schema = new XmlSchemaInference();

                    XmlSchemaSet schemaSet = schema.InferSchema(reader);

                    int i = 0;
                    foreach (XmlSchema s in schemaSet.Schemas())
                    {
                        string filename = dlgOpenFile.FileName;
                        if (i > 0)
                        {
                            string extension = Path.GetExtension(filename);
                            if (string.IsNullOrWhiteSpace(extension))
                            {
                                extension = ".xsd";
                            }
                            string name = Path.GetFileNameWithoutExtension(filename);
                            filename = Path.Combine(Path.GetDirectoryName(filename) ?? "", name + "." + i + extension);
                        }

                        if (File.Exists(filename))
                        {
                            var res = MessageBox.Show(Application.Current.MainWindow, "File " + filename + " already exists. Overwrite?", "Question", MessageBoxButton.OKCancel,
                                                      MessageBoxImage.Question);
                            if (res == MessageBoxResult.Cancel)
                            {
                                throw new Exception("Action was cancelled");
                            }
                        }

                        using (FileStream output = new FileStream(filename, FileMode.Create))
                        {
                            s.Write(output);
                        }
                        i++;
                    }
                    MessageBox.Show(Application.Current.MainWindow, i.ToString() + " files were created.", "Information", MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.MainWindow, "Error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #10
0
        /// <summary>
        /// </summary>
        /// <param name="ef"></param>
        /// <returns>true if saving succeeded</returns>
        public static bool SaveWithoutQuestion(EditorFrame ef)
        {
            if (ef.XSDocument.Filename == null)
            {
                SaveFileDialog dlgSaveFile = new SaveFileDialog();
                dlgSaveFile.Filter   = "Xml Files|*.xml|Xsd Files|*.xsd|Xslt Files|*.xslt|All Files|*.*";
                dlgSaveFile.Title    = "Select a file to save";
                dlgSaveFile.FileName = ef.XSDocument.Filename;

                if (dlgSaveFile.ShowDialog() == true)
                {
                    try
                    {
                        MainWindow mainWnd = (MainWindow)Application.Current.MainWindow;
                        mainWnd.SaveFile(dlgSaveFile.FileName);

                        //TGW
                        if (ef.XSDocument.Filename != null && ef.XSDocument.Filename.ToLower().EndsWith(".xsd"))
                        {
                            Schema.Parser.IXsdNode nd = new Schema.Parser.SchemaParser(ef.XSDocument.Filename, false).GetVirtualRoot();
                            ef._xsdVisualizer.SetRoot(nd);
                            ef._xsdVisualizer.Refresh();
                            ef._xsdVisualizer._lblModified.Visibility = System.Windows.Visibility.Collapsed;
                        }
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Application.Current.MainWindow, ex.Message, "Error", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                try
                {
                    MainWindow mainWnd = (MainWindow)Application.Current.MainWindow;
                    mainWnd.SaveFile(ef.XSDocument.Filename);

                    //TGW
                    if (ef.XSDocument.Filename != null && ef.XSDocument.Filename.ToLower().EndsWith(".xsd"))
                    {
                        Schema.Parser.IXsdNode nd = new Schema.Parser.SchemaParser(ef.XSDocument.Filename, false).GetVirtualRoot();
                        ef._xsdVisualizer.SetRoot(nd);
                        ef._xsdVisualizer.Refresh();
                        ef._xsdVisualizer._lblModified.Visibility = System.Windows.Visibility.Collapsed;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Application.Current.MainWindow, ex.Message, "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            return(false);
        }
Example #11
0
 public void EditorDestroy()
 {
     if (HasEditorDialog)
     {
         EditorDialog.Close();
         EditorDialog.Dispose();
         EditorDialog = null;
     }
 }
Example #12
0
 private void PwdList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (EditorFrame is null)
     {
         EditorFrame = new Frame();
     }
     EditorFrame.NavigationService.Navigate(new Uri("PwdViewer.xaml", UriKind.Relative));
     EditorFrame.Refresh();
 }
Example #13
0
        protected override void Execute(EditorFrame ef)
        {
            if (ef.XSDocument == null)
            {
                throw new Exception("Parameter must be TextEditor");
            }

            Clipboard.SetText(ef.XSDocument.Filename);
        }
Example #14
0
        protected override void Execute(EditorFrame ef)
        {
            if (ef._xsdVisualizer == null || ef._xsdVisualizer.Visibility == Visibility.Hidden)
            {
                throw new Exception();
            }

            Execute(ef._xsdVisualizer);
        }
Example #15
0
        protected override void Execute(EditorFrame ef, TreeViewItem parameter, ViewerNode selectedNode, XmlDocument xmldoc, XmlNode node, XmlNode parentNode)
        {
            string newName = InputBox.Show(Application.Current.MainWindow, "Rename", "New name of the node", node.Name);

            if (newName != null)
            {
                RenameNode(xmldoc, node, node.NamespaceURI, newName);
                ef.XmlEditor.Text = xmldoc.ToUTF8String();
            }
        }
Example #16
0
 public void createFrame(EditorFrame frame)
 {
     if (!managingInput)
     {
         frameIndex++;
         frame = new EditorFrame(frame);
         frames.Add(frame);
         managingInput = true;
     }
 }
Example #17
0
 protected override void Execute(EditorFrame ef)
 {
     if (ef.XmlEditor.SelectionLength != 0)
     {
         ef.XmlEditor.SelectedText = XmlEscape.EscapeXml(ef.XmlEditor.SelectedText);
     }
     else
     {
         ef.XmlEditor.Text = XmlEscape.EscapeXml(ef.XmlEditor.Text);
     }
 }
        protected override void Execute(EditorFrame ef)
        {
            if (ef.XSDocument == null)
            {
                throw new Exception("Parameter must be TextEditor");
            }

            new Xsd2XmlGenerator(ef.XSDocument.Filename)
            {
                Owner = Application.Current.MainWindow
            }.ShowDialog();
        }
Example #19
0
 protected override bool CanExecute(EditorFrame ef)
 {
     if (ef.XmlEditor == null)
     {
         return(false);
     }
     if (string.IsNullOrWhiteSpace(ef.Data.XsltData.File))
     {
         return(false);
     }
     return(true);
 }
Example #20
0
 protected override bool CanExecute(EditorFrame ef)
 {
     if (ef._editorTree == null)
     {
         return(false);
     }
     if (ef._editorTree.tree == null)
     {
         return(false);
     }
     return(true);
 }
Example #21
0
 protected override bool CanExecute(EditorFrame ef)
 {
     if (ef.XmlEditor == null)
     {
         return(false);
     }
     if (ef._xsdVisualizerDockable.Visibility == Visibility.Hidden)
     {
         return(false);
     }
     return(ef._xsdVisualizerDockable.IsSelected); //IsActiveContent;
 }
Example #22
0
 protected override bool CanExecute(EditorFrame ef)
 {
     if (ef.XSDocument == null)
     {
         return(false);
     }
     if (ef.XSDocument.Filename == null)
     {
         return(false);
     }
     return(true);
 }
Example #23
0
        protected override bool CanExecute(EditorFrame ef)
        {
            if (ef.XmlEditor == null)
            {
                return(false);
            }
//            if (!ef.XmlEditor.TextArea.IsFocused)
//            {
//                return false;
//            }
            return(true);
        }
Example #24
0
        private void CreateUI()
        {
            _Frame = new EditorFrame("Frame", this);

            _Frame.Grid.ColumnDefinitions.Add(224, Skill.Framework.UI.GridUnitType.Pixel); // _PnlLeft
            _Frame.Grid.ColumnDefinitions[0].MinWidth = 224;
            _Frame.Grid.ColumnDefinitions.Add(2, Skill.Framework.UI.GridUnitType.Pixel);   // _GridSplitter
            _Frame.Grid.ColumnDefinitions.Add(5, Skill.Framework.UI.GridUnitType.Star);    // _CurveEditor

            _PnlLeft = new Skill.Framework.UI.Grid()
            {
                Row = 0, Column = 0
            };
            _PnlLeft.RowDefinitions.Add(24, Skill.Framework.UI.GridUnitType.Pixel); // _ObjectField
            _PnlLeft.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star);   // _CurveTreeView
            _PnlLeft.RowDefinitions.Add(26, Skill.Framework.UI.GridUnitType.Pixel); // _PresetPanel

            _ObjectField = new ObjectField <GameObject>()
            {
                Row = 0, Column = 0, VerticalAlignment = Skill.Framework.UI.VerticalAlignment.Center
            };
            _CurveTreeView = new TreeView()
            {
                Row = 1, Column = 0
            };
            _CurveTreeView.DisableFocusable();
            _PresetPanel = new CurvePresetLibrary()
            {
                Row = 2, Column = 0
            };

            _PnlLeft.Controls.Add(_ObjectField);
            _PnlLeft.Controls.Add(_CurveTreeView);
            _PnlLeft.Controls.Add(_PresetPanel);


            _GridSplitter = new Skill.Editor.UI.GridSplitter()
            {
                Row = 0, Column = 1, Orientation = Skill.Framework.UI.Orientation.Vertical
            };
            _CurveEditor = new CurveEditor()
            {
                Row = 0, Column = 2
            };

            _Frame.Controls.Add(_PnlLeft);
            _Frame.Controls.Add(_GridSplitter);
            _Frame.Controls.Add(_CurveEditor);

            _ObjectField.ObjectChanged  += _ObjectField_ObjectChanged;
            _PresetPanel.PresetSelected += _PresetPanel_PresetSelected;
        }
        protected override void Execute(EditorFrame ef)
        {
            if (ef.XSDocument == null)
            {
                throw new Exception("Parameter must be TextEditor");
            }

            OpenFileDialog dlgOpenFile = new OpenFileDialog();

            dlgOpenFile.Filter = "Xml Files (*.xml)|*.xml";
            dlgOpenFile.Title  = "Select an Xml file to validate";

            if (dlgOpenFile.ShowDialog() == true)
            {
                try
                {
                    var file = dlgOpenFile.FileName;
                    var xsd  = new XmlTextReader(new StringReader(ef.XmlEditor.Text));

                    XsdValidationResult result = XsdValidationHelper.Instance.ValidateInstance(
                        xsd, File.ReadAllText(file));
                    switch (result.State)
                    {
                    case ValidationState.Success:
                        MessageBox.Show(Application.Current.MainWindow, "Document is valid", "Validation result",
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        break;

                    case ValidationState.Warning:
                        MessageBox.Show(Application.Current.MainWindow, "Document is valid with warnings", "Validation result",
                                        MessageBoxButton.OK, MessageBoxImage.Warning);
                        break;

                    case ValidationState.ValidationError:
                        MessageBox.Show(Application.Current.MainWindow, "Document is invalid", "Validation result",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                        break;

                    case ValidationState.OtherError:
                        MessageBox.Show(Application.Current.MainWindow, "Document is invalid", "Validation result",
                                        MessageBoxButton.OK, MessageBoxImage.Error);

                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Application.Current.MainWindow, "Error: " + ex.Message, "Validation result",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
 protected override void Execute(EditorFrame ef)
 {
     if (ef._xPathSearchAndReplaceDockable.Visibility == Visibility.Visible)
     {
         ef._xPathQueryDockable.Focus();
         ef._xPathSearchAndReplaceDockable.Visibility = Visibility.Collapsed;
     }
     else
     {
         ef._xPathSearchAndReplaceDockable.Visibility = Visibility.Visible;
         ef._xPathSearchAndReplaceDockable.Focus();
     }
 }
Example #27
0
 protected override void Execute(EditorFrame ef)
 {
     try
     {
         uint result = Convert.ToUInt32(ef.XmlEditor.SelectedText, 16);
         ef.XmlEditor.SelectedText = result.ToString(CultureInfo.InvariantCulture);
     }
     catch
     {
         MessageBox.Show(Application.Current.MainWindow, "Selection is not a hexadecimal number.", "Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }
Example #28
0
 protected override void Execute(EditorFrame ef)
 {
     try
     {
         string stringToInsert = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.fffffffZ");
         ef.XmlEditor.SelectedText = stringToInsert;
     }
     catch (Exception e)
     {
         MessageBox.Show(Application.Current.MainWindow, "Error: " + e.Message, "Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }
Example #29
0
 protected override void Execute(EditorFrame ef)
 {
     try
     {
         var tv = ef._editorTree.tree;
         tv.CollapseAll();
     }
     catch (Exception e)
     {
         MessageBox.Show(Application.Current.MainWindow, "Error: " + e.Message, "Error", MessageBoxButton.OK,
                         MessageBoxImage.Error);
     }
 }
        public TcpListeningWindow(ConfigureListener.Config configuration, EditorFrame editorFrame)
        {
            InitializeComponent();
            Closed += OnClosed;

            _editor        = editorFrame;
            _configuration = configuration;

            _edtResult.Options.ShowBoxForControlCharacters = true;
            _edtResult.Options.ShowEndOfLine = true;
            _edtResult.Options.ShowSpaces    = true;
            _edtResult.Options.ShowTabs      = true;
        }