private void UISetup() { try { Version cv = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string ver = cv.ToString(); taskpaneView = swApp.CreateTaskpaneView2(Properties.Settings.Default.NetPath + Properties.Settings.Default.Icon, string.Format(Properties.Resources.Title, ver)); taskpaneHost = (SWTaskPaneHost)taskpaneView.AddControl(SWTaskPaneHost.SWTASKPANE_PROGID, string.Empty); taskpaneHost.OnRequestSW += new Func <SldWorks>(delegate { return(this.swApp); }); bool result = taskpaneView.AddStandardButton((int)swTaskPaneBitmapsOptions_e.swTaskPaneBitmapsOptions_Ok, "OK"); result = taskpaneView.AddStandardButton((int)swTaskPaneBitmapsOptions_e.swTaskPaneBitmapsOptions_Options, "Configuration"); //result = taskpaneView.AddStandardButton((int)swTaskPaneBitmapsOptions_e.swTaskPaneBitmapsOptions_Close, "Close"); result = taskpaneView.AddCustomButton(Properties.Settings.Default.NetPath + Properties.Settings.Default.RefreshIcon, "Refresh"); result = taskpaneView.AddCustomButton(Properties.Settings.Default.NetPath + Properties.Settings.Default.ArchiveIcon, "Archive PDF"); result = taskpaneView.AddCustomButton(Properties.Settings.Default.NetPath + Properties.Settings.Default.HelpIcon, "Usage Help"); taskpaneView.TaskPaneToolbarButtonClicked += taskpaneView_TaskPaneToolbarButtonClicked; taskpaneHost.cookie = cookie; taskpaneHost.Start(); } catch (Exception e) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(e); em.ShowDialog(); } }
private void UpdateCutlist(string itemNo, string rev) { int itpSetup = int.Parse(cbSetupBy.SelectedValue.ToString()); ushort itpState = 0; ushort itpCust = 0; double dtpLength = 0.0f; double dtpWidth = 0.0f; double dtpHeight = 0.0f; try { if (!ushort.TryParse(CutlistData.GetCutlistData(itemNo, rev).Tables[0]. Rows[0][(int)CutlistData.CutlistDataFields.STATEID].ToString(), out itpState)) { itpState = 0; } } catch (IndexOutOfRangeException ioore) { System.Diagnostics.Debug.Print(string.Format(@"{0}, but it's OK.", ioore.Message)); } catch (Exception ex) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(ex, CutlistData); em.Show(); } if (!ushort.TryParse(cbCustomer.SelectedValue.ToString(), out itpCust)) { itpCust = 0; } dtpLength = ParseFloat(tbL.Text); dtpWidth = ParseFloat(tbW.Text); dtpHeight = ParseFloat(tbH.Text); if (table != null) { CutlistData.EmptyCutlist(itemNo, rev); CutlistData.UpdateCutlist(itemNo, cbDrawingReference.Text, rev, cbDescription.Text, itpCust, dtpLength, dtpWidth, dtpHeight, itpState, itpSetup, table.GetParts()); } else if (part != null) { Dictionary <string, Part> d = new Dictionary <string, Part>(); d.Add(part.PartNumber, part); CutlistData.UpdateCutlist(itemNo, cbDrawingReference.Text, rev, cbDescription.Text, itpCust, dtpLength, dtpWidth, dtpHeight, itpState, itpSetup, d); } else { DrawingPropertySet.SwApp.SendMsgToUser2("Failed to read table or part.", (int)SolidWorks.Interop.swconst.swMessageBoxIcon_e.swMbStop, (int)SolidWorks.Interop.swconst.swMessageBoxBtn_e.swMbOk); } }
private void InitTableData() { md = (ModelDoc2)DrawingPropertySet.SwApp.ActiveDoc; mde = md.Extension; fracdisp = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); //int den = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearFractionDenominator, // (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decs = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decd = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); try { mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, (int)swFractionDisplay_e.swDECIMAL); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); md.ForceRebuild3(false); table = new swTableType.swTableType((DrawingPropertySet.SwApp.ActiveDoc as ModelDoc2), Redbrick.MasterHashes); } catch (NullReferenceException nre) { if (_swApp != null) { if (dept > -1) { Redbrick.InsertBOM(_swApp, dept); } else { Redbrick.InsertBOM(_swApp); } InitTableData(); } else { throw new NullReferenceException(@"No table found."); } } catch (Exception e) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(e); em.ShowDialog(); Close(); } finally { // } }
/// <summary> /// Copy to_clip to clipboard. /// </summary> /// <param name="to_clip">A string.</param> static public void Clip(string to_clip) { if ((to_clip != null && to_clip != string.Empty) && to_clip != System.Windows.Forms.Clipboard.GetText()) { System.Windows.Forms.Clipboard.SetText(to_clip.Replace(Properties.Settings.Default.NotSavedMark, string.Empty)); if (Properties.Settings.Default.MakeSounds) { try { System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Properties.Settings.Default.ClipboardSound); sp.PlaySync(); } catch (Exception ex) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(ex); em.ShowDialog(); } } } else { if (Properties.Settings.Default.MakeSounds) { System.Media.SystemSounds.Asterisk.Play(); } } }
private void UpdateCutlist(string itemNo, string rev) { int itpSetup = int.Parse(cbSetupBy.SelectedValue.ToString()); ushort itpState = 0; ushort itpCust = 0; double dtpLength = 0.0f; double dtpWidth = 0.0f; double dtpHeight = 0.0f; try { if (!ushort.TryParse(CutlistData.GetCutlistData(itemNo, rev).Tables[0]. Rows[0][(int)CutlistData.CutlistDataFields.STATEID].ToString(), out itpState)) { itpState = 0; } } catch (IndexOutOfRangeException ioore) { System.Diagnostics.Debug.Print(string.Format(@"{0}, but it's OK.", ioore.Message)); } catch (Exception ex) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(ex, CutlistData); em.Show(); } if (!ushort.TryParse(cbCustomer.SelectedValue.ToString(), out itpCust)) { itpCust = 0; } dtpLength = ParseFloat(tbL.Text); dtpWidth = ParseFloat(tbW.Text); dtpHeight = ParseFloat(tbH.Text); if (table != null) { CutlistData.EmptyCutlist(itemNo, rev); CutlistData.UpdateCutlist(itemNo, cbDrawingReference.Text, rev, cbDescription.Text, itpCust, dtpLength, dtpWidth, dtpHeight, itpState, itpSetup, table.GetParts()); } else if (part != null) { Dictionary<string, Part> d = new Dictionary<string, Part>(); d.Add(part.PartNumber, part); CutlistData.UpdateCutlist(itemNo, cbDrawingReference.Text, rev, cbDescription.Text, itpCust, dtpLength, dtpWidth, dtpHeight, itpState, itpSetup, d); } else { DrawingPropertySet.SwApp.SendMsgToUser2("Failed to read table or part.", (int)SolidWorks.Interop.swconst.swMessageBoxIcon_e.swMbStop, (int)SolidWorks.Interop.swconst.swMessageBoxBtn_e.swMbOk); } }
private void InitTableData() { md = (ModelDoc2)DrawingPropertySet.SwApp.ActiveDoc; mde = md.Extension; fracdisp = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); //int den = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearFractionDenominator, // (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decs = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); decd = mde.GetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified); try { mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, (int)swFractionDisplay_e.swDECIMAL); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, 3); md.ForceRebuild3(false); table = new swTableType.swTableType((DrawingPropertySet.SwApp.ActiveDoc as ModelDoc2), Redbrick.MasterHashes); } catch (NullReferenceException nre) { if (_swApp != null) { Redbrick.InsertBOM(_swApp); InitTableData(); } else { throw new NullReferenceException(@"No table found."); } } catch (Exception e) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(e); em.ShowDialog(); Close(); } finally { // } }
/// <summary> /// Copy to_clip to clipboard. /// </summary> /// <param name="to_clip">A string.</param> public static void Clip(string to_clip) { if ((to_clip != null && to_clip != string.Empty) && to_clip != System.Windows.Forms.Clipboard.GetText()) { System.Windows.Forms.Clipboard.SetText(to_clip.Replace(Properties.Settings.Default.NotSavedMark, string.Empty)); if (Properties.Settings.Default.MakeSounds) { try { System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Properties.Settings.Default.ClipboardSound); sp.PlaySync(); } catch (Exception ex) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(ex); em.ShowDialog(); } } } else { if (Properties.Settings.Default.MakeSounds) { System.Media.SystemSounds.Asterisk.Play(); } } }
private void UISetup() { try { Version cv = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string ver = cv.ToString(); taskpaneView = swApp.CreateTaskpaneView2(Properties.Settings.Default.NetPath + Properties.Settings.Default.Icon, string.Format(Properties.Resources.Title, ver)); taskpaneHost = (SWTaskPaneHost)taskpaneView.AddControl(SWTaskPaneHost.SWTASKPANE_PROGID, string.Empty); taskpaneHost.OnRequestSW += new Func<SldWorks>(delegate { return this.swApp; }); bool result = taskpaneView.AddStandardButton((int)swTaskPaneBitmapsOptions_e.swTaskPaneBitmapsOptions_Ok, "OK"); result = taskpaneView.AddStandardButton((int)swTaskPaneBitmapsOptions_e.swTaskPaneBitmapsOptions_Options, "Configuration"); //result = taskpaneView.AddStandardButton((int)swTaskPaneBitmapsOptions_e.swTaskPaneBitmapsOptions_Close, "Close"); result = taskpaneView.AddCustomButton(Properties.Settings.Default.NetPath + Properties.Settings.Default.RefreshIcon, "Refresh"); result = taskpaneView.AddCustomButton(Properties.Settings.Default.NetPath + Properties.Settings.Default.ArchiveIcon, "Archive PDF"); result = taskpaneView.AddCustomButton(Properties.Settings.Default.NetPath + Properties.Settings.Default.HelpIcon, "Usage Help"); taskpaneView.TaskPaneToolbarButtonClicked += taskpaneView_TaskPaneToolbarButtonClicked; taskpaneHost.cookie = cookie; taskpaneHost.Start(); } catch (Exception e) { RedbrickErr.ErrMsg em = new RedbrickErr.ErrMsg(e); em.ShowDialog(); } }