예제 #1
0
        protected override void OnVisibleChanged(EventArgs e)
        {
            if (this.Visible)
            {
                if (Program.EntryForm.Laser != null)
                {
                    Program.EntryForm.Laser.Flashing = false;
                    if (Program.EntryForm.LaserType == LaserType.SaturnActive)
                    {
                        var activeLaser = Program.EntryForm.Laser as ActiveLaser;
                        if (activeLaser != null)
                        {
                            activeLaser.ResetCircles();
                        }
                    }
                }
                var laserHoleSize = CtrlFactory.GetCtrlFactory().GetCtrlByType <LaserHoleSize>(CtrlType.LaserHoleSize);
                if (laserHoleSize != null)
                {
                    if (laserHoleSize.CurrentPoint != null)
                    {
                        double y = CalXY(laserHoleSize.CurrentPoint.X);
                        this.sliderCtrl.Slider.Value   = (int)laserHoleSize.CurrentPoint.X * 10;
                        this.sliderCtrl.PulseHole.Text = string.Format("{0:N}us {1:N}um", laserHoleSize.CurrentPoint.X, y);
                        CheckPulse(PulseValue);

                        if (graphicsProperties != null && Program.SysConfig.LaserConfig != null)
                        {
                            Program.SysConfig.LaserConfig.UpdatePulseWidth((float)y);
                        }
                    }
                }
                if (this.Visible)
                {
                    CheckRedLaserStatus();
                }
            }
            else
            {
                if (Program.EntryForm.Laser != null)
                {
                    Program.EntryForm.Laser.Flashing = false;
                    if (Program.EntryForm.LaserType == LaserType.SaturnActive)
                    {
                        var activeLaser = Program.EntryForm.Laser as ActiveLaser;
                        if (activeLaser != null)
                        {
                            activeLaser.ResetCircles();
                        }
                    }
                }
            }
        }
예제 #2
0
 public void CloseSimulator()
 {
     if (this.btnSimulator.Text == CII.LAR.Properties.Resources.StrCloseSimulator)
     {
         if (this.richPictureBox != null)
         {
             updateCmbImage = false;
             this.richPictureBox.Picture = null;
             this.richPictureBox.GraphicsList.DeleteAll();
             CtrlFactory.GetCtrlFactory().GetCtrlByType <StatisticsCtrl>(CtrlType.StatisticsCtrl).StatisticsListView.Items.Clear();
             cmbImage.SelectedIndex = -1;
             updateCmbImage         = true;
         }
         simulatorOpen          = false;
         this.btnSimulator.Text = CII.LAR.Properties.Resources.StrOpenSimulator;
     }
 }
예제 #3
0
 private void btnSimulator_Click(object sender, EventArgs e)
 {
     if (this.btnSimulator.Text == CII.LAR.Properties.Resources.StrOpenSimulator)
     {
         //Turn on simulator
         updateCmbImage = false;
         int fileIndex = 0;
         if (cmbImage.SelectedIndex < 0)
         {
             cmbImage.SelectedIndex = 0;
         }
         else
         {
             fileIndex = cmbImage.SelectedIndex;
         }
         StartSimulator(GetSimulatorFileName(fileIndex));
         updateCmbImage = true;
     }
     else if (this.btnSimulator.Text == CII.LAR.Properties.Resources.StrCloseSimulator)
     {
         //Close simulator
         if (this.richPictureBox != null)
         {
             updateCmbImage = false;
             this.richPictureBox.Picture = null;
             this.richPictureBox.GraphicsList.DeleteAll();
             CtrlFactory.GetCtrlFactory().GetCtrlByType <StatisticsCtrl>(CtrlType.StatisticsCtrl).StatisticsListView.Items.Clear();
             cmbImage.SelectedIndex = -1;
             updateCmbImage         = true;
         }
         if (!string.IsNullOrEmpty(Program.SysConfig.DeviceName))
         {
             FilterInfo fileInfo = Program.SysConfig.EnumerateVideoDevices();
             if (fileInfo != null)
             {
                 DelegateClass.GetDelegate().CaptureDeviceHandler(fileInfo.MonikerString);
             }
         }
         simulatorOpen          = false;
         this.btnSimulator.Text = CII.LAR.Properties.Resources.StrOpenSimulator;
     }
     Program.EntryForm.ClearStatisticsListViewItems();
 }
