Пример #1
0
        // Create an MDI child.   Only creates it if not already open
        private void CreateMDIChild(string file, bool bMenuUpdate)
        {
            MDIChild mcOpen = null;

            if (file != null)
            {
                file = file.Trim();

                foreach (MDIChild mc in this.MdiChildren)
                {
                    if (file == mc.SourceFile.Trim())
                    {                                                                           // we found it
                        mcOpen = mc;
                        break;
                    }
                }
            }
            if (mcOpen == null)
            {
                MDIChild mc = new MDIChild(this.ClientRectangle.Width * 3 / 4, this.ClientRectangle.Height * 3 / 4);
                mc.MdiParent = this;
                mc.Viewer.GetDataSourceReferencePassword = _GetPassword;
                mc.SourceFile = file;
                mc.Text       = file;
                NoteRecentFiles(file, bMenuUpdate);
                mc.Show();
            }
            else
            {
                mcOpen.Activate();
            }
        }
Пример #2
0
        private void menuPL_Popup(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null)
            {
                return;
            }

            menuPLSinglePage.Checked = menuPLContinuous.Checked =
                menuPLFacing.Checked = menuPLContinuousFacing.Checked = false;;

            switch (mc.Viewer.ScrollMode)
            {
            case ScrollModeEnum.Continuous:
                menuPLContinuous.Checked = true;
                break;

            case ScrollModeEnum.ContinuousFacing:
                menuPLContinuousFacing.Checked = true;
                break;

            case ScrollModeEnum.Facing:
                menuPLFacing.Checked = true;
                break;

            case ScrollModeEnum.SinglePage:
                menuPLSinglePage.Checked = true;
                break;
            }
        }
Пример #3
0
        private void menuView_Popup(object sender, EventArgs e)
        {
            // These menus require an MDIChild in order to work
            bool bEnable = this.MdiChildren.Length > 0? true: false;

            menuPLZoomTo.Enabled     = bEnable;
            menuPLActualSize.Enabled = bEnable;
            menuPLFitPage.Enabled    = bEnable;
            menuPLFitWidth.Enabled   = bEnable;
            menuPL.Enabled           = bEnable;
            if (!bEnable)
            {
                return;
            }

            // Now handle checking the correct sizing menu
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            menuPLActualSize.Checked = menuPLFitPage.Checked = menuPLFitWidth.Checked = false;

            if (mc.Viewer.ZoomMode == ZoomEnum.FitWidth)
            {
                menuPLFitWidth.Checked = true;
            }
            else if (mc.Viewer.ZoomMode == ZoomEnum.FitPage)
            {
                menuPLFitPage.Checked = true;
            }
            else if (mc.Viewer.Zoom == 1)
            {
                menuPLActualSize.Checked = true;
            }
        }
Пример #4
0
        public Reader(bool mono)
        {
            bMono = mono;
            GetStartupState();
            BuildMenus();
            InitializeComponent();
            Application.AddMessageFilter(this);

            this.Closing += new System.ComponentModel.CancelEventHandler(this.RdlReader_Closing);
            _GetPassword  = new Engine.NeedPassword(this.GetPassword);

            // open up the current files if any
            if (_CurrentFiles != null)
            {
                foreach (string file in _CurrentFiles)
                {
                    MDIChild mc = new MDIChild(this.ClientRectangle.Width * 3 / 4, this.ClientRectangle.Height * 3 / 4);
                    mc.MdiParent = this;
                    mc.Viewer.GetDataSourceReferencePassword = _GetPassword;
                    mc.SourceFile = file;
                    mc.Text       = file;
                    mc.Show();
                }
                _CurrentFiles = null;                           // don't need this any longer
            }
        }
Пример #5
0
        private void menuPLActualSize_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc != null)
            {
                mc.Viewer.Zoom = 1;
            }
        }
Пример #6
0
        private void menuPLFitWidth_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc != null)
            {
                mc.Viewer.ZoomMode = ZoomEnum.FitWidth;
            }
        }
Пример #7
0
        private void menuPLSinglePage_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc != null)
            {
                mc.Viewer.ScrollMode = ScrollModeEnum.SinglePage;
            }
        }
