Exemple #1
0
 private void listBox2_DoubleClick(object sender, EventArgs e)
 {
     listBox2.Focus();
     string autoText = string.Format("<{0}></{0}>", listBox2.SelectedItem.ToString());
     int beginPlace = focusedRichTextBox.SelectionStart - count;
     try
     {
         focusedRichTextBox.Select(beginPlace, count);
         focusedRichTextBox.SelectedText = "";
         focusedRichTextBox.Text = focusedRichTextBox.Text.Insert(focusedRichTextBox.SelectionStart, autoText); ;
         focusedRichTextBox.Focus();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         listBox1.Items.Add("You forgot modify your other xml. Now you can modify this");
     }
     listShow = false;
     listBox2.Hide();
     int endPlace = autoText.Length + beginPlace;
     focusedRichTextBox.SelectionStart = endPlace;
     count = 0;
     HighLight.hLRTF(focusedRichTextBox);
     focusedRichTextBox.Focus();
 }
Exemple #2
0
        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            listBox2.Items.Clear();
            currentTab = e.TabPage;
            Font fontSize = listBox1.Font;
            if (e.TabPage.HasChildren)
            {
                richTextBox2.Text = "";
                currentTab.Controls.Add(richTextBox2);
                focusedRichTextBox = e.TabPage.Controls.OfType<RichTextBoxSynchronizedScroll>().First();
                try
                {
                    if (focusedRichTextBox.Text != "" && focusedRichTextBox.Lines.Length > 1)
                    {
                        elementGetter();
                    }
                }
                catch (XmlException xe)
                {
                    listBox1.Items.Add(xe.Message);
                }


                focusedRichTextBox.Font = fontSize;
                HighLight.hLRTF(focusedRichTextBox);
                focusedRichTextBox.vScroll += scrollSyncTxtBox1_vScroll;
                focusedRichTextBox.MouseWheel += FocusedRichTextBox_MouseWheel;
                currentxsd = null;
                isvalidated = false;
                lineNumbering();
            }



        }
Exemple #3
0
        private void IndentSize_Click(object sender, EventArgs e)
        {
            var itemText = (sender as ToolStripMenuItem).Text;
            var intText = int.Parse(itemText);
            var xml = focusedRichTextBox.Text;
            focusedRichTextBox.Text = xmlIndenter(intText, xml);
            HighLight.hLRTF(focusedRichTextBox);

        }
Exemple #4
0
        private void FontSizeOption_Click(object sender, EventArgs e)
        {
            FontDialog fd = new FontDialog();

            if (fd.ShowDialog() == DialogResult.OK)
            {
                listBox1.Font = fd.Font;
                focusedRichTextBox.Font = fd.Font;
                HighLight.hLRTF(focusedRichTextBox);
                if (isvalidated)
                {
                    validationToolStripMenuItem.PerformClick();
                }

            }
        }
Exemple #5
0
        private void openXMLFile(string xmlPath, Stream xmlStream)
        {
            Font font = listBox1.Font;
            using (StreamReader sr = new StreamReader(xmlPath))
            {
                /*if (xmlStream != null)
                {*/
                RichTextBoxSynchronizedScroll box = new RichTextBoxSynchronizedScroll();
                box.Dock = DockStyle.Fill;
                box.Multiline = true;
                box.AcceptsTab = true;
                box.Text = sr.ReadToEnd();
                //box.BackColor = Color.Black;

                XDocument doc = XDocument.Parse(box.Text);
                TabPage tab = addTab(xmlPath);
                foreach (var name in doc.Root.DescendantNodes().OfType<XElement>().Select(x => x.Name).Distinct())
                {
                    listBox2.Items.Add(name);
                }
                tab.Controls.Add(richTextBox2);

                //...........................................................................

                tab.Controls.Add(box);
                tab.Controls.SetChildIndex(box, 0);
                focusedRichTextBox = box;
                focusedRichTextBox.Font = font;

                focusedRichTextBox.vScroll += scrollSyncTxtBox1_vScroll;
                focusedRichTextBox.MouseWheel += FocusedRichTextBox_MouseWheel;

                HighLight.hLRTF(focusedRichTextBox);
                listBox1.Items.Add("XML file loaded");
                lineNumbering();
                //}
            }
        }
