Exemple #1
0
        private void bttnOK_Click(object sender, EventArgs e)
        {
            bool changed = EditAttribute(treeNode.Node);

            if (changed == false)
            {
                isOpen = false;
                ClearTxtB();
                return;
            }

            TreeView treeView = (tree as TreeView);

            treeView.BeginUpdate();
            XMLTree.UpdateTime(treeNode.Node);
            treeView.EndUpdate();

            TabPage         tabPage  = tabControl.SelectedTab;
            FileInformation fileInfo = (tabPage.Tag as FileInformation);

            if (fileInfo != null)
            {
                fileInfo.isSave = false;
                tabPage.Text    = fileInfo.fileName + "*";
            }
            isOpen = false;
            ClearTxtB();
        }
Exemple #2
0
        private void Openfile()
        {
            DialogResult resultOpen = openFileDialog.ShowDialog();

            if (resultOpen != DialogResult.OK)
            {
                return;
            }
            string filePath = openFileDialog.FileNames[0];

            TabPage tabPage = GetTab(filePath);

            if (tabPage != null)
            {
                tabControl.SelectedTab = tabPage;
                return;
            }

            FileInformation file = new FileInformation(filePath);

            file.Document = LoadFile(filePath);
            if (file.Document == null)
            {
                return;
            }
            string fileName = file.fileName;

            tabPage     = new TabPage(fileName);
            tabPage.Tag = file;
            TreeView treeView = XMLTree.GetTreeView(file.Document);

            if (treeView.Nodes.Count == 0)
            {
                MessageBox.Show("Не удалось прочитать файл \"{0}\".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            file.isSave = true;

            treeView.Dock = DockStyle.Fill;
            tabPage.Controls.Add(treeView);
            treeView.NodeMouseDoubleClick += EditNode;

            treeView.MouseDown      += MouseDownEvent;
            treeView.BeforeCollapse += CollapseEvent;
            treeView.BeforeExpand   += ExpandEvent;

            tabControl.TabPages.Add(tabPage);
            tabControl.SelectTab(tabPage);
            CheckNumberTabs();
        }