//when the selection is document private void RadioDocument_Click(object sender, System.EventArgs e) { if (oSelectOption != SelectOptionsEnum.eDocument) { // record it for next use if (oSelectOption == SelectOptionsEnum.eApplication) { oSelectSetting_App.setEqualTo(oSelectSetting_Current); } else if (oSelectOption == SelectOptionsEnum.eWindow) { oSelectSetting_Win.setEqualTo(oSelectSetting_Current); } oSelectOption = SelectOptionsEnum.eDocument; ButtonWindow.Enabled = false; //final check if it needs to be updated if (!(clsSelectSetting.compare(oSelectSetting_Doc, oSelectSetting_Current)) | oBitmap_Doc == null) // ' when the dialog is re-opened { closeDialogForSnapshot(); } else { //set existing image to picturebox if (oBitmap_Doc != null) { PictureBox1.Image = oBitmap_Doc; oResultBitmap = oBitmap_Doc; } } } }
//when the mode is window private void RadioWindow_Click(object sender, System.EventArgs e) { if (oSelectOption != SelectOptionsEnum.eWindow) { // record it for next use if (oSelectOption == SelectOptionsEnum.eApplication) { oSelectSetting_App.setEqualTo(oSelectSetting_Current); } else if (oSelectOption == SelectOptionsEnum.eDocument) { oSelectSetting_Doc.setEqualTo(oSelectSetting_Current); } oSelectOption = SelectOptionsEnum.eWindow; ButtonWindow.Enabled = true; //final check if it needs to be updated if (!(clsSelectSetting.compare(oSelectSetting_Win, oSelectSetting_Current)) | oBitmap_Win == null) { closeDialogForSnapshot(); } else { if (!(oHasSelectWindow)) { //need to select by user. so set preview to warning PictureBox1.Image = GetWarningBitmap(); return; } else { //set existing image to picturebox if (oBitmap_Win != null) { PictureBox1.Image = oBitmap_Win; oResultBitmap = oBitmap_Win; } } } } }
public ScreenshotForm(Application oApp) { InitializeComponent(); if (oApp == null) { MessageBox.Show("Error: Inventor Application is null"); return; } m_inventorApplication = oApp; //initialize the option as eApplication oSelectOption = SelectOptionsEnum.eApplication; //disable window button ButtonWindow.Enabled = false; //Param for selecting application oSelectParam_App = new clsSelectParam(m_inventorApplication.Left, m_inventorApplication.Top, m_inventorApplication.Width, m_inventorApplication.Height); //params for selecting document if (m_inventorApplication.ActiveView != null) { oSelectParam_Doc = new clsSelectParam(m_inventorApplication.ActiveView.Left, m_inventorApplication.ActiveView.Top, m_inventorApplication.ActiveView.Width, m_inventorApplication.ActiveView.Height); } //params for selecting window, wait the user to input oSelectParam_Win = new clsSelectParam(); ComboBoxBG.SelectedIndex = 0; ComboBoxFG.SelectedIndex = 0; ComboBoxGray.SelectedIndex = 0; //picurebox's mode is StretchImage PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; //original size values of the dialog //the third and forth are for newer values this.Tag = this.Width.ToString() + "," + this.Height.ToString() + "," + "0" + "," + "0"; try { foreach (Control oCtrl in this.Controls) { //size values of the sub-control oCtrl.Tag = oCtrl.Left.ToString() + "," + oCtrl.Top.ToString() + "," + oCtrl.Width.ToString() + "," + oCtrl.Height.ToString(); if (oCtrl.Name == "GroupBoxSelectOp" || oCtrl.Name == "GroupBoxSettings" || oCtrl.Name == "GroupBoxOutput") { foreach (Control oSubCtrl in oCtrl.Controls) { oSubCtrl.Tag = oSubCtrl.Left.ToString() + "," + oSubCtrl.Top.ToString() + "," + oSubCtrl.Width.ToString() + "," + oSubCtrl.Height.ToString(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }