Exemplo n.º 1
0
        public void PrintPreviewNoDisplay(Image img)
        {
            m_Image = img;

            printDoc.PrintPage  += new PrintPageEventHandler(PrintPageEventHandler);
            printDoc.BeginPrint += new PrintEventHandler(BeginPrintEventHandler);

            // display the preview dialog
            SetupPrint();

            // if the caller hasn't provided a print preview dialog, then create one
            if (null == PreviewDialog)
            {
                //PreviewDialog = new PrintPreviewDialog();
                PreviewDialog = new KB9Utility.CoolPrintPreviewDialog();
            }

            // set up dialog for preview
            PreviewDialog.Document = printDoc;
            //PreviewDialog.UseAntiAlias = true;
            PreviewDialog.Owner = Owner;
            //PreviewDialog.PrintPreviewControl.Zoom = PrintPreviewZoom;
            PreviewDialog.Width  = PreviewDisplayWidth();
            PreviewDialog.Height = PreviewDisplayHeight();

            //if (null != ppvIcon)
            //    PreviewDialog.Icon = ppvIcon;

            // show the dialog
            PreviewDialog.ShowDialog();
        }
Exemplo n.º 2
0
 private void cmnuBrowser_Click(object sender, EventArgs e)
 {
     cmnuBrowser.Checked = !cmnuBrowser.Checked;
     if (cmnuBrowser.Checked)
     {
         if (m_Preview == null)
         {
             PreviewDialog.VisibleChanged += this.PreviewDialog_VisibleChanged;
         }
         bLoad.PerformClick(); // Reload browser contents
     }
     else
     {
         PreviewDialog.Hide();
     }
 }
