Exemplo n.º 1
0
        public ProjectType SelectNewProjectType()
        {
            ProjectSelectionDialog psd;
            int response;

            psd = new ProjectSelectionDialog();
            psd.TransientFor = mainWindow as Gtk.Window;;
            response         = psd.Run();
            psd.Destroy();
            if (response != (int)ResponseType.Ok)
            {
                return(ProjectType.None);
            }
            return(psd.ProjectType);
        }
Exemplo n.º 2
0
        private async Task <bool> LoadProject()
        {
            LockUI();

            try
            {
                string[] args     = Environment.GetCommandLineArgs();
                string   filePath = null;

                // If the project file provided via the command line, open it
                if (args.Count() > 1 && File.Exists(args[1]))
                {
                    filePath = args[1];
                }
                else
                {
                    ProjectSelectionDialog pSel = new ProjectSelectionDialog();

                    // If the project file was not found, show the open file dialog
                    if (pSel.ShowDialog() == DialogResult.OK)
                    {
                        filePath = pSel.FileName;
                    }
                    else
                    {
                        _isBusy = false;
                        Close();
                        return(false);
                    }
                }

                this.Activate();

                // Load the project
                await _project.LoadAsync(FilePath : filePath, Progress : _statusBarProgress);

                mainViewsTabControl.ViewSet = _project.ViewSet;
                mainViewsTabControl.Logger  = _logger;

                subViewsTabControl.ViewSet = _project.ViewSet;
                subViewsTabControl.Logger  = _logger;

                // Creating the menu for target
                CreateTargetMenu();

                // Creating the menu for all components except target component
                CreateComponentsMenu(excludeComponents: new List <string>()
                {
                    "Target"
                });

                // Getting the icons from views and add them to the icons list
                CreateTabIconsList();

                // Start the update cycle
                _updateCycleTimer.Start();
            }
            catch (Exception ex)
            {
                _logger.Log(ex);
                _isBusy = false;
                Close();
                return(false);
            }

            UnlockUI();

            await UpdateViewsAndUI();

            LockUI();

            await AutoOpenAllViews();

            ShowMenuForCurrentView(mainViewsTabControl, mainViewMenuToolStripMenuItem);

            ShowMenuForCurrentView(subViewsTabControl, subViewToolStripMenuItem);

            UnlockUI();

            return(true);
        }
Exemplo n.º 3
0
        private void CreateNewProject(out Project project, out ProjectType projectType,
                                      out CaptureSettings captureSettings)
        {
            ProjectSelectionDialog psd;
            NewProjectDialog       npd;
            List <Device>          devices = null;
            int response;

            Log.Debug("Creating new project");
            /* The out parameters must be set before leaving the method */
            project         = null;
            projectType     = ProjectType.None;
            captureSettings = new CaptureSettings();

            /* Show the project selection dialog */
            psd = new ProjectSelectionDialog();
            psd.TransientFor = mainWindow;
            response         = psd.Run();
            psd.Destroy();
            if (response != (int)ResponseType.Ok)
            {
                return;
            }
            projectType = psd.ProjectType;

            if (projectType == ProjectType.CaptureProject)
            {
                devices = VideoDevice.ListVideoDevices();
                if (devices.Count == 0)
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                              Catalog.GetString("No capture devices were found."));
                    return;
                }
            }

            /* Show the new project dialog and wait to get a valid project
             * or quit if the user cancel it.*/
            npd = new NewProjectDialog();
            npd.TransientFor     = mainWindow;
            npd.Use              = projectType;
            npd.TemplatesService = Core.TemplatesService;
            if (projectType == ProjectType.CaptureProject)
            {
                npd.Devices = devices;
            }
            response = npd.Run();

            while (true)
            {
                /* User cancelled: quit */
                if (response != (int)ResponseType.Ok)
                {
                    npd.Destroy();
                    return;
                }
                /* No file chosen: display the dialog again */
                if (npd.Project == null)
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                              Catalog.GetString("Please, select a video file."));
                }
                /* If a project with the same file path exists show a warning */
                else if (Core.DB.Exists(npd.Project))
                {
                    MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                              Catalog.GetString("This file is already used in another Project.") + "\n" +
                                              Catalog.GetString("Select a different one to continue."));
                }

                else
                {
                    /* We are now ready to create the new project */
                    project = npd.Project;
                    if (projectType == ProjectType.CaptureProject)
                    {
                        captureSettings = npd.CaptureSettings;
                    }
                    npd.Destroy();
                    break;
                }
                response = npd.Run();
            }
            if (projectType == ProjectType.FileProject)
            {
                /* We can safelly add the project since we already checked if
                 * it can can added */
                Core.DB.AddProject(project);
            }
        }