Пример #1
0
        private bool SetLicense()
        {
            var _files = Directory.GetFiles(Path.Combine(LibUtilities.TheEnvironmentVariablePath, TheEnvVarSubDir.License), "*.*", SearchOption.AllDirectories)
                         .Where(file => (file.ToLower().EndsWith("lic") || file.ToLower().EndsWith("key")))
                         .ToArray();

            if (_files.ToList().Count < 2)
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(_files.Where(file => file.ToLower().EndsWith("lic")).ToList()[0]) ||
                string.IsNullOrWhiteSpace(_files.Where(file => file.ToLower().EndsWith("key")).ToList()[0]))
            {
                return(false);
            }

            RasterSupport.SetLicense(_files.Where(file => file.ToLower().EndsWith("lic")).ToList()[0],
                                     File.ReadAllText(_files.Where(file => file.ToLower().EndsWith("key")).ToList()[0]));

            if (RasterSupport.KernelExpired)
            {
                return(false);
            }
            if (RasterSupport.IsLocked(RasterSupportType.Forms))
            {
                return(false);
            }
            if (RasterSupport.IsLocked(RasterSupportType.OcrLEAD))
            {
                return(false);
            }
            return(true);
        }
Пример #2
0
        private void Rotate(int angle)
        {
            RasterImage image = _imageViewer.Image;

            // We must rotate our overlay rect too. We could rotate it ourselves or we could do this:
            // Get the rect in image coordinates (regardless of the view persective)
            // Rotate the image
            // Get the rect again in top-left from the image coordinates we saved

            LeadRect imageRect = LeadRect.Empty;

            if (!_overlayRect.IsEmpty)
            {
                // Save the overlay rect in image coordinates
                imageRect = image.RectangleToImage(RasterViewPerspective.TopLeft, _overlayRect);
            }

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                MessageBox.Show("Document support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            // Fast rotation involves changing the image view-perspective
            image.RotateViewPerspective(angle);

            if (!_overlayRect.IsEmpty)
            {
                // Now re-get the overlay rectangle as top left from the image data coordinates
                // we saved
                _overlayRect = image.RectangleFromImage(RasterViewPerspective.TopLeft, imageRect);
            }

            UpdateImageInfo();
        }
Пример #3
0
        private bool InitClass()
        {
            if (RasterSupport.IsLocked(RasterSupportType.PrintDriver) && RasterSupport.IsLocked(RasterSupportType.PrintDriverServer))
            {
                throw new Exception("Printer driver capability is required.");
            }

            if (FrmMain.StartedPrinter == string.Empty)
            {
                bSelectedPrinter = GetPrinterName(true);
                if (!bSelectedPrinter)
                {
                    return(false);
                }

                SetCurrentPrinter();
            }
            else
            {
                bSelectedPrinter    = true;
                _currentPrinterName = FrmMain.StartedPrinter;
                SetCurrentPrinter();
            }

            return(bSelectedPrinter);
        }
Пример #4
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            Boolean bLocked = RasterSupport.IsLocked(RasterSupportType.Forms);

            if (bLocked)
            {
                MessageBox.Show("Forms support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Boolean bOCRLocked = RasterSupport.IsLocked(RasterSupportType.OcrLEAD) & RasterSupport.IsLocked(RasterSupportType.OcrOmniPage);

            if (bOCRLocked)
            {
                MessageBox.Show("OCR support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (bLocked | bOCRLocked)
            {
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MasterFormsWizard());
        }
Пример #5
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            StartupMessageBox startupMsgBox = new StartupMessageBox("CSAnnotationsLayersDemo");

            if (startupMsgBox.ShowStartUpDialog)
            {
                startupMsgBox.ShowDialog();
            }

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.Document.ToString()), "Warning");
                return;
            }

            Application.EnableVisualStyles();
            Application.DoEvents();

            Application.Run(new MainForm());
        }
