private void NewFile() { //Create and show NewTagViewModel newTagViewModel = new NewTagViewModel(); NewFileDialog newFileDialog = new NewFileDialog() { Owner = Owner, DataContext = newTagViewModel }; if (newFileDialog.ShowDialog() ?? false) { //Get tag group Group tagGroup = TagLookup.CreateTagGroup(newTagViewModel.SelectedTagDefinition.GroupTag); //Create file TagFileModel newTagFileModel = new TagFileModel($"new_{tagGroup.GroupName}.{tagGroup.GroupName}", new AbideTagGroupFile() { TagGroup = tagGroup }) { IsDirty = true, CloseCallback = File_Close }; newTagFileModel.OpenTagReferenceRequested += OpenTagReferenceRequested; Files.Add(newTagFileModel); //Set SelectedFile = newTagFileModel; } }
public override void Run() { ProjectNode node = ProjectBrowserPad.Instance.CurrentProject; if (node != null) { if (node.Project.ReadOnly) { MessageService.ShowWarningFormatted("${res:Dialog.NewFile.ReadOnlyProjectWarning}", node.Project.FileName); } else { int result = MessageService.ShowCustomDialog("${res:Dialog.NewFile.AddToProjectQuestionTitle}", "${res:Dialog.NewFile.AddToProjectQuestion}", "${res:Dialog.NewFile.AddToProjectQuestionProject}", "${res:Dialog.NewFile.AddToProjectQuestionStandalone}"); if (result == 0) { node.AddNewItemsToProject(); return; } else if (result == -1) { return; } } } using (NewFileDialog nfd = new NewFileDialog(null)) { nfd.Owner = WorkbenchSingleton.MainForm; nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } }
public override void Run() { NewFileDialog nfd = new NewFileDialog(); if (nfd.ShowDialog() == DialogResult.OK) { WorkbenchSingleton.Workbench.NewFile((string)nfd.Tag, nfd.Text); } }
/// <summary> /// Generates new Layer and sets it as active one. /// </summary> /// <param name="parameter">CommandParameter.</param> public void OpenNewFilePopup(object parameter) { NewFileDialog newFile = new NewFileDialog(); if (newFile.ShowDialog()) { NewDocument(newFile.Width, newFile.Height); } }
public override void PerformAction(AppWorkspace appWorkspace) { using (NewFileDialog nfd = new NewFileDialog()) { Size newDocSize = appWorkspace.GetNewDocumentSize(); if (Utility.IsClipboardImageAvailable()) { try { Utility.GCFullCollect(); IDataObject clipData = System.Windows.Forms.Clipboard.GetDataObject(); using (Image clipImage = (Image)clipData.GetData(DataFormats.Bitmap)) { int width2 = clipImage.Width; int height2 = clipImage.Height; newDocSize = new Size(width2, height2); } } catch (Exception ex) { if (ex is OutOfMemoryException || ex is ExternalException || ex is NullReferenceException) { // ignore } else { throw; } } } nfd.OriginalSize = new Size(newDocSize.Width, newDocSize.Height); nfd.ConstrainToAspect = Settings.CurrentUser.GetBoolean(SettingNames.LastMaintainAspectRatioNF, false); DialogResult dr = nfd.ShowDialog(appWorkspace); if (dr == DialogResult.OK) { bool success = appWorkspace.CreateBlankDocumentInNewWorkspace(new Size(nfd.ImageWidth, nfd.ImageHeight), false); if (success) { appWorkspace.ActiveDocumentWorkspace.ZoomBasis = ZoomBasis.FitToWindow; Settings.CurrentUser.SetBoolean(SettingNames.LastMaintainAspectRatioNF, nfd.ConstrainToAspect); } } } }
public override void PerformAction(AppWorkspace appWorkspace) { if (appWorkspace.CanSetActiveWorkspace) { using (NewFileDialog dialog = new NewFileDialog()) { SizeInt32?clipboardImageSize; SizeInt32 newDocumentSize = appWorkspace.GetNewDocumentSize(); using (new WaitCursorChanger(appWorkspace)) { CleanupManager.RequestCleanup(); try { IPdnDataObject dataObject = PdnClipboard.GetDataObject(); clipboardImageSize = ClipboardUtil.GetClipboardImageSize(appWorkspace, dataObject); dataObject = null; } catch (Exception) { clipboardImageSize = null; } CleanupManager.RequestCleanup(); } if (clipboardImageSize.HasValue) { newDocumentSize = clipboardImageSize.Value; } dialog.OriginalSize = new Size(newDocumentSize.Width, newDocumentSize.Height); dialog.OriginalDpuUnit = AppSettings.Instance.Workspace.LastNonPixelUnits.Value; dialog.OriginalDpu = Document.GetDefaultDpu(dialog.OriginalDpuUnit); dialog.Units = dialog.OriginalDpuUnit; dialog.Resolution = dialog.OriginalDpu; dialog.ConstrainToAspect = AppSettings.Instance.Workspace.LastMaintainAspectRatioNF.Value; if ((((dialog.ShowDialog(appWorkspace) == DialogResult.OK) && (dialog.ImageWidth > 0)) && ((dialog.ImageHeight > 0) && dialog.Resolution.IsFinite())) && (dialog.Resolution > 0.0)) { SizeInt32 size = new SizeInt32(dialog.ImageWidth, dialog.ImageHeight); if (appWorkspace.CreateBlankDocumentInNewWorkspace(size, dialog.Units, dialog.Resolution, false)) { appWorkspace.ActiveDocumentWorkspace.ZoomBasis = ZoomBasis.FitToWindow; AppSettings.Instance.Workspace.LastMaintainAspectRatioNF.Value = dialog.ConstrainToAspect; if (dialog.Units != MeasurementUnit.Pixel) { AppSettings.Instance.Workspace.LastNonPixelUnits.Value = dialog.Units; } if (appWorkspace.Units != MeasurementUnit.Pixel) { appWorkspace.Units = dialog.Units; } } } } } }
//private ElementInsertPanel ElementInsert //{ // get { return elementInsertPanel.Controls[0] as ElementInsertPanel; } //} //private ElementChangePanel ElementChange //{ // get { return elementChangePanel.Controls[0] as ElementChangePanel; } //} //private QuickFixPanel QuickFix //{ // get { return quickFixPanel.Controls[0] as QuickFixPanel; } //} private void ShowNewForm(object sender, EventArgs e) { NewFileDialog dlg = new NewFileDialog(); DialogResult res = dlg.ShowDialog(this); if (res == DialogResult.Cancel) { return; } XmlDocument doc = dlg.CreateNewDocument(); OpenNew(doc); }
public FileTemplateResult ShowNewFileDialog(IProject project, DirectoryName directory, IEnumerable <TemplateCategory> templates) { #if DEBUG SD.Templates.UpdateTemplates(); #endif using (NewFileDialog nfd = new NewFileDialog(project, directory, templates ?? SD.Templates.TemplateCategories)) { if (nfd.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) { return(nfd.result); } else { return(null); } } }
public override void Run() { using (NewFileDialog nfd = new NewFileDialog()) { nfd.Owner = (Form)WorkbenchSingleton.Workbench; nfd.ShowDialog(); } IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent; if (content != null) { content.ViewSelected += AlgorithmManager.Algorithms.ClearPadsHandler; content.SelectView(); AlgorithmManager.Algorithms.Timer.Enabled = false; } }
// return true if we actually created a new level private bool NewFile() { if (DisplayUnsavedDialog()) { return(false); } var dialog = new NewFileDialog(); var result = dialog.ShowDialog(this); if (result != DialogResult.OK) { return(false); } CreateNewLevel(dialog.LevelName, dialog.LevelType); return(true); }
void c_NewFile(object sender, EventArgs e) { NewFileDialog newFileDialogWindow = new NewFileDialog(); var newFileViewModel = new NewFileViewModel(); EventHandler handler = null; handler = delegate { newFileViewModel.RequestClose -= handler; newFileDialogWindow.Close(); if (newFileViewModel.Finished) { viewModel.CreateNewFile(newFileViewModel.FileName); } }; newFileViewModel.RequestClose += handler; newFileDialogWindow.DataContext = newFileViewModel; newFileDialogWindow.ShowDialog(); }
public override void Run() { TreeNode selectedNode = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedNode; DirectoryNode node = null; while (selectedNode != null && node == null) { node = selectedNode as DirectoryNode; selectedNode = selectedNode.Parent; } if (node == null) { return; } node.Expand(); node.Expanding(); using (NewFileDialog nfd = new NewFileDialog(node.Directory)) { if (nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { bool additionalProperties = false; foreach (KeyValuePair <string, FileDescriptionTemplate> createdFile in nfd.CreatedFiles) { FileProjectItem item = CreateNewFile(node, createdFile.Key); if (createdFile.Value.SetProjectItemProperties(item)) { additionalProperties = true; } } if (additionalProperties) { node.Project.Save(); node.RecreateSubNodes(); } } } }
public override void Run() { if (ProjectBrowserPad.Instance.CurrentProject != null) { int result = MessageService.ShowCustomDialog("${res:Dialog.NewFile.AddToProjectQuestionTitle}", "${res:Dialog.NewFile.AddToProjectQuestion}", "${res:Dialog.NewFile.AddToProjectQuestionProject}", "${res:Dialog.NewFile.AddToProjectQuestionStandalone}"); if (result == 0) { ProjectBrowserPad.Instance.CurrentProject.AddNewItemsToProject(); return; } else if (result == -1) { return; } } using (NewFileDialog nfd = new NewFileDialog(null)) { nfd.Owner = (Form)WorkbenchSingleton.Workbench; nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } }
protected IEnumerable <FileProjectItem> AddNewItems() { DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode; if (node == null) { return(null); } node.Expand(); node.Expanding(); List <FileProjectItem> addedItems = new List <FileProjectItem>(); using (NewFileDialog nfd = new NewFileDialog(node.Directory)) { if (nfd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { bool additionalProperties = false; foreach (KeyValuePair <string, FileDescriptionTemplate> createdFile in nfd.CreatedFiles) { FileProjectItem item = node.AddNewFile(createdFile.Key); addedItems.Add(item); if (createdFile.Value.SetProjectItemProperties(item)) { additionalProperties = true; } } if (additionalProperties) { node.Project.Save(); node.RecreateSubNodes(); } } } return(addedItems.AsReadOnly()); }
/// <summary> /// Shows the add new item dialog and adds a new item /// </summary> public void AddNewItem() { if (!IsProjectOpen()) return; var nfd = new NewFileDialog(); if (nfd.ShowDialog() != DialogResult.OK) return; var pf = new OpenedFile(); string filePath; if (_explorer.tvFiles.SelectedNode == null) // Just do the normal adding to project... { filePath = Project.Path; pf.Folder = null; } else switch (_explorer.tvFiles.SelectedNode.Tag.GetType().Name) { case "Project": filePath = Project.Path; pf.Folder = null; break; case "Folder": filePath = ((Folder) _explorer.tvFiles.SelectedNode.Tag).FullName(); pf.Folder = ((Folder) _explorer.tvFiles.SelectedNode.Tag); break; case "OpenedFile": if (((OpenedFile) _explorer.tvFiles.SelectedNode.Tag).Folder == null) // Project File { filePath = Project.Path; pf.Folder = null; } else // File in Folder, so folders parent is cool :D { filePath = ((OpenedFile) _explorer.tvFiles.SelectedNode.Tag).Folder.FullName(); pf.Folder = ((OpenedFile) _explorer.tvFiles.SelectedNode.Tag).Folder; } break; default: filePath = Project.Path; pf.Folder = null; break; } if (File.Exists(filePath + @"\" + nfd.FileName)) { Util.ShowError(StringTable.FileAlreadyExists); AddNewItem(); return; } File.Create(filePath + @"\" + nfd.FileName).Close(); File.WriteAllText(filePath + @"\" + nfd.FileName, PreprocessCode(nfd.SelectedTemplate.Code)); pf.Name = nfd.FileName; pf.Saved = false; pf.FullName = filePath + @"\" + pf.Name; Project.Saved = false; AddProjectFile(pf); SaveProject(); OpenFile(filePath + @"\" + nfd.FileName); }
void FileNewToolStripMenuItemClick(object sender, EventArgs e) { using (NewFileDialog dialog = new NewFileDialog()) { dialog.FileName = GetNewFileName(); if (dialog.ShowDialog() == DialogResult.OK) { string fileName = dialog.FileName; using (StreamWriter file = File.CreateText(fileName)) { file.Write(String.Empty); } LoadFile(fileName); AddFileToProject(fileName); } } }
public MainWindow() { InitializeComponent(); LogEntries = new ObservableCollection <LogEntry>(); LogPanel.ItemsSource = LogEntries; ZerothCompiler compiler = new ZerothCompiler(Logger); Debug.WriteLine(compiler.removeComments("Hello world / comment\nNext line ( also a comment ) is here")); NewFileButton.Click += (object sender, RoutedEventArgs e) => { if (currentProject == null) { MessageBox.Show("There is currently no project open", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } NewFileDialog dialog = new NewFileDialog(); dialog.FileName = "NewZerothFile.zth"; dialog.ShowDialog(); if (!dialog.cancelled) { if (currentProject.fileExists(dialog.FileName)) { MessageBox.Show($"{dialog.FileName} already exists in the current project", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } LoadedFile newFile = new LoadedFile { FilePath = currentProject.ProjectPath + System.IO.Path.DirectorySeparatorChar + dialog.FileName, FileContent = "" }; currentProject.addFile(newFile); CurrentFile = newFile; currentProject.save(); Logger.log($"Imported '{newFile.FileName}'"); } }; ImportFileButton.Click += (object sender, RoutedEventArgs e) => { if (currentProject == null) { MessageBox.Show("There is currently no project open", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } OpenFileDialog dialog = new OpenFileDialog(); dialog.FileName = Directory.GetCurrentDirectory(); dialog.Filter = "Zeroth Source Files (*.zth)|*.zth"; if (dialog.ShowDialog() == true) { LoadedFile imported = currentProject.import(dialog.FileName); if (imported != null) { CurrentFile = imported; } Logger.log($"Imported '{imported.FileName}'"); } }; BuildLocalButton.Click += (object sender, RoutedEventArgs e) => { if (currentProject == null || CurrentFile == null) { MessageBox.Show("There is currently no file open", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } compiler.BuildFile(CurrentFile); }; BuildProjectButton.Click += (object sender, RoutedEventArgs e) => { }; this.Closing += (object sender, CancelEventArgs e) => { if (currentProject != null) { currentProject.save(); } }; Logger.log("Logging started"); }
public override void PerformAction(AppWorkspace appWorkspace) { using (NewFileDialog nfd = new NewFileDialog()) { Size newDocSize = appWorkspace.GetNewDocumentSize(); if (Utility.IsClipboardImageAvailable()) { try { Utility.GCFullCollect(); IDataObject clipData = System.Windows.Forms.Clipboard.GetDataObject(); using (Image clipImage = (Image)clipData.GetData(DataFormats.Bitmap)) { int width2 = clipImage.Width; int height2 = clipImage.Height; newDocSize = new Size(width2, height2); } } catch (Exception ex) { if (ex is OutOfMemoryException || ex is ExternalException || ex is NullReferenceException) { // ignore } else { throw; } } } nfd.OriginalSize = new Size(newDocSize.Width, newDocSize.Height); nfd.OriginalDpuUnit = SettingNames.GetLastNonPixelUnits(); nfd.OriginalDpu = Document.GetDefaultDpu(nfd.OriginalDpuUnit); nfd.Units = nfd.OriginalDpuUnit; nfd.Resolution = nfd.OriginalDpu; nfd.ConstrainToAspect = Settings.CurrentUser.GetBoolean(SettingNames.LastMaintainAspectRatioNF, false); DialogResult dr = nfd.ShowDialog(appWorkspace); if (dr == DialogResult.OK) { bool success = appWorkspace.CreateBlankDocumentInNewWorkspace(new Size(nfd.ImageWidth, nfd.ImageHeight), nfd.Units, nfd.Resolution, false); if (success) { appWorkspace.ActiveDocumentWorkspace.ZoomBasis = ZoomBasis.FitToWindow; Settings.CurrentUser.SetBoolean(SettingNames.LastMaintainAspectRatioNF, nfd.ConstrainToAspect); if (nfd.Units != MeasurementUnit.Pixel) { Settings.CurrentUser.SetString(SettingNames.LastNonPixelUnits, nfd.Units.ToString()); } if (appWorkspace.Units != MeasurementUnit.Pixel) { appWorkspace.Units = nfd.Units; } } } } }
void NewFile() { using (var dialog = new NewFileDialog()) { dialog.FileName = GetNewFileName(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileName = dialog.FileName; using (StreamWriter file = File.CreateText(fileName)) { file.Write(String.Empty); } LoadFile(fileName); AddFileToProject(fileName); } } }