示例#1
0
 /// <summary>
 /// Updates the form when the image pixel is selected.
 /// </summary>
 /// <param name="x">Pixel X coordinate.</param>
 /// <param name="y">Pixel Y coordinate.</param>
 internal void SelectPixel(int x, int y)
 {
     if (x >= 0 && y >= 0)
     {
         VintasoftImage image = _viewer.Image;
         if (x < image.Width && y < image.Height)
         {
             try
             {
                 ColorBase pixelColor = _viewer.Image.GetPixelColor(x, y);
                 ShowSelectedPixelColor(x, y, pixelColor);
             }
             catch (Exception e)
             {
                 DemosTools.ShowErrorMessage(e);
             }
             return;
         }
     }
     selectedPixelLabel.Text           = "Selected Pixel: click on image to select";
     argbPanel.Visible                 = false;
     indexedPanel.Visible              = false;
     gray16Panel.Visible               = false;
     selectedPixelColorPanel.BackColor = Color.Transparent;
 }
示例#2
0
 /// <summary>
 /// Handles the Click event of TextPropertiesButton object.
 /// </summary>
 private void TextPropertiesButton_Click(object sender, EventArgs e)
 {
     try
     {
         // if visual editor has focused text
         OpenXmlTextProperties textProperties = VisualEditor.GetTextProperties();
         if (textProperties != null)
         {
             // show text properties form
             OpenXmlTextPropertiesForm textPropertiesForm = new OpenXmlTextPropertiesForm(VisualEditor.GetFontNames());
             textPropertiesForm.TextProperties = textProperties;
             if (textPropertiesForm.ShowDialog() == DialogResult.OK)
             {
                 // set text properties
                 textProperties = textPropertiesForm.GetChangedTextProperties();
                 if (textProperties != null)
                 {
                     VisualEditor.SetTextProperties(textProperties);
                 }
             }
             // set focus to the parent form
             Parent.FindForm().Owner.Focus();
         }
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
 /// <summary>
 /// Handles the Click event of ParagraphNumberingButton object.
 /// </summary>
 private void ParagraphNumberingButton_Click(object sender, EventArgs e)
 {
     try
     {
         // if focused paragraph has numeration
         if (paragraphNumberingButton.Checked)
         {
             // remove numeration
             OpenXmlParagraphProperties paragraphProperties = new OpenXmlParagraphProperties();
             paragraphProperties.RemoveNumeration();
             VisualEditor.SetParagraphProperties(paragraphProperties);
         }
         else
         {
             // if visual editor has focused paragraph
             if (VisualEditor.GetParagraphProperties() != null)
             {
                 // set numeration properties
                 using (SetOpenXmlParagraphNumerationForm form = new SetOpenXmlParagraphNumerationForm(VisualEditor))
                 {
                     form.ShowDialog();
                 }
                 // set focus to parent form
                 Parent.FindForm().Owner.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
示例#4
0
        /// <summary>
        /// Executes the SetAlphaChannelCommand command.
        /// </summary>
        public void ExecuteSetAlphaChannelCommand()
        {
            if (_openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            VintasoftImage maskImage;

            try
            {
                maskImage = new VintasoftImage(_openFileDialog.FileName);
            }
            catch (Exception ex)
            {
                DemosTools.ShowErrorMessage("SetAlphaChannelMaskCommand", ex);
                return;
            }

            SetAlphaChannelMaskCommand command = new SetAlphaChannelMaskCommand(maskImage);

            ExecuteProcessingCommand(command, false);

            maskImage.Dispose();
        }
示例#5
0
        /// <summary>
        /// Determines whether specified processing command can process the specified image.
        /// </summary>
        /// <param name="command">Image processing command.</param>
        /// <param name="image">Image to process.</param>
        /// <returns>
        /// <b>true</b> - processing command can process image;
        /// otherwise, <b>false</b>.
        /// </returns>
        private bool CommandCanProcessImage(ProcessingCommandBase command, VintasoftImage image)
        {
            bool needConvertToSupportedPixelFormat = command.ExpandSupportedPixelFormats;

            command.ExpandSupportedPixelFormats = ExpandSupportedPixelFormats;
            PixelFormat outputPixelFormat = command.GetOutputPixelFormat(image);

            command.ExpandSupportedPixelFormats = needConvertToSupportedPixelFormat;

            if (outputPixelFormat != PixelFormat.Undefined)
            {
                return(true);
            }

            System.Text.StringBuilder        sb      = new System.Text.StringBuilder();
            ReadOnlyCollection <PixelFormat> formats = command.SupportedPixelFormats;

            for (int i = 0; i < formats.Count; i++)
            {
                sb.Append(" -");
                sb.Append(formats[i].ToString());
                sb.AppendLine(";");
            }
            string supportedPixelFormatNames = sb.ToString();

            string message = string.Format(
                System.Globalization.CultureInfo.InvariantCulture,
                "{0}: unsupported pixel format - {1}.\n\nProcessing command supports only the following pixel formats:\n{2}\nPlease convert the image to supported pixel format first.",
                command.Name,
                image.PixelFormat,
                supportedPixelFormatNames);

            DemosTools.ShowErrorMessage("Image processing exception", message);
            return(false);
        }
        /// <summary>
        /// Edits a color management settings of specified image viewer.
        /// </summary>
        public static bool EditColorManagement(ImageViewerBase imageViewer)
        {
            using (ColorManagementSettingsForm colorManagementSettingsForm = new ColorManagementSettingsForm())
            {
                if (imageViewer.ImageDecodingSettings == null)
                {
                    colorManagementSettingsForm.ColorManagementSettings = null;
                }
                else
                {
                    colorManagementSettingsForm.ColorManagementSettings = imageViewer.ImageDecodingSettings.ColorManagement;
                }

                colorManagementSettingsForm.TopMost = true;

                if (colorManagementSettingsForm.ShowDialog() == DialogResult.OK)
                {
                    DecodingSettings settings = imageViewer.ImageDecodingSettings;
                    if (settings == null)
                    {
                        settings = new DecodingSettings();
                    }

                    settings.ColorManagement          = colorManagementSettingsForm.ColorManagementSettings;
                    imageViewer.ImageDecodingSettings = settings;

                    // reload images in image viewer
                    DemosTools.ReloadImagesInViewer(imageViewer);

                    return(true);
                }

                return(false);
            }
        }
 /// <summary>
 /// Handles the Click event of ParagraphPropertiesButton object.
 /// </summary>
 private void ParagraphPropertiesButton_Click(object sender, EventArgs e)
 {
     try
     {
         // if visual editor has focused paragraph
         OpenXmlParagraphProperties paragraphProperties = VisualEditor.GetParagraphProperties();
         if (paragraphProperties != null)
         {
             // show paragraph properties form
             OpenXmlParagraphPropertiesForm paragraphPropertiesForm = new OpenXmlParagraphPropertiesForm();
             paragraphPropertiesForm.ParagraphProperties = paragraphProperties;
             if (paragraphPropertiesForm.ShowDialog() == DialogResult.OK)
             {
                 // set paragraph properties
                 paragraphProperties = paragraphPropertiesForm.GetChangedParagraphProperties();
                 if (paragraphProperties != null)
                 {
                     VisualEditor.SetParagraphProperties(paragraphProperties);
                 }
             }
             // set focus to parent form
             Parent.FindForm().Owner.Focus();
         }
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
        /// <summary>
        /// Updates the UI from <see cref="ParagraphProperties"/>.
        /// </summary>
        private void UpdateUI()
        {
            textJustificationComboBox.SelectedItem = _paragraphProperties.Justification;

            fillColorPanel.Color = _paragraphProperties.FillColor.Value;

            firstLineIndentationComboBox.Text = DemosTools.ToString(_paragraphProperties.FirstLineIndentation);

            leftIndentationComboBox.Text = DemosTools.ToString(_paragraphProperties.LeftIndentation);

            rightIndentationComboBox.Text = DemosTools.ToString(_paragraphProperties.RightIndentation);

            lineHeightComboBox.Text = DemosTools.ToString(_paragraphProperties.LineHeightFactor);

            spacingBeforeComboBox.Text = DemosTools.ToString(_paragraphProperties.SpacingBeforeParagraph);

            spacingAfterComboBox.Text = DemosTools.ToString(_paragraphProperties.SpacingAfterParagraph);

            keepLinesCheckBox.Checked = _paragraphProperties.KeepLines.Value;

            keepNextCheckBox.Checked = _paragraphProperties.KeepNext.Value;

            pageBreakBeforeCheckBox.Checked = _paragraphProperties.PageBreakBefore.Value;

            widowControlCheckBox.Checked = _paragraphProperties.WidowControl.Value;
        }
示例#9
0
        /// <summary>
        /// Loads the measurement annotations from a file.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void loadMeasurementsAction_Clicked(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.FileName = null;
                openFileDialog.Filter   =
                    "Binary Annotations(*.vsabm)|*.vsabm|XMP Annotations(*.xmpm)|*.xmpm|All Formats(*.vsabm;*.xmpm)|*.vsabm;*.xmpm";
                openFileDialog.FilterIndex = 3;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        using (FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read))
                        {
                            ImageMeasureTool visualTool = (ImageMeasureTool)VisualTool;
                            // get the annotation collection
                            AnnotationDataCollection annotations = visualTool.AnnotationViewCollection.DataCollection;
                            // clear the annotation collection
                            annotations.ClearAndDisposeItems();
                            // add annotations from stream to the annotation collection
                            annotations.AddFromStream(fs, visualTool.ImageViewer.Image.Resolution);
                        }
                    }
                    catch (Exception ex)
                    {
                        DemosTools.ShowErrorMessage(ex);
                    }
                }
            }
        }
        /// <summary>
        /// Updates the User Interface from <see cref="TextProperties"/>.
        /// </summary>
        private void UpdateUI()
        {
            if (_textProperties.FontName != null)
            {
                if (Array.IndexOf(_fontNames, _textProperties.FontName) < 0)
                {
                    fontListBox.Items.Insert(0, _textProperties.FontName);
                }
            }
            fontListBox.SelectedItem = _textProperties.FontName;

            fontSizeComboBox.Text = DemosTools.ToString(_textProperties.FontSize);

            if (_textProperties.IsBold.Value && _textProperties.IsItalic.Value)
            {
                fontStyleListBox.SelectedIndex = 3;
            }
            else if (_textProperties.IsItalic.Value)
            {
                fontStyleListBox.SelectedIndex = 2;
            }
            else if (_textProperties.IsBold.Value)
            {
                fontStyleListBox.SelectedIndex = 1;
            }
            else
            {
                fontStyleListBox.SelectedIndex = 0;
            }

            if (_textProperties.VerticalAlignment == OpenXmlTextVerticalPositionType.Subscript)
            {
                subscriptCheckBox.Checked = true;
            }
            else if (_textProperties.VerticalAlignment == OpenXmlTextVerticalPositionType.Superscript)
            {
                superscriptCheckBox.Checked = true;
            }

            if (_textProperties.IsStrike.Value)
            {
                strikeoutCheckBox.Checked = true;
            }
            else if (_textProperties.IsDoubleStrike.Value)
            {
                doubleStrikeoutcheckBox.Checked = true;
            }

            fontColorPanel.Color = _textProperties.Color.Value;

            underlineComboBox.SelectedItem = _textProperties.Underline;

            underlineColorPanel.Color = _textProperties.UnderlineColor.Value;

            textHighlightComboBox.SelectedItem = _textProperties.Highlight;

            horizontalScaleComboBox.Text = DemosTools.ToString(_textProperties.CharacterHorizontalScaling);

            characterSpacingComboBox.Text = DemosTools.ToString(_textProperties.CharacterSpacing);
        }
        /// <summary>
        /// Edits the document layout settings using DocumentLayoutSettingsDialog.
        /// </summary>
        public void EditLayoutSettingsUseDialog()
        {
            // create dialog with necessary layout settings
            using (DocumentLayoutSettingsDialog dialog = CreateLayoutSettingsDialog())
            {
                // pass current layout settings to the dialog
                if (LayoutSettings != null)
                {
                    dialog.LayoutSettings = (DocumentLayoutSettings)LayoutSettings.Clone();
                }

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    // get layout settings from dialog
                    try
                    {
                        LayoutSettings = dialog.LayoutSettings;
                    }
                    catch (Exception ex)
                    {
                        DemosTools.ShowErrorMessage(ex);
                    }
                }
            }
        }
示例#12
0
 /// <summary>
 /// Handles the Click event of ChangeUnderlineButton object.
 /// </summary>
 private void ChangeUnderlineButton_Click(object sender, EventArgs e)
 {
     try
     {
         VisualEditor.Actions.CreateChangeTextUnderlineUIAction(OpenXmlTextUnderlineType.Single).Execute();
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
示例#13
0
 /// <summary>
 /// Sets color to selected pixel.
 /// </summary>
 private void SetColorOfSelectedPixel()
 {
     try
     {
         _viewer.Image.SetPixelColor(_selectedColorX, _selectedColorY, _selectedColor);
     }
     catch (Exception e)
     {
         DemosTools.ShowErrorMessage(e);
     }
 }
示例#14
0
 /// <summary>
 /// Handles the Click event of ChangeBoldButton object.
 /// </summary>
 private void ChangeBoldButton_Click(object sender, EventArgs e)
 {
     try
     {
         VisualEditor.Actions.ChangeFocusedTextBold.Execute();
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
示例#15
0
 /// <summary>
 /// Handles the Click event of DecreaseTextSizeButton object.
 /// </summary>
 private void DecreaseTextSizeButton_Click(object sender, EventArgs e)
 {
     try
     {
         VisualEditor.Actions.CreateChangeTextSize(-1).Execute();
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
 /// <summary>
 /// Handles the Click event of ParagraphJLeftButton object.
 /// </summary>
 private void ParagraphJLeftButton_Click(object sender, EventArgs e)
 {
     try
     {
         VisualEditor.Actions.CreateSetParagraphJustification(OpenXmlParagraphJustification.Left).Execute();
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
 /// <summary>
 /// Handles the Click event of IncParagraphLeftIndentationButton object.
 /// </summary>
 private void IncParagraphLeftIndentationButton_Click(object sender, EventArgs e)
 {
     try
     {
         VisualEditor.Actions.CreateChangeParagraphLeftIndentation(ParagraphIndentationDelta).Execute();
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
        /// <summary>
        /// Updates the <see cref="ParagraphProperties"/> from UI.
        /// </summary>
        private bool UpdateParagraphProperties()
        {
            _paragraphProperties.Justification = (OpenXmlParagraphJustification)textJustificationComboBox.SelectedItem;

            _paragraphProperties.FillColor = fillColorPanel.Color;

            float value;

            if (!DemosTools.ParseFloat(firstLineIndentationComboBox.Text, "First Line Indentation", out value))
            {
                return(false);
            }
            _paragraphProperties.FirstLineIndentation = value;

            if (!DemosTools.ParseFloat(leftIndentationComboBox.Text, "Left Indentation", out value))
            {
                return(false);
            }
            _paragraphProperties.LeftIndentation = value;

            if (!DemosTools.ParseFloat(rightIndentationComboBox.Text, "Right Indentation", out value))
            {
                return(false);
            }
            _paragraphProperties.RightIndentation = value;

            if (!DemosTools.ParseFloat(lineHeightComboBox.Text, "Line Height Factor", out value))
            {
                return(false);
            }
            _paragraphProperties.LineHeightFactor = value;

            if (!DemosTools.ParseFloat(spacingBeforeComboBox.Text, "Spacing Before Paragraph", out value))
            {
                return(false);
            }
            _paragraphProperties.SpacingBeforeParagraph = value;

            if (!DemosTools.ParseFloat(spacingAfterComboBox.Text, "Spacing After Paragraph", out value))
            {
                return(false);
            }
            _paragraphProperties.SpacingAfterParagraph = value;

            _paragraphProperties.KeepLines = keepLinesCheckBox.Checked;

            _paragraphProperties.KeepNext = keepNextCheckBox.Checked;

            _paragraphProperties.PageBreakBefore = pageBreakBeforeCheckBox.Checked;

            _paragraphProperties.WidowControl = widowControlCheckBox.Checked;

            return(true);
        }
示例#19
0
 /// <summary>
 /// Handles the Click event of DecreaseContentScaleButton object.
 /// </summary>
 private void decreaseContentScaleButton_Click(object sender, EventArgs e)
 {
     try
     {
         _visualEditor.InteractiveObject.ContentScale *= (1 - ContentScaleDelta / 100f);
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
示例#20
0
        /// <summary>
        /// Saves the settings of thumbnail viewer.
        /// </summary>
        private bool SetSettings()
        {
            _viewer.GenerateOnlyVisibleThumbnails = generateOnlyVisibleThumbnailsCheckBox.Checked;

            // Thumbnail Size
            try
            {
                string[] sizeStrings = thumbnailSizeComboBox.Text.Split('x');
                int      width;
                int      height;
                if (sizeStrings.Length == 1)
                {
                    width  = Convert.ToInt32(sizeStrings[0]);
                    height = width;
                }
                else
                {
                    width  = Convert.ToInt32(sizeStrings[0]);
                    height = Convert.ToInt32(sizeStrings[1]);
                }
                _viewer.ThumbnailSize = new Size(width, height);
            }
            catch (Exception e)
            {
                DemosTools.ShowErrorMessage(e);
                return(false);
            }

            if ((ThumbnailFlowStyle)thumbnailFlowStyleComboBox.SelectedItem == ThumbnailFlowStyle.FixedColumns)
            {
                _viewer.ThumbnailFixedColumnCount = (int)thumbnailColumnsCountComboBox.SelectedIndex + 1;
            }
            _viewer.ThumbnailFlowStyle            = (ThumbnailFlowStyle)thumbnailFlowStyleComboBox.SelectedItem;
            _viewer.ThumbnailScale                = (ThumbnailScale)thumbnailScaleComboBox.SelectedItem;
            _viewer.BackColor                     = thumbnailViewerBackColorPanelControl.Color;
            _viewer.ThumbnailRenderingThreadCount = (int)thumbnailRenderingThreadCountNumericUpDown.Value;

            _viewer.ThumbnailAppearance         = _normalThumbnailAppearance;
            _viewer.FocusedThumbnailAppearance  = _focusedThumbnailAppearance;
            _viewer.HoveredThumbnailAppearance  = _hoveredThumbnailAppearance;
            _viewer.SelectedThumbnailAppearance = _selectedThumbnailAppearance;
            _viewer.NotReadyThumbnailAppearance = _notReadyThumbnailAppearance;

            _viewer.ThumbnailImagePadding = imagePaddingEditorControl.PaddingValue;

            _viewer.ThumbnailCaption.IsVisible     = captionIsVisibleCheckBox.Checked;
            _viewer.ThumbnailCaption.Padding       = captionPaddingFEditorControl.PaddingValue;
            _viewer.ThumbnailCaption.TextColor     = captionTextColorPanelControl.Color;
            _viewer.ThumbnailCaption.CaptionFormat = captionFormatTextBox.Text;
            _viewer.ThumbnailCaption.Anchor        = captionAnchorTypeEditor.SelectedAnchorType;
            _viewer.ThumbnailCaption.Font          = captionFontDialog.Font;

            return(true);
        }
        /// <summary>
        /// Saves annotation collection to a file.
        /// </summary>
        /// <param name="annotationViewer">The annotation viewer.</param>
        /// <param name="saveFileDialog">The save file dialog.</param>
        public static void SaveAnnotationsToFile(AnnotationViewer annotationViewer, SaveFileDialog saveFileDialog)
        {
            // cancel annotation building
            annotationViewer.CancelAnnotationBuilding();

            saveFileDialog.FileName    = null;
            saveFileDialog.Filter      = "Binary Annotations|*.vsab|XMP Annotations|*.xmp|WANG Annotations|*.wng";
            saveFileDialog.FilterIndex = 1;

            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    // open specified file
                    using (FileStream fs = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.ReadWrite))
                    {
                        // get annotation formatter

                        IFormatter formatter = null;
                        if (saveFileDialog.FilterIndex == 1)
                        {
                            formatter = new AnnotationVintasoftBinaryFormatter();
                        }
                        else if (saveFileDialog.FilterIndex == 2)
                        {
                            formatter = new AnnotationVintasoftXmpFormatter();
                        }
                        else if (saveFileDialog.FilterIndex == 3)
                        {
                            if (MessageBox.Show(
                                    "Important: some data from annotations will be lost. Do you want to continue anyway?",
                                    "Warning",
                                    MessageBoxButtons.OKCancel,
                                    MessageBoxIcon.Warning) == DialogResult.Cancel)
                            {
                                return;
                            }

                            formatter = new AnnotationWangFormatter(annotationViewer.Image.Resolution);
                        }

                        // get focused annotation data collection
                        AnnotationDataCollection annotations = annotationViewer.AnnotationDataController[annotationViewer.FocusedIndex];
                        // serialize annotation data to specified stream
                        formatter.Serialize(fs, annotations);
                    }
                }
                catch (Exception ex)
                {
                    DemosTools.ShowErrorMessage(ex);
                }
            }
        }
 /// <summary>
 /// Handles the TextChanged event of ImageSizeComboBox object.
 /// </summary>
 private void imageSizeComboBox_TextChanged(object sender, EventArgs e)
 {
     try
     {
         // update value
         _imageSize = float.Parse(imageSizeComboBox.Text, CultureInfo.InvariantCulture);
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
 /// <summary>
 /// Handles the Click event of ButtonOk object.
 /// </summary>
 private void buttonOk_Click(object sender, EventArgs e)
 {
     try
     {
         // update encoder settings
         SetEncoderSettings();
         DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
示例#24
0
 /// <summary>
 /// Handles the TextChanged event of ImageSizeComboBox object.
 /// </summary>
 private void imageSizeComboBox_TextChanged(object sender, EventArgs e)
 {
     try
     {
         // update requirement image size for selected codec
         _codecNameToImageSizeInMegapixels[(string)codecComboBox.SelectedItem] =
             float.Parse(imageSizeComboBox.Text, CultureInfo.InvariantCulture);
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
     }
 }
示例#25
0
 /// <summary>
 /// TransformController interaction logic.
 /// </summary>
 private void TransformController_Interaction(object sender, InteractionEventArgs e)
 {
     // if interact with move area then
     if (e.Area == TransformController.MoveArea)
     {
         if (TransformController.MoveArea.ActionMouseButton == ActionButton)
         {
             // if action begins then
             if ((e.Action & InteractionAreaAction.Begin) != 0)
             {
                 _needStartBarcodeRecognition = true;
             }
             // if action is mowing
             else if ((e.Action & InteractionAreaAction.Move) != 0)
             {
                 // change cursor to "move" cursor
                 _needStartBarcodeRecognition        = false;
                 TransformController.MoveArea.Cursor = Cursors.SizeAll;
             }
             else if ((e.Action & InteractionAreaAction.End) != 0)
             {
                 if (_needStartBarcodeRecognition)
                 {
                     try
                     {
                         ReadBarcodesAsync();
                     }
                     catch (InvalidOperationException)
                     {
                     }
                     catch (Exception ex)
                     {
                         DemosTools.ShowErrorMessage(ex);
                     }
                     finally
                     {
                         _needStartBarcodeRecognition = false;
                     }
                 }
                 else
                 {
                     TransformController.MoveArea.Cursor = ActionCursor;
                 }
             }
             else if ((e.Action & InteractionAreaAction.Cancel) != 0)
             {
                 TransformController.MoveArea.Cursor = ActionCursor;
             }
         }
     }
 }
 /// <summary>
 /// Handles the Click event of RecognizeBarcodeButton object.
 /// </summary>
 private void recognizeBarcodeButton_Click(object sender, EventArgs e)
 {
     if (!_readerTool.IsRecognitionStarted)
     {
         try
         {
             _readerTool.ReadBarcodesAsync();
         }
         catch (Exception ex)
         {
             DemosTools.ShowErrorMessage(ex);
         }
     }
 }
示例#27
0
        /// <summary>
        /// Starts printing the images.
        /// </summary>
        public void Print()
        {
            try
            {
                _printDialog.PrinterSettings.FromPage = 1;
                _printDialog.PrinterSettings.ToPage   = _imageViewer.Images.Count;

                Print(true, false);
            }
            catch (Exception ex)
            {
                DemosTools.ShowErrorMessage(ex);
            }
        }
        /// <summary>
        /// Handles the Click event of SetInputProfileButton object.
        /// </summary>
        private void setInputProfileButton_Click(object sender, EventArgs e)
        {
            // if input ICC profile is selected
            if (_openIccFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // create ICC profile
                    IccProfile iccProfile = new IccProfile(_openIccFileDialog.FileName);
                    _openIccFileDialog.InitialDirectory = Path.GetDirectoryName(_openIccFileDialog.FileName);
                    IccProfile oldIccProfile = null;

                    switch (iccProfile.DeviceColorSpace)
                    {
                    case ColorSpaceType.CMYK:
                        oldIccProfile = _colorManagementSettings.InputCmykProfile;
                        _colorManagementSettings.InputCmykProfile = iccProfile;
                        ShowProfileDescription(inputCmykTextBox, iccProfile);
                        break;

                    case ColorSpaceType.sRGB:
                        oldIccProfile = _colorManagementSettings.InputRgbProfile;
                        _colorManagementSettings.InputRgbProfile = iccProfile;
                        ShowProfileDescription(inputRgbTextBox, iccProfile);
                        break;

                    case ColorSpaceType.Gray:
                        oldIccProfile = _colorManagementSettings.InputGrayscaleProfile;
                        _colorManagementSettings.InputGrayscaleProfile = iccProfile;
                        ShowProfileDescription(inputGrayscaleTextBox, iccProfile);
                        break;

                    default:
                        iccProfile.Dispose();
                        throw new Exception(string.Format("Unexpected profile color space: {0}.", iccProfile.DeviceColorSpace));
                    }

                    if (oldIccProfile != null)
                    {
                        oldIccProfile.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    DemosTools.ShowErrorMessage(ex);
                }
            }
        }
示例#29
0
 /// <summary>
 /// Handles the Shown event of WebcamVideoForm object.
 /// </summary>
 private void WebcamVideoForm_Shown(object sender, EventArgs e)
 {
     try
     {
         // start the device monitor
         _imageCaptureDeviceMonitor.Start();
         // start the capture source
         _imageCaptureSource.Start();
         // initialize new image capture request
         _imageCaptureSource.CaptureAsync();
     }
     catch (Exception ex)
     {
         DemosTools.ShowErrorMessage(ex);
         Close();
     }
 }
示例#30
0
            /// <summary>
            /// Executes image processing.
            /// </summary>
            public void Execute()
            {
                try
                {
                    // execute image processing command
                    _command.ExecuteInPlace(_image);
                    // previous image will be disposed automatically
                }
                catch (Exception ex)
                {
                    if (ImageProcessingExceptionOccurs != null)
                    {
                        ImageProcessingExceptionOccurs(this, EventArgs.Empty);
                    }

                    DemosTools.ShowErrorMessage("Image processing exception", ex);
                }
            }