Пример #6
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.Medical))
            {
                MessageBox.Show("Medical support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            try
            {
                mainForm = new MainForm();
                Application.Run(mainForm);
            }
            catch (System.IO.FileNotFoundException)
            {
                string LTMM_MISSING = string.Format("This demo is designed to run ONLY if you have both a LEADTOOLS Medical toolkit " +
                                                    "and a LEADTOOLS Multimedia toolkit installed.\n\n" +
                                                    "In order to run this demo, please download and install the LEADTOOLS Multimedia SDK:\n" +
                                                    "https://www.leadtools.com/downloads?category=mm");

                if (MessageBox.Show(LTMM_MISSING + "\n\nDo you wish to navigate there now?", "LEADTOOLS Multimedia SDK Missing", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("https://www.leadtools.com/downloads?category=mm");
                }
            }
        }
Пример #7
0
        static void Main()
        {
            if (Leadtools.Demos.Support.SetLicense(false) == false)
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.Omr))
            {
                MessageBox.Show("OMR support must be unlocked.  Application will exit.");

                return;
            }

            try
            {
                MainForm.GetOmrEngine();
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to initialize OMR engine.  Application will exit.");

                return;
            }



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Пример #8
0
        private bool Init()
        {
            // Check support required to use this demo
            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                Messager.ShowError(this, string.Format(DemosGlobalization.GetResxString(GetType(), "resx_DemoWillExit"), "RasterSupportType.Document"));
                return(false);
            }

            _rasterCodecs = new RasterCodecs();

            _demoOptions = DemoOptions.Load();

            _viewerControl.Visible = false;
            _pagesControl.Visible  = false;

            _documentAnnotations = new DocumentAnnotations(this);

            _viewerControl.BringToFront();

            UpdateUIState();

            LoadDefaultDocument();

            return(true);
        }
 private void UnlockLeadToolsPDFSupport()
 {
     if (RasterSupport.IsLocked(RasterSupportType.PdfAdvanced))
     {
         RasterSupport.Unlock(RasterSupportType.PdfAdvanced, "haDLeYrAE");
     }
 }
Пример #10
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            Boolean bMedicalLocked = RasterSupport.IsLocked(RasterSupportType.Medical);

            if (bMedicalLocked)
            {
                MessageBox.Show("Medical support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Boolean bDocLocked = RasterSupport.IsLocked(RasterSupportType.Document);

            if (bDocLocked)
            {
                MessageBox.Show("Document support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (bMedicalLocked | bDocLocked)
            {
                return;
            }

            Application.Run(new MainForm());
        }
        private bool TrySetLicense(string licensePath, string developerKey)
        {
            try
            {
                RasterSupport.SetLicense(licensePath, developerKey); //try to set license
            }
            catch (Exception ex)
            {
                // log.Error(ex, "Error while setup license");
            }

            if (RasterSupport.KernelExpired)
            {
                // log.Error("Your license file is missing, invalid or expired. LEADTOOLS will not function. Please contact LEAD Sales for information on obtaining a valid license.");
                return(false);
            }

            if (RasterSupport.IsLocked(RasterSupportType.Forms))
            {
                // log.Error("Forms support must be unlocked!");
                return(false);
            }

            if (RasterSupport.IsLocked(RasterSupportType.OcrLEAD))
            {
                // log.Error("OCR support must be unlocked!");
                return(false);
            }

            //  log.Info("Licnse is valid.");
            return(true);
        }
Пример #12
0
        static void Main( )
        {
            Application.EnableVisualStyles();
#if LEADTOOLS_V175_OR_LATER
            if (!Support.SetLicense())
            {
                return;
            }
#else
            Support.Unlock(false);
#endif // #if LEADTOOLS_V175_OR_LATER

#if LEADTOOLS_V175_OR_LATER
            if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.DicomCommunication.ToString()), "Warning");
                return;
            }
#else
            if (RasterSupport.IsLocked(RasterSupportType.MedicalNet))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.MedicalNet.ToString()), "Warning");
                return;
            }
#endif // #if LEADTOOLS_V175_OR_LATER

            Application.Run(new MainForm());
        }
Пример #13
0
        private void InitViewer()
        {
            // Use ScaleToGray and Bicubic for optimum viewing of black/white and color images
            RasterPaintProperties props = _rasterImageViewer.PaintProperties;

            props.PaintDisplayMode |= RasterPaintDisplayModeFlags.Bicubic;

            if (!RasterSupport.IsLocked(RasterSupportType.Document))
            {
                props.PaintDisplayMode |= RasterPaintDisplayModeFlags.ScaleToGray;
            }

            _rasterImageViewer.PaintProperties = props;

            // Pad the viewer
            _rasterImageViewer.Padding = new Padding(10);

            // Set the cursors
            _noneInteractiveMode                        = new ImageViewerNoneInteractiveMode();
            _panInteractiveMode                         = new ImageViewerPanZoomInteractiveMode();
            _panInteractiveMode.MouseButtons            = System.Windows.Forms.MouseButtons.Left;
            _zoomToInteractiveMode                      = new ImageViewerZoomToInteractiveMode();
            _zoomToInteractiveMode.RubberBandCompleted += new EventHandler <ImageViewerRubberBandEventArgs>(_rasterImageViewer_InteractiveZoomTo);
            _rectInteractiveMode                        = new ImageViewerRubberBandInteractiveMode();
            _regionInteractiveMode                      = new ImageViewerAddRegionInteractiveMode();
            _regionInteractiveMode.RubberBandCompleted += new EventHandler <ImageViewerRubberBandEventArgs>(_rasterImageViewer_InteractiveRegionRectangle);
            _regionInteractiveMode.RubberBandStarted   += new EventHandler <ImageViewerRubberBandEventArgs>(RegionInteractiveMode_RubberBandStarted);
            _rectInteractiveMode.RubberBandCompleted   += new EventHandler <ImageViewerRubberBandEventArgs>(RectInteractiveMode_RubberBandCompleted);
            _noneInteractiveMode.IdleCursor             = Cursors.Arrow;
            _noneInteractiveMode.WorkingCursor          = Cursors.Arrow;

            _panInteractiveMode.IdleCursor    = Cursors.Hand;
            _panInteractiveMode.WorkingCursor = Cursors.Hand;

            _zoomToInteractiveMode.IdleCursor    = Cursors.Cross;
            _zoomToInteractiveMode.WorkingCursor = Cursors.Cross;

            _rectInteractiveMode.IdleCursor    = Cursors.Cross;
            _rectInteractiveMode.WorkingCursor = Cursors.Cross;

            _regionInteractiveMode.IdleCursor    = Cursors.Cross;
            _regionInteractiveMode.WorkingCursor = Cursors.Cross;

            _rasterImageViewer.InteractiveModes.BeginUpdate();
            _rasterImageViewer.InteractiveModes.Add(_noneInteractiveMode);
            _rasterImageViewer.InteractiveModes.Add(_panInteractiveMode);
            _rasterImageViewer.InteractiveModes.Add(_zoomToInteractiveMode);
            _rasterImageViewer.InteractiveModes.Add(_rectInteractiveMode);
            _rasterImageViewer.InteractiveModes.Add(_regionInteractiveMode);
            _rasterImageViewer.InteractiveModes.EndUpdate();
        }
