예제 #1
0
        private void ctlAcrobatPdfViewer_OnError(object sender, EventArgs e)
        {
            Control ctl = sender as Control;

            if (ctl != null)
            {
                this.RaiseViewerError(new XslFOViewerEventArgs(String.Format("Error occurred in the Acrobat Pdf ActiveX Viewer control [Type={0}] [Name={1}]:  {2}", ctl.GetType().ToString(), ctl.Name, e.ToString())));
                //MessageBox.Show(String.Format("Error occurred in the Acrobat Pdf Viewer control:  {0}", e.ToString()));
            }
            ctl = null;
            _ctlAcrobatPdfViewer = null;
        }
예제 #2
0
		///<summary>Selection doesn't only happen by the tree and mouse clicks, but can also happen by automatic processes, such as image import, image paste, etc...</summary>
		private void SelectTreeNode(TreeNode node) {
			//Select the node always, but perform additional tasks when necessary (i.e. load an image, or mount).
			treeDocuments.SelectedNode=node;
			treeDocuments.Invalidate();
			//Clear the copy document number for mount item swapping whenever a new mount is potentially selected.
			IdxDocToCopy=-1;
			//We only perform a load if the new selection is different than the old selection.
			ImageNodeId nodeId=new ImageNodeId();
			if(node!=null) {
				nodeId=(ImageNodeId)node.Tag;
			}
			if(nodeId.Equals(NodeIdentifierOld)) {
				return;
			}
			pictureBoxMain.Visible=true;
			if(axAcroPDF1!=null) {
				axAcroPDF1.Dispose();//Clear any previously loaded Acrobat .pdf file.
			}
			DocSelected=new Document();
			NodeIdentifierOld=nodeId;
			//Disable all item tools until the currently selected node is loaded properly in the picture box.
			EnableAllTreeItemTools(false);
			if(ToolBarPaint.Buttons["Hand"]!=null) {
				ToolBarPaint.Buttons["Hand"].Pushed=true;
			}
			if(ToolBarPaint.Buttons["Crop"]!=null) {
				ToolBarPaint.Buttons["Crop"].Pushed=false;
			}
			//Stop any current image processing. This will avoid having the ImageRenderingNow set to a valid image after
			//the current image has been erased. This will also avoid concurrent access to the the currently loaded images by
			//the main and worker threads.
			EraseCurrentImages();
			if(nodeId.NodeType==ImageNodeType.Category) {
				//A folder was selected (or unselection, but I am not sure unselection would be possible here).
				//The panel note control is made invisible to start and then made visible for the appropriate documents. This
				//line prevents the possibility of showing a signature box after selecting a folder node.
				panelNote.Visible=false;
				//Make sure the controls are sized properly in the image module since the visibility of the panel note might
				//have just changed.
				ResizeAll();
			}
			else if(nodeId.NodeType==ImageNodeType.Eob) {
				EobAttach eob=EobAttaches.GetOne(nodeId.PriKey);
				ImagesCur=ImageStore.OpenImagesEob(eob);
				if(ImagesCur[0]==null) {
					if(ImageHelper.HasImageExtension(eob.FileName)) {
						MessageBox.Show(Lan.g(this,"File not found: ") + eob.FileName);
					}
					else if(Path.GetExtension(eob.FileName).ToLower()==".pdf") {//Adobe acrobat file.
						try {
							axAcroPDF1=new AxAcroPDFLib.AxAcroPDF();
							this.Controls.Add(axAcroPDF1);
							axAcroPDF1.Visible=true;
							axAcroPDF1.Size=pictureBoxMain.Size;
							axAcroPDF1.Location=pictureBoxMain.Location;
							axAcroPDF1.OnError+=new EventHandler(pdfFileError);
							string pdfFilePath=ODFileUtils.CombinePaths(ImageStore.GetEobFolder(),eob.FileName);
							if(!File.Exists(pdfFilePath)) {
								MessageBox.Show(Lan.g(this,"File not found: ") + eob.FileName);
							}
							else {
								axAcroPDF1.LoadFile(pdfFilePath);//The return status of this function doesn't seem to be helpful.
								pictureBoxMain.Visible=false;
							}
						}
						catch {
							//An exception can happen if they do not have Adobe Acrobat Reader version 8.0 or later installed.
							//Simply ignore this exception and do nothing. We never used to display .pdf files anyway, so we
							//essentially revert back to the old behavior in this case.
						}
					}
					//return;?
				}
				EnableTreeItemTools(pictureBoxMain.Visible,true,true,pictureBoxMain.Visible,true,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,
					pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible);
			}
			else if(nodeId.NodeType==ImageNodeType.Doc) {
				//Reload the doc from the db. We don't just keep reusing the tree data, because it will become more and 
				//more stale with age if the program is left open in the image module for long periods of time.
				DocSelected=Documents.GetByNum(nodeId.PriKey);
				IdxSelectedInMount=0;
				ImagesCur=ImageStore.OpenImages(new Document[] { DocSelected },PatFolder);
				bool isExportable=pictureBoxMain.Visible;
				if(ImagesCur[0]==null) {
					if(ImageHelper.HasImageExtension(DocSelected.FileName)) {
						MessageBox.Show(Lan.g(this,"File not found: ") + DocSelected.FileName);
					}
					else if(Path.GetExtension(DocSelected.FileName).ToLower()==".pdf") {//Adobe acrobat file.
						try {
							axAcroPDF1=new AxAcroPDFLib.AxAcroPDF();
							this.Controls.Add(axAcroPDF1);
							axAcroPDF1.Visible=true;
							axAcroPDF1.Size=pictureBoxMain.Size;
							axAcroPDF1.Location=pictureBoxMain.Location;
							axAcroPDF1.OnError+=new EventHandler(pdfFileError);
							string pdfFilePath=ODFileUtils.CombinePaths(PatFolder,DocSelected.FileName);
							if(!File.Exists(pdfFilePath)) {
								MessageBox.Show(Lan.g(this,"File not found: ") + DocSelected.FileName);
							}
							else {
								axAcroPDF1.LoadFile(pdfFilePath);//The return status of this function doesn't seem to be helpful.
								pictureBoxMain.Visible=false;
								isExportable=true;
							}
						}
						catch {
							//An exception can happen if they do not have Adobe Acrobat Reader version 8.0 or later installed.
							//Simply ignore this exception and do nothing. We never used to display .pdf files anyway, so we
							//essentially revert back to the old behavior in this case.
						}
					}
				}
				SetBrightnessAndContrast();
				EnableTreeItemTools(pictureBoxMain.Visible,true,true,pictureBoxMain.Visible,true,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,
					pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,isExportable);
			}
			else if(nodeId.NodeType==ImageNodeType.Mount) {
				//Creates a complete initial mount image. No need to call invalidate until changes are made to the mount later.
				MountItemsForSelected=MountItems.GetItemsForMount(nodeId.PriKey);
				DocsInMount=Documents.GetDocumentsForMountItems(MountItemsForSelected);
				IdxSelectedInMount=-1;//No selection to start.
				ImagesCur=ImageStore.OpenImages(DocsInMount,PatFolder);
				MountSelected=Mounts.GetByNum(nodeId.PriKey);
				ImageRenderingNow=new Bitmap(MountSelected.Width,MountSelected.Height);
				ImageHelper.RenderMountImage(ImageRenderingNow,ImagesCur,MountItemsForSelected,DocsInMount,IdxSelectedInMount);
				EnableTreeItemTools(true,true,true,true,false,false,false,true,true,true,false,false,false,true);
			}
			else if(nodeId.NodeType==ImageNodeType.Amd) {
				EhrAmendment amd=EhrAmendments.GetOne(nodeId.PriKey);
				ImagesCur=ImageStore.OpenImagesAmd(amd);
				if(ImagesCur[0]==null) {
					if(ImageHelper.HasImageExtension(amd.FileName)) {
						MessageBox.Show(Lan.g(this,"File not found: ") + amd.FileName);
					}
					else if(Path.GetExtension(amd.FileName).ToLower()==".pdf") {//Adobe acrobat file.
						try {
							axAcroPDF1=new AxAcroPDFLib.AxAcroPDF();
							this.Controls.Add(axAcroPDF1);
							axAcroPDF1.Visible=true;
							axAcroPDF1.Size=pictureBoxMain.Size;
							axAcroPDF1.Location=pictureBoxMain.Location;
							axAcroPDF1.OnError+=new EventHandler(pdfFileError);
							string pdfFilePath=ODFileUtils.CombinePaths(ImageStore.GetAmdFolder(),amd.FileName);
							if(!File.Exists(pdfFilePath)) {
								MessageBox.Show(Lan.g(this,"File not found: ") + amd.FileName);
							}
							else {
								axAcroPDF1.LoadFile(pdfFilePath);//The return status of this function doesn't seem to be helpful.
								pictureBoxMain.Visible=false;
							}
						}
						catch {
							//An exception can happen if they do not have Adobe Acrobat Reader version 8.0 or later installed.
							//Simply ignore this exception and do nothing. We never used to display .pdf files anyway, so we
							//essentially revert back to the old behavior in this case.
						}
					}
					//return;?
				}
				EnableTreeItemTools(pictureBoxMain.Visible,true,true,pictureBoxMain.Visible,true,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,
					pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible,pictureBoxMain.Visible);
			}
			if(nodeId.NodeType==ImageNodeType.Doc || nodeId.NodeType==ImageNodeType.Mount || nodeId.NodeType==ImageNodeType.Eob || nodeId.NodeType==ImageNodeType.Amd) {
				WidthsImagesCur=new int[ImagesCur.Length];
				HeightsImagesCur=new int[ImagesCur.Length];
				for(int i=0;i<ImagesCur.Length;i++) {
					if(ImagesCur[i]!=null) {
						WidthsImagesCur[i]=ImagesCur[i].Width;
						HeightsImagesCur[i]=ImagesCur[i].Height;
					}
				}
				//Adjust visibility of panel note control based on if the new document has a signature.
				SetPanelNoteVisibility(DocSelected);
				//Resize controls in our window to adjust for a possible change in the visibility of the panel note control.
				ResizeAll();
				//Refresh the signature and note in case the last document also had a signature.
				FillSignature();
			}
			if(nodeId.NodeType==ImageNodeType.Mount) {
				ReloadZoomTransCrop(ImageRenderingNow.Width,ImageRenderingNow.Height,new Document(),
					new Rectangle(0,0,pictureBoxMain.Width,pictureBoxMain.Height),out ZoomImage,
					out ZoomLevel,out ZoomOverall,out PointTranslation);
				RenderCurrentImage(new Document(),ImageRenderingNow.Width,ImageRenderingNow.Height,ZoomImage,PointTranslation);
			}
			if(nodeId.NodeType==ImageNodeType.Doc || nodeId.NodeType==ImageNodeType.Eob || nodeId.NodeType==ImageNodeType.Amd) {
				//Render the initial image within the current bounds of the picturebox (if the document is an image).
				InvalidateSettings(ImageSettingFlags.ALL,true);
			}
		}
