public static bool RunLoop(Form win, AddToFavoritesFrame frame, Action updateFavorite)
        {
            for (; ;)
            {
                if (win.ShowDialogEx() == DialogResult.OK)
                {
                    if (updateFavorite != null)
                    {
                        updateFavorite();
                    }
                    var fh = frame.GetHolder();
                    if (File.Exists(fh.File))
                    {
                        var res = MessageBox.Show(Texts.Get("s_favorite_allready_exists_overwrite"), VersionInfo.ProgramTitle, MessageBoxButtons.YesNoCancel);
                        if (res == DialogResult.Yes)
                        {
                            File.Delete(fh.File);
                        }
                        else if (res == DialogResult.No)
                        {
                            return(false);
                        }
                        else
                        {
                            continue;
                        }
                    }

                    Favorites.AddLast(fh);
                    Favorites.NotifyChanged();
                    return(true);
                }
                return(false);
            }
        }
Exemple #2
0
        public void CopyLast(AppObject appobj)
        {
            var n   = appobj as FavoriteAppObject;
            var fav = n.LoadHolder().Clone();

            fav.ChangeGroup(m_group.Name);
            Favorites.AddLast(fav);
            Favorites.NotifyChanged();
            this.CompleteRefresh();
        }
Exemple #3
0
        public static SaveJobResult Run(Func <Job> createJob)
        {
            if (!LicenseTool.FeatureAllowedMsg(JobsFeature.Test))
            {
                return(null);
            }
            //if (!Licenseto. Registration.TryCheckEdition(SoftwareEdition.Professional, "export to job")) return null;
            SaveJobForm win = new SaveJobForm();

            if (win.ShowDialogEx() == DialogResult.OK)
            {
                if (win.rbtCreateNewJob.Checked)
                {
                    string fn = Path.Combine(Core.JobsDirectory, win.tbxJob.Text + ".djb");
                    if (File.Exists(fn))
                    {
                        if (!StdDialog.ReallyOverwriteFile(fn))
                        {
                            return(null);
                        }
                    }
                    try
                    {
                        Job job = createJob();
                        job.SaveToFile(fn);
                        if (win.chbAddToFavorites.Checked)
                        {
                            if (String.IsNullOrEmpty(win.addToFavoritesFrame1.FavoriteName))
                            {
                                win.addToFavoritesFrame1.FavoriteName = Path.GetFileNameWithoutExtension(fn);
                            }
                            win.addToFavoritesFrame1.Favorite = new JobFavorite {
                                JobFile = fn
                            };
                            Favorites.AddLast(win.addToFavoritesFrame1.GetHolder());
                            Favorites.NotifyChanged();
                        }
                        //UsageStats.Usage("export_as_job", "jobname", job.ToString(), "addtofavorite", win.chbAddToFavorites.Checked ? "1" : "0");
                        return(new SaveJobResult
                        {
                            Commands = new List <JobCommand>(job.Root.m_commands),
                            JobConn = new JobConnection(fn),
                        });
                    }
                    catch (Exception err)
                    {
                        Errors.Report(err);
                    }
                }
                if (win.rbtAppendToExistingJob.Checked)
                {
                    string fn   = Path.Combine(Core.JobsDirectory, win.lbxJobs.Items[win.lbxJobs.SelectedIndex].ToString());
                    Job    job  = Job.LoadFromFile(fn);
                    Job    job2 = createJob();
                    job.Root.m_commands.AddRange(job2.Root.m_commands);
                    job.SaveToFile(fn);
                    return(new SaveJobResult
                    {
                        Commands = new List <JobCommand>(job2.Root.m_commands),
                        JobConn = new JobConnection(fn),
                    });
                }
            }
            return(null);
        }