예제 #4
0
 public static void InitializeCtrlFactory(RichPictureBox richPictureBox)
 {
     ctrlFactory = new CtrlFactory(richPictureBox);
 }
예제 #5
0
 public void LoadDebugCtrl()
 {
     df          = CtrlFactory.GetCtrlFactory().GetCtrlByType <DebugCtrl>(CtrlType.DebugCtrl);
     df.Location = new Point(48, this.Height - df.Height);
     this.Controls.Add(df);
 }
예제 #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                lock (sync)
                {
                    if (PictureBoxPaintedEvent != null)
                    {
                        Rectangle controlClientRect = ClientRectangle;
                        controlClientRect.X -= OffsetX;
                        controlClientRect.Y -= OffsetY;
                        PictureBoxPaintedEvent(controlClientRect, this.ClientRectangle);
                    }

                    if (this.Picture != null)
                    {
                        e.Graphics.ScaleTransform(Zoom, Zoom);
                        e.Graphics.TranslateTransform(OffsetX, OffsetY);
                        //this.ToHighQuality(e.Graphics);
                        this.ToLowQuality(e.Graphics);
                        //ToHighQuality(e.Graphics);
                        e.Graphics.DrawImage(this.Picture, 0, 0, RealSize.Width, RealSize.Height);
                        e.Graphics.ResetTransform();
                    }

                    if (LaserFunction)
                    {
                        if (Program.EntryForm.Laser != null && Program.SysConfig.Function == SystemFunction.Laser)
                        {
                            e.Graphics.ScaleTransform(Zoom, Zoom);
                            e.Graphics.TranslateTransform(OffsetX, OffsetY);
                            Program.EntryForm.Laser.OnPaint(e);
                            e.Graphics.ResetTransform();
                        }
                    }
                    if (GraphicsList != null && Program.SysConfig.Function == SystemFunction.Measure)
                    {
                        GraphicsList.Draw(e.Graphics, this);
                    }
                    if (this.restrictArea != null)
                    {
                        Color drawColor = Color.FromArgb(200, Color.Blue);

                        using (Pen pen = new Pen(drawColor, 2f))
                        {
                            //模拟模式不需要绘制限制区域
                            if (Program.SysConfig.LiveMode)
                            {
                                //激光校准不需要绘制限制区域
                                var laserAlignment = CtrlFactory.GetCtrlFactory().GetCtrlByType <LaserAlignment>(CtrlType.LaserAlignment);
                                if (laserAlignment != null && !laserAlignment.Visible)
                                {
                                    this.restrictArea.TestDrawMotorRectangle(e.Graphics, pen);
                                }
                            }
                        }
                    }
                    if (this.CaptureVideo)
                    {
                        Color drawColor = Color.FromArgb(200, Color.Red);

                        using (Pen pen = new Pen(drawColor, 2f))
                            using (Font font = new Font("宋体", 25f, FontStyle.Bold))
                                using (SolidBrush sb = new SolidBrush(drawColor))
                                {
                                    e.Graphics.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                                    e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                                    Circle circle = new Circle(new PointF(98, 60), new SizeF(40, 40));
                                    //e.Graphics.DrawEllipse(pen, circle.Rectangle);
                                    var size = e.Graphics.MeasureString("REC", font);
                                    e.Graphics.DrawString("REC", font, sb, circle.CenterPoint.X + 30 + 48, 60 - size.Height / 2);
                                    e.Graphics.FillEllipse(sb, circle.Rectangle);
                                    string time  = GetRecordTime();
                                    var    tSize = e.Graphics.MeasureString(time, font);
                                    e.Graphics.DrawString(time, font, sb, new PointF(circle.CenterPoint.X + 30 + size.Width + 48, 60 - tSize.Height / 2));
                                }
                    }
                    if (rulers != null)
                    {
                        rulers.Draw(e.Graphics);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }