Exemple #1
0
        //========================================================================================
        // Add handlers
        //========================================================================================

        #region Add handlers

        private void DoAddNewFolder(object sender, EventArgs e)
        {
            var          dialog = new Dialogs.NewFolderDialog();
            DialogResult result = dialog.ShowDialog();

            if ((result == DialogResult.OK) && (dialog.FolderName != null))
            {
                TreeNode          parent    = tree.SelectedNode;
                IProjectContainer container = (IProjectContainer)parent.Tag;

                if (!Directory.Exists(container.FolderPath))
                {
                    Directory.CreateDirectory(container.FolderPath);
                }

                var item = new DirectoryItem(container.FolderPath + "\\" + dialog.FolderName);

                int      index = container.AddChild(item);
                TreeNode node  = CreateNode(item);

                if (index < tree.SelectedNode.Nodes.Count)
                {
                    parent.Nodes.Insert(index, node);
                }
                else
                {
                    parent.Nodes.Add(node);
                }

                parent.Expand();
            }
        }
Exemple #2
0
        private void DoAddNewItem(object sender, EventArgs e)
        {
            var dialog = new Dialogs.NewItemDialog();

            var translator = new Translator("Dialogs.NewItems");

            dialog.SetTemplateConfiguration(translator.GetString("SqlProjectItems"));

            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                TreeNode          parent    = tree.SelectedNode;
                IProjectContainer container = (IProjectContainer)parent.Tag;

                if (!Directory.Exists(container.FolderPath))
                {
                    Directory.CreateDirectory(container.FolderPath);
                }

                string filnam = container.FolderPath + "\\" + dialog.FileName;

                using (var writer = new StreamWriter(filnam, false))
                {
                    writer.WriteLine(dialog.TemplateContent);
                    writer.Close();
                }

                var item = new FileItem(container.FolderPath + "\\" + dialog.FileName);

                int      index = container.AddChild(item);
                TreeNode node  = CreateNode(item);

                if (index < tree.SelectedNode.Nodes.Count)
                {
                    parent.Nodes.Insert(index, node);
                }
                else
                {
                    parent.Nodes.Add(node);
                }

                parent.Expand();
            }
        }