Пример #14
0
        private bool Init()
        {
            // Check support required to use this program
            if (RasterSupport.IsLocked(RasterSupportType.Barcodes1D) && RasterSupport.IsLocked(RasterSupportType.Barcodes2D))
            {
                Messager.ShowError(this, BarcodeGlobalization.GetResxString(GetType(), "Resx_LEADBarcodeSupport"));
                return(false);
            }

            try
            {
                _rasterCodecs = new RasterCodecs();
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, string.Format("RasterCodec initialize error: {0}", ex.Message));
                return(false);
            }

            // this is very important, must be placed leadtools.engine.dll in this path
            _rasterCodecs.Options.Pdf.InitialPath = AppDomain.CurrentDomain.BaseDirectory;

            _barcodeOptions = BarcodeOptions.Load();

            //BarcodeSymbology[] supportedSymbologies = BarcodeEngine.GetSupportedSymbologies();
            WriteLine(string.Format("{0} Supported symbologies:", _barcodeOptions.ReadOptionsSymbologies.Length), TraceEventType.Information);
            foreach (BarcodeSymbology symbology in _barcodeOptions.ReadOptionsSymbologies)
            {
                WriteLine(string.Format("{0}: {1}", symbology, BarcodeEngine.GetSymbologyFriendlyName(symbology)), TraceEventType.Information);
            }
            WriteLine(string.Format("----------"), TraceEventType.Information);

            _sampleSymbologiesRasterImage = null;

            // Create the barcodes symbologies multi-frame RasterImage
            using (Stream stream = GetType().Assembly.GetManifestResourceStream("BarcodeSplitManage.Resources.Symbologies.tif"))
            {
                _rasterCodecs.Options.Load.AllPages = true;
                _sampleSymbologiesRasterImage       = _rasterCodecs.Load(stream);
            }

            _barcodeEngine = new BarcodeEngine();
            _barcodeEngine.Reader.ImageType = BarcodeImageType.Unknown;
            _barcodeEngine.Reader.EnableReturnFourPoints = false;
            // Continue on errors
            _barcodeEngine.Reader.ErrorMode = BarcodeReaderErrorMode.IgnoreAll;

            _directorySettings = new DirectorySettings();

            return(true);
        }
Пример #15
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.Medical))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.Medical.ToString()), "Warning");
                return;
            }

            Application.Run(new MainForm());
        }
Пример #16
0
        private void EnableControls()
        {
            try
            {
                bool bEnable = (_txtBoxPrinterName.Text != string.Empty);
                _btnOk.Enabled = bEnable;

                if (RasterSupport.IsLocked(RasterSupportType.PrintDriverServer)) //Network Key
                {
                    _ckEnableNetwork.Enabled = false;
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), "LEADTOOLS Printer Demo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #17
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.Hl7))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.Hl7.ToString()), "Warning");
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainView());
        }
Пример #18
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                MessageBox.Show("Document support must be unlocked for this demo!", "Support Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Пример #19
0
            static void Main(string[] args)
            {
                if (!Support.SetLicense())
                {
                    return;
                }

                if (RasterSupport.IsLocked(RasterSupportType.Ccow))
                {
                    MessageBox.Show("CCOW Support is locked!  Application will exit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
Пример #20
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.Document.ToString()), "Warning");
                return;
            }

            Application.EnableVisualStyles();
            Application.DoEvents();

            Application.Run(new MainForm());
        }
Пример #21
0
        public static void Main()
        {
            bool created = false;

            Mutex m = new Mutex(true, "DicomDirLinqDemo", out created);

#if LEADTOOLS_V175_OR_LATER
            if (!Support.SetLicense())
            {
                return;
            }
#else
            Support.Unlock(false);
#endif // #if LEADTOOLS_V175_OR_LATER

            if (RasterSupport.IsLocked(RasterSupportType.Medical))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.Medical.ToString()), "Warning");
                return;
            }

            if (created)
            {
                Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());

                GC.KeepAlive(m);
            }
            else
            {
                Process current = Process.GetCurrentProcess();

                foreach (Process process in Process.GetProcessesByName(current.ProcessName))
                {
                    if (process.Id != current.Id)
                    {
                        SetForegroundWindow(process.MainWindowHandle);
                        break;
                    }
                }
            }
        }
Пример #22
0
        public static void Set()
        {
            string licenseFilePath = "LeadToolsHelpers\\eval-license-files.lic";                                 //Your .LIC file path here
            string developerKey    = System.IO.File.ReadAllText("LeadToolsHelpers\\eval-license-files.lic.key"); //Your .KEY file path here

            RasterSupport.SetLicense(licenseFilePath, developerKey);

            //Tests to see if license supports a particular type
            bool isLocked = RasterSupport.IsLocked(RasterSupportType.Document);

            if (isLocked)
            {
                Trace.WriteLine("Document support is locked");
            }
            else
            {
                Trace.WriteLine("Document support is unlocked");
            }
        }
