コード例 #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();
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: RichTextEditor.cs プロジェクト: waffle-iron/nequeo
        /// <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);
            }
        }
コード例 #4
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.");
            }
        }