예제 #3
0
        private bool doAxAcroPdfControlInit()
        {
            //Short circuit if the Viewer is already initialized correctly (ie. Not Null);
            if (_ctlAcrobatPdfViewer != null)
            {
                return(true);
            }

            try
            {
                //TEST EXCEPTION!
                //throw new Exception("Test Initialization Failures for Adobe AxAcroPDFLib...");

                //NOTE:  Manually Call CreateControl() which is required to ensure the correct AxHost state
                //       for all ActiveX controls generated Dynamically
                this._ctlAcrobatPdfViewer = new AxAcroPDFLib.AxAcroPDF();
                this._ctlAcrobatPdfViewer.CreateControl();

                ////The following code was copied from Designer code to support Lazy Loading of the AxAcroPdf Control
                this.SuspendLayout();
                ((System.ComponentModel.ISupportInitialize)(this._ctlAcrobatPdfViewer)).BeginInit();

                ////
                //// _ctlAcrobatPdfViewer
                ////
                //this._ctlAcrobatPdfViewer.Dock = System.Windows.Forms.DockStyle.Fill;
                //NOTE:  Changed default state of Enabled to False due to the FOCUS control issues!
                this._ctlAcrobatPdfViewer.Enabled  = false;
                this._ctlAcrobatPdfViewer.Location = new System.Drawing.Point(246, 141);
                this._ctlAcrobatPdfViewer.Name     = "ctlAcrobatPdfViewer";
                //this.ctlAcrobatPdfViewer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("ctlAcrobatPdfViewer.OcxState")));
                this._ctlAcrobatPdfViewer.Size     = new System.Drawing.Size(192, 192);
                this._ctlAcrobatPdfViewer.TabIndex = 3;
                this._ctlAcrobatPdfViewer.Visible  = false;
                this._ctlAcrobatPdfViewer.TabStop  = false;

                //Wire Up Event Handlers
                //BBernard - 02/26/2018
                //This stopped working in recent versions of Acrobat Reader (~v11).
                //this._ctlAcrobatPdfViewer.OnError += new EventHandler(this.ctlAcrobatPdfViewer_OnError);

                ////The following code was copied from Designer code to support Lazy Loading of the AxAcroPdf Control
                this.Controls.Add(this._ctlAcrobatPdfViewer);
                ((System.ComponentModel.ISupportInitialize)(this._ctlAcrobatPdfViewer)).EndInit();

                //NOTE:  We initialize the Container Properties here just in case . . . never proven if this is necessary though.
                this._ctlAcrobatPdfViewer.ContainingControl = this;
                this._ctlAcrobatPdfViewer.Parent            = this;

                //Finalize UI Layout by Docking the Control correctly
                this._ctlAcrobatPdfViewer.Dock = DockStyle.Fill;

                //NOTE:  Default status is always Unloaded from the Base Control
                //       because we assume that in general the control will initialize
                //this.LoadStatus = XslFOViewerControlState.Unloaded
            }
            catch (Exception exc)
            {
                //NOTE:  If there is an exception here we should not have to do anything as the control will
                //       continue to be lazily initialized OnLoad and that will update the UI as needed.
                //if (_ctlAcrobatPdfViewer == null)
                //{
                //    this.SetLoadingState(XslFOViewerControlState.Unloaded);
                //}

                //Dispose of and Ensure that our ActiveX Control reference is NULL if there is an exception
                //NOTE:  If for some reason another error occurs we can disgard it because we are already at an error state that
                //          we don't care to handle, but to just prevent from bubbling up to the user.  Our display will
                //          let the user know that a pre-requisite installaion of Adobe Acrobat Reader is required.
                try
                {
                    _ctlAcrobatPdfViewer.DisposeSafely();
                }
                finally
                {
                    _ctlAcrobatPdfViewer = null;
                    //NOTE:  Since this instance of the base control couldn't be initialized we set our Status as NOW Unavailable
                    this.LoadStatus = XslFOViewerControlState.Unavailable;
                }

                //For debugging (ie. Alert of error message) we store a reference to the last Exception here
                initException = exc;
            }
            finally
            {
                this.ResumeLayout();
            }

            //Finally return the iniitalization status (ie. Successful if not Null)
            return(_ctlAcrobatPdfViewer != null);
        }
