public void NewDashboard() { string dname = InputBox.Run("s_type_new_dashboard_name", "new dashboard"); if (dname == null) { return; } string fn = Path.Combine(Core.DashboardsDirectory, dname + ".das"); if (File.Exists(fn)) { if (!StdDialog.ReallyOverwriteFile(fn)) { return; } } var dash = new DockPanelDashboard(fn); dash.Filter = GetFilter(); dash.SaveToFile(fn); //dash.EnableDesign(true); DashboardManager.Instance.Addons.Add(dash); var pars = new DashboardInstanceParams { LayoutName = null }; var win = dash.CreateControl(pars) as DashboardFrame; win.SetSelectedObject(this); MainWindow.Instance.OpenContent(win); MainWindow.Instance.ShowDocker(new PropertiesDockerFactory()); MainWindow.Instance.ShowDocker(new ToolboxDockerFactory()); dash.SetDesignFrame(win); }
public static bool CheckAbsoluteOutputFileName(string fn, string extensions) { try { if (!Path.IsPathRooted(fn)) { StdDialog.ShowError("s_please_enter_full_path_to_file"); return(false); } string dir = Path.GetDirectoryName(fn); if (!Directory.Exists(dir)) { StdDialog.ShowError("s_output_directory_does_not_exist"); return(false); } if (!IOTool.FileHasOneOfExtension(fn, extensions)) { StdDialog.ShowError(Texts.Get("s_incorrect_file$extension", "extension", extensions.ToLower())); return(false); } } catch (Exception err) { StdDialog.ShowError(err.Message); return(false); } if (File.Exists(fn) && !StdDialog.ReallyOverwriteFile(fn)) { return(false); } return(true); }
private void DragDropFile(AppObject appobj, CopyFileMode mode) { if (appobj is FileAppObjectBase) { var ao = (FileAppObjectBase)appobj; var src = ao.GetFile(); var newfile = Folder.GetFile(src.Name); if (newfile.Exists()) { if (!StdDialog.ReallyOverwriteFile(newfile.Name)) { return; } } ao.CopyFileTo(newfile, mode); //src.CopyFileTo(newfile, mode); //CopyVirtualFileTo(src, newfile, mode); CallCompleteChanged(); } }
public string SaveCommonTemplate(IAddonInstance addon, string defname) { string name = InputBox.Run(Texts.Get("s_select_template_name"), defname ?? "tpl1"); if (name != null) { WantCommonFolder(); string fn = Path.Combine(CommonSpace.Folder, name + FileExtension); if (File.Exists(fn)) { if (!StdDialog.ReallyOverwriteFile(fn)) { return(null); } } addon.SaveToFile(fn); CommonSpace.ClearCache(); return(name + "."); } return(null); }
private object CopyTo(object item, CopyFileMode mode) { string file = GetFileName(item); string oldname = GetItemName(file); string newname = InputBox.Run(Texts.Get("s_new_name"), oldname); if (newname != null) { string newfile = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(file), System.IO.Path.ChangeExtension(newname, System.IO.Path.GetExtension(file))); if (File.Exists(newfile)) { if (!StdDialog.ReallyOverwriteFile(newfile)) { return(null); } } if (mode == CopyFileMode.Copy) { File.Copy(file, newfile, true); } if (mode == CopyFileMode.Move) { File.Move(file, newfile); } var res = CreateNewAddon(); res.LoadFromFile(newfile); if (res is IFileBasedAddonInstance) { ((IFileBasedAddonInstance)res).AddonFileName = newfile; } return(res); //return GetItemName(newfile); } return(null); }
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); }