Ejemplo n.º 1
0
        public static TaskButton Show(
            IWin32Window owner,
            Icon formIcon,
            string formTitle,
            Image taskImage,
            bool scaleTaskImageWithDpi,
            string introText,
            TaskButton[] taskButtons,
            TaskButton acceptTaskButton,
            TaskButton cancelTaskButton,
            int pixelWidth96Dpi)
        {
            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;

                int pixelWidth = UI.ScaleWidth(pixelWidth96Dpi);
                form.ClientSize = new Size(pixelWidth, form.ClientSize.Height);

                DialogResult dr = form.ShowDialog(owner);
                TaskButton result = form.DialogResult;

                return result;
            }
        }
Ejemplo n.º 2
0
 public static TaskButton Show(
     IWin32Window owner,
     Icon formIcon,
     string formTitle,
     Image taskImage,
     string introText,
     TaskButton[] taskButtons,
     TaskButton acceptTaskButton,
     TaskButton cancelTaskButton)
 {
     return Show(owner, formIcon, formTitle, taskImage, true, introText,
         taskButtons, acceptTaskButton, cancelTaskButton);
 }
Ejemplo n.º 3
0
 public static TaskButton Show(
     IWin32Window owner,
     Icon formIcon,
     string formTitle,
     Image taskImage,
     bool scaleTaskImageWithDpi,
     string introText,
     TaskButton[] taskButtons,
     TaskButton acceptTaskButton,
     TaskButton cancelTaskButton)
 {
     return Show(owner, formIcon, formTitle, taskImage, scaleTaskImageWithDpi, introText,
         taskButtons, acceptTaskButton, cancelTaskButton, DefaultPixelWidth96Dpi);
 }
Ejemplo n.º 4
0
 public static TaskButton Show(
     IWin32Window owner,
     Icon formIcon,
     string formTitle,
     Image taskImage,
     bool scaleTaskImageWithDpi,
     string introText,
     TaskButton[] taskButtons,
     TaskButton acceptTaskButton,
     TaskButton cancelTaskButton)
 {
     return(Show(owner, formIcon, formTitle, taskImage, scaleTaskImageWithDpi, introText,
                 taskButtons, acceptTaskButton, cancelTaskButton, DefaultPixelWidth96Dpi));
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Warns the user that we need to flatten the image.
        /// </summary>
        /// <returns>Returns DialogResult.Yes if they want to proceed or DialogResult.No if they don't.</returns>
        private DialogResult WarnAboutFlattening()
        {
            Icon formIcon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileSaveIcon.png").Reference);
            string formTitle = PdnResources.GetString("WarnAboutFlattening.Title");

            string introText = PdnResources.GetString("WarnAboutFlattening.IntroText");
            Image taskImage = null;

            TaskButton flattenTB = new TaskButton(
                PdnResources.GetImageResource("Icons.MenuImageFlattenIcon.png").Reference,
                PdnResources.GetString("WarnAboutFlattening.FlattenTB.ActionText"),
                PdnResources.GetString("WarnAboutFlattening.FlattenTB.ExplanationText"));

            TaskButton cancelTB = new TaskButton(
                TaskButton.Cancel.Image,
                PdnResources.GetString("WarnAboutFlattening.CancelTB.ActionText"),
                PdnResources.GetString("WarnAboutFlattening.CancelTB.ExplanationText"));

            TaskButton clickedTB = TaskDialog.Show(
                AppWorkspace,
                formIcon,
                formTitle,
                taskImage,
                true,
                introText,
                new TaskButton[] { flattenTB, cancelTB },
                flattenTB,
                cancelTB,
                (TaskDialog.DefaultPixelWidth96Dpi * 5) / 4);

            if (clickedTB == flattenTB)
            {
                return DialogResult.Yes;
            }
            else
            {
                return DialogResult.No;
            }
        }
Ejemplo n.º 7
0
            private WorkItemFailureAction ShowFileTransferFailedDialog(Exception ex)
            {
                WorkItemFailureAction result;
                Icon formIcon = this.progressDialog.Icon;

                string formTitle = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.Title");

                Image taskImage = PdnResources.GetImageResource("Icons.WarningIcon.png").Reference;

                string introTextFormat = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.IntroText.Format");
                string introText = string.Format(introTextFormat, ex.Message);

                TaskButton retryTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.MenuImageRotate90CWIcon.png").Reference,
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ActionText"),
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ExplanationText"));

                TaskButton skipTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.HistoryFastForwardIcon.png").Reference,
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ActionText"),
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ExplanationText"));

                TaskButton cancelTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ActionText"),
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ExplanationText"));

                List<TaskButton> taskButtons = new List<TaskButton>();
                taskButtons.Add(retryTB);

                // Only have the Skip button if there is more than 1 item being transferred.
                // If only 1 item is begin transferred, Skip and Cancel are essentially synonymous.
                if (this.itemCount > 1)
                {
                    taskButtons.Add(skipTB);
                }

                taskButtons.Add(cancelTB);

                int width96 = (TaskDialog.DefaultPixelWidth96Dpi * 4) / 3; // 33% wider

                TaskButton clickedTB = TaskDialog.Show(
                    this.progressDialog,
                    formIcon,
                    formTitle,
                    taskImage,
                    true,
                    introText,
                    taskButtons.ToArray(),
                    retryTB,
                    cancelTB,
                    width96);

                if (clickedTB == retryTB)
                {
                    result = WorkItemFailureAction.RetryItem;
                }
                else if (clickedTB == skipTB)
                {
                    result = WorkItemFailureAction.SkipItem;
                }
                else
                {
                    result = WorkItemFailureAction.CancelOperation;
                }

                return result;
            }
Ejemplo n.º 8
0
        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,
                            Document.DefaultDpuUnit,
                            Document.GetDefaultDpu(Document.DefaultDpuUnit),
                            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);
        }