예제 #4
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Main = ((SimpleReader.MainWindow)(target));

            #line 9 "..\..\MainWindow.xaml"
                this.Main.Closed += new System.EventHandler(this.Main_Closed);

            #line default
            #line hidden
                return;

            case 2:

            #line 12 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this._ReadBook_Click);

            #line default
            #line hidden
                return;

            case 3:

            #line 13 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this._EditBook_Click);

            #line default
            #line hidden
                return;

            case 4:

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this._AddToFavorites_Click);

            #line default
            #line hidden
                return;

            case 5:

            #line 15 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this._DeleteBook_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.MainGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 7:
                this._MainBar_ = ((System.Windows.Controls.Grid)(target));
                return;

            case 8:
                this._SearchLbl_ = ((System.Windows.Controls.Label)(target));
                return;

            case 9:
                this._Add_ = ((System.Windows.Controls.Button)(target));

            #line 90 "..\..\MainWindow.xaml"
                this._Add_.Click += new System.Windows.RoutedEventHandler(this._Add__Click);

            #line default
            #line hidden

            #line 90 "..\..\MainWindow.xaml"
                this._Add_.MouseEnter += new System.Windows.Input.MouseEventHandler(this._Button__MouseEnter);

            #line default
            #line hidden

            #line 90 "..\..\MainWindow.xaml"
                this._Add_.MouseLeave += new System.Windows.Input.MouseEventHandler(this._Button_MouseLeave);

            #line default
            #line hidden

            #line 90 "..\..\MainWindow.xaml"
                this._Add_.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseDown);

            #line default
            #line hidden

            #line 90 "..\..\MainWindow.xaml"
                this._Add_.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseUp);

            #line default
            #line hidden
                return;

            case 10:
                this._Favorites_ = ((System.Windows.Controls.Button)(target));

            #line 104 "..\..\MainWindow.xaml"
                this._Favorites_.MouseEnter += new System.Windows.Input.MouseEventHandler(this._FButton__MouseEnter);

            #line default
            #line hidden

            #line 104 "..\..\MainWindow.xaml"
                this._Favorites_.MouseLeave += new System.Windows.Input.MouseEventHandler(this._FButton_MouseLeave);

            #line default
            #line hidden

            #line 104 "..\..\MainWindow.xaml"
                this._Favorites_.Click += new System.Windows.RoutedEventHandler(this._Favorites__Click);

            #line default
            #line hidden

            #line 104 "..\..\MainWindow.xaml"
                this._Favorites_.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseDown);

            #line default
            #line hidden

            #line 104 "..\..\MainWindow.xaml"
                this._Favorites_.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseUp);

            #line default
            #line hidden
                return;

            case 11:
                this._Settings_ = ((System.Windows.Controls.Button)(target));

            #line 118 "..\..\MainWindow.xaml"
                this._Settings_.Click += new System.Windows.RoutedEventHandler(this._Settings__Click);

            #line default
            #line hidden

            #line 118 "..\..\MainWindow.xaml"
                this._Settings_.MouseEnter += new System.Windows.Input.MouseEventHandler(this._Button__MouseEnter);

            #line default
            #line hidden

            #line 118 "..\..\MainWindow.xaml"
                this._Settings_.MouseLeave += new System.Windows.Input.MouseEventHandler(this._Button_MouseLeave);

            #line default
            #line hidden

            #line 118 "..\..\MainWindow.xaml"
                this._Settings_.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseDown);

            #line default
            #line hidden

            #line 118 "..\..\MainWindow.xaml"
                this._Settings_.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseUp);

            #line default
            #line hidden
                return;

            case 12:
                this._ReadingMode_ = ((System.Windows.Controls.Button)(target));

            #line 132 "..\..\MainWindow.xaml"
                this._ReadingMode_.Click += new System.Windows.RoutedEventHandler(this._ReadingMode__Click);

            #line default
            #line hidden

            #line 132 "..\..\MainWindow.xaml"
                this._ReadingMode_.MouseEnter += new System.Windows.Input.MouseEventHandler(this._Button__MouseEnter);

            #line default
            #line hidden

            #line 132 "..\..\MainWindow.xaml"
                this._ReadingMode_.MouseLeave += new System.Windows.Input.MouseEventHandler(this._Button_MouseLeave);

            #line default
            #line hidden

            #line 132 "..\..\MainWindow.xaml"
                this._ReadingMode_.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseDown);

            #line default
            #line hidden

            #line 132 "..\..\MainWindow.xaml"
                this._ReadingMode_.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(this._Button__MouseUp);

            #line default
            #line hidden
                return;

            case 13:
                this.textBlock = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 14:
                this._Settings__ = ((System.Windows.Controls.Image)(target));
                return;

            case 15:
                this._Settings___Copy = ((System.Windows.Controls.Image)(target));
                return;

            case 16:
                this._Favorites__ = ((System.Windows.Controls.Image)(target));
                return;

            case 17:
                this._Add__ = ((System.Windows.Controls.Image)(target));
                return;

            case 18:
                this._ConnectionStatus_ = ((System.Windows.Controls.Image)(target));
                return;

            case 19:
                this._Back_ = ((System.Windows.Controls.Button)(target));

            #line 152 "..\..\MainWindow.xaml"
                this._Back_.Click += new System.Windows.RoutedEventHandler(this._Back__Click);

            #line default
            #line hidden

            #line 152 "..\..\MainWindow.xaml"
                this._Back_.MouseEnter += new System.Windows.Input.MouseEventHandler(this._Book__MouseEnter);

            #line default
            #line hidden

            #line 152 "..\..\MainWindow.xaml"
                this._Back_.MouseLeave += new System.Windows.Input.MouseEventHandler(this._Book__MouseLeave);

            #line default
            #line hidden
                return;

            case 20:
                this._Search_ = ((System.Windows.Controls.TextBox)(target));

            #line 154 "..\..\MainWindow.xaml"
                this._Search_.GotFocus += new System.Windows.RoutedEventHandler(this._Search__GotFocus);

            #line default
            #line hidden

            #line 154 "..\..\MainWindow.xaml"
                this._Search_.LostFocus += new System.Windows.RoutedEventHandler(this._Search__LostFocus);

            #line default
            #line hidden
                return;

            case 21:
                this._Header_ = ((System.Windows.Controls.Label)(target));
                return;

            case 22:
                this._MainSeparator_ = ((System.Windows.Controls.Separator)(target));
                return;

            case 23:
                this._MainSeparator__Copy = ((System.Windows.Controls.Separator)(target));
                return;

            case 24:
                this.ReaderGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 25:
                this.WinFormsHost = ((System.Windows.Forms.Integration.WindowsFormsHost)(target));
                return;

            case 26:
                this.PDFReader = ((AxAcroPDFLib.AxAcroPDF)(target));
                return;

            case 27:
                this.WebReaderGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 28:
                this.PDFBrowser = ((System.Windows.Controls.WebBrowser)(target));
                return;

            case 29:
                this.BooksGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 30:
                this.BooksPanel = ((System.Windows.Controls.WrapPanel)(target));
                return;

            case 31:
                this.BookTemplate = ((System.Windows.Controls.Button)(target));
                return;
            }
            this._contentLoaded = true;
        }