Пример #1
0
        private void InitInteractiveModes()
        {
            //None
            noneInteractiveMode = new ImageViewerNoneInteractiveMode();
            _rasterImageViewer.InteractiveModes.Add(noneInteractiveMode);

            automationInteractiveMode = new AutomationInteractiveMode();
            automationInteractiveMode.MouseButtons  = System.Windows.Forms.MouseButtons.Left | System.Windows.Forms.MouseButtons.Right;
            automationInteractiveMode.IdleCursor    = Cursors.Default;
            automationInteractiveMode.WorkingCursor = Cursors.Default;
            _rasterImageViewer.InteractiveModes.Add(automationInteractiveMode);

            PanInteractiveMode                 = new ImageViewerPanZoomInteractiveMode();
            PanInteractiveMode.IdleCursor      = Cursors.Hand;
            PanInteractiveMode.WorkingCursor   = Cursors.Hand;
            PanInteractiveMode.IsEnabled       = false;
            PanInteractiveMode.WorkOnBounds    = true;
            PanInteractiveMode.EnablePan       = true;
            PanInteractiveMode.EnableZoom      = false;
            PanInteractiveMode.EnablePinchZoom = false;
            _rasterImageViewer.InteractiveModes.Add(PanInteractiveMode);

            ZoomToInteractiveMode = new ImageViewerZoomToInteractiveMode();
            ZoomToInteractiveMode.WorkCompleted += new EventHandler(zoomToMode_WorkCompleted);
            ZoomToInteractiveMode.IdleCursor     = Cursors.Cross;
            ZoomToInteractiveMode.WorkingCursor  = Cursors.Cross;
            ZoomToInteractiveMode.IsEnabled      = false;
            ZoomToInteractiveMode.WorkOnBounds   = true;
            _rasterImageViewer.InteractiveModes.Add(ZoomToInteractiveMode);

            automationInteractiveMode.IsEnabled = true;
            _rasterImageViewer.InteractiveModes.EnableById(automationInteractiveMode.Id);
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                // Use ScaleToGray and Bicubic for optimum viewing of black/white and color images
                RasterPaintProperties props = _rasterImageViewer.PaintProperties;
                props.PaintDisplayMode            |= RasterPaintDisplayModeFlags.ScaleToGray | RasterPaintDisplayModeFlags.Bicubic;
                _rasterImageViewer.PaintProperties = props;

                // Pad the viewer
                _rasterImageViewer.ViewMargin          = new Padding(10);
                _rasterImageViewer.ViewBorderThickness = 1;
                _automationInteractiveMode             = new AutomationInteractiveMode();
                _noneInteractiveMode                        = new ImageViewerNoneInteractiveMode();
                _panInteractiveMode                         = new ImageViewerPanZoomInteractiveMode();
                _panInteractiveMode.MouseButtons            = System.Windows.Forms.MouseButtons.Left;
                _panInteractiveMode.IdleCursor              = Cursors.Hand;
                _panInteractiveMode.WorkingCursor           = Cursors.Hand;
                _zoomToInteractiveMode                      = new ImageViewerZoomToInteractiveMode();
                _zoomToInteractiveMode.RubberBandCompleted += new EventHandler <ImageViewerRubberBandEventArgs>(_rasterImageViewer_InteractiveZoomTo);

                _rasterImageViewer.InteractiveModes.BeginUpdate();
                _rasterImageViewer.InteractiveModes.Add(_noneInteractiveMode);
                _rasterImageViewer.InteractiveModes.Add(_automationInteractiveMode);
                _rasterImageViewer.InteractiveModes.Add(_panInteractiveMode);
                _rasterImageViewer.InteractiveModes.Add(_zoomToInteractiveMode);
                _rasterImageViewer.InteractiveModes.EndUpdate();

                DisableInteractiveModes();

                _rasterImageViewer.InteractiveModes.EnableById(_automationInteractiveMode.Id);

                // These events are needed and not visible from the designer, so
                // hook into them here
                _zoomToolStripComboBox.LostFocus += new EventHandler(_zoomToolStripComboBox_LostFocus);
                _pageToolStripTextBox.LostFocus  += new EventHandler(_pageToolStripTextBox_LostFocus);

                // Call the transform changed event
                _rasterImageViewer_TransformChanged(_rasterImageViewer, EventArgs.Empty);

                FitPage(false);

                _mousePositionLabel.Text = string.Empty;

                // Initialize the annotation objects
                InitAnnotations();
            }

            base.OnLoad(e);
        }
Пример #3
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // Initialize the viewer object.
            DicomEngine.Startup();

            _viewer           = new MyAutomationImageViewer();
            _viewer.BackColor = SystemColors.Control;
            _viewer.KeyDown  += new KeyEventHandler(_viewer_KeyDown);
            _viewer.Dock      = DockStyle.Fill;
            this._splitContainer.Panel2.Controls.Add(_viewer);

            _automationInteractiveMode = new AutomationInteractiveMode();

            _automationInteractiveMode.IdleCursor    = Cursors.Arrow;
            _automationInteractiveMode.WorkingCursor = Cursors.Cross;

            _viewer.InteractiveModes.BeginUpdate();
            _viewer.InteractiveModes.Add(_automationInteractiveMode);
            _viewer.InteractiveModes.EndUpdate();

            _dsImage = new DicomDataSet();

            if (_dsImage == null)
            {
                Messager.ShowError(this, "Can't create dicom object. Quitting app.");
                Application.Exit();
                return;
            }

            BringToFront();

            InitAutomationManager();

            _presentation = new DicomPresentationStateInformation();
            _presentation.InstanceNumber    = 1;
            _presentation.PresentationLabel = "LABEL";

            _presentationStateDialog   = new PresentationStateAttributesDialog();
            _dicomAnnotationsUtilities = new DicomAnnotationsUtilities();

            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

            LoadImage(true);
        }
Пример #4
0
        private void InitializeInteractivemodes()
        {
            //None
            NoneInteractiveMode = new ImageViewerNoneInteractiveMode();
            _rasterImageViewer.InteractiveModes.Add(NoneInteractiveMode);
            //Annotations
            automationInteractiveMode = new AutomationInteractiveMode();
            automationInteractiveMode.MouseButtons  = System.Windows.Forms.MouseButtons.Left | System.Windows.Forms.MouseButtons.Right;
            automationInteractiveMode.IdleCursor    = Cursors.Default;
            automationInteractiveMode.WorkingCursor = Cursors.Default;
            _rasterImageViewer.InteractiveModes.Add(automationInteractiveMode);
            //Pan
            PanInteractiveMode                 = new ImageViewerPanZoomInteractiveMode();
            PanInteractiveMode.EnablePan       = true;
            PanInteractiveMode.EnableZoom      = false;
            PanInteractiveMode.EnablePinchZoom = false;
            PanInteractiveMode.WorkOnBounds    = true;
            _rasterImageViewer.InteractiveModes.Add(PanInteractiveMode);
            //ZoomTo
            ZoomToInteractiveMode = new ImageViewerZoomToInteractiveMode();
            ZoomToInteractiveMode.WorkOnBounds   = true;
            ZoomToInteractiveMode.Shape          = ImageViewerRubberBandShape.Rectangle;
            ZoomToInteractiveMode.WorkCompleted += new EventHandler(ZoomToInteractiveMode_WorkCompleted);
            _rasterImageViewer.InteractiveModes.Add(ZoomToInteractiveMode);
            //Region
            RegionInteractiveMode       = new ImageViewerAddRegionInteractiveMode();
            RegionInteractiveMode.Shape = ImageViewerRubberBandShape.Rectangle;
            RegionInteractiveMode.AutoRegionToFloater = true;
            RegionInteractiveMode.WorkOnBounds        = true;
            _rasterImageViewer.InteractiveModes.Add(RegionInteractiveMode);
            //Rectangle
            RectangleInteractiveMode                      = new ImageViewerRubberBandInteractiveMode();
            RectangleInteractiveMode.Shape                = ImageViewerRubberBandShape.Rectangle;
            RectangleInteractiveMode.WorkOnBounds         = true;
            RectangleInteractiveMode.RubberBandCompleted += new EventHandler <ImageViewerRubberBandEventArgs>(RectangleInteractiveMode_RubberBandCompleted);
            _rasterImageViewer.InteractiveModes.Add(RectangleInteractiveMode);

            automationInteractiveMode.IsEnabled = true;
            _rasterImageViewer.InteractiveModes.EnableById(automationInteractiveMode.Id);
        }
Пример #5
0
        private void InitInteractiveModes()
        {
            _automationInteractiveMode = new AutomationInteractiveMode();
            // Don't set the cursors, AnnAutomation will take care of it
            _automationInteractiveMode.AutomationControl = _automationControl;

            _magnifyGlassInteractiveMode               = new ImageViewerMagnifyGlassInteractiveMode();
            _magnifyGlassInteractiveMode.IdleCursor    = Cursors.Cross;
            _magnifyGlassInteractiveMode.WorkingCursor = Cursors.Cross;

            _panZoomInteractiveMode               = new ImageViewerPanZoomInteractiveMode();
            _panZoomInteractiveMode.IdleCursor    = Cursors.SizeAll;
            _panZoomInteractiveMode.WorkingCursor = Cursors.SizeAll;

            ImageViewerInteractiveMode[] modes =
            {
                _automationInteractiveMode,
                _panZoomInteractiveMode,
                _magnifyGlassInteractiveMode
            };
            _viewer.InteractiveModes.BeginUpdate();
            foreach (var mode in modes)
            {
                mode.IsEnabled = false;

                var spyglass = mode as ImageViewerSpyGlassInteractiveMode;
                if (spyglass != null)
                {
                    mode.IdleCursor = Cursors.Cross;
                    spyglass.Shape  = ImageViewerSpyGlassShape.Rectangle;
                }

                _viewer.InteractiveModes.Add(mode);
            }
            _automationInteractiveMode.IsEnabled = true;
            _viewer.InteractiveModes.EndUpdate();
        }
Пример #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            viewer      = new ImageViewer();
            viewer.Dock = DockStyle.Fill;

            automationControl             = new ImageViewerAutomationControl();
            automationControl.ImageViewer = viewer;

            ScreenCaptureEngine.Startup();
            scEngine.CaptureInformation += new EventHandler <ScreenCaptureInformationEventArgs>(scEngine_CaptureInformation);
            ScreenCaptureOptions captureOptions = scEngine.CaptureOptions;

            captureOptions.Hotkey   = Keys.None;
            scEngine.CaptureOptions = captureOptions;

            // initialize a new RasterCodecs object
            RasterCodecs codecs = new RasterCodecs();

            // load the main image into the viewer
            viewer.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\OCR1.TIF");
            viewer.Zoom(ControlSizeMode.FitAlways, 1.0, viewer.DefaultZoomOrigin);

            // initialize the interactive mode for the viewer
            AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();

            automationInteractiveMode.AutomationControl = automationControl;

            // add the interactive mode to the viewer
            viewer.InteractiveModes.BeginUpdate();
            viewer.InteractiveModes.Add(automationInteractiveMode);
            viewer.InteractiveModes.EndUpdate();

            if (viewer.Image != null)
            {
                // create and set up the automation manager
                annAutomationManager = new AnnAutomationManager();
                annAutomationManager.RestrictDesigners   = true;
                annAutomationManager.EditObjectAfterDraw = false;

                // Instruct the manager to create all of the default automation objects.
                annAutomationManager.CreateDefaultObjects();

                AnnObservableCollection <AnnAutomationObject> annObservable = annAutomationManager.Objects;
                foreach (AnnAutomationObject annObject in annObservable)
                {
                    if (annObject.Id != AnnObject.SelectObjectId)
                    {
                        //  annObservable.Remove(annObject);
                        // annAutomationManager.Objects.Remove(annObject);
                    }
                }


                // initialize the manager helper and create the toolbar and add it then the viewer to the controls
                AutomationManagerHelper managerHelper = new AutomationManagerHelper(annAutomationManager);
                managerHelper.CreateToolBar();
                managerHelper.ToolBar.Dock = DockStyle.Right;
                Controls.Add(managerHelper.ToolBar);
                Controls.Add(viewer);


                // set up the automation (it will create the container as well)
                automation              = new AnnAutomation(annAutomationManager, automationControl);
                automation.EditContent += new EventHandler <AnnEditContentEventArgs>(automation_EditContent);
                // set this automation as the active one
                automation.Active = true;

                //set the size of the container to the size of the viewer
                automation.Container.Size = automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(viewer.Image.ImageWidth, viewer.Image.ImageHeight));
            }
        }
