Esempio n. 1
0
        Project NewProject(IDatabase db, Project project, ProjectType type,
                           ITemplatesService tps, List <LongoMatch.Common.Device> devices, out CaptureSettings captureSettings)
        {
            NewProjectDialog npd = new NewProjectDialog();

            npd.TransientFor     = mainWindow as Gtk.Window;
            npd.Use              = type;
            npd.TemplatesService = tps;
            npd.Project          = project;
            if (type == ProjectType.CaptureProject)
            {
                npd.Devices = devices;
            }
            int response = npd.Run();

            while (true)
            {
                if (response != (int)ResponseType.Ok)
                {
                    project = null;
                    break;
                }
                else if (npd.Project == null)
                {
                    InfoMessage(Catalog.GetString("Please, select a video file."));
                    response = npd.Run();
                }
                else
                {
                    project = npd.Project;
                    break;
                }
            }
            if (type == ProjectType.CaptureProject || type == ProjectType.URICaptureProject)
            {
                captureSettings = npd.CaptureSettings;
            }
            else
            {
                captureSettings = new CaptureSettings();
            }
            npd.Destroy();
            return(project);
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        private void ImportProject()
        {
            Project           project;
            bool              isFake, exists;
            int               res;
            string            fileName;
            FileFilter        filter;
            NewProjectDialog  npd;
            FileChooserDialog fChooser;

            Log.Debug("Importing project");
            /* Show a file chooser dialog to select the file to import */
            fChooser = new FileChooserDialog(Catalog.GetString("Import Project"),
                                             mainWindow,
                                             FileChooserAction.Open,
                                             "gtk-cancel", ResponseType.Cancel,
                                             "gtk-open", ResponseType.Accept);
            fChooser.SetCurrentFolder(Config.HomeDir());
            filter      = new FileFilter();
            filter.Name = Constants.PROJECT_NAME;
            filter.AddPattern("*.lpr");
            fChooser.AddFilter(filter);


            res      = fChooser.Run();
            fileName = fChooser.Filename;
            fChooser.Destroy();
            /* return if the user cancelled */
            if (res != (int)ResponseType.Accept)
            {
                return;
            }

            /* try to import the project and show a message error is the file
             * is not a valid project */
            try {
                project = Project.Import(fileName);
            }
            catch (Exception ex) {
                MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                          Catalog.GetString("Error importing project:") +
                                          "\n" + ex.Message);
                Log.Exception(ex);
                return;
            }

            isFake = (project.Description.File.FilePath == Constants.FAKE_PROJECT);

            /* If it's a fake live project prompt for a video file and
             * create a new PreviewMediaFile for this project */
            if (isFake)
            {
                Log.Debug("Importing fake live project");
                project.Description.File = null;
                npd = new NewProjectDialog();
                npd.TransientFor = mainWindow;
                npd.Use          = ProjectType.EditProject;
                npd.Project      = project;
                int response = npd.Run();
                while (true)
                {
                    if (response != (int)ResponseType.Ok)
                    {
                        npd.Destroy();
                        return;
                    }
                    else if (npd.Project == null)
                    {
                        MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                                  Catalog.GetString("Please, select a video file."));
                        response = npd.Run();
                    }
                    else
                    {
                        project = npd.Project;
                        npd.Destroy();
                        break;
                    }
                }
            }

            /* If the project exists ask if we want to overwrite it */
            if (Core.DB.Exists(project))
            {
                MessageDialog md = new MessageDialog(mainWindow,
                                                     DialogFlags.Modal,
                                                     MessageType.Question,
                                                     Gtk.ButtonsType.YesNo,
                                                     Catalog.GetString("A project already exists for the file:") +
                                                     project.Description.File.FilePath + "\n" +
                                                     Catalog.GetString("Do you want to overwrite it?"));
                md.Icon = Gtk.IconTheme.Default.LoadIcon("longomatch", 48, 0);
                res     = md.Run();
                md.Destroy();
                if (res != (int)ResponseType.Yes)
                {
                    return;
                }
                exists = true;
            }
            else
            {
                exists = false;
            }

            if (isFake)
            {
                CreateThumbnails(project);
            }
            if (exists)
            {
                Core.DB.UpdateProject(project);
            }
            else
            {
                Core.DB.AddProject(project);
            }


            MessagePopup.PopupMessage(mainWindow, MessageType.Info,
                                      Catalog.GetString("Project successfully imported."));
        }
Esempio n. 4
0
        protected override void OnActivated()
        {
            base.OnActivated();
            string projectName = String.Empty;

            if (String.IsNullOrEmpty(MainClass.Workspace.FilePath))
            {
                NewWorkspaceDialog nwd = new NewWorkspaceDialog(true);
                int result             = nwd.Run();

                if (result == (int)ResponseType.Ok)
                {
                    string workspaceName   = nwd.WorkspaceName;
                    string workspaceOutput = nwd.WorkspaceOutput;
                    string workspaceRoot   = nwd.WorkspaceRoot;
                    bool   copyLibs        = nwd.CopyLibs;
                    //projectName = nwd.ProjectName;
                    projectName = MainClass.Tools.RemoveDiacritics(nwd.ProjectName).Replace(" ", "_");

                    string workspaceFile = System.IO.Path.Combine(workspaceRoot, workspaceName + ".msw");

                    MainClass.MainWindow.CreateWorkspace(workspaceFile, workspaceName, workspaceOutput, workspaceRoot, copyLibs);

                    if (!String.IsNullOrEmpty(projectName))
                    {
                        CreateProject(projectName, nwd.Skin, nwd.Theme);
                    }
                }
                nwd.Destroy();
            }
            else
            {
                NewProjectDialog npd = new NewProjectDialog();
                int result           = npd.Run();

                if (result == (int)ResponseType.Ok)
                {
                    if (!String.IsNullOrEmpty(npd.ProjectName))
                    {
                        //projectName = npd.ProjectName;
                        projectName = MainClass.Tools.RemoveDiacritics(npd.ProjectName).Replace(" ", "_");
                        CreateProject(projectName, npd.Skin, npd.Theme);
                    }
                }
                npd.Destroy();

                /*EntryDialog ed = new EntryDialog("",MainClass.Languages.Translate("new_project_name"));
                 * int result = ed.Run();
                 * if (result == (int)ResponseType.Ok){
                 *      if (!String.IsNullOrEmpty(ed.TextEntry) ){
                 *              projectName = ed.TextEntry;
                 *              CreateProject(projectName);
                 *      }
                 * }
                 * ed.Destroy();*/
            }

            //projectName

            /*
             * NewProjectDialog nfd = new NewProjectDialog();
             * int result = nfd.Run();
             *
             * if (result == (int)ResponseType.Ok) {
             *      string projectName = nfd.ProjectName;
             *      string projectDir = MainClass.Tools.RemoveDiacritics(nfd.ProjectName).Replace(" ","_");
             *      //string projectLocat = MainClass.Tools.RemoveDiacritics(nfd.ProjectName).Replace(" ","_");
             *      string projectLocat = MainClass.Workspace.RootDirectory;
             *
             *      string projectFile = System.IO.Path.Combine(projectLocat, projectName + ".msp");
             *      string appFile = System.IO.Path.Combine(projectLocat, projectName + ".app");
             *
             *      MainClass.Workspace.CreateProject(projectFile,projectName,projectLocat,projectDir,appFile);
             *      //MainClass.MainWindow.CreateProject(projectName);
             * }
             * nfd.Destroy();*/
        }