コード例 #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if DEBUG
            //MessageBox.Show("Attach to editor if desired", "Debug ProjectEditor?");
#endif

            // Set up main editor triad
            ProjectDocument doc       = new ProjectDocument();
            MainForm        view      = new MainForm();
            MainPresenter   presenter = new MainPresenter(doc, view);

            // TODO: Process arguments
            //    -new          = create new project
            //    -config=name  = create a new config (implies -new)
            //    assemblyName  = add assembly to the last config specified (or Default)

            if (args.Length == 1 && ProjectDocument.IsProjectFile(args[0]))
            {
                doc.OpenProject(args[0]);
            }
            else if (args.Length > 0)
            {
                doc.CreateNewProject();
                XmlNode configNode = XmlHelper.AddElement(doc.RootNode, "Config");
                XmlHelper.AddAttribute(configNode, "name", "Default");

                foreach (string fileName in args)
                {
                    if (PathUtils.IsAssemblyFileType(fileName))
                    {
                        XmlNode assemblyNode = XmlHelper.AddElement(configNode, "assembly");
                        XmlHelper.AddAttribute(assemblyNode, "path", fileName);
                    }
                }

                // Simulate view change so view gets updated
                presenter.ActiveViewChanged();
            }

            Application.Run(view);
        }
コード例 #2
0
ファイル: MainPresenter.cs プロジェクト: jnm2/testcentric-gui
        private static bool IsValidWritableProjectPath(string path)
        {
            if (!Path.IsPathRooted(path))
            {
                return(false);
            }

            if (!ProjectDocument.IsProjectFile(path))
            {
                return(false);
            }

            if (!File.Exists(path))
            {
                return(true);
            }

            return((File.GetAttributes(path) & FileAttributes.ReadOnly) == 0);
        }