Ejemplo n.º 9
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            if (PdnInfo.IsExpired)
            {
                foreach (Form form in Application.OpenForms)
                {
                    form.Enabled = false;
                }

                TaskButton checkForUpdatesTB = new TaskButton(
                    ImageResource.Get("Icons.MenuHelpCheckForUpdatesIcon.png").Reference,
                    PdnResources.GetString("ExpiredTaskDialog.CheckForUpdatesTB.ActionText"),
                    PdnResources.GetString("ExpiredTaskDialog.CheckForUpdatesTB.ExplanationText"));

                TaskButton goToWebSiteTB = new TaskButton(
                    ImageResource.Get("Icons.MenuHelpPdnWebsiteIcon.png").Reference,
                    PdnResources.GetString("ExpiredTaskDialog.GoToWebSiteTB.ActionText"),
                    PdnResources.GetString("ExpiredTaskDialog.GoToWebSiteTB.ExplanationText"));

                TaskButton doNotCheckForUpdatesTB = new TaskButton(
                    ImageResource.Get("Icons.CancelIcon.png").Reference,
                    PdnResources.GetString("ExpiredTaskDialog.DoNotCheckForUpdatesTB.ActionText"),
                    PdnResources.GetString("ExpiredTaskDialog.DoNotCheckForUpdatesTB.ExplanationText"));

                TaskButton[] taskButtons =
                    new TaskButton[]
                    {
                        checkForUpdatesTB,
                        goToWebSiteTB,
                        doNotCheckForUpdatesTB
                    };

                TaskButton clickedTB = TaskDialog.Show(
                    this,
                    Icon,
                    PdnInfo.GetFullAppName(),
                    ImageResource.Get("Icons.WarningIcon.png").Reference,
                    true,
                    PdnResources.GetString("ExpiredTaskDialog.InfoText"),
                    taskButtons,
                    checkForUpdatesTB,
                    doNotCheckForUpdatesTB,
                    450);

                if (clickedTB == checkForUpdatesTB)
                {
                    this.appWorkspace.CheckForUpdates();
                }
                else if (clickedTB == goToWebSiteTB)
                {
                    PdnInfo.LaunchWebSite(this, InvariantStrings.ExpiredPage);
                }

                Close();
            }
        }
Ejemplo n.º 10
0
        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
                {
                    TaskButton openTB = new TaskButton(
                        ImageResource.Get("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(
                        ImageResource.Get("Icons.MenuLayersImportFromFileIcon.png").Reference,
                        PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ActionText"),
                        importLayersExplanation);

                    TaskButton clickedTB = TaskDialog.Show(
                        this,
                        new Icon(PdnResources.GetResourceStream("Icons.Question.ico")),
                        PdnInfo.GetBareProductName(),
                        null,
                        false,
                        PdnResources.GetString("DragDrop.OpenOrImport.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,
                            Document.DefaultDpuUnit,
                            Document.GetDefaultDpu(Document.DefaultDpuUnit),
                            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);
        }
Ejemplo n.º 11
0
 private void CommandLink_Click(object sender, EventArgs e)
 {
     CommandLink commandLink = (CommandLink)sender;
     this.dialogResult = (TaskButton)commandLink.Tag;
     Close();
 }
Ejemplo n.º 12
0
 private void CommandButton_Click(object sender, EventArgs e)
 {
     CommandButton commandButton = (CommandButton)sender;
     this.dialogResult = (TaskButton)commandButton.Tag;
     Close();
 }