Exemple #6
0
        private void loadPrevious()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            List<string> xmlPaths;
            try
            {
                if (File.Exists(path + "\\config.xml"))
                {
                    //do you wanna build a snowman?
                    crayonsSet = xmlHandler.loadColorConfig();
                    HighLight.config(crayonsSet);
                    listBox1.Font = xmlHandler.loadFontConfig();
                    wplayer.controls.play();

                    DialogResult dialog = MessageBox.Show("Do you wanna build a snowman?", "Last session", MessageBoxButtons.YesNo);
                    if (dialog == DialogResult.Yes)
                    {

                        xmlPaths = xmlHandler.XmlLoad();
                        if (xmlPaths.Count > 0)
                        {
                            foreach (string xmlPath in xmlPaths)
                            {
                                openXMLFile(xmlPath, null);

                            }
                            tabControl1.TabPages.Remove(tabPage1);
                        }

                        focusedRichTextBox.Font = listBox1.Font;
                        Snowman snowman = new Snowman();
                        snowman.Show();
                        snowman.TopMost = true;
                        snowman.FormClosed += Snowman_FormClosed;

                    }

                }
                else
                {

                    xmlHandler.createConfig();
                    crayonsSet = HighLight.defaultColors();
                    currentTab = tabPage1;
                    focusedRichTextBox = richTextBox1;
                    focusedRichTextBox.MouseWheel += FocusedRichTextBox_MouseWheel;
                    focusedRichTextBox.vScroll += scrollSyncTxtBox1_vScroll;
                    lineNumbering();
                }
            }
            catch (ArgumentNullException ae)
            {
                listBox1.Items.Add("The config was empty, we made you another one.");
                xmlHandler.createConfig();
                crayonsSet = HighLight.defaultColors();
                currentTab = tabPage1;
                focusedRichTextBox = richTextBox1;
                focusedRichTextBox.MouseWheel += FocusedRichTextBox_MouseWheel;
                focusedRichTextBox.vScroll += scrollSyncTxtBox1_vScroll;
                lineNumbering();
            }
            return;
        }
Exemple #7
0
        private void saveOverride(object sender, EventArgs e)
        {


            string lpath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\config.xml";
            try
            {
                if (currentTab.Tag != null)
                {

                    string path = currentTab.Tag.ToString();
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(focusedRichTextBox.Text);
                    doc.Save(path);

                    listBox1.Items.Add("File saved");
                    currentTab.Text = Path.GetFileName(path);
                }
                else
                {
                    saveFileToolStripMenuItem_Click(sender, e);
                }
                if (currentTab.Tag != null && currentTab.Tag.Equals(lpath))
                {
                    try
                    {
                        currentxsd = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\config.xsd";
                        
                        validationToolStripMenuItem.PerformClick();
                        crayonsSet = new List<string>();
                        using (XmlReader xmlReader = XmlReader.Create(lpath))
                        {
                            while (xmlReader.Read())
                            {
                                if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "nodeColor"))
                                {
                                    crayonsSet.Add(xmlReader.ReadInnerXml());
                                }
                                if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "stringColor"))
                                {
                                    crayonsSet.Add(xmlReader.ReadInnerXml());
                                }
                                if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "attributeColor"))
                                {
                                    crayonsSet.Add(xmlReader.ReadInnerXml());
                                }
                                if ((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "textColor"))
                                {
                                    crayonsSet.Add(xmlReader.ReadInnerXml());
                                }
                            }
                        }

                        HighLight.config(crayonsSet);
                        listBox1.Font = xmlHandler.loadFontConfig();
                    }catch(Exception ex)
                    {
                        listBox1.Items.Add(ex.Message);
                    }


                    /*tabControl1.TabPages.Remove(currentTab);
                    tabControl1.TabPages[0].Select();
                    currentTab = tabControl1.TabPages[0];*/
                }
            }
            catch (XmlException xe)
            {
                Console.WriteLine(xe.Message);
                listBox1.Items.Add("Invalid XML formation, can't save");
                listBox1.Items.Add(xe.Message);
            }
        }