Пример #8
0
        private void menuFileClose_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc != null)
            {
                mc.Close();
            }
        }
Пример #9
0
        private void menuPLContinuousFacing_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc != null)
            {
                mc.Viewer.ScrollMode = ScrollModeEnum.ContinuousFacing;
            }
        }
Пример #10
0
        private void menuCopy_Click(object sender, System.EventArgs ea)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null || !mc.Viewer.CanCopy)
            {
                return;
            }

            mc.Viewer.Copy();
        }
Пример #11
0
        private void menuFilePrint_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null)
            {
                return;
            }
            if (printChild != null)                             // already printing
            {
                MessageBox.Show("Can only print one file at a time.");
                return;
            }

            printChild = mc;

            PrintDocument pd = new PrintDocument();

            pd.DocumentName                = mc.SourceFile;
            pd.PrinterSettings.FromPage    = 1;
            pd.PrinterSettings.ToPage      = mc.Viewer.PageCount;
            pd.PrinterSettings.MaximumPage = mc.Viewer.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            if (mc.Viewer.PageWidth > mc.Viewer.PageHeight)
            {
                pd.DefaultPageSettings.Landscape = true;
            }
            else
            {
                pd.DefaultPageSettings.Landscape = false;
            }

            PrintDialog dlg = new PrintDialog();

            dlg.Document       = pd;
            dlg.AllowSelection = true;
            dlg.AllowSomePages = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (pd.PrinterSettings.PrintRange == PrintRange.Selection)
                    {
                        pd.PrinterSettings.FromPage = mc.Viewer.PageCurrent;
                    }
                    mc.Viewer.Print(pd);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Print error: " + ex.Message);
                }
            }
            printChild = null;
        }
Пример #12
0
        private void menuSelection_Click(object sender, System.EventArgs ea)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null)
            {
                return;
            }

            mc.Viewer.SelectTool = !mc.Viewer.SelectTool;
        }
Пример #13
0
        private void menuPLZoomTo_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null)
            {
                return;
            }

            ZoomTo dlg = new ZoomTo(mc.Viewer);

            dlg.StartPosition = FormStartPosition.CenterParent;
            dlg.ShowDialog();
        }
Пример #14
0
        private void menuFind_Click(object sender, System.EventArgs ea)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null)
            {
                return;
            }

            if (!mc.Viewer.ShowFindPanel)
            {
                mc.Viewer.ShowFindPanel = true;
            }
            mc.Viewer.FindNext();
        }
Пример #15
0
        private void menuEdit_Popup(object sender, EventArgs e)
        {
            // These menus require an MDIChild in order to work
            bool bEnable = this.MdiChildren.Length > 0 ? true : false;

            menuCopy.Enabled      = bEnable;
            menuFind.Enabled      = bEnable;
            menuSelection.Enabled = bEnable;
            if (!bEnable)
            {
                return;
            }

            MDIChild mc = this.ActiveMdiChild as MDIChild;

            menuCopy.Enabled      = mc.Viewer.CanCopy;
            menuSelection.Checked = mc.Viewer.SelectTool;
        }
Пример #16
0
        // Create an MDI child.   Only creates it if not already open
        private void CreateMDIChild(string file, bool bMenuUpdate)
        {
            MDIChild mcOpen=null;
            if (file != null)
            {
                file = file.Trim();

                foreach (MDIChild mc in this.MdiChildren)
                {
                    if (file == mc.SourceFile.Trim())
                    {							// we found it
                        mcOpen = mc;
                        break;
                    }
                }
            }
            if (mcOpen == null)
            {
                MDIChild mc = new MDIChild(this.ClientRectangle.Width*3/4, this.ClientRectangle.Height*3/4);
                mc.MdiParent = this;
                mc.Viewer.GetDataSourceReferencePassword = _GetPassword;
                mc.SourceFile = file;
                mc.Text = file;
                NoteRecentFiles(file, bMenuUpdate);
                mc.Show();
            }
            else
                mcOpen.Activate();
        }