Exemplo n.º 3
0
        public bool Preview(IntPtr parentWindowHandle,
                            string devSerial,
                            string devFilename)
        {
            DocumentPreview preview = createPreview(devSerial, devFilename);

            if (preview == null)
            {
                return(false);
            }

            var previewDialog = new PreviewDialog(preview);

            previewDialog.Owner = owner;
            previewDialog.ShowDialog(owner);

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Print command implemented using RichTextBoxDocument class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void printToolStripButton_Click(object sender, EventArgs e)
        {
            // create document
            var doc = new RichTextBoxDocument(richTextBox1);

            // set document header and footer
            // use '[page]' to get the current page number in headers and footers
            // use '[pages]' to get the page count in headers and footers
            //doc.Header = string.Format("\t - RichTextBoxDocument - \r\n** {0} **", richTextBox1.Name);
            //doc.Footer = string.Format("{0}\t{1}\tPage [page] of [pages]", DateTime.Today.ToShortDateString(), DateTime.Now.ToShortTimeString());

            // preview the document
            using (var dlg = new PreviewDialog())
            {
                dlg.Document = doc;
                dlg.ShowDialog(this);
            }
        }
Exemplo n.º 5
0
        private void bLoad_Click(object sender, EventArgs e)
        {
            // Load URL contents and show a wait cursor in the meantime
            Cursor = Cursors.WaitCursor;

            try
            {
                using (WebClient client = new WebClient(this.UserAgent))
                {
                    string expandedUrl = null;
                    string postData    = null;

                    // Note: The Text property might modify the text value
                    using (ProgressDialog dialog = new ProgressDialog("Loading URL", "Please wait while the content is being downloaded..."))
                    {
                        dialog.OnDoWork = delegate
                        {
                            expandedUrl = CurrentVariable.ExpandedUrl;
                            if (dialog.Cancelled)
                            {
                                return(false);
                            }
                            client.SetPostData(CurrentVariable);
                            postData = client.PostData;
                            CurrentVariable.TempContent = client.DownloadString(new Uri(expandedUrl));
                            return(true);
                        };
                        dialog.OnCancel = delegate {
                            dialog.Cancel();
                        };
                        dialog.ShowDialog(this);

                        // Did an error occur?
                        if (!dialog.Cancelled && dialog.Error != null)
                        {
                            LogDialog.Log("Failed loading URL", dialog.Error);

                            // Check whether or not the URL is valid and show an error message if necessary
                            if (dialog.Error is ArgumentNullException || string.IsNullOrEmpty(expandedUrl))
                            {
                                MessageBox.Show(this, "The URL you entered is empty and cannot be loaded.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else if (dialog.Error is UriFormatException)
                            {
                                MessageBox.Show(this, "The specified URL '" + expandedUrl + "' is not valid.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                MessageBox.Show(this, "The contents of the URL can not be loaded: " + dialog.Error.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }

                    rtfContent.Text = CurrentVariable.TempContent;
                    // For Regex: Go to match after thread finish
                    this.gotoMatch = true;
                    UpdateRegexMatches();
                    // For Start/End: Go to match now
                    RefreshRtfFormatting();

                    this.GoToMatch();

                    // Show page preview if desired
                    if (cmnuBrowser.Checked)
                    {
                        PreviewDialog.ShowPreview(this, expandedUrl, postData);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "An error occured when loading the URL: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Exemplo n.º 6
0
        private void StartBatch(object sender, RoutedEventArgs e)
        {
            // clear fileList and folderList
            fileList   = new ObservableCollection <FileClass>();
            folderList = new ObservableCollection <FileClass>();
            // create files list and folders list for executing methods
            foreach (FileClass f in FileTab.Items)
            {
                fileList.Add(f);
            }
            foreach (FileClass folder in FolderTab.Items)
            {
                folderList.Add(folder);
            }


            //  no method selected?
            if (methodListBox.Items.Count == 0)
            {
                MessageBox.Show("Method box is empty ?");
                return;
            }

            // no file & folder selected?
            if (fileList.Count == 0 && folderList.Count == 0)
            {
                MessageBox.Show("No file/folder selected!");
                return;
            }

            //begin batching files

            for (int i = 0; i < fileList.Count; i++)
            {
                string result = fileList[i].FileName;
                string path   = Path.GetDirectoryName(fileList[i].Path);
                foreach (StringAction action in methodListBox.Items)
                {
                    result = action.Processor.Invoke(result);
                    ObservableCollection <FileClass> temp = new ObservableCollection <FileClass>(fileList);
                    temp.Remove(temp[i]);
                    foreach (FileClass f in temp)
                    {
                        if (result == f.FileName)
                        {
                            fileList[i].Error       = "Duplicate detected.";
                            fileList[i].NewFileName = result;
                        }
                    }
                    if (result == " ")
                    {
                        // a space mean there was an error when executed this method, defined in classes of BatchRename.Features
                        // stop performing other methods
                        fileList[i].Error = "Error.";
                        break;
                    }
                    ;
                }
                // all done without error ?
                if (fileList[i].Error != "Duplicate detected.")
                {
                    fileList[i].NewFileName = result;
                    fileList[i].Error       = "Ok.";
                }


                // check if status column has a value or not, if not, mark Done to it.
            }
            // begin batching folders
            for (int i = 0; i < folderList.Count; i++)
            {
                string result = folderList[i].FileName;
                string path   = Path.GetDirectoryName(folderList[i].Path);

                foreach (StringAction action in methodListBox.Items)
                {
                    // ignore extension method
                    if (action.Name == "Change extension")
                    {
                        continue;
                    }
                    result = action.Processor.Invoke(result);
                    ObservableCollection <FileClass> temp = new ObservableCollection <FileClass>(folderList);
                    temp.Remove(temp[i]);
                    foreach (FileClass f in temp)
                    {
                        if (result == f.FileName)
                        {
                            folderList[i].Error       = "Duplicate detected.";
                            folderList[i].NewFileName = result;
                        }
                    }
                    if (result == " ")
                    {
                        // a space mean there was an error when executed this method
                        folderList[i].Error = "Error.";
                        break;
                    }
                }
                // all done without error?
                if (fileList[i].Error != "Duplicate detected.")
                {
                    fileList[i].NewFileName = result;
                    fileList[i].Error       = "Ok.";
                }
            }

            var previewScreen = new PreviewDialog(fileList, folderList);

            if (previewScreen.ShowDialog() == true)
            {
                string dupAction = previewScreen.DuplicateAction;
                if (dupAction == "keep")
                {
                    foreach (FileClass f in fileList)
                    {
                        if (f.Error == "Duplicate detected.")
                        {
                            continue;
                        }
                        var fInfo = new FileInfo(f.Path);
                        fInfo.MoveTo($"{Path.GetDirectoryName(f.Path)}\\{f.NewFileName}");
                    }
                    foreach (FileClass folder in folderList)
                    {
                        if (folder.Error == "Duplicate detected.")
                        {
                            continue;
                        }
                        var f = new FileInfo(folder.Path);
                        f.MoveTo($"{Path.GetDirectoryName(folder.Path)}\\{folder.NewFileName}");
                    }
                    FileTab.Items.Refresh();
                    FolderTab.Items.Refresh();
                    MessageBox.Show("Done.");
                }

                else if (dupAction == "addnumber")
                {
                    foreach (FileClass f in fileList)
                    {
                        if (f.Error == "Duplicate detected.")
                        {
                            var fInfo1 = new FileInfo(f.Path);
                            fInfo1.MoveTo($"{Path.GetDirectoryName(f.Path)}\\{f.NewFileName}01");
                        }
                        else
                        {
                            var fInfo = new FileInfo(f.Path);
                            fInfo.MoveTo($"{Path.GetDirectoryName(f.Path)}\\{f.NewFileName}");
                        }
                    }
                    foreach (FileClass folder in folderList)
                    {
                        if (folder.Error == "Duplicate detected.")
                        {
                            var f1 = new FileInfo(folder.Path);
                            f1.MoveTo($"{Path.GetDirectoryName(folder.Path)}\\{folder.NewFileName}01");
                        }
                        else
                        {
                            var f = new FileInfo(folder.Path);
                            f.MoveTo($"{Path.GetDirectoryName(folder.Path)}\\{folder.NewFileName}");
                        }
                    }
                    FileTab.Items.Refresh();
                    FolderTab.Items.Refresh();
                    MessageBox.Show("Done.");
                }
            }
            else
            {
                MessageBox.Show("Cancelled by user.");
            }
        }