示例#1
0
        private void tabControlMain_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.ControlKey)
            {
                LabelManagerObject.CtrlKeyIsPressed = true;
            }
            else if (e.KeyCode == Keys.ShiftKey)
            {
                LabelManagerObject.ShiftKeyIsPressed = true;
            }
            else if (e.KeyCode == Keys.V)
            {
                if (toolStripAddLable.Enabled)
                {
                    toolStripAddLable_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.S)
            {
                if (toolStripMoveLable.Enabled)
                {
                    toolStripMoveLable_Click(null, null);
                }
            }
            else if (e.KeyCode == Keys.H)
            {
                if (toolStripPan.Enabled)
                {
                    toolStripPan_Click(null, null);
                }
            }

            if (LabelManagerObject.SelectedLabels.Count > 0)
            {
                if (e.KeyCode == Keys.Up)
                {
                    LabelManagerObject.MoveSelectedUp();
                }
                else if (e.KeyCode == Keys.Down)
                {
                    LabelManagerObject.MoveSelectedDown();
                }
                else if (e.KeyCode == Keys.Right)
                {
                    LabelManagerObject.MoveSelectedRight();
                }
                else if (e.KeyCode == Keys.Left)
                {
                    LabelManagerObject.MoveSelectedLeft();
                }
            }
        }
示例#2
0
        private void LoadFile(string fileName)
        {
            const string MESSAGE_IMAGE_LOAD_FAILED = "هنگام بارگذاری فایل خطایی رخ داده است، لطفا فایل انتخاب شده را بررسی کنید.";
            const string MESSAGE_FILE_LOADED       = "تصویر بارگذاری شد.";

            Bitmap img         = null;
            bool   imageLoaded = true;

            // Load file
            try {
                DocumentObject.LoadFromFile(fileName);
                img = (Bitmap)DocumentObject.InputImage;
            }
            catch (Exception exp) {
                imageLoaded = false;
                UpdateUI(false, false);
                StaticMethods.ShowErrorMessage(MESSAGE_IMAGE_LOAD_FAILED, exp);
            }

            if (imageLoaded)
            {
                ImageAnalyzerObject.Rest();
                ImageAnalyzerObject.Input           = new Bitmap(img);
                ImageAnalyzerObject.OutputImageZoom = 8;
                LabelManagerObject.DeleteAllLabels(false);

                picInput.Image  = img;
                picOutput.Image = null;

                // Update UI
                UpdateUI(true, false);
                tabControlMain.SelectedIndex = 0;
                lblStatusRight.Text          = MESSAGE_FILE_LOADED;

                // if A ".cpg" file is opened, we should add labels and process it automatically
                if (DocumentObject.IsCpgDocument)
                {
                    ImageAnalyzerObject.OutputImageZoom = DocumentObject.OutputImageZoom;

                    // Start Analyzing
                    menu_Program_StartAnalyze_Click(null, null);

                    // Add Labels
                    LabelManagerObject.AddLabels(DocumentObject.Labels.ToArray());
                }

                //
                UpdateOutputImageMenuUI();
            }
        }
示例#3
0
        private void picOutput_Click(object sender, EventArgs e)
        {
            MouseEventArgs arg = (MouseEventArgs)e;

            if (arg.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (_selectedTool == Tool.AddLabel)
                {
                    // Add a new label
                    string s;
                    Color  labelBackgroundColor;

                    if (_mouseInfo.OriginalPixelLocation.X != -1)
                    {
                        s = _mouseInfo.ColorID.ToString();
                        labelBackgroundColor =
                            ImageAnalyzerObject.Pixels[_mouseInfo.OriginalPixelLocation.X,
                                                       _mouseInfo.OriginalPixelLocation.Y].Color;
                    }
                    else
                    {
                        s = "?";
                        labelBackgroundColor = Color.White;
                    }
                    LabelManagerObject.AddLabel(arg.X, arg.Y, s, labelBackgroundColor);
                }
                else if (_selectedTool == Tool.SelectLabel)
                {
                    toolStripMoveLable_Click(null, null);
                    LabelManagerObject.DeselectAllLabels();
                }
            }
            else
            {
                toolStripMoveLable_Click(null, null);
                LabelManagerObject.DeselectAllLabels();
            }
        }
示例#4
0
        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            const string IMAGE_PROCCESSED_SUCCESSFULLY = "پردازش تصویر با موفقیت به اتمام رسید.";
            const string IMAGE_PROCCESSING_CANCELED    = "عملیات پردازش تصویر لغو شد.";
            const string IMAGE_PROCCESSING_FAILED      = "هنگام پردازش تصویر خطایی رخ داد.";

            if (ImageAnalyzerObject.AnalyzeCanceled)
            {
                // Analyzing input image has canceled
                LabelManagerObject.DeleteAllLabels();
                lblStatusRight.Text = IMAGE_PROCCESSING_CANCELED;
                UpdateUI(true, false);
            }
            else if (ImageAnalyzerObject.AnalyzeException != null)
            {
                // An error has occured while analyzing input image
                UpdateUI(true, false);
                LabelManagerObject.DeleteAllLabels();

                lblStatusRight.Text = IMAGE_PROCCESSING_FAILED;
                StaticMethods.ShowImageProccessingFailedErrorMessage(ImageAnalyzerObject.AnalyzeException);
            }
            else
            {
                // IMAGE PROCCESSED SUCCESSFULLY
                picOutput.Image                = ImageAnalyzerObject.Output;
                lblStatusRight.Text            = IMAGE_PROCCESSED_SUCCESSFULLY;
                tabControlMain.SelectedIndex   = 1;
                toolStripCmbZoom.SelectedIndex = 11;

                UpdateUI(true, true);
            }

            menu_Program_StartAnalyze.Enabled = true;
            menu_Program_Open.Enabled         = true;
            menu_Program_SaveDocument.Enabled = true;
            lnkStopAnalyze.Visible            = false;
        }
示例#5
0
 private void menu_Labeling_EditSelectedLabels_Click(object sender, EventArgs e)
 {
     LabelManagerObject.EditSelectedLabels();
     DocumentObject.IsDocumentChanged = true;
 }
示例#6
0
 private void menu_Labeling_LargerFont_Click(object sender, EventArgs e)
 {
     LabelManagerObject.MakeSelectedLabelsLarger();
     DocumentObject.IsDocumentChanged = true;
 }
示例#7
0
 private void menu_Labeling_SelectAllLabels_Click(object sender, EventArgs e)
 {
     LabelManagerObject.SelectAllLabels();
 }