static PKL_Interface() { if (!CHECK_XISL_DLL) { if (CapturePub.readCaptrueValue(XmlField.PanelInterface, false) == "0") { string XislFilePath = CapturePub.LinkFilePath + "\\xisl\\XISL(3.2.0.14).dll"; string newXislFilePath = System.Windows.Forms.Application.StartupPath.ToString() + "\\xisl.dll"; if (System.IO.File.Exists(XislFilePath)) { File.Copy(XislFilePath, newXislFilePath, true); CapturePub.saveCaptrueValue(XmlField.NeedCheckPanelInterface, "F"); CapturePub.saveCaptrueValue(XmlField.PanelInterface, "0"); } } else { string XislFilePath = CapturePub.LinkFilePath + "\\xisl\\XISL(3.3.3.32).dll"; string newXislFilePath = System.Windows.Forms.Application.StartupPath.ToString() + "\\xisl.dll"; if (File.Exists(XislFilePath)) { File.Copy(XislFilePath, newXislFilePath, true); CapturePub.saveCaptrueValue(XmlField.NeedCheckPanelInterface, "F"); CapturePub.saveCaptrueValue(XmlField.PanelInterface, "1"); } } CHECK_XISL_DLL = true; } }
protected void btnOK_Click(object sender, EventArgs e) { //Capture Parameter if (comboBoxWorkMode.SelectedIndex == 0) { CapturePub.saveCaptrueValue(XmlField.KZCheckMode, ((int)CareRayInterface.CheckMode.MODE_RAD).ToString()); } else if (comboBoxWorkMode.SelectedIndex == 1) { CapturePub.saveCaptrueValue(XmlField.KZCheckMode, ((int)CareRayInterface.CheckMode.MODE_FLUORO_START + 2).ToString()); } else if (comboBoxWorkMode.SelectedIndex == 2) { CapturePub.saveCaptrueValue(XmlField.KZCheckMode, ((int)CareRayInterface.CheckMode.MODE_RAD).ToString()); } CapturePub.saveCaptrueValue(XmlField.CareRay_ExposureTime, this.textBoxExposureTime.Text); CapturePub.saveCaptrueValue(XmlField.CareRay_ExposureDelay, this.textBoxDelayTime.Text); CapturePub.saveCaptrueValue(XmlField.CareRay_ExposureWait, this.textBoxWaitTime.Text); string config_file = CapturePub.CareRayPath + "Config.ini"; CareRayInterface.SaveConfigOptionValue(config_file, "ipAddress", textBoxPanelIP.Text.Trim()); this.DialogResult = DialogResult.OK; }
void ReadCOMConfig() { if (!int.TryParse(CapturePub.readCaptrueValue("ComBufferSize"), out ComBufferSize)) { ComBufferSize = 2048; } if (!int.TryParse(CapturePub.readCaptrueValue("MaxReplyCount"), out MaxReplyCount)) { MaxReplyCount = 3; } if (!int.TryParse(CapturePub.readCaptrueValue("ComPortWriteTimeOut"), out ComPortWriteTimeOut)) { ComPortWriteTimeOut = 1000; } if (!int.TryParse(CapturePub.readCaptrueValue("ComPortReadTimeOut"), out ComPortReadTimeOut)) { ComPortReadTimeOut = 2000; } if (!int.TryParse(CapturePub.readCaptrueValue("ComErrorSleepTime"), out ComErrorSleepTime)) { ComErrorSleepTime = 500; } COMName = CapturePub.readCaptrueValue("ComName"); ByteBuf = new byte[ComBufferSize]; ByteBuf2 = new byte[ComBufferSize]; }
public static CaptureBase GetCapture() { string linkPanelStr = CapturePub.readCaptrueValue(XmlField.LinkPanel, false); bool linkPanel = linkPanelStr.ToUpper() != "F"; CaptureBase capture = null; if (linkPanel) { //string panelBrandName = CapturePub.readCaptrueValue(XmlField.PanelBrandName, false); //if (panelBrandName.ToUpper() == "CareRay".ToUpper()) //{ // capture = new CaptureCareRay(); //} //else //{ capture = new Capture1800I_096(); //} } else { //capture = new CaptureSim(); //capture.InitParam(); } return(capture); }
public FormCaptureSetupHight(CaptureBase capture, TriggerBase trigger) { InitializeComponent(); this.userControlMutiDicomImages.SignImg = TIcon.Change4dDisplay; TCursor.LoadAllCursors(System.Windows.Forms.Application.StartupPath); ImgCapture = capture; Trigger = trigger; ImgCapture.RefreshHostHandle(this.Handle); this.Shown -= new EventHandler(FormCapture_Shown); this.Shown += new EventHandler(FormCapture_Shown); bool showBeamButton = CapturePub.readCaptrueValue("ShowBeamButton", false) == "T"; bool showCaptureButton = CapturePub.readCaptrueValue("HaveImagePanel") == "T"; showCaptureButton = showCaptureButton || (CapturePub.readCaptrueValue("SimImagePanel") == "T"); //btnCapture.Visible = showCaptureButton; //btnOverlay.Visible = showCaptureButton; GraphicButton.ShowButtonToolTip -= new GraphicButton.ShowButtonTooltip(GraphicButton_ShowButtonToolTip); GraphicButton.ShowButtonToolTip += new GraphicButton.ShowButtonTooltip(GraphicButton_ShowButtonToolTip); GraphicButton.LeaveButton -= new GraphicButton.ShowButtonTooltip(GraphicButton_LeaveButton); GraphicButton.LeaveButton += new GraphicButton.ShowButtonTooltip(GraphicButton_LeaveButton); userControlMutiDicomImages.MayCancelSelect = true; }
/// <summary> /// 向WLModel表中添加或更新行 /// </summary> /// <param name="w"></param> public static void Update_WLModelRow(ImageWindow w) { DataSet ds = GetDataTable_WLModel(); DataTable table = ds.Tables[0]; DataRow[] drs = table.Select("[Window Name] = '" + w.Name + "' and [Image Type] = '" + w.ImageType + "'"); DataRow dr; if (drs != null && drs.Length > 0) { dr = drs[0]; dr["Window Center"] = w.Center; dr["Window Width"] = w.Width; dr["Image Type"] = w.ImageType; } else { dr = table.NewRow(); dr["Window Name"] = w.Name; dr["Window Center"] = w.Center; dr["Window Width"] = w.Width; dr["Image Type"] = w.ImageType; table.Rows.Add(dr); } CapturePub.WriteData(ds, fileWLModel); ds.Dispose(); }
private void CaptureParameterSetting_Load(object sender, EventArgs e) { //Capture Parameter string xmlValueString; xmlValueString = CapturePub.readCaptrueValue(XmlField.KZCheckMode); if (xmlValueString == ((int)CareRayInterface.CheckMode.MODE_RAD).ToString()) { comboBoxWorkMode.SelectedIndex = 0; } else if (xmlValueString == ((int)CareRayInterface.CheckMode.MODE_FLUORO_START + 2).ToString()) { comboBoxWorkMode.SelectedIndex = 1; } else if (xmlValueString == ((int)CareRayInterface.CheckMode.MODE_FLUORO_START).ToString()) { comboBoxWorkMode.SelectedIndex = 2; } this.textBoxExposureTime.Text = CapturePub.readCaptrueValue(XmlField.CareRay_ExposureTime); this.textBoxDelayTime.Text = CapturePub.readCaptrueValue(XmlField.CareRay_ExposureDelay); this.textBoxWaitTime.Text = CapturePub.readCaptrueValue(XmlField.CareRay_ExposureWait); string config_file = CapturePub.CareRayPath + "Config.ini"; string PanelIP = CareRayInterface.ReadConfigOptionValue(config_file, "ipAddress"); this.textBoxPanelIP.Text = PanelIP; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void userControlMutiDicomImages_ImageNumChanged(object Sender, EventArgs e) { if (captureImagesNow.Count <= 0) { return; } pixelMapData = null; int index = userControlMutiDicomImages.SelectedIndex; imgROI = captureImagesNow[index]; pixelMapData = new ushort[imgROI.ImageData.GetLength(0), imgROI.ImageData.GetLength(1)]; int Average = 0; long SumValue = 0; string xmlValue = CapturePub.readCaptrueValue("UNIT"); string unit = (xmlValue == "" ? "4" : xmlValue); int unitlength = int.Parse(unit); xmlValue = CapturePub.readCaptrueValue("Coefficient"); string coefficient = (xmlValue == "" ? "0.9" : xmlValue); float percentage = float.Parse(coefficient); for (int i = 0; i < imgROI.ImageData.GetLength(0) / unitlength; i++) { for (int j = 0; j < imgROI.ImageData.GetLength(1) / unitlength; j++) { Average = 0; SumValue = 0; for (int ii = 0; ii < unitlength; ii++) { for (int jj = 0; jj < unitlength; jj++) { SumValue += imgROI.ImageData[i * unitlength + ii, j *unitlength + jj]; } } Average = (int)(((double)SumValue / (unitlength * unitlength)) * percentage); for (int ii = 0; ii < unitlength; ii++) { for (int jj = 0; jj < unitlength; jj++) { if (imgROI.ImageData[i * unitlength + ii, j *unitlength + jj] >= Average) { pixelMapData[i * unitlength + ii, j *unitlength + jj] = 0; } else { pixelMapData[i * unitlength + ii, j *unitlength + jj] = 65535; } } } } } his.ComputeHistogram(imgROI.ImageData); imgROI.GenerateBMP(his.LUT); imgShow.InitImageData(imgROI, his, pixelMapData); labelMedianValue.Text = "Ave:" + (int)his.AverageValue; labelWL.Text = "L=" + his.windowCenter + ",W=" + his.windowWidth; }
protected override void gbtOK_Click(object sender, EventArgs e) { string name = txtBeamName.Text.Trim(); if (name == "") { MessageBox.Show("The name should not be null !"); txtBeamName.Focus(); return; } else { if (name != oldBeamName && CheckFieldNameExisted(name)) { MessageBox.Show("The beam name has existed, input a new one please!"); txtBeamName.Focus(); return; } } float gantry = 0; if (!float.TryParse(txtAquireGantry.Text, out gantry))//2010/08/10 wzf add temp for prtected { MessageBox.Show("Gantry angle should be number!"); txtAquireGantry.Focus(); return; } float sad = 0; if (!float.TryParse(CapturePub.readCaptrueValue("Sad"), out sad)) { sad = 0; } if (BeamInfo.ID < 0)//add { BeamInfo.TreatmentDeliveryType = "PORTAL"; BeamInfo.name = name; BeamInfo.gantry_angle = gantry; BeamInfo.Note = txtnote.Text; BeamInfo.SAD = sad; BeamInfo.ISOCenterX = float.MinValue; BeamInfo.ISOCenterY = float.MinValue; BeamInfo.ISOCenterZ = float.MinValue; BeamInfo.PitchAngle = 0; BeamInfo.RollAngle = 0; BeamInfo.RotateAngle = 0; } else//Edit { BeamInfo.name = name; BeamInfo.gantry_angle = gantry; BeamInfo.Note = txtnote.Text; } base.gbtOK_Click(sender, e); }
protected override void gbtOK_Click(object sender, EventArgs e) { //CapturePub.saveCaptrueValue(XmlField.OffsetFile, textBoxOffsetFile.Tag.ToString() + "\\" + textBoxOffsetFile.Text); //CapturePub.saveCaptrueValue(XmlField.GainFile, textBoxGainFile.Tag.ToString() + "\\" + textBoxGainFile.Text); CapturePub.saveCaptrueValue(XmlField.GainSeqFile_Image, textBoxGainSeqFile_Image.Tag.ToString() + "\\" + textBoxGainSeqFile_Image.Text); //CapturePub.saveCaptrueValue(XmlField.GainSeqFile_Dose, textBoxGainSeqFile_Dose.Tag.ToString() + "\\" + textBoxGainSeqFile_Dose.Text); CapturePub.saveCaptrueValue(XmlField.PixelMapFile, textBoxPixelMapFile.Tag.ToString() + "\\" + textBoxPixelMapFile.Text); //2011.12.22 //CapturePub.saveCaptrueValue(XmlField.MachineQAMachineData, txtMachineDataFile.Tag.ToString() + "\\" + txtMachineDataFile.Text);// base.gbtOK_Click(sender, e); }
public static DataSet GetClaheModel() { DataSet ds = CapturePub.GetData(fileClaheModel); if (ds.Tables.Count < 1) { ds.Tables.Add(GenerateTable_ClaheModel()); } return(ds); }
private void FormCapture_Shown(object sender, EventArgs e) { //先显示出默认界面内容 SetContextMenuStrip(); userControlMutiDicomImages.DrawImagesInPane(new List <Bitmap>(), false); pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(pictureBox1.Image); g.Clear(Color.Black); g.Dispose(); histogramControl1.SetCenterWindow(0, 0); histogramControl1.RefreshHistogram(null); //Setup Parameter string xmlValue = CapturePub.readCaptrueValue("SetupAngle"); int idx = cbAngle.Items.IndexOf(xmlValue); if (idx < 0) { idx = 0; } cbAngle.SelectedIndex = idx; xmlValue = CapturePub.readCaptrueValue("SetupHeight"); textBoxSetupHeight.Text = (xmlValue == "" ? "1600" : xmlValue); xmlValue = CapturePub.readCaptrueValue("SAD"); textBoxSAD.Text = (xmlValue == "" ? "1000" : xmlValue); xmlValue = CapturePub.readCaptrueValue("PhysicsWidth"); textBoxPhysicsWidth.Text = (xmlValue == "" ? "410" : xmlValue); xmlValue = CapturePub.readCaptrueValue("PhysicsHeight"); textBoxPhysicsHeight.Text = (xmlValue == "" ? "410" : xmlValue); xmlValue = CapturePub.readCaptrueValue("ImageCenterX"); textBoxImageCenterX.Text = (xmlValue == "" ? "0" : xmlValue); xmlValue = CapturePub.readCaptrueValue("ImageCenterY"); textBoxImageCenterY.Text = (xmlValue == "" ? "0" : xmlValue); Refresh(); Show(); //刷新数据在界面显示 userControlMutiDicomImages.ImageNumChanged -= new UserControlMutiImages.EventChanged(userControlMutiDicomImages_ImageNumChanged); userControlMutiDicomImages.ImageNumChanged += new UserControlMutiImages.EventChanged(userControlMutiDicomImages_ImageNumChanged); //userControlMutiDicomImages.ImageNumChanged -= new UserControlMutiImages.EventChanged(userControlMutiDicomImages_ImageNumChanged); //userControlMutiDicomImages.ImageNumChanged += new UserControlMutiImages.EventChanged(userControlMutiDicomImages_ImageNumChanged); histogramControl1.LUTChanged -= new HistogramControl.LUTChangedDelegate(cImage_LUTChanged); histogramControl1.LUTChanged += new HistogramControl.LUTChangedDelegate(cImage_LUTChanged); histogramControl1.EventLutMouseUp -= new HistogramControl.LUTChangedDelegate(cImage_LutMouseUp); histogramControl1.EventLutMouseUp += new HistogramControl.LUTChangedDelegate(cImage_LutMouseUp); this.KeyUp -= new KeyEventHandler(FormCapture_KeyUp); this.KeyUp += new KeyEventHandler(FormCapture_KeyUp); //tabControlCalibration_Selected(null,null); Refresh(); ImgCapture.Ready(); }
public ComPort(string com) { if (!int.TryParse(CapturePub.readCaptrueValue("ComBufferSize"), out ComBufferSize)) { ComBufferSize = 2048; } if (!int.TryParse(CapturePub.readCaptrueValue("MaxReplyCount"), out MaxReplyCount)) { MaxReplyCount = 3; } if (!int.TryParse(CapturePub.readCaptrueValue("ComPortWriteTimeOut"), out ComPortWriteTimeOut)) { ComPortWriteTimeOut = 1000; } if (!int.TryParse(CapturePub.readCaptrueValue("ComPortReadTimeOut"), out ComPortReadTimeOut)) { ComPortReadTimeOut = 2000; } if (!int.TryParse(CapturePub.readCaptrueValue("ComErrorSleepTime"), out ComErrorSleepTime)) { ComErrorSleepTime = 500; } ByteBuf = new byte[ComBufferSize]; ByteBuf2 = new byte[ComBufferSize]; //创建接收线程 ThreadStart threadDelegate = new ThreadStart(Receive); ReceiveThread = new Thread(threadDelegate); //打开串口 try { PortPtr = new SerialPort(com, BaudRate); PortPtr.ReadBufferSize = ComBufferSize; PortPtr.WriteBufferSize = ComBufferSize; PortPtr.WriteTimeout = ComPortWriteTimeOut; PortPtr.ReadTimeout = ComPortReadTimeOut; PortPtr.DataReceived += new SerialDataReceivedEventHandler(Receive); PortPtr.ErrorReceived += new SerialErrorReceivedEventHandler(ErrorReceive); PortPtr.PinChanged += new SerialPinChangedEventHandler(PinChange); Open(com); } catch (Exception ex) { Database.LogDB.SaveTxtLog(ex.ToString()); } }
public FormGainSeqCapture(CaptureBase capture) { InitializeComponent(); this.userControlMutiDicomImages.SignImg = TIcon.Change4dDisplay; imgShow.Dock = DockStyle.Fill; this.panelMain.Controls.Add(imgShow); try { string s = CapturePub.readCaptrueValue("FORM_SIZE", false); if (s != "") { string[] s_ = s.Split(','); this.Size = new Size(int.Parse(s_[0]), int.Parse(s_[1])); } } catch { } ImgCapture = capture; Trigger = capture.GetTrigger(); ImgCapture.RefreshHostHandle(this.Handle); int size = pictureBox1.Size.Height; linkImage = new Bitmap(size, size); grayImage = new Bitmap(size, size); Graphics g = Graphics.FromImage(linkImage); int radis = (int)((size - 2) / 2.0F); g.DrawEllipse(Pens.LightSteelBlue, new Rectangle(size / 2 - radis, size / 2 - radis, radis * 2, radis * 2)); g.FillEllipse(Brushes.Green, new Rectangle(size / 2 - radis, size / 2 - radis, radis * 2, radis * 2)); g = Graphics.FromImage(grayImage); //g.Clear(Color.Black); g.DrawEllipse(Pens.LightSteelBlue, new Rectangle(size / 2 - radis, size / 2 - radis, radis * 2, radis * 2)); g.FillEllipse(Brushes.Gray, new Rectangle(size / 2 - radis, size / 2 - radis, radis * 2, radis * 2)); timerStatus.Interval = 500; timerStatus.Elapsed -= new System.Timers.ElapsedEventHandler(timerStatus_Elapsed); timerStatus.Elapsed += new System.Timers.ElapsedEventHandler(timerStatus_Elapsed); timerStatus.Start(); this.Shown -= new EventHandler(FormCapture_Shown); this.Shown += new EventHandler(FormCapture_Shown); GraphicButton.ShowButtonToolTip -= new GraphicButton.ShowButtonTooltip(GraphicButton_ShowButtonToolTip); GraphicButton.ShowButtonToolTip += new GraphicButton.ShowButtonTooltip(GraphicButton_ShowButtonToolTip); GraphicButton.LeaveButton -= new GraphicButton.ShowButtonTooltip(GraphicButton_LeaveButton); GraphicButton.LeaveButton += new GraphicButton.ShowButtonTooltip(GraphicButton_LeaveButton); userControlMutiDicomImages.MayCancelSelect = true; }
public Capture1800I_096Dynamic() : base() { //是否后台监测Panel网络连接 MonitorPanelNetwork_Background = CapturePub.readCaptrueValue(XmlField.MonitorPanelNetwork_Background) == "T"; //读取Panel IP地址 string config_file = CapturePub.CareRayPath + "Config.ini"; PanelIP = CareRayInterface.ReadConfigOptionValue(config_file, "ipAddress"); LinkPanelThread = new Thread(LinkPanelThreadFun); LinkPanelThread.IsBackground = true; EventCallbak = new CareRayInterface.EventCallbackDelegate(drocEventCallback); }
public virtual void InitParam() { if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.TriggerDelayTime), out ResponseDelayTime)) { ResponseDelayTime = 0; } PortName = CapturePub.readCaptrueValue(XmlField.TriggerPort); if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.SignalInterval), out SignalInterval)) { SignalInterval = 2; } if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.SignalTimeout), out SignalHZ)) { SignalHZ = 50; } }
protected void ReadSetupConfig() { if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.CaptureFrameCount), out SeqFrameCount)) { SeqFrameCount = 1; } SeqFrameCount = 1; if (!int.TryParse(CapturePub.readCaptrueValue("SetupAngle"), out SetupAngle)) { SetupAngle = 0; } float sad, sid, phyW, phyH, offsetX, offsetY; if (!float.TryParse(CapturePub.readCaptrueValue("Sad"), out sad)) { sad = 1000;//mm } if (!float.TryParse(CapturePub.readCaptrueValue("SetupHeight"), out sid)) { sid = 1600;//mm } if (!float.TryParse(CapturePub.readCaptrueValue("PhysicsWidth"), out phyW)) { phyW = 410;//mm } if (!float.TryParse(CapturePub.readCaptrueValue("PhysicsHeight"), out phyH)) { phyH = 410;//mm } if (!float.TryParse(CapturePub.readCaptrueValue("OffsetPanelCenterX"), out offsetX)) { offsetX = 0; } if (!float.TryParse(CapturePub.readCaptrueValue("OffsetPanelCenterY"), out offsetY)) { offsetY = 0; } SAD = sad; SID = sid; phySize = phyW; phyCenterX = phyW / 2.0f + offsetX; phyCenterY = phyH / 2.0f + offsetY; }
protected override void gbtOK_Click(object sender, EventArgs e) { if (combPort.SelectedIndex < 0 || combPort.SelectedItem.ToString() == "") { cls_MessageBox.Show("Please check Trigger Port !"); return; } //Trigger Parameter CapturePub.saveCaptrueValue(XmlField.TriggerPort, combPort.Text.Trim()); CapturePub.saveCaptrueValue(XmlField.TriggerDelayTime, textBoxSleep.Text); CapturePub.saveCaptrueValue(XmlField.SignalSourceID, (cbBBeamSource.SelectedIndex + 1).ToString()); CapturePub.saveCaptrueValue(XmlField.SignalTimeout, tbHZ.Text.Trim()); CapturePub.saveCaptrueValue(XmlField.SignalInterval, tbBeamInterval.Text.Trim()); CapturePub.saveCaptrueValue(XmlField.SignalFeedInterval, tbComFeedInterval.Text.Trim()); base.gbtOK_Click(sender, e); }
//private void ModifyLabel_MouseEnter(object sender, EventArgs e) //{ // TextBox Temp = sender as TextBox; // if (Temp.ReadOnly && Temp.BorderStyle != BorderStyle.FixedSingle) // { // Temp.BorderStyle = BorderStyle.FixedSingle; // } //} //private void ModifyLabel_MouseLeave(object sender, EventArgs e) //{ // TextBox Temp = sender as TextBox; // if (Temp.ReadOnly) // { // Temp.BorderStyle = BorderStyle.None; // } //} //private void ModifyLabel_MouseDown(object sender, MouseEventArgs e) //{ // TextBox Temp = sender as TextBox; // if (Temp.ReadOnly && Temp.Focused && e.Button == MouseButtons.Left) // { // string s = Temp.Text; // Temp.BorderStyle = BorderStyle.Fixed3D; // Temp.BackColor = Color.White; // Temp.ReadOnly = false; // Temp.Text = s; // } //} private void ModifyLabel_Validating(object sender, EventArgs e) { TextBox Temp = sender as TextBox; if (!Temp.ReadOnly) { if (Temp.Name == textBoxSAD.Name) { if (Temp.Text.Trim() == "") { Temp.Text = CapturePub.readCaptrueValue("SAD", false); } else { CapturePub.saveCaptrueValue("SAD", textBoxSAD.Text.Trim()); } } else if (Temp.Name == textBoxPhysicsWidth.Name) { if (Temp.Text.Trim() == "") { Temp.Text = CapturePub.readCaptrueValue("PhysicsWidth", false); } else { CapturePub.saveCaptrueValue("PhysicsWidth", textBoxPhysicsWidth.Text.Trim()); } } else if (Temp.Name == textBoxPhysicsHeight.Name) { if (Temp.Text.Trim() == "") { Temp.Text = CapturePub.readCaptrueValue("PhysicsHeight", false); } else { CapturePub.saveCaptrueValue("PhysicsHeight", textBoxPhysicsHeight.Text.Trim()); } } } //Temp.BorderStyle = BorderStyle.None; //Temp.BackColor = Color.LightSteelBlue; //Temp.ReadOnly = true; }
public CaptureSim() : base() { imageRows = 1024; imageColumns = 1024; timerGenerateImage.Interval = 1000; timerGenerateImage.Elapsed -= new ElapsedEventHandler(timerGenerateImage_Elapsed); timerGenerateImage.Elapsed += new ElapsedEventHandler(timerGenerateImage_Elapsed); int mode; if (int.TryParse(CapturePub.readCaptrueValue(XmlField.CaptureMode, false), out mode)) { captureImageMode = (CapturePKI.PanelCaptureMode)mode; } else { captureImageMode = CapturePKI.PanelCaptureMode.Sequence; } }
private void CaptureParameterSetting_Load(object sender, EventArgs e) { //Trigger Parameter string[] ports = System.IO.Ports.SerialPort.GetPortNames();//获取机器的COM口信息 List <string> portlist = new List <string>(); portlist.Add("NONE"); for (int i = 0; i < ports.Length; ++i) { if (!portlist.Contains(ports[i])) { portlist.Add(ports[i]); } } combPort.Items.AddRange(portlist.ToArray()); string xmlValue = CapturePub.readCaptrueValue(XmlField.TriggerPort).Trim(); if (xmlValue != "") { combPort.Text = xmlValue; } xmlValue = CapturePub.readCaptrueValue(XmlField.TriggerDelayTime); textBoxSleep.Text = (xmlValue == "" ? "5000" : xmlValue); xmlValue = CapturePub.readCaptrueValue(XmlField.SignalSourceID); if (xmlValue == "" || xmlValue == null) { cbBBeamSource.SelectedIndex = 0; } else { cbBBeamSource.Text = "CH" + xmlValue; } //this.cbBBeamSource.Text = (xmlValue == "" ? "1" : xmlValue); xmlValue = CapturePub.readCaptrueValue(XmlField.SignalTimeout); this.tbHZ.Text = (xmlValue == "" ? "0" : xmlValue); xmlValue = CapturePub.readCaptrueValue(XmlField.SignalInterval);//BeamOn信号认为消失的时间间隔 this.tbBeamInterval.Text = (xmlValue == "" ? "20" : xmlValue); xmlValue = CapturePub.readCaptrueValue(XmlField.SignalFeedInterval); this.tbComFeedInterval.Text = (xmlValue == "" ? "100" : xmlValue); combPort.Focus(); }
public override void CaptureImageData() { base.CaptureImageData(); OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "*.*|*.*"; string lastFilePath = CapturePub.readCaptrueValue(XmlField.OpenFilePath); if (Directory.Exists(lastFilePath)) { dlg.InitialDirectory = lastFilePath; } dlg.Multiselect = true; string[] files = null; if (dlg.ShowDialog() == DialogResult.OK) { files = dlg.FileNames; SeqFrameCount = files.Length; } if (files != null && files.Length > 0) { FileInfo fi = new FileInfo(files[0]); CapturePub.saveCaptrueValue(XmlField.OpenFilePath, fi.DirectoryName); int msgID = GenerateWinMessage("Loading files..."); Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, msgID, SeqFrameCount); for (int i = 0; i < SeqFrameCount; i++) { ReadFile(files[i]); Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, -1, 1); } Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, -2, 0); //Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_CAPTURE_DATA, (int)CapturePKI.PanelCaptureMode.Sequence,0); } else { files = null; } Files = files; }
public void DrawGraph(Graphics gp, Matrix transform) { if (img != null) { this.Transform = transform; Rectangle tempRect = new Rectangle(); tempRect = img.ROIRectangle; Point[] temp = new Point[] { tempRect.Location }; transform.TransformPoints(temp); tempRect.Location = temp[0]; tempRect.Width = (int)(tempRect.Width * transform.Elements[0]); tempRect.Height = (int)(tempRect.Height * transform.Elements[0]); Pen rectPen = new Pen(Color.Red, 1); rectPen.DashStyle = DashStyle.Dash; gp.DrawRectangle(rectPen, tempRect); Pen errorPen = new Pen(Color.Blue, 2); if (img.noisePoint != null) { if (img.noisePoint.Count != 0) { try { string flag = CapturePub.readCaptrueValue("ShowDiffPoint"); if (flag == "T") { for (int i = 0; i < img.noisePoint.Count; i++) { Point[] tempDraw = new Point[] { img.noisePoint[i] }; Transform.TransformPoints(tempDraw); gp.DrawEllipse(errorPen, tempDraw[0].X, tempDraw[0].Y, 2, 2); } } } catch { CapturePub.saveCaptrueValue("ShowDiffPoint", "F"); } } } } }
/// <summary> /// 从本地文件读取采集配置参数 /// </summary> public override void ReadCaptureConfig() { //1,工作模式; checkMode = CareRayInterface.CheckMode.MODE_FLUORO_START + 2; //2,采集同步模式; TriggerSyncMode = CareRayInterface.SyncMode.EXT_TRIGGER; //3,采集曝光时间,单位ms; if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.CareRay_ExposureTime), out ExposureTime)) { ExposureTime = 333; CapturePub.saveCaptrueValue(XmlField.CareRay_ExposureTime, ExposureTime.ToString()); } //4,采集延迟时间,单位ms; if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.CareRay_ExposureDelay), out DelayTime)) { DelayTime = 1; CapturePub.saveCaptrueValue(XmlField.CareRay_ExposureDelay, DelayTime.ToString()); } //5,采集等待时间,单位ms; if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.CareRay_ExposureWait), out WaitTime)) { WaitTime = 1; CapturePub.saveCaptrueValue(XmlField.CareRay_ExposureWait, WaitTime.ToString()); } //6,是否启用Gain校正算法 Enable1800IGainAlgorithm = CapturePub.readCaptrueValue(XmlField.Enable1800IGainAlgorithm) == "T"; //7,Sequence采集的帧数 if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.CaptureFrameCount), out SeqFrameCount)) { SeqFrameCount = 1; CapturePub.saveCaptrueValue(XmlField.CaptureFrameCount, SeqFrameCount.ToString()); } //8,Gain值 if (!int.TryParse(CapturePub.readCaptrueValue(XmlField.CareRay_GainValue), out GainValue)) { GainValue = 1; CapturePub.saveCaptrueValue(XmlField.CareRay_GainValue, GainValue.ToString()); } }
private void btnCreatePixelMap_Click(object sender, EventArgs e) { if (pixelMapData == null) { cls_MessageBox.Show("No pixel map data."); return; } if (!Directory.Exists(CapturePub.SaveDFPath + "\\pixelmap")) { Directory.CreateDirectory(CapturePub.SaveDFPath + "\\pixelmap"); } if (!Directory.Exists(CapturePub.SaveDFPath + "\\offset")) { Directory.CreateDirectory(CapturePub.SaveDFPath + "\\offset"); } List <ushort[, ]> dataList = new List <ushort[, ]>(); dataList.Add(pixelMapData); string pxlmapFile = "pxlmap_" + DateTime.Now.ToString("yyyy.MM.dd.HHmmss") + "_" + getGainString((CapturePKI.ElectricCapacityMode)comboBoxGainMode_Image.SelectedIndex) + "_" + dataList[0].GetLength(0) + "x" + dataList[0].GetLength(1) + ".his"; string pxl_fullPath = CapturePub.SaveDFPath + "\\pixelmap\\" + pxlmapFile; SaveasHisFile(pxl_fullPath, dataList, 1000); CapturePub.saveCaptrueValue(XmlField.PixelMapFile, pxl_fullPath); if (ImgCapture is CapturePKI) { (ImgCapture as CapturePKI).SetLinkCorrection(); } cls_MessageBox.Show("Create pixel map successfully!"); }
private void CorrectFile_Load(object sender, EventArgs e) { try { string ss = CapturePub.readCaptrueValue(XmlField.SortGainFolder, false); if (Directory.Exists(ss)) { dirListBox.Path = ss; } else { dirListBox.Path = CapturePub.SaveDFPath; } } catch { dirListBox.Path = CapturePub.SaveDFPath; } this.fileListBox.Path = this.dirListBox.Path + "\\"; dirListBox.DoubleClick += new EventHandler(dirListBox_DoubleClick); string s = CapturePub.readCaptrueValue(XmlField.OffsetFile); if (File.Exists(s)) { textBoxOffsetFile.Tag = s.Substring(0, s.LastIndexOf('\\') + 1); textBoxOffsetFile.Text = s.Substring(s.LastIndexOf('\\') + 1); toolTipBase.SetToolTip(textBoxOffsetFile, s); } else { toolTipBase.SetToolTip(textBoxOffsetFile, ""); } s = CapturePub.readCaptrueValue(XmlField.GainFile); if (File.Exists(s)) { textBoxGainFile.Tag = s.Substring(0, s.LastIndexOf('\\') + 1); textBoxGainFile.Text = s.Substring(s.LastIndexOf('\\') + 1); toolTipBase.SetToolTip(textBoxGainFile, s); } else { toolTipBase.SetToolTip(textBoxGainFile, ""); } s = CapturePub.readCaptrueValue(XmlField.GainSeqFile_Image); if (File.Exists(s)) { textBoxGainSeqFile_Image.Tag = s.Substring(0, s.LastIndexOf('\\') + 1); textBoxGainSeqFile_Image.Text = s.Substring(s.LastIndexOf('\\') + 1); toolTipBase.SetToolTip(textBoxGainSeqFile_Image, s); } else { toolTipBase.SetToolTip(textBoxGainSeqFile_Image, ""); } s = CapturePub.readCaptrueValue(XmlField.GainSeqFile_Dose); if (File.Exists(s)) { textBoxGainSeqFile_Dose.Tag = s.Substring(0, s.LastIndexOf('\\') + 1); textBoxGainSeqFile_Dose.Text = s.Substring(s.LastIndexOf('\\') + 1); toolTipBase.SetToolTip(textBoxGainSeqFile_Dose, s); } else { toolTipBase.SetToolTip(textBoxGainSeqFile_Dose, ""); } s = CapturePub.readCaptrueValue(XmlField.PixelMapFile); if (File.Exists(s)) { textBoxPixelMapFile.Tag = s.Substring(0, s.LastIndexOf('\\') + 1); textBoxPixelMapFile.Text = s.Substring(s.LastIndexOf('\\') + 1); toolTipBase.SetToolTip(textBoxPixelMapFile, s); } else { toolTipBase.SetToolTip(textBoxPixelMapFile, ""); } s = CapturePub.readCaptrueValue(XmlField.MachineQAMachineData); if (File.Exists(s)) { txtMachineDataFile.Tag = s.Substring(0, s.LastIndexOf('\\') + 1); txtMachineDataFile.Text = s.Substring(s.LastIndexOf('\\') + 1); toolTipBase.SetToolTip(txtMachineDataFile, s); } else { toolTipBase.SetToolTip(txtMachineDataFile, ""); } }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { switch (CalibrationType) { case "LENGTH": { if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count) { return; } ImageObject img = captureImagesNow[userControlMutiDicomImages.SelectedIndex]; Point p = e.Location; Matrix mxInvert = (Matrix)myMatrix.Clone(); mxInvert.Invert(); Point[] ps = new Point[] { p }; mxInvert.TransformPoints(ps); endP = new Point(ps[0].X, ps[0].Y); UserControlCalibrationLength ctrl = new UserControlCalibrationLength(); if (ShowBaseForm.ShowControlDialog(ctrl) == DialogResult.OK) { float len = ctrl.length; float pixelLen = (float)Math.Sqrt((float)((startP.X - endP.X) * (startP.X - endP.X) + (startP.Y - endP.Y) * (startP.Y - endP.Y))); float SAD = float.Parse(textBoxSAD.Text.Trim()); float panelSize = float.Parse(textBoxPhysicsWidth.Text.Trim()); float setupHeight = (float)((SAD * (panelSize / img.imageWidth) * pixelLen) / len); setupHeight = float.Parse(setupHeight.ToString("0.0")); if (cls_MessageBox.Show("Will you apply setup height " + setupHeight + "(mm)?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes) { textBoxSetupHeight.Text = setupHeight.ToString(); CapturePub.saveCaptrueValue("SetupHeight", setupHeight.ToString()); } } } break; case "CENTER": { if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count) { return; } ImageObject img = captureImagesNow[userControlMutiDicomImages.SelectedIndex]; Point p = e.Location; Matrix mxInvert = (Matrix)myMatrix.Clone(); mxInvert.Invert(); Point[] ps = new Point[] { p }; mxInvert.TransformPoints(ps); Point originalPoint = new Point(ps[0].X, ps[0].Y); Point imageCenter = new Point(512, 512); float offsetX = (originalPoint.X - imageCenter.X) * (float.Parse(textBoxPhysicsWidth.Text.Trim()) / img.imageWidth); // panel上的偏移距离 float offsetY = (originalPoint.Y - imageCenter.Y) * (float.Parse(textBoxPhysicsWidth.Text.Trim()) / img.imageWidth); offsetX = float.Parse(offsetX.ToString("0.0")); offsetY = float.Parse(offsetY.ToString("0.0")); if (cls_MessageBox.Show("Will you apply center offset value X:" + offsetX + ",Y:" + offsetY + "(mm)?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes) { textBoxImageCenterX.Text = offsetX.ToString(); CapturePub.saveCaptrueValue("ImageCenterX", offsetX.ToString()); textBoxImageCenterY.Text = offsetY.ToString(); CapturePub.saveCaptrueValue("ImageCenterY", offsetY.ToString()); } } break; case "NONE": break; } } else if (e.Button == MouseButtons.Right) { if (CalibrationType == "LENGTH") { this.Cursor = DistanceCursor; } else if (CalibrationType == "CENTER") { this.Cursor = Cursors.Cross; } else { this.Cursor = Cursors.Default; } } }
private void cbAngle_SelectedIndexChanged(object sender, EventArgs e) { string xmlValue = CapturePub.readCaptrueValue("SetupAngle"); int idx1 = cbAngle.Items.IndexOf(xmlValue); if (idx1 < 0) { idx1 = 0; } int SetupAngle = (cbAngle.SelectedIndex - idx1) * 90; ImgCapture.SetupAngle = int.Parse(cbAngle.Text.Trim()); CapturePub.saveCaptrueValue("SetupAngle", cbAngle.Text); if (captureImagesNow == null || captureImagesNow.Count <= 0) { return; } if (SetupAngle % 90 != 0 || SetupAngle % 360 == 0) { return; } while (SetupAngle < 0) { SetupAngle += 360; } for (int n = 0; n < captureImagesNow.Count; n++) { int idx = SetupAngle / 90; int r = captureImagesNow[n].ImageData.GetLength(0); int c = captureImagesNow[n].ImageData.GetLength(1); List <int[]> COUNTANGLE = new List <int[]> { new int[5] { 1, -1, 1, c - 1, 0 }, new int[5] { 0, -1, -1, r - 1, c - 1 }, new int[5] { 1, 1, -1, 0, r - 1 }, new int[5] { 0, 1, -1, 0, c - 1 }, new int[5] { 0, -1, 1, r - 1, 0 } }; //[exchange,scaleX,scaleY,offX,offY] int[] ca = COUNTANGLE[idx - 1]; ushort[,] temp = new ushort[r, c]; if (ca[0] == 1) { for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { temp[i, j] = captureImagesNow[n].ImageData[j * ca[1] + ca[3], i *ca[2] + ca[4]]; } } captureImagesNow[n].ImageData = (ushort[, ])temp.Clone(); } else { for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { temp[i, j] = captureImagesNow[n].ImageData[i * ca[1] + ca[3], j *ca[2] + ca[4]]; } } captureImagesNow[n].ImageData = (ushort[, ])temp.Clone(); } } if (userControlMutiDicomImages.Num <= 0) { return; } else { int index = userControlMutiDicomImages.SelectedIndex; if (index >= userControlMutiDicomImages.Num || index < 0) { index = 0; } userControlMutiDicomImages.DrawImagesInPane(GetSmallBitmapList(captureImagesNow), index); ImageObject img = captureImagesNow[index]; srcBitmap = img.BMP; RefreshImage(img); } }
public static float[] ComputeOff(float gantry1, float offx1, float offy1, float gantry2, float offx2, float offy2) { float[] result = new float[3]; if (ComputeShift(new float[] { gantry1, offx1, offx2 }, new float[] { gantry2, offx2, offy2 }, ref result)) { return(result); } else { return(null); } float s = 100.0f; try { s = float.Parse(CapturePub.readCaptrueValue("SAD")) * 0.1f; } catch (System.Exception ex) { s = 100.0f; } float[] diff = new float[3]; float r1 = gantry1; float r2 = gantry2; float dx = offx1; float dy = offy1; float ds = offx2; float dt = offy2; dx = float.Parse(dx.ToString("0.00")); dy = float.Parse(dy.ToString("0.00")); ds = float.Parse(ds.ToString("0.00")); dt = float.Parse(dt.ToString("0.00")); float[][] tempB1 = new float[2][]; tempB1[0] = new float[3]; tempB1[1] = new float[3]; float[][] tempB2 = new float[2][]; tempB2[0] = new float[3]; tempB2[1] = new float[3]; //float[] result = new float[3]; float[] sourse = { 0, 0, s }; float[] A2 = { dx, dy, 0 }; float[] B2 = { ds, dt, 0 }; float a = (float)(Math.Cos(r1 * Math.PI / 180) * Math.Cos(r2 * Math.PI / 180)); float b = dx * ds; float c = dy * dt; if ((a * b < -0.0001) || ((Math.Abs(r1 - r2) == 180) && ((b > -0.0001) || Math.Abs(dx + ds) > 0.01)) || c < -0.0001) { return(null); } tempB1[0] = TransCoor(0, r1, A2); tempB1[1] = TransCoor(0, r1, sourse); tempB2[0] = TransCoor(0, r2, B2); tempB2[1] = TransCoor(0, r2, sourse); float[,] coorB = { { tempB1[0][0], tempB1[1][0], tempB2[0][0], tempB2[1][0] }, { tempB1[0][1], tempB1[1][1], tempB2[0][1], tempB2[1][1] }, { tempB1[0][2], tempB1[1][2], tempB2[0][2], tempB2[1][2] } }; result = interPoint(coorB); float[] trans1 = new float[3]; float[] trans2 = new float[3]; //坐标变换,将求得交点的坐标由0度时的坐标系分别变换到两个角度坐标系下的坐标。 trans1 = TransCoor(0, r1, result); trans2 = TransCoor(0, r2, result); //r1角度下x方向偏移量不为零时,理论上 Math.Abs(Math.Abs(trans1[0] / dx) + Math.Abs(trans1[2] / s)=1,r2角度下亦然 if ((dx != 0 && Math.Abs(Math.Abs(trans1[0] / dx) + Math.Abs(trans1[2] / s) - 1) > 0.1) || (ds != 0 && Math.Abs(Math.Abs(trans2[0] / ds) + Math.Abs(trans2[2] / s) - 1) > 0.1)) { return(null); } if (c == 0)//y偏移量中有0值,result[1]=0 { if (result[1] != 0) { return(null); } } else { //若两个角度下Y方向上的偏移都不为零 //往x正方向旋转为正,旋转角度在180度以内,理论上Math.Abs(Math.Abs(trans1[1] / dy) + Math.Abs(trans1[2] / s)=1 if (((180 - r1) > 0 || (180 + r1) < 0) && Math.Abs(Math.Abs(trans1[1] / dy) + Math.Abs(trans1[2] / s) - 1) > 0.1) { return(null); } else//180度以外,Math.Abs(Math.Abs(dy / trans1[1]) + Math.Abs(s / (s + trans1[2]))) - 1 =0 { if (((180 - r1) < 0 || (180 + r1) > 0) && Math.Abs(Math.Abs(dy / trans1[1]) + Math.Abs(s / (s + trans1[2]))) - 1 > 0.1) { return(null); } } if (((180 - r2) > 0 || (180 + r2) < 0) && Math.Abs(Math.Abs(trans2[1] / dt) + Math.Abs(trans2[2] / s) - 1) > 0.1) { return(null); } else { if (((180 - r2) < 0 || (180 + r2) > 0) && Math.Abs(Math.Abs(dt / trans2[1]) + Math.Abs(Math.Abs(trans2[2]) / (s + Math.Abs(trans2[2])))) - 1 > 0.1) { return(null); } } } result[0] = float.Parse(result[0].ToString("0.00")); result[1] = float.Parse(result[1].ToString("0.00")); result[2] = -float.Parse(result[2].ToString("0.00")); return(result); }
//初始化对象的信息 public override void UserCtrlShown() { base.UserCtrlShown(); //先将界面元素显示出来 //.................... string detectionAreaString = CapturePub.readCaptrueValue("LinearDetectionArea", false); int detectionArea = 15; if (!int.TryParse(detectionAreaString, out detectionArea)) { detectionArea = 15; } double[] mus = new double[imageList.Count]; double[] imgVs = new double[imageList.Count]; for (int i = 0; i < imageList.Count; i++) { //ushort[,] imgData = imageList[i].imageData; //int radius = (int)((detectionArea * 10 / imageList[i].pixelSize) / 2.0F); //if (radius <= 0 || radius >= imgData.GetLength(0) / 2) //{ // radius = 500; //} //double v = 0; //int upRow = (int)(imageList[i].centerY - radius); //if (upRow < 0 || upRow >= imgData.GetLength(0)) //{ // upRow = 0; //} //int downRow = (int)(imageList[i].centerY + radius); //if (downRow < 0 || downRow >= imgData.GetLength(0)) //{ // downRow = imgData.GetLength(0) - 1; //} //int leftCol = (int)(imageList[i].centerX - radius); //if (leftCol < 0 || leftCol >= imgData.GetLength(1)) //{ // leftCol = 0; //} //int rightCol = (int)(imageList[i].centerX + radius); //if (rightCol < 0 || rightCol >= imgData.GetLength(1)) //{ // rightCol = imgData.GetLength(1) - 1; //} //int recNum = 0; //for (int row = upRow; row <= downRow; row++) //{ // for (int col = leftCol; col <= rightCol; col++) // { // v += imgData[row, col]; // recNum++; // } //} mus[i] = imageList[i].mu; imgVs[i] = imageList[i].frameNum * imageList[i].ROIMeanValue; } double xMin = mus[0]; double xMax = mus[0]; foreach (double v in mus) { if (v < xMin) { xMin = v; } if (v > xMax) { xMax = v; } } double yMin = imgVs[0]; double yMax = imgVs[0]; foreach (double v in imgVs) { if (v < yMin) { yMin = v; } if (v > yMax) { yMax = v; } } int VertiNum = 10; int HoriNum = 10; double VertiLen = (int)(yMax - yMin + 1); double HoriLen = (int)(xMax - xMin + 1); double vTag = double.Parse(VertiLen.ToString()[0].ToString()); long vScale = 1; for (int i = 1; i < VertiLen.ToString().Length; i++) { vScale *= 10; } vTag = (++vTag) * vScale; double hTag = double.Parse(HoriLen.ToString()[0].ToString()); long hScale = 1; for (int i = 1; i < HoriLen.ToString().Length; i++) { hScale *= 10; } hTag = (++hTag) * hScale; yMin = (((long)yMin) / vScale) * vScale; xMin = (((long)xMin) / hScale) * hScale; if (hTag == 0) { hScale = 10; hTag = 100; } if (vTag == 0) { vScale = 100; vTag = 1000; } double xUnit = hTag / HoriNum; double yUnit = vTag / VertiNum; Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bmp); Pen pen = new Pen(Color.Green, 2.0F); Font font = new Font("Tahoma", 8.0F); Brush brush = new SolidBrush(Color.White); float stringwidth = g.MeasureString(vScale.ToString(), font).Width; float stringheight = g.MeasureString(vScale.ToString(), font).Height; float vBorder = stringheight + 35; float hBorder = stringwidth + 35; float xbmpUnit = (bmp.Width - 2 * hBorder) / HoriNum; float ybmpUnit = (bmp.Height - 2 * vBorder) / VertiNum; PointF yTop = new PointF(hBorder, 10); PointF originPt = new PointF(hBorder, bmp.Height - vBorder); PointF xRight = new PointF(bmp.Width - 10, bmp.Height - vBorder); g.DrawLine(pen, originPt, yTop); g.DrawLine(pen, originPt, xRight); g.DrawLine(pen, yTop, new PointF(yTop.X - 5, yTop.Y + 10)); g.DrawLine(pen, yTop, new PointF(yTop.X + 5, yTop.Y + 10)); g.DrawLine(pen, xRight, new PointF(xRight.X - 10, xRight.Y - 5)); g.DrawLine(pen, xRight, new PointF(xRight.X - 10, xRight.Y + 5)); float strleny = g.MeasureString("(average value)", font).Width; float strlenx = g.MeasureString("(mu)", font).Width; g.DrawString("(average value)", font, Brushes.Green, new PointF(hBorder - strleny - 5, 10)); g.DrawString("(mu)", font, Brushes.Green, new PointF(bmp.Width - 10 - strlenx, bmp.Height - vBorder + 5)); for (int i = 0; i <= VertiNum; i++) { if (i == 0) { PointF p1 = new PointF(hBorder - 2, bmp.Height - vBorder); //g.DrawLine(pen, originPt, p1); float ylen = g.MeasureString(yMin.ToString(), font).Width + 1; PointF strP = new PointF(hBorder - ylen, p1.Y - stringheight); g.DrawString(yMin.ToString(), font, brush, strP); } else { PointF p1 = new PointF(hBorder - 2, bmp.Height - vBorder - i * ybmpUnit); PointF p2 = new PointF(hBorder, bmp.Height - vBorder - i * ybmpUnit); g.DrawLine(pen, p1, p2); float ylen = g.MeasureString((yMin + i * yUnit).ToString(), font).Width + 1; PointF strP = new PointF(hBorder - ylen, p1.Y - stringheight); g.DrawString((yMin + i * yUnit).ToString(), font, brush, strP); } } for (int i = 0; i <= HoriNum; i++) { if (i == 0) { PointF p1 = new PointF(hBorder - 2, bmp.Height - vBorder); //g.DrawLine(pen, originPt, p1); PointF strP = new PointF(hBorder, p1.Y + 1); g.DrawString(xMin.ToString(), font, brush, strP); } else { PointF p1 = new PointF(hBorder + i * xbmpUnit, bmp.Height - vBorder - 2); PointF p2 = new PointF(hBorder + i * xbmpUnit, bmp.Height - vBorder); g.DrawLine(pen, p1, p2); PointF strP = new PointF(p1.X, p1.Y + 1); g.DrawString((xMin + i * xUnit).ToString(), font, brush, strP); } } List <PointF> list = new List <PointF>(); for (int i = 0; i < mus.Length; i++) { double offmu = mus[i] - xMin; float offbmpmu = (float)((offmu / hTag) * (bmp.Width - 2 * hBorder)); double offvalue = imgVs[i] - yMin; float offbmpvalue = (float)((offvalue / vTag) * (bmp.Height - 2 * vBorder)); PointF p1 = new PointF(hBorder + offbmpmu, bmp.Height - vBorder - offbmpvalue); g.FillEllipse(Brushes.Green, new RectangleF(p1.X - 2, p1.Y - 2, 4, 4)); list.Add(p1); } g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.DrawLines(pen, list.ToArray()); g.Flush(); g.Dispose(); brush.Dispose(); font.Dispose(); pictureBox1.Image = bmp; pictureBox1.Refresh(); }