Пример #23
0
            static void Main(string[] args)
            {
                bool createdNew = true;

                using (Mutex mutex = new Mutex(true, "CSCCOWAthenticationDemo", out createdNew))
                {
                    if (createdNew)
                    {
                        if (!Support.SetLicense())
                        {
                            return;
                        }

                        if (RasterSupport.IsLocked(RasterSupportType.Ccow))
                        {
                            MessageBox.Show("CCOW Support is locked!  Application will exit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        if (args.Length > 0)
                        {
                            _LaunchArgs = string.Join(" ", args);
                        }

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new MainForm());
                    }
                    else
                    {
                        Process current = Process.GetCurrentProcess();

                        foreach (Process process in Process.GetProcessesByName(current.ProcessName))
                        {
                            if (process.Id != current.Id)
                            {
                                SetForegroundWindow(process.MainWindowHandle);
                                break;
                            }
                        }
                    }
                }
            }
Пример #24
0
        static void Main()
        {
            if (!Support.SetLicense())
            {
                return;
            }

            if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.DicomCommunication.ToString()), "Warning");
                return;
            }


            Utils.EngineStartup();
            Utils.DicomNetStartup();

            Application.Run(new MainForm());
        }
Пример #25
0
        private static void startApplication(string[] args)
        {
//设置License
            if (!Support.SetLicense())
            {
                return;
            }
            //leadtools验证liccense
            if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.DicomCommunication.ToString()),
                                "Warning");
                return;
            }
            //对Uac进行判断,如果需要提升权限进行运行,已通过manifest设置requireAdministrator绕过
            if (DemosGlobal.MustRestartElevated())
            {
                DemosGlobal.TryRestartElevated(args);
                return;
            }
            //启动leadtools引擎,DicomEngine.Startup();
            Utils.EngineStartup();
            //DicomNet.Startup();
            Utils.DicomNetStartup();

            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(true);
                //运行主界面
                Application.Run(new MainForm());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Utils.EngineShutdown();
                Utils.DicomNetShutdown();
            }
        }
Пример #26
0
        static void Main()
        {
#if LEADTOOLS_V175_OR_LATER
            if (!Support.SetLicense())
            {
                return;
            }
#else
            Support.Unlock(false);
#endif // #if LEADTOOLS_V175_OR_LATER

            if (RasterSupport.IsLocked(RasterSupportType.MediaWriter))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.MediaWriter.ToString()), "Warning");
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Пример #27
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                // We cannot run without document support
                if (!RasterSupport.IsLocked(RasterSupportType.Document))
                {
                    InitViewer();

                    // 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);

                    InteractiveMode = ViewerControlInteractiveMode.SelectMode;

                    _mousePositionLabel.Text = string.Empty;
                }
            }

            base.OnLoad(e);
        }
Пример #28
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (_sampleSymbologiesRasterImage == null)
            {
                return;
            }

            if (e.Index == -1)
            {
                return;
            }

            Rectangle rc = new Rectangle(e.Bounds.X + _delta, e.Bounds.Y + _delta, e.Bounds.Width - 10, e.Bounds.Height - _delta);

            if (_stringFormat == null)
            {
                _stringFormat               = new StringFormat();
                _stringFormat.Alignment     = StringAlignment.Center;
                _stringFormat.LineAlignment = StringAlignment.Far;
            }

            BarcodeSymbology symbology = (BarcodeSymbology)Items[e.Index];
            string           name      = BarcodeEngine.GetSymbologyFriendlyName(symbology);

            _sampleSymbologiesRasterImage.Page = (int)symbology;

            if (_itemPen == null)
            {
                _itemPen = new Pen(Brushes.Black, 2);
            }

            e.Graphics.DrawRectangle(_itemPen, rc);
            e.Graphics.FillRectangle(Brushes.White, rc);

            RasterPaintProperties paintProperties = RasterPaintProperties.Default;

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic;
            }
            else
            {
                paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray;
            }

            LeadRect imageRect = new LeadRect(rc.X + 2, rc.Y + 2, rc.Width - 4, rc.Height * 2 / 3);

            imageRect = RasterImage.CalculatePaintModeRectangle(
                _sampleSymbologiesRasterImage.ImageWidth,
                _sampleSymbologiesRasterImage.ImageHeight,
                imageRect,
                RasterPaintSizeMode.FitAlways,
                RasterPaintAlignMode.CenterAlways,
                RasterPaintAlignMode.CenterAlways);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rc);
                RasterImagePainter.Paint(_sampleSymbologiesRasterImage, e.Graphics, imageRect, paintProperties);
                e.Graphics.DrawRectangle(Pens.Black, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                e.Graphics.DrawString(name, Font, SystemBrushes.HighlightText, rc, _stringFormat);
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Control, rc);
                RasterImagePainter.Paint(_sampleSymbologiesRasterImage, e.Graphics, imageRect, paintProperties);
                e.Graphics.DrawRectangle(Pens.Black, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                e.Graphics.DrawString(name, Font, SystemBrushes.ControlText, rc, _stringFormat);
            }
        }
Пример #29
0
        static int Main(string[] args)
        {
#if LEADTOOLS_V19_OR_LATER
            if (!Support.SetLicense())
            {
                return(0);
            }
#else
            Support.SetLicense();
            if (RasterSupport.KernelExpired)
            {
                return(0);
            }
#endif

            Mutex m;
            if (DemosGlobal.MustRestartElevated())
            {
                DemosGlobal.TryRestartElevated(args);
                return(0);
            }
#if !FOR_DOTNET4
            bool dotNet35Installed = DemosGlobal.IsDotNet35Installed();
            if (!dotNet35Installed)
            {
                return(0);
            }
#endif

            bool ok;

#if LEADTOOLS_V175_OR_LATER
            m = new Mutex(true, "LEADTOOLS_V175_OR_LATER", out ok);

            if (!ok)
            {
                return(1);
            }
#else
            SingleInstanceController controller;
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);



#if LEADTOOLS_V175_OR_LATER
            if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
#else
            if (RasterSupport.IsLocked(RasterSupportType.MedicalNet))
#endif
            {
                MessageBox.Show("Support for LEADTOOLS PACS Module is locked!\nServer Manager cannot run!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(-1);
            }

#if (LEADTOOLS_V20_OR_LATER)
            if (DemosGlobal.IsDotNet45OrLaterInstalled() == false)
            {
                MessageBox.Show("To run this application, you must first install Microsoft .NET Framework 4.5 or later.",
                                "Microsoft .NET Framework 4.5 or later Required",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return(-1);
            }
#endif

            {
                string   message         = string.Empty;
                string[] productsToCheck = new string[] { DicomDemoSettingsManager.ProductNameStorageServer };
                bool     dbConfigured    = GlobalPacsUpdater.IsDbComponentsConfigured(productsToCheck, out message);

                if (!dbConfigured &&
                    !RequestUserToConfigureDbSucess(message))
                {
                    return(-1);
                }

                if (!GlobalPacsUpdater.IsProductDatabaseUpTodate(DicomDemoSettingsManager.ProductNameDemoServer) &&
                    !RequestUserToUpgradeDbSucess())
                {
                    return(-1);
                }

                if (!ok)
                {
                    return(-1);
                }
            }


            BaseDir = Path.GetFullPath(GetWorkingDirectory()).ToLower();
            DicomEngine.Startup();
            DicomNet.Startup();
#if !LEADTOOLS_V175_OR_LATER
            controller = new SingleInstanceController();
            controller.Run(Environment.GetCommandLineArgs());
#else
            try
            {
                Application.Run(new MainForm());
            }
            catch (FileNotFoundException ex)
            {
                MessageBox.Show("File not found exception.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
#endif
            DicomNet.Shutdown();
            DicomEngine.Shutdown();
#if LEADTOOLS_V175_OR_LATER
            GC.KeepAlive(m);
#endif
            return(0);
        }
        static int Main(string[] args)
        {
            if (!DicomDemoSettingsManager.Is64Process())
            {
                _demoName = "LEADTOOLS PACS Configuration Demo  (32 bit)";
            }
            else
            {
                _demoName = "LEADTOOLS PACS Configuration Demo  (64 bit)";
            }

            if (DemosGlobal.MustRestartElevated())
            {
                DemosGlobal.TryRestartElevated(args);
                return(0);
            }

            ReadCommandLine(args);
            MySettings mySettings = new MySettings();

            if (_bInitialize)
            {
#if !FOR_DOTNET4
                if (false == DemosGlobal.IsDotNet35Installed())
                {
                    return(0);
                }
#endif

                MyUtils.RemoveConfigurationFiles();
                MyUtils.RemoveGlobalPacsConfig();
                mySettings.Save();
                return(0);
            }

            bool showUI = !_bUninstall && !_bInitialize;

#if !FOR_DOTNET4
            bool dotNet35Installed = DemosGlobal.IsDotNet35Installed();
            if (showUI && !dotNet35Installed)
            {
                Messager.ShowWarning(null, ".NET Framework 3.5 could not be found on this machine.\n\nPlease install the .NET Framework 3.5 runtime and try again. This program will now exit.");
            }
            if (!dotNet35Installed)
            {
                return(0);
            }
#endif

            mySettings.Load();

#if LEADTOOLS_V19_OR_LATER
            if (showUI)
            {
                if (!Support.SetLicense())
                {
                    return(-1);
                }
            }
#endif

            // If calling with the /uninstall flag, do not display the nag message
            if (_bUninstall == false)
            {
                if (RasterSupport.KernelExpired)
                {
                    return(-1);
                }
            }

#if LEADTOOLS_V175_OR_LATER
            if (showUI)
            {
                if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
                {
                    MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.DicomCommunication.ToString()), "Warning");
                    return(-1);
                }
            }
#else
            if (RasterSupport.IsLocked(RasterSupportType.MedicalNet))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.MedicalNet.ToString()), "Warning");
                return(-1);
            }

            if (RasterSupport.IsLocked(RasterSupportType.MedicalServer))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.MedicalServer.ToString()), "Warning");
                return(-1);
            }
#endif

            //_admin = new ServiceAdministrator(_baseDir);
            //_admin.Unlock(Support.MedicalServerKey);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if (LEADTOOLS_V20_OR_LATER)
            if (DemosGlobal.IsDotNet45OrLaterInstalled() == false)
            {
                MessageBox.Show("To run this application, you must first install Microsoft .NET Framework 4.5 or later.",
                                "Microsoft .NET Framework 4.5 or later Required",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return(-1);
            }
#endif

            //Utils.EngineStartup();
            DicomEngine.Startup();

            if (_bUninstall)
            {
                try
                {
                    using (ServiceAdministrator serviceAdmin = CreateServiceAdministrator())
                    {
                        MyUtils.UninstallAllDicomServersSilent(serviceAdmin);
                        MyUtils.RemoveConfigurationFiles();
                    }
                }
                catch (Exception)
                {
                }
            }
            else
            {
                string       missingDbComponents;
                DialogResult result = DialogResult.Yes;
                Messager.Caption = _demoName;
                string platform = "32-bit";
                if (DicomDemoSettingsManager.Is64Process())
                {
                    platform = "64-bit";
                }

                string [] productsToCheck = new string[] { DicomDemoSettingsManager.ProductNameDemoServer, DicomDemoSettingsManager.ProductNameWorkstation, DicomDemoSettingsManager.ProductNameStorageServer };

                bool isDbConfigured = GlobalPacsUpdater.IsDbComponentsConfigured(productsToCheck, out missingDbComponents);
                if (!isDbConfigured) // databases not configured
                {
                    string message = "The following databases are not configured:\n\n{0}\nRun the {1} CSPacsDatabaseConfigurationDemo to configure the missing databases then run this demo again.\n\nDo you want to run the {2} CSPacsDatabaseConfigurationDemo wizard now?";
                    message = string.Format(message, missingDbComponents, platform, platform);

                    result = Messager.ShowQuestion(null, message, MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        RunDatabaseConfigurationDemo();
                    }
                }

                mySettings._settings.FirstRun = false;
                mySettings.Save();

                // Add event handler for handling UI thread exceptions to the event
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

                // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                try
                {
                    Application.Run(new MainForm());
                }
                catch (FileNotFoundException ex)
                {
                    MessageBox.Show("File not found exception.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            DicomEngine.Shutdown();
            return(0);
        }