Example #1
0
        public void RefreshAll()
        {
            if (root == null)
            {
                return;
            }
            var filename = root.Text;

            FileWriter(mapNode, filename);


            LoadTree.id = 1;
            id          = 0;
            root        = new TreeNode();
            root.Name   = id.ToString();
            id++;
            root.Text       = Path.GetFileName(dialog.FileName);
            root.ImageIndex = root.SelectedImageIndex = 3;

            mainTreeView.Nodes.Clear();

            mapNode = null;
            mapNode = new MappingNode(root.Text, 0, true);
            var yaml = FileHandler.LoadFile(mapNode, dialog.FileName);

            LoadTree.CreateTree(mapNode, yaml.Documents[0].RootNode as YamlMappingNode, root);
            mainTreeView.Nodes.Add(root);
            setTreeId(root);
            root.Expand();
        }
Example #2
0
        public void setNewTreeRoot(TreeNode root, MappingNode mapingNode)
        {
            mainTreeView.Nodes.Clear();
            if (root == null)
            {
                return;
            }
            var filename = root.Text;

            FileWriter(mapNode, filename);

            root = (mainTreeView.Nodes.Add(Path.GetFileName(dialog.FileName)));

            root.ImageIndex = root.SelectedImageIndex = 3;
            this.id         = 0;
            root.Name       = id.ToString();
            id++;
            LoadTree.LoadTreeNode(root, mapingNode);
            setTreeId(root);
            root.Expand();
        }
Example #3
0
 private void Grid_Loaded(object sender, RoutedEventArgs e)
 {
     this.dataGrid1.ItemsSource = GetDepartmentModel();
     lt = new LoadTree(this.tvProperties);
     lt.TreeLoad();
 }
Example #4
0
        private void OnOpen(object sender, EventArgs e)
        {
            string[] recoveryFiles = null;
            try
            {
                recoveryFiles = Directory.GetFiles(@"..\\..\\Config_Files\\bin", "*.yaml");
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.Message);
            }

            if (recoveryFiles != null)
            {
                if (recoveryFiles.Count() > 0)
                {
                    DialogResult dialogResult = MessageBox.Show("You have unrecovered files do you wish to restore them: ", "Files Found!",
                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    var finalDirectory = @".\\";
                    if (dialogResult == DialogResult.Yes)
                    {
                        foreach (var file in recoveryFiles)
                        {
                            try
                            {
                                File.Move(file, finalDirectory + Path.GetFileName(file));
                            }
                            catch (IOException q)
                            {
                                File.Delete(finalDirectory + Path.GetFileName(file));
                                File.Move(file, finalDirectory + Path.GetFileName(file));
                            }
                        }
                    }
                }
            }

            dialog = new OpenFileDialog()
            {
                Filter = @"Yaml files (*.yaml)|*.yaml|All files (*.*)|*.*", DefaultExt = "yaml"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                System.Diagnostics.Trace.WriteLine($"Filename: {dialog.FileName}");
                Directory.SetCurrentDirectory(Path.GetDirectoryName(dialog.FileName) ?? "");

                mainTreeView.Nodes.Clear();

                LoadTree.id = 1;

                id              = 0;
                root            = new TreeNode();
                root            = (mainTreeView.Nodes.Add(Path.GetFileName(dialog.FileName)));
                root.ImageIndex = root.SelectedImageIndex = 3;
                root.Name       = id.ToString();
                id++;

                mapNode = null;
                mapNode = new MappingNode(root.Text, 0, true);
                var yaml = FileHandler.LoadFile(mapNode, dialog.FileName);

                LoadTree.CreateTree(mapNode, yaml.Documents[0].RootNode as YamlMappingNode, root);

                InitTimer();



                setTreeId(root);
                root.Expand();
            }
        }