示例#1
0
        private void createFile(Boolean toProject, String type)
        {
            String bleh = this.projectPathDir + @"\" + this.header.pSrcDir;
            String dir  = (this.latestInteracted == null)?bleh:((this.latestInteracted == this.projectNode)?bleh:Path.GetDirectoryName(this.latestInteracted.Name));

            if (!(dir.EndsWith(@"\", StringComparison.CurrentCulture)))
            {
                dir += '\\';
            }
            CreateFileEditorDialog cfed = new CreateFileEditorDialog()
            {
                type = type,
                dir  = dir
            };

            CreateFileEditorDialog.ShowDialog(cfed, () => {
                if (String.IsNullOrEmpty(cfed.fn))
                {
                    return;
                }

                String cfedFn = dir + cfed.fn + type;

                File.Create(cfedFn).Close();
                this.loadTabPage(cfedFn);

                String s         = Path.GetFileName(cfedFn);
                Int32 imageIndex = (s.EndsWith(".asm"))?1:(s.EndsWith(".bat"))?2:4;

                if (toProject)
                {
                    this.projectNode.Nodes.Add(new TreeNode()
                    {
                        Name               = cfedFn,
                        Text               = s,
                        ImageIndex         = imageIndex,
                        SelectedImageIndex = imageIndex
                    });
                    return;
                }

                this.latestInteracted.Nodes.Add(new TreeNode()
                {
                    Name               = cfedFn,
                    Text               = s,
                    ImageIndex         = imageIndex,
                    SelectedImageIndex = imageIndex
                });

                this.latestInteracted.Expand();
            });
        }
        public static void ShowDialog(CreateFileEditorDialog form, Action whatever)
        {
            form.Show();

            form.Closing += delegate { whatever.Invoke(); };
        }