コード例 #1
0
ファイル: PathRegistry.cs プロジェクト: IronFox/Projector
        /// <summary>
        /// Attempts to locate the path of a project file by name.
        /// If the project is currently not registered or ignored, a dialog will open to select the matching project file.
        /// On success the requested project will be registered to point to the user-supplied path.
        /// On abort, the project will be ignored until the program is restarted.
        /// Automatically saves the local registry if deemed necessary.
        /// </summary>
        /// <param name="name">Project name to lookup</param>
        /// <returns>Existing full path to the project file or unset File descriptor if none was chosen</returns>
        public static File LocateProject(string name)
        {
            LoadMap();
            if (ignore.Contains(name))
            {
                return(new File());
            }
            File info;

            if (map.TryGetValue(name, out info))
            {
                if (info.Exists)
                {
                    return(info);
                }
            }
            MessageBox.Show("Project '" + name + "' is currently unknown. Please locate the .project file to continue...", "Project not known");
            ProjectView    view   = (ProjectView)Application.OpenForms["ProjectView"];
            OpenFileDialog dialog = view.OpenDialog;

            do
            {
                dialog.Filter   = "Project|" + name + ".project";
                dialog.Title    = "Locate project '" + name + "'";
                dialog.FileName = name + ".project";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    dialog.Filter = "Projects|*.project|All files|*.*";
                    info          = new File(dialog.FileName);
                    if (info.CoreName != name)
                    {
                        MessageBox.Show("The selected file's name does not match the expected project name '" + name + '"');
                        continue;
                    }
                    map[name] = info;
                    //map.Add(name, info);
                    SaveMap();
                    return(info);
                }
                dialog.Filter = "Projects|*.project|All files|*.*";
                ignore.Add(name);
                return(new File());
            }while (true);
        }
コード例 #2
0
        static void Main()
        {
            var cmds = Environment.GetCommandLineArgs();

            if (cmds.Length > 1)
            {
                AttachConsole(ATTACH_PARENT_PROCESS);
                if (cmds[1] == "--help" || cmds[1] == "-h")
                {
                    Console.WriteLine("Usage: projector [parameters]");
                    Console.WriteLine("  (no parameters): start GUI");
                    Console.WriteLine("  --help/-h: show this text");
                    Console.WriteLine("  --make/-m X.solution: generate .make files for all involved projects of the specified solution");
                    Application.Exit();
                    return;
                }
                if (cmds[1] == "--make" || cmds[1] == "-m")
                {
                    if (cmds.Length < 2)
                    {
                        Console.Error.WriteLine("Missing parameter. --make/-m Requires a valid .solution file");
                        return;
                    }
                    EventLog.LogToConsole = true;
                    List <Project> projects = new List <Project>();

                    bool     isNew;
                    Solution solution = Solution.LoadNew(new File(cmds[2]), out isNew);

                    solution.ScanEmptySources();
                    foreach (var p in solution.Projects)
                    {
                        projects.Add(p);
                    }
                    DependencyTree.Clear();
                    foreach (var p in projects)
                    {
                        p.RegisterDependencyNodes();
                    }
                    DependencyTree.ParseDependencies();
                    DependencyTree.GenerateMakefiles();

                    EventLog.Inform(null, null, "All done. Exiting.");
                    Application.Exit();
                    return;
                }
                Console.WriteLine("Unknown parameter given. Use --help to see the list of compatible parameters.");
                Application.Exit();
            }

            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());             // Edit as needed

            //bool createdNew = true;
            //using (Mutex mutex = new Mutex(true, MutexName, out createdNew))
            //{
            //	if (createdNew)
            //	{
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //	CreatePipeServer();

            view = new ProjectView();
            Application.Run(view);
            //}
            //else
            //{
            //	Process current = Process.GetCurrentProcess();
            //	foreach (Process process in Process.GetProcessesByName(current.ProcessName))
            //	{
            //		if (process.Id != current.Id)
            //		{
            //			SetForegroundWindow(process.MainWindowHandle);

            //			string[] parameters = Environment.GetCommandLineArgs();
            //			if (parameters.Length > 1)
            //			{
            //				NamedPipeClientStream pipeClient = new NamedPipeClientStream(".",PipeName, PipeDirection.Out, PipeOptions.None);

            //				if (pipeClient.IsConnected != true)
            //					pipeClient.Connect();

            //				StreamWriter sw = new StreamWriter(pipeClient);

            //				try
            //				{
            //					sw.WriteLine(parameters[1]);
            //					sw.Flush();
            //					pipeClient.Close();
            //				}
            //				catch (Exception ex) { throw ex; }
            //			}

            //			break;
            //		}
            //	}
            //}
            //}
        }