Пример #7
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                _automationManager             = new AnnAutomationManager();
                _automationManager.GroupsRoles = _groupsRoles;
                _automationManager.RedactionRealizePassword = string.Empty;
                _automationManager.CreateDefaultObjects();
                _managerHelper = new AutomationManagerHelper(_automationManager);

                _managerHelper.CreateToolBar();
                tabControl1.TabPages[1].Controls.Add(_managerHelper.ToolBar);

                _imageViewer          = new AutomationImageViewer();
                _imageViewer.KeyDown += new KeyEventHandler(_imageViewer_KeyDown);
                tabControl1.TabPages[1].Controls.Add(_imageViewer);

                _managerHelper.ToolBar.Dock       = DockStyle.Right;
                _managerHelper.ToolBar.AutoSize   = false;
                _managerHelper.ToolBar.Appearance = ToolBarAppearance.Flat;
                _managerHelper.ToolBar.BringToFront();

                _imageViewer.Dock   = DockStyle.Fill;
                _imageViewer.UseDpi = false;
                _imageViewer.ImageHorizontalAlignment = Leadtools.Controls.ControlAlignment.Center;
                _imageViewer.ImageBorderColor         = Color.Black;
                _imageViewer.ImageBorderThickness     = 1;
                _imageViewer.BringToFront();

                AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();
                automationInteractiveMode.MouseButtons = MouseButtons.Left | MouseButtons.Right;
                _imageViewer.InteractiveModes.Add(automationInteractiveMode);

                using (RasterCodecs codec = new RasterCodecs())
                {
                    _imageViewer.Image = codec.Load(DemosGlobal.ImagesFolder + @"\ocr1.tif");
                    _imageViewer.Zoom(Leadtools.Controls.ControlSizeMode.FitWidth, 1, LeadPoint.Empty);
                }

                _automation = new AnnAutomation(_automationManager, _imageViewer);

                // Update the container size
                _automation.Container.Size = _automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(_imageViewer.Image.ImageWidth, _imageViewer.Image.ImageHeight));

                _automation.EditText               += new EventHandler <AnnEditTextEventArgs>(automation_EditText);
                _automation.OnShowContextMenu      += new EventHandler <AnnAutomationEventArgs>(automation_OnShowContextMenu);
                _automation.OnShowObjectProperties += new EventHandler <AnnAutomationEventArgs>(automation_OnShowObjectProperties);
                _automation.LockObject             += new EventHandler <AnnLockObjectEventArgs>(automation_LockObject);
                _automation.UnlockObject           += new EventHandler <AnnLockObjectEventArgs>(automation_UnlockObject);
                _automation.SetCursor              += new EventHandler <AnnCursorEventArgs>(automation_SetCursor);
                _automation.RestoreCursor          += new EventHandler(automation_RestoreCursor);

                FlipReverseText(_automationManager.RenderingEngine, true);
                _automation.Active = true;

                _chkLstGroups.CheckOnClick = true;
                _chkLstGroups.ItemCheck   += new ItemCheckEventHandler(_chkLstGroups_ItemCheck);
                _chkLstGroups.Enabled      = _lstUsers.Items.Count > 0 && _lstUsers.SelectedIndex >= 0;

                _chkLstRoles.CheckOnClick = true;
                _chkLstRoles.ItemCheck   += new ItemCheckEventHandler(_chkLstRoles_ItemCheck);
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.View));
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.ViewAll));
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.Edit));
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.EditAll));
                _chkLstRoles.Items.Add(new CheckRoleItem(CustomRoles.RulersOnly));

                _lstGroups.SelectedIndexChanged += new EventHandler(_lstGroups_SelectedIndexChanged);

                _chkLstRoles.Enabled            = _lstGroups.Items.Count > 0 && _lstGroups.SelectedIndex >= 0;
                _lstUsers.SelectedIndexChanged += new EventHandler(_lstUsers_SelectedIndexChanged);
                _groupsRoles.GenerateRole      += new EventHandler <AnnOperationInfoEventArgs>(_groupsRoles_GenerateRole);

                AnnRoles medicalRoles = new AnnRoles();
                medicalRoles.Add(CustomRoles.RulersOnly);
                AddGroup(_groupsRoles, "Medical", medicalRoles);

                AnnRoles documentRoles = new AnnRoles();
                documentRoles.Add(AnnRoles.View);
                documentRoles.Add(AnnRoles.Edit);

                AddGroup(_groupsRoles, "Document", documentRoles);

                AnnRoles adminRoles = new AnnRoles();
                adminRoles.Add(AnnRoles.EditAll);
                AddGroup(_groupsRoles, "Admins", adminRoles);

                AnnRoles guestRoles = new AnnRoles();
                guestRoles.Add(AnnRoles.ViewAll);
                AddGroup(_groupsRoles, "Guests", guestRoles);

                AddUser(_groupsRoles, "Medical", "MedicalUser");
                AddUser(_groupsRoles, "Document", "DocumentUser");
                AddUser(_groupsRoles, "Guests", "Guest");
                AddUser(_groupsRoles, "Admins", "Admin");
                OnResize(EventArgs.Empty);
            }

            base.OnLoad(e);
        }
