public static TaskButton Show( IWin32Window owner, Icon formIcon, string formTitle, Image taskImage, bool scaleTaskImageWithDpi, string introText, TaskButton[] taskButtons, TaskButton acceptTaskButton, TaskButton cancelTaskButton, int pixelWidth96Dpi) { return(Show(owner, formIcon, formTitle, taskImage, scaleTaskImageWithDpi, introText, taskButtons, acceptTaskButton, cancelTaskButton, pixelWidth96Dpi, null, null)); }
public static TaskButton Show( IWin32Window owner, Icon formIcon, string formTitle, Image taskImage, bool scaleTaskImageWithDpi, string introText, TaskButton[] taskButtons, TaskButton acceptTaskButton, TaskButton cancelTaskButton, int pixelWidth96Dpi, string auxButtonText, EventHandler auxButtonClickHandler) { using (TaskDialogForm form = new TaskDialogForm()) { form.Icon = formIcon; form.IntroText = introText; form.Text = formTitle; form.TaskImage = taskImage; form.ScaleTaskImageWithDpi = scaleTaskImageWithDpi; form.TaskButtons = taskButtons; form.AcceptTaskButton = acceptTaskButton; form.CancelTaskButton = cancelTaskButton; if (auxButtonText != null) { form.AuxButtonText = auxButtonText; } if (auxButtonClickHandler != null) { form.AuxButtonClick += auxButtonClickHandler; } int pixelWidth = UI.ScaleWidth(pixelWidth96Dpi); form.ClientSize = new Size(pixelWidth, form.ClientSize.Height); DialogResult dr = form.ShowDialog(owner); TaskButton result = form.DialogResult; return(result); } }
protected override void OnDragDrop(DragEventArgs drgevent) { Activate(); if (!IsCurrentModalForm || !Enabled) { // do nothing } else if (drgevent.Data.GetDataPresent(DataFormats.FileDrop)) { string[] allFiles = (string[])drgevent.Data.GetData(DataFormats.FileDrop); if (allFiles == null) { return; } string[] files = PruneDirectories(allFiles); bool importAsLayers = true; if (files.Length == 0) { return; } else { Icon formIcon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.DragDrop.OpenOrImport.FormIcon.png").Reference); string title = PdnResources.GetString("DragDrop.OpenOrImport.Title"); string infoText = PdnResources.GetString("DragDrop.OpenOrImport.InfoText"); TaskButton openTB = new TaskButton( PdnResources.GetImageResource("Icons.MenuFileOpenIcon.png").Reference, PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ActionText"), PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ExplanationText")); string importLayersExplanation; if (this.appWorkspace.DocumentWorkspaces.Length == 0) { importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText.NoImagesYet"); } else { importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText"); } TaskButton importLayersTB = new TaskButton( PdnResources.GetImageResource("Icons.MenuLayersImportFromFileIcon.png").Reference, PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ActionText"), importLayersExplanation); TaskButton clickedTB = TaskDialog.Show( this, formIcon, title, null, false, infoText, new TaskButton[] { openTB, importLayersTB, TaskButton.Cancel }, null, TaskButton.Cancel); if (clickedTB == openTB) { importAsLayers = false; } else if (clickedTB == importLayersTB) { importAsLayers = true; } else { return; } } if (!importAsLayers) { // open files into new tabs this.appWorkspace.OpenFilesInNewWorkspace(files); } else { // no image open? we will have to create one if (this.appWorkspace.ActiveDocumentWorkspace == null) { Size newSize = this.appWorkspace.GetNewDocumentSize(); this.appWorkspace.CreateBlankDocumentInNewWorkspace(newSize, false); } ImportFromFileAction action = new ImportFromFileAction(); HistoryMemento ha = action.ImportMultipleFiles(this.appWorkspace.ActiveDocumentWorkspace, files); if (ha != null) { this.appWorkspace.ActiveDocumentWorkspace.History.PushNewMemento(ha); } } } base.OnDragDrop(drgevent); }