Пример #17
0
        public Reader(bool mono)
        {
            bMono = mono;
            GetStartupState();
            BuildMenus();
            InitializeComponent();
            Application.AddMessageFilter(this);

            this.Closing += new System.ComponentModel.CancelEventHandler(this.RdlReader_Closing);
            _GetPassword = new Engine.NeedPassword(this.GetPassword);

            // open up the current files if any
            if (_CurrentFiles != null)
            {
                foreach (string file in _CurrentFiles)
                {
                    MDIChild mc = new MDIChild(this.ClientRectangle.Width*3/4, this.ClientRectangle.Height*3/4);
                    mc.MdiParent = this;
                    mc.Viewer.GetDataSourceReferencePassword = _GetPassword;
                    mc.SourceFile = file;
                    mc.Text = file;
                    mc.Show();
                }
                _CurrentFiles = null;		// don't need this any longer
            }
        }
Пример #18
0
        private void menuFileSaveAs_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;

            if (mc == null)
            {
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter =
                "PDF files (*.pdf)|*.pdf|" +
                "XML files (*.xml)|*.xml|" +
                "HTML files (*.html)|*.html|" +
                "CSV files (*.csv)|*.csv|" +
                "RTF files (*.rtf)|*.rtf|" +
                "TIF files (*.tif)|*.tif|" +
                "Excel files (*.xlsx)|*.xlsx|" +
                "MHT files (*.mht)|*.mht";
            sfd.FilterIndex = 1;

            string file = mc.SourceFile;

            if (file != null)
            {
                int index = file.LastIndexOf('.');
                if (index > 1)
                {
                    sfd.FileName = file.Substring(0, index) + ".pdf";
                }
                else
                {
                    sfd.FileName = "*.pdf";
                }
            }
            else
            {
                sfd.FileName = "*.pdf";
            }

            if (sfd.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // save the report in a rendered format
            string ext = null;
            int    i   = sfd.FileName.LastIndexOf('.');

            if (i < 1)
            {
                ext = "";
            }
            else
            {
                ext = sfd.FileName.Substring(i + 1).ToLower();
            }
            switch (ext)
            {
            case "pdf":
            case "xml":
            case "html":
            case "htm":
            case "csv":
            case "rtf":
            case "mht":
            case "mhtml":
            case "xlsx":
            case "tif":
            case "tiff":
                if (ext == "tif" || ext == "tiff")
                {
                    DialogResult dr = MessageBox.Show(this, "Do you want to save colors in TIF file?", "Export", MessageBoxButtons.YesNoCancel);
                    if (dr == DialogResult.No)
                    {
                        ext = "tifbw";
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        break;
                    }
                }
                try { mc.Viewer.SaveAs(sfd.FileName, ext); }
                catch (Exception ex)
                {
                    MessageBox.Show(this,
                                    ex.Message, "Save As Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            default:
                MessageBox.Show(this,
                                String.Format("{0} is not a valid file type.  File extension must be PDF, XML, HTML, CSV, MHT, RTF, TIF, XLSX.", sfd.FileName), "Save As Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
            return;
        }
Пример #19
0
        private void menuFilePrint_Click(object sender, EventArgs e)
        {
            MDIChild mc = this.ActiveMdiChild as MDIChild;
            if (mc == null)
                return;
            if (printChild != null)			// already printing
            {
                MessageBox.Show("Can only print one file at a time.");
                return;
            }

            printChild = mc;

            PrintDocument pd = new PrintDocument();
            pd.DocumentName = mc.SourceFile;
            pd.PrinterSettings.FromPage = 1;
            pd.PrinterSettings.ToPage = mc.Viewer.PageCount;
            pd.PrinterSettings.MaximumPage = mc.Viewer.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            if (mc.Viewer.PageWidth > mc.Viewer.PageHeight)
                pd.DefaultPageSettings.Landscape=true;
            else
                pd.DefaultPageSettings.Landscape=false;

            PrintDialog dlg = new PrintDialog();
            dlg.Document = pd;
            dlg.AllowSelection = true;
            dlg.AllowSomePages = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (pd.PrinterSettings.PrintRange == PrintRange.Selection)
                    {
                        pd.PrinterSettings.FromPage = mc.Viewer.PageCurrent;
                    }
                    mc.Viewer.Print(pd);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Print error: " + ex.Message);
                }
            }
            printChild = null;
        }