Пример #8
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                _automationManager = AnnAutomationManager.Create(new AnnWinFormsRenderingEngine());

                _automationManager.RedactionRealizePassword = string.Empty;
                _automationManager.CreateDefaultObjects();

                _managerHelper = new AutomationManagerHelper(_automationManager);
                _managerHelper.CreateToolBar();
                FlipReverseText(_automationManager.RenderingEngine, true);

                _managerHelper.ToolBar.Dock       = DockStyle.Right;
                _managerHelper.ToolBar.AutoSize   = false;
                _managerHelper.ToolBar.Width      = 100;
                _managerHelper.ToolBar.Appearance = ToolBarAppearance.Normal;
                this.Controls.Add(_managerHelper.ToolBar);
                _managerHelper.ToolBar.BringToFront();

                _imageViewer          = new AutomationImageViewer();
                _imageViewer.KeyDown += new KeyEventHandler(_imageViewer_KeyDown);
                _imageViewer.Dock     = DockStyle.Fill;
                this.Controls.Add(_imageViewer);
                _imageViewer.BringToFront();

                AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();
                automationInteractiveMode.MouseButtons = MouseButtons.Left | MouseButtons.Right;
                _imageViewer.InteractiveModes.Add(automationInteractiveMode);

                _imageViewer.UseDpi = false;

                _imageViewer.Zoom(Leadtools.Controls.ControlSizeMode.FitWidth, 1, LeadPoint.Empty);
                _imageViewer.ImageHorizontalAlignment = Leadtools.Controls.ControlAlignment.Center;
                _imageViewer.ImageBorderColor         = Color.Black;
                _imageViewer.BorderStyle          = BorderStyle.Fixed3D;
                _imageViewer.ImageBorderThickness = 1;

                using (RasterCodecs codec = new RasterCodecs())
                {
                    _imageViewer.Image = codec.Load(DemosGlobal.ImagesFolder + @"\ocr1.tif");
                    _imageViewer.AutomationDataProvider = new RasterImageAutomationDataProvider(_imageViewer.Image);
                }

                _automation = new AnnAutomation(_automationManager, _imageViewer);

                // Update the container size
                _automation.Container.Size = _automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(_imageViewer.Image.ImageWidth, _imageViewer.Image.ImageHeight));

                _automation.EditText               += new EventHandler <AnnEditTextEventArgs>(automation_EditText);
                _automation.OnShowContextMenu      += new EventHandler <AnnAutomationEventArgs>(automation_OnShowContextMenu);
                _automation.OnShowObjectProperties += new EventHandler <AnnAutomationEventArgs>(automation_OnShowObjectProperties);
                _automation.LockObject             += new EventHandler <AnnLockObjectEventArgs>(automation_LockObject);
                _automation.UnlockObject           += new EventHandler <AnnLockObjectEventArgs>(automation_UnlockObject);
                _automation.SetCursor              += new EventHandler <AnnCursorEventArgs>(automation_SetCursor);
                _automation.RestoreCursor          += new EventHandler(automation_RestoreCursor);

                _automation.Active = true;

                _tvLayers.BeginUpdate();
                _tvLayers.HideSelection = false;
                AnnLayer            layer    = AnnLayer.Create("Container");
                AnnObjectCollection children = _automation.Container.Children;
                foreach (AnnObject annObject in children)
                {
                    layer.Children.Add(annObject);
                }

                _containerNode     = new LayerNode(layer, null, false);
                _containerNode.Tag = "Container";

                _tvLayers.Nodes.Add(_containerNode);
                _tvLayers.EndUpdate();
                CreateDefaultLayers();
                OnResize(EventArgs.Empty);
            }

            base.OnLoad(e);
        }