Example #1
0
        private void toolStripButton_Click(object sender, EventArgs e)
        {
            ToolStripButton tsb = (ToolStripButton)sender;

            if (tsb.Text.Equals(LanguageControl.STR_MENU_OPEN))    //打开文件
            {
                OpenNewImageFile();
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_SAVE_AS))    //另存为
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter   = "位图|*.bmp";
                sfd.FileName = m_fileName;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SaveAsNewImage(sfd.FileName);
                    MessageBox.Show(LanguageControl.MSG_SAVE_SUCCESSFULLY);
                    CloseCurrentImageFile();
                }
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_SAVE_DATA))  //保存数据
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter          = "文本文件|*.txt";
                sfd.OverwritePrompt = false;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SaveDataFile(sfd.FileName);
                }
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_CLOSE)) //关闭
            {
                CloseCurrentImageFile();
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_EXIT))   //退出
            {
                this.Close();
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_MEASURE_DISTANCE))   //测量距离
            {
                this.测量距离ToolStripMenuItem.CheckState = CheckState.Checked;
                this.测量面积ToolStripMenuItem.CheckState = CheckState.Unchecked;
                m_bMeasureDistance = true;
                this.Refresh();
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_MEASURE_AREA))   //测量面积
            {
                this.测量距离ToolStripMenuItem.CheckState = CheckState.Unchecked;
                this.测量面积ToolStripMenuItem.CheckState = CheckState.Checked;
                m_bMeasureDistance = false;
                HistogramForm hf = new HistogramForm(this, mCalcuAera);
                hf.ShowDialog();
                this.Refresh();
            }
            else if (tsb.Text.Equals(LanguageControl.STR_MENU_CALIBRATE))    //标定
            {
                SetScaleForm ssf = new SetScaleForm(this);
                ssf.ShowDialog();
            }
        }
Example #2
0
        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;

            if (tsmi.Text.Equals(LanguageControl.STR_MENU_OPEN))    //打开文件
            {
                OpenNewImageFile();
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_SAVE_AS))    //另存为
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter   = "位图|*.bmp";
                sfd.FileName = m_fileName;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SaveAsNewImage(sfd.FileName);
                    MessageBox.Show(LanguageControl.MSG_SAVE_SUCCESSFULLY);
                    CloseCurrentImageFile();
                }
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_SAVE_DATA))  //保存数据
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter          = "文本文件|*.txt";
                sfd.OverwritePrompt = false;
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    SaveDataFile(sfd.FileName);
                }
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_CLOSE)) //关闭
            {
                CloseCurrentImageFile();
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_EXIT))   //退出
            {
                this.Close();
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_MEASURE_DISTANCE))   //测量距离
            {
                this.测量距离ToolStripMenuItem.CheckState = CheckState.Checked;
                this.测量面积ToolStripMenuItem.CheckState = CheckState.Unchecked;
                m_bMeasureDistance = true;
                this.Refresh();
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_MEASURE_AREA))   //测量面积
            {
                this.测量距离ToolStripMenuItem.CheckState = CheckState.Unchecked;
                this.测量面积ToolStripMenuItem.CheckState = CheckState.Checked;
                m_bMeasureDistance = false;
                HistogramForm hf = new HistogramForm(this, mCalcuAera);
                hf.ShowDialog();
                this.Refresh();
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_CALIBRATE))    //标定
            {
                SetScaleForm ssf = new SetScaleForm(this);
                ssf.ShowDialog();
            }
            else if (tsmi.Text.Equals("中文"))
            {
                LanguageControl.m_bChinese = true;
                SetLanguage();
                CallCalcuAeras();
                this.中文ToolStripMenuItem.CheckState      = CheckState.Checked;
                this.englishToolStripMenuItem.CheckState = CheckState.Unchecked;
                if (CalcuAeras.PIX_DIS_RATIO < 0)
                {
                    this.toolStrip_StatusLabel.Text = LanguageControl.MSG_STATUS_LABEL;
                }
                else
                {
                    this.toolStrip_StatusLabel.Text = LanguageControl.MSG_STATUS_LABEL2 + CalcuAeras.PIX_DIS_RATIO.ToString("f2");
                }
            }
            else if (tsmi.Text.Equals("Français"))       //English
            {
                LanguageControl.m_bChinese = false;
                SetLanguage();
                CallCalcuAeras();
                this.中文ToolStripMenuItem.CheckState      = CheckState.Unchecked;
                this.englishToolStripMenuItem.CheckState = CheckState.Checked;
                if (CalcuAeras.PIX_DIS_RATIO < 0)
                {
                    this.toolStrip_StatusLabel.Text = LanguageControl.MSG_STATUS_LABEL;
                }
                else
                {
                    this.toolStrip_StatusLabel.Text = LanguageControl.MSG_STATUS_LABEL2 + CalcuAeras.PIX_DIS_RATIO.ToString("f2");
                }
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_ABOUT))
            {
                AboutForm af = new AboutForm();
                af.ShowDialog();
            }
            else if (tsmi.Text.Equals(LanguageControl.STR_MENU_PRINT_IMAGE))
            {
                if (this.pictureBox.Image == null)
                {
                    return;
                }
                this.printDocument.PrintPage += new PrintPageEventHandler(PrintPage);
                //初始化要显示的设置窗口
                PageSetupDialog objPageSetupDialog = new PageSetupDialog();
                objPageSetupDialog.Document = this.printDocument;       //获取文档
                if (objPageSetupDialog.ShowDialog() == DialogResult.OK)
                {
                    //初始化要预览窗口
                    PrintPreviewDialog objPrintPreviewDialog = new PrintPreviewDialog();
                    objPrintPreviewDialog.Document = this.printDocument;  //获取要预览的文档
                    if (objPrintPreviewDialog.ShowDialog() == DialogResult.OK)
                    {
                        objPrintPreviewDialog.ShowDialog();
                    }
                }
                this.printDocument.PrintPage -= new PrintPageEventHandler(PrintPage);
                CloseCurrentImageFile();
            }
        }