public Ops(ref SwProperties prop) { cd = prop.cutlistData; propertySet = prop; InitializeComponent(); }
private void xInitControlsWithPart(Part p, CutlistData cd, string itemNo, string Rev) { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) { cbRev.Items.Add(i.ToString()); } cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); DataSet dr = CutlistData.GetCutlistData(itemNo, Rev); cbCustomer.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.CUSTID].ToString()); cbItemNo.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString(); cbDescription.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DESCR].ToString(); tbL.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.LENGTH].ToString(); tbW.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.WIDTH].ToString(); tbH.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.HEIGHT].ToString(); cbDrawingReference.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DRAWING].ToString(); cbSetupBy.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.SETUP_BY].ToString()); }
private void InitControlsWithDrawing() { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) { cbRev.Items.Add(i.ToString()); } cbRev.Items.Add("NS"); cbRev.SelectedIndex = 0; string[] title = (DrawingPropertySet.SwApp.ActiveDoc as ModelDoc2).GetTitle().Split(new string [] { @"REV", @".", @" " }, StringSplitOptions.None); Text = "Add/Update Cutlist for " + title[0] + "..."; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbDrawingReference.Text = DrawingPropertySet.GetProperty("PartNo").ResValue; cbItemNo.Text = title[0]; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbCustomer.SelectedIndex = cbCustomer.FindString(DrawingPropertySet.GetProperty("CUSTOMER").Value.Split('-')[0].Trim()); cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); cbRev.Text = DrawingPropertySet.GetProperty("REVISION LEVEL").Value; cbDescription.Text = description; InitTableData(); }
private void InitControlsWithPart(Part p, CutlistData cd, string itemNo, string Rev) { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) { cbRev.Items.Add(i.ToString()); } cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbItemNo.DataSource = CutlistData.GetCutlists().Tables[0]; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbCustomer.SelectedIndex = Properties.Settings.Default.LastCustomerSelection; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); }
private void InitControlsWithPart(Part p, CutlistData cd) { Text = "Add to cutlist..."; for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) { cbRev.Items.Add(i.ToString()); } cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbRev.Enabled = false; cbItemNo.DataSource = CutlistData.GetCutlists().Tables[0]; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); // Not classy, but it makes the boxes update the first time around. clicked = true; CurrentCutlist = Properties.Settings.Default.CurrentCutlist; if (CurrentCutlist != 0) { cbItemNo.SelectedIndex = cbItemNo.FindString( cd.GetCutlistData(CurrentCutlist).Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString()); } }
public CutlistHeaderInfo(Part p, CutlistData cd) // New Cutlist { InitializeComponent(); SetLWHVisibility(Properties.Settings.Default.CHIHideLWH); Location = Properties.Settings.Default.CutlistHeaderLocation; Size = Properties.Settings.Default.CutlistHeaderSize; InitControlsWithPart(p, cd); }
public tvRevs(ref DrawingProperties prop, ref DrawingRevs dr) { propertySet = prop; cd = prop.CutlistData; revSet = dr; InitializeComponent(); Init(); }
public CutlistHeaderInfo(Part p, CutlistData cd) { // New Cutlist InitializeComponent(); SetLWHVisibility(Properties.Settings.Default.CHIHideLWH); Location = Properties.Settings.Default.CutlistHeaderLocation; Size = Properties.Settings.Default.CutlistHeaderSize; InitControlsWithPart(p, cd); }
public void UpdateFields() { foreach (SwProperty s in this._innerArray) { if (s.Ctl != null) { if (s.Ctl is System.Windows.Forms.ComboBox) { int si = 0; string ss = s.Value.Split(' ', '-')[0]; if (s.Ctl.Name.Contains("cbM")) { ss = s.Value; } if (s.Ctl.Name.ToUpper().Contains("AUTHOR")) { si = (s.Ctl as System.Windows.Forms.ComboBox).FindString(CutlistData.GetAuthorFullName(ss)); } else { si = (s.Ctl as System.Windows.Forms.ComboBox).FindString(ss); } if (si < 0 && !s.Ctl.Name.ToUpper().Contains("CUSTOMER")) { (s.Ctl as System.Windows.Forms.ComboBox).SelectedValue = ss; } else { (s.Ctl as System.Windows.Forms.ComboBox).SelectedIndex = si; } if ((s.Ctl as System.Windows.Forms.ComboBox).SelectedItem == null) { (s.Ctl as System.Windows.Forms.ComboBox).Text = ss; } } else if (s.Ctl is System.Windows.Forms.NumericUpDown) { decimal x = 0; if (decimal.TryParse(s.Value, out x)) { (s.Ctl as System.Windows.Forms.NumericUpDown).Value = x; } else { (s.Ctl as System.Windows.Forms.NumericUpDown).Value = 100; } } else { s.Ctl.Text = s.Value; } } } }
/// <summary> /// Take a dictionary, inspect the inner types of the resultant anonymous object, and make a DataTable object. /// </summary> /// <param name="d">A Dictionary<string, Part> of Part values, with their name as keys.</param> /// <param name="cd">An active CutlistData object.</param> /// <returns>A DataTable object.</returns> private static DataTable DictToPartList(Dictionary <string, Part> d, CutlistData cd) { List <object> lp = new List <object>(); DataTable dt = new DataTable(); foreach (KeyValuePair <string, Part> p in d) { Part i = p.Value; var o = new { Part = i.PartNumber, Description = i.Description, Qty = i.Qty, Material = cd.GetMaterialByID(i.MaterialID.ToString()), L = i.Length, W = i.Width, T = i.Thickness, BlankQty = i.BlankQty, OverL = i.OverL, OverW = i.OverW, CNC1 = i.CNC1, CNC2 = i.CNC2, Op1 = cd.GetOpAbbreviationByID(i.get_OpID(0).ToString()), Op2 = cd.GetOpAbbreviationByID(i.get_OpID(1).ToString()), Op3 = cd.GetOpAbbreviationByID(i.get_OpID(2).ToString()), Op4 = cd.GetOpAbbreviationByID(i.get_OpID(3).ToString()), Op5 = cd.GetOpAbbreviationByID(i.get_OpID(4).ToString()), EdgeFront = cd.GetEdgeByID(i.EdgeFrontID.ToString()), EdgeBack = cd.GetEdgeByID(i.EdgeBackID.ToString()), EdgeLeft = cd.GetEdgeByID(i.EdgeLeftID.ToString()), EdgeRight = cd.GetEdgeByID(i.EdgeRightID.ToString()), Comment = i.Comment, Deptartment = cd.GetDeptByID((int)i.DepartmentID), Update = i.UpdateCNC ? "Yes" : "No" }; lp.Add(o); } // Wow, reflection! Fancy! C++ can't do this (yet). System.Reflection.PropertyInfo[] props = lp[0].GetType().GetProperties(); foreach (var prop in props) { dt.Columns.Add(prop.Name); } foreach (var item in lp) { var values = new object[props.Length]; for (var i = 0; i < props.Length; i++) { values[i] = props[i].GetValue(item, null); } dt.Rows.Add(values); } return(dt); }
public ConfigurationSpecific(ref SwProperties prop) { propertySet = prop; cd = prop.cutlistData; _edgeDiffL = 0.0; _edgeDiffW = 0.0; InitializeComponent(); init(); }
/// <summary> /// Update fields with data from the SwProperties we receive. /// </summary> /// <param name="prop">An SwProperties object.</param> public void Update(ref SwProperties prop) { propertySet = prop; configurationName = prop.modeldoc.ConfigurationManager.ActiveConfiguration.Name; cd = prop.cutlistData; Updte(); Redbrick.unselect(Controls); Redbrick.unselect(tableLayoutPanel1.Controls); }
public EditRev(ref DrawingRevs revs, int NodeCount, CutlistData cd, SwProperty rev) { System.Diagnostics.Debug.Print(NodeCount.ToString()); nodeCount = NodeCount; cutlist_data = cd; revision = rev; _revs = revs; InitializeComponent(); Init(); }
public void Write(ModelDoc2 md) { CustomPropertyManager glP = md.Extension.get_CustomPropertyManager(string.Empty); CutlistData.IncrementOdometer(CutlistData.Functions.GreenCheck); this.ClearProps(md); foreach (SwProperty p in this._innerArray) { p.Write(md); } }
private void btnCreate_Click(object sender, EventArgs e) { if (cbCustomer.Text == string.Empty) { DrawingPropertySet.SwApp.SendMsgToUser2(Properties.Resources.CustomerEmpty, (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } else if (cbItemNo.Text == string.Empty) { DrawingPropertySet.SwApp.SendMsgToUser2(Properties.Resources.ItemNumberEmpty, (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } else if (cbDescription.Text.Length > 50) { DrawingPropertySet.SwApp.SendMsgToUser2(Properties.Resources.CutlistDescriptionTooLong, (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } else { string[] clData = cbItemNo.Text.Split(new string[] { "REV" }, StringSplitOptions.None); if (clData.Length > 1) { if (CutlistData.GetCutlistID(clData[0].Trim(), clData[1].Trim()) > 0) { UpdateCutlist(clData[0].Trim(), clData[1].Trim()); } } else { UpdateCutlist(cbItemNo.Text, cbRev.Text); } if (mde != null) { mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, fracdisp); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalPlaces, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, decs); mde.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsLinearDecimalDisplay, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, decd); md.ForceRebuild3(false); } if (Properties.Settings.Default.MakeSounds) { System.Media.SystemSounds.Beep.Play(); } Close(); } }
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); } }
public MachineProgramManager(SwProperties p, string searchterm) { InitializeComponent(); prop = p; cutlistData = p.cutlistData; string s = OnlyDigits(searchterm); dtP1 = cutlistData.GetMachinesByProg(s, 1); dtP2 = cutlistData.GetMachinesByProg(s, 2); dtP3 = cutlistData.GetMachinesByProg(s, 3); wubp = cutlistData.GetWhereUsedByProg(s); gpbc = cutlistData.GetPartsByCNC(s); init(); }
private void Init() { CutlistData cd; if (cutlist_data != null) { cd = cutlist_data; } else { cd = new CutlistData(); } cbBy.DataSource = cd.GetAuthors().Tables[0]; cbBy.DisplayMember = "NAME"; cbBy.ValueMember = "USERNAME"; if (!Revs.Contains("REVISION " + (char)(nodeCount + 65))) { cbBy.SelectedValue = System.Environment.UserName; string theRev = "REVISION " + (char)(nodeCount + 65); Text = "Creating new " + theRev + "..."; if (nodeCount < 1) { tbDesc.Text = "RELEASED"; tbECO.Text = "NA"; } } else { string theRev = "REVISION " + (char)(nodeCount + 65); DrawingRev r = Revs.GetRev(theRev); tbECO.Text = r.Eco.Value; tbDesc.Text = r.Description.Value; cbBy.SelectedValue = cd.GetAuthorUserName(r.List.Value); System.DateTime dt = new System.DateTime(); if (DateTime.TryParse(r.Date.Value, out dt)) { dtpDate.Value = dt; } Text = "Editing " + theRev + "..."; } for (int i = 0; i < Properties.Settings.Default.RevLimit; i++) { cbRev.Items.Add("A" + (char)(i + 65)); } cbRev.SelectedIndex = (nodeCount); }
private void OnOpenPDF(object sender, EventArgs e) { CutlistData cd = new CutlistData(); object[] o = cd.GetDrawingData(part); string fullpath = string.Format(@"{0}\{1}", o[2], o[1]); if (o[1].ToString() == @"NULL") { o = cd.GetMetalDrawingData(part); fullpath = string.Format(@"{0}\{1}", o[2], o[1]); } if (o[1] != @"NULL") { System.Diagnostics.Process.Start(fullpath); } }
public override void Get(ModelDoc2 md, CutlistData cd) { Configuration cf = md.ConfigurationManager.ActiveConfiguration; CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty); CustomPropertyManager scpm; bool wasResolved; bool useCached = false; string tempval = string.Empty; string tempresval = string.Empty; if (cf != null) { scpm = md.Extension.get_CustomPropertyManager(cf.Name); } else { scpm = md.Extension.get_CustomPropertyManager(string.Empty); } if (SWCustPropMgr != null) { scpm = SWCustPropMgr; } int res; res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetOpAbbreviationByID(Value); } else { ID = cd.GetOpIDByName(Value).ToString(); Descr = Value; } //base.Get(md, cd); }
/// <summary> /// Pop up the CutlistHeaderInfo form. /// </summary> private void AddToCutlist() { string question = string.Format(Properties.Resources.AddToExistingCutlist, propertySet.PartName); swMessageBoxResult_e res = (swMessageBoxResult_e)propertySet.SwApp.SendMsgToUser2(question, (int)swMessageBoxIcon_e.swMbQuestion, (int)swMessageBoxBtn_e.swMbYesNoCancel); switch (res) { case swMessageBoxResult_e.swMbHitAbort: break; case swMessageBoxResult_e.swMbHitCancel: break; case swMessageBoxResult_e.swMbHitIgnore: break; case swMessageBoxResult_e.swMbHitNo: CutlistHeaderInfo chin = new CutlistHeaderInfo(CutlistData.MakePartFromPropertySet(propertySet, Convert.ToUInt16(nudQ.Value)), propertySet.cutlistData, CutlistHeaderInfo.CutlistFunction.CreateNew); chin.Text = "Creating new cutlist..."; chin.ShowDialog(); break; case swMessageBoxResult_e.swMbHitOk: break; case swMessageBoxResult_e.swMbHitRetry: break; case swMessageBoxResult_e.swMbHitYes: CutlistHeaderInfo chiy = new CutlistHeaderInfo(CutlistData.MakePartFromPropertySet(propertySet, Convert.ToUInt16(nudQ.Value)), propertySet.cutlistData, CutlistHeaderInfo.CutlistFunction.AddToExistingNotSelected); chiy.Text = "Adding to cutlist..."; chiy.ShowDialog(); break; default: break; } }
public CutlistHeaderInfo(Part p, CutlistData cd, CutlistFunction c) { InitializeComponent(); SetLWHVisibility(Properties.Settings.Default.CHIHideLWH); Location = Properties.Settings.Default.CutlistHeaderLocation; Size = Properties.Settings.Default.CutlistHeaderSize; switch (c) { case CutlistFunction.AddToExistingAlreadySelected: InitControlsWithPart(p, cd); break; case CutlistFunction.AddToExistingNotSelected: InitControlsWithPart(p, cd); break; case CutlistFunction.CreateNew: InitControlsWithNewPart(p, cd); break; default: break; } }
int taskpaneView_TaskPaneToolbarButtonClicked(int ButtonIndex) { switch (ButtonIndex) { case 0: taskpaneHost.Write(); if (Properties.Settings.Default.MakeSounds) { System.Media.SystemSounds.Beep.Play(); } break; case 1: RedbrickConfiguration rbc = new RedbrickConfiguration(); rbc.ShowDialog(); taskpaneHost.ConnectSelection(); break; case 2: taskpaneHost.ReStart(); break; case 3: CutlistData cd = new CutlistData(); cd.IncrementOdometer(CutlistData.Functions.ArchivePDF); cd.Dispose(); cd = null; ArchivePDF.csproj.ArchivePDFWrapper apw = new ArchivePDF.csproj.ArchivePDFWrapper(swApp, GeneratePathSet()); apw.Archive(); break; case 4: System.Diagnostics.Process.Start(Properties.Settings.Default.UsageLink); break; default: break; } return(1); }
/// <summary> /// Take a dictionary, inspect the inner types of the resultant anonymous object, and make a DataTable object. /// </summary> /// <param name="d">A Dictionary<string, Part> of Part values, with their name as keys.</param> /// <param name="cd">An active CutlistData object.</param> /// <returns>A DataTable object.</returns> private static DataTable DictToPartList(Dictionary<string, Part> d, CutlistData cd) { List<object> lp = new List<object>(); DataTable dt = new DataTable(); foreach (KeyValuePair<string, Part> p in d) { Part i = p.Value; var o = new { Part = i.PartNumber, Description = i.Description, Qty = i.Qty, Material = cd.GetMaterialByID(i.MaterialID.ToString()), L = i.Length, W = i.Width, T = i.Thickness, BlankQty = i.BlankQty, OverL = i.OverL, OverW = i.OverW, CNC1 = i.CNC1, CNC2 = i.CNC2, Op1 = cd.GetOpAbbreviationByID(i.get_OpID(0).ToString()), Op2 = cd.GetOpAbbreviationByID(i.get_OpID(1).ToString()), Op3 = cd.GetOpAbbreviationByID(i.get_OpID(2).ToString()), Op4 = cd.GetOpAbbreviationByID(i.get_OpID(3).ToString()), Op5 = cd.GetOpAbbreviationByID(i.get_OpID(4).ToString()), EdgeFront = cd.GetEdgeByID(i.EdgeFrontID.ToString()), EdgeBack = cd.GetEdgeByID(i.EdgeBackID.ToString()), EdgeLeft = cd.GetEdgeByID(i.EdgeLeftID.ToString()), EdgeRight = cd.GetEdgeByID(i.EdgeRightID.ToString()), Comment = i.Comment, Deptartment = cd.GetDeptByID((int)i.DepartmentID), Update = i.UpdateCNC ? "Yes" : "No" }; lp.Add(o); } // Wow, reflection! Fancy! C++ can't do this (yet). System.Reflection.PropertyInfo[] props = lp[0].GetType().GetProperties(); foreach (var prop in props) { dt.Columns.Add(prop.Name); } foreach (var item in lp) { var values = new object[props.Length]; for (var i = 0; i < props.Length; i++) { values[i] = props[i].GetValue(item, null); } dt.Rows.Add(values); } return dt; }
private void InitControlsWithPart(Part p, CutlistData cd, string itemNo, string Rev) { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) cbRev.Items.Add(i.ToString()); cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbItemNo.DataSource = CutlistData.GetCutlists().Tables[0]; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbCustomer.SelectedIndex = Properties.Settings.Default.LastCustomerSelection; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); }
//private void insert_BOM() { // ModelDoc2 md = (ModelDoc2)SwApp.ActiveDoc; // DrawingDoc dd = (DrawingDoc)SwApp.ActiveDoc; // ModelDocExtension ex = (ModelDocExtension)md.Extension; // int bom_type = (int)swBomType_e.swBomType_PartsOnly; // int bom_numbering = (int)swNumberingType_e.swNumberingType_Flat; // int bom_anchor =(int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft; // SolidWorks.Interop.sldworks.View v = GetFirstView(SwApp); // if (dd.ActivateView(v.Name)) { // v.InsertBomTable4( // false, // Properties.Settings.Default.BOMLocationX, Properties.Settings.Default.BOMLocationY, // bom_anchor, // bom_type, // v.ReferencedConfiguration, // Properties.Settings.Default.BOMTemplatePath, // false, // bom_numbering, // false); // } //} /// <summary> /// Show what will be uploaded to the as a cutlist, only with hardware and other oddments filtered out. /// </summary> /// <param name="sender">Who clicked?</param> /// <param name="e">Any args?</param> private void btnLookup_Click(object sender, EventArgs e) { DataDisplay dd = new DataDisplay(); dd.swApp = _swApp; ModelDoc2 doc = (ModelDoc2)PropertySet.SwApp.ActiveDoc; CutlistData cd = PropertySet.CutlistData; string name = string.Empty; swTableType.swTableType st; try { st = new swTableType.swTableType(doc, Redbrick.MasterHashes); cd.IncrementOdometer(CutlistData.Functions.ExamineBOM); DataTable stp = (DataTable)DictToPartList(st.GetParts(Redbrick.BOMFilter), cd); dd.PathIndex = st.PathList; if (doc != null) { name = doc.GetPathName(); dd.Text = System.IO.Path.GetFileNameWithoutExtension(name) + " cutlist BOM..."; } dd.Grid.DataSource = stp; dd.ColorRows( // λ! Wooo! (r) => { if (r.Cells["Update"].Value != null) { return(r.Cells["Update"].Value.ToString().ToUpper() == "YES"); } else { return(false); } }, Color.Red, Color.Yellow ); dd.ShowDialog(); } catch (NullReferenceException nre) { if (comboBox1.SelectedValue != null) { Redbrick.InsertBOM(_swApp, (int)comboBox1.SelectedValue); } else { Redbrick.InsertBOM(_swApp); } btnLookup_Click(this, new EventArgs()); } catch (ArgumentOutOfRangeException aoore) { PropertySet.SwApp.SendMsgToUser2(@"No acceptable parts in BOM.", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } catch (Exception ex) { PropertySet.SwApp.SendMsgToUser2(ex.Message, (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } }
private void cbDescription_TextChanged(object sender, EventArgs e) { CutlistData.FilterTextForControl(cbDescription); }
/// <summary> /// Show a list of materials used. Doesn't seem overly useful. /// TODO: Make this button cool /// </summary> /// <param name="sender">Who clicked?</param> /// <param name="e">Any args?</param> private void btnMatList_Click(object sender, EventArgs e) { DataDisplay dd = new DataDisplay(); ModelDoc2 doc = (ModelDoc2)PropertySet.SwApp.ActiveDoc; CutlistData cd = PropertySet.CutlistData; string name = string.Empty; swTableType.swTableType st; try { st = new swTableType.swTableType(doc, Redbrick.MasterHashes); cd.IncrementOdometer(CutlistData.Functions.MaterialList); DataTable stp = (DataTable)DictToPartList(st.GetParts(), cd); if (doc != null) { name = doc.GetPathName(); dd.Text = "Materials/Edges used in " + System.IO.Path.GetFileNameWithoutExtension(name); } var q = (from a in stp.AsEnumerable() group a by a.Field <string>("Material") into x orderby x.Key select new { Material = x.Key, Count = x.Count() }); var r = (from a in stp.AsEnumerable() group a by a.Field <string>("EdgeFront") into x where x.Key != string.Empty orderby x.Key select new { Edging = x.Key, Count = x.Count() }); var s = (from a in stp.AsEnumerable() group a by a.Field <string>("EdgeBack") into x where x.Key != string.Empty orderby x.Key select new { Edging = x.Key, Count = x.Count() }); var t = (from a in stp.AsEnumerable() group a by a.Field <string>("EdgeLeft") into x where x.Key != string.Empty orderby x.Key select new { Edging = x.Key, Count = x.Count() }); var u = (from a in stp.AsEnumerable() group a by a.Field <string>("EdgeRight") into x where x.Key != string.Empty orderby x.Key select new { Edging = x.Key, Count = x.Count() }); var v = (from a in q select a.Material) .Union (from b in r select b.Edging) .Union (from c in s select c.Edging) .Union (from d in t select d.Edging) .Union (from f in u select f.Edging); dd.Grid.DataSource = ListToDataTable(v.ToList()); // heheheehe! dd.ColorRows((rw) => { return(rw.Cells["Material"].Value.ToString().Contains("TBD")); }, Color.Yellow, Color.Red); dd.ShowDialog(); } catch (NullReferenceException nre) { if (comboBox1.SelectedValue != null) { Redbrick.InsertBOM(_swApp, (int)comboBox1.SelectedValue); } else { Redbrick.InsertBOM(_swApp); } btnLookup_Click(this, new EventArgs()); } catch (ArgumentOutOfRangeException aoore) { PropertySet.SwApp.SendMsgToUser2(@"No acceptable parts in BOM.", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } catch (Exception ex) { PropertySet.SwApp.SendMsgToUser2(ex.Message, (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } }
private void tbComment_TextChanged(object sender, EventArgs e) { CutlistData.FilterTextForControl(tbComment); }
public DrawingProperties(SldWorks sw) { this._swApp = sw; CutlistData = new CutlistData(); this._innerArray = new ArrayList(); }
private void InitControlsWithPart(Part p, CutlistData cd) { Text = "Add to cutlist..."; for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) cbRev.Items.Add(i.ToString()); cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbRev.Enabled = false; cbItemNo.DataSource = CutlistData.GetCutlists().Tables[0]; cbItemNo.DisplayMember = "PARTNUM"; cbItemNo.ValueMember = "CLID"; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); // Not classy, but it makes the boxes update the first time around. clicked = true; CurrentCutlist = Properties.Settings.Default.CurrentCutlist; if (CurrentCutlist != 0) { cbItemNo.SelectedIndex = cbItemNo.FindString( cd.GetCutlistData(CurrentCutlist).Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString()); } }
private void Init() { CutlistData cd; if (cutlist_data != null) { cd = cutlist_data; } else { cd = new CutlistData(); } cbBy.DataSource = cd.GetAuthors().Tables[0]; cbBy.DisplayMember = "NAME"; cbBy.ValueMember = "USERNAME"; if (!Revs.Contains("REVISION " + (char)(nodeCount + 65))) { cbBy.SelectedValue = System.Environment.UserName; string theRev = "REVISION " + (char)(nodeCount + 65); Text = "Creating new " + theRev + "..."; if (nodeCount < 1) { tbDesc.Text = "RELEASED"; tbECO.Text = "NA"; } } else { string theRev = "REVISION " + (char)(nodeCount + 65); DrawingRev r = Revs.GetRev(theRev); tbECO.Text = r.Eco.Value; tbDesc.Text = r.Description.Value; cbBy.SelectedValue = cd.GetAuthorUserName(r.List.Value); System.DateTime dt = new System.DateTime(); if (DateTime.TryParse(r.Date.Value, out dt)) { dtpDate.Value = dt; } Text = "Editing " + theRev + "..."; } for (int i = 0; i < Properties.Settings.Default.RevLimit; i++) cbRev.Items.Add("A" + (char)(i + 65)); cbRev.SelectedIndex = (nodeCount); }
/// <summary> /// Directly draws from SW, assinging SwApp. Why do I have all these? /// </summary> /// <param name="md">A ModelDoc2.</param> /// <param name="cd">The Cutlist handler.</param> public void Get2(ModelDoc2 md, CutlistData cd) { Configuration cf = md.ConfigurationManager.ActiveConfiguration; CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty); CustomPropertyManager scpm; bool wasResolved; bool useCached = false; string tempval = string.Empty; string tempresval = string.Empty; if (cf != null) { scpm = md.Extension.get_CustomPropertyManager(cf.Name); } else { scpm = md.Extension.get_CustomPropertyManager(string.Empty); } int res; if (this.Global) { res = gcpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (res == (int)swCustomInfoGetResult_e.swCustomInfoGetResult_NotPresent) { Value = tempval; ResValue = tempresval; Type = (swCustomInfoType_e)gcpm.GetType2(this.Name); } else { // check in wrong place; sometimes it's there. res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (wasResolved) { Value = tempval; ResValue = tempresval; Type = (swCustomInfoType_e)gcpm.GetType2(this.Name); } } if (Type == swCustomInfoType_e.swCustomInfoNumber && Name.ToUpper().Contains("OVER")) Type = swCustomInfoType_e.swCustomInfoDouble; if (this.Name.Contains("OP")) { int tp = 0; if (int.TryParse(this._value, out tp)) { ID = _resValue; _descr = cd.GetOpAbbreviationByID(_resValue); } else { ID = cd.GetOpIDByName(_resValue).ToString(); } } } else { res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (wasResolved) { Value = tempval; ResValue = tempresval; Type = (swCustomInfoType_e)scpm.GetType2(this.Name); } if (Name.ToUpper().Contains("CUTLIST MATERIAL")) { int tp = 0; if (int.TryParse(_value, out tp)) { ID = _resValue; _value = cd.GetMaterialByID(_resValue); } else { ID = cd.GetMaterialID(_value).ToString(); } } if (Name.ToUpper().Contains("EDGE")) { int tp = 0; if (int.TryParse(_value, out tp)) { ID = _resValue; _value = cd.GetEdgeByID(_resValue); } else { ID = cd.GetEdgeID(_value).ToString(); } } } }
/// <summary> /// Directly draws from SW, assinging SwApp. Why do I have all these? /// </summary> /// <param name="md">A ModelDoc2.</param> /// <param name="cd">The Cutlist handler.</param> public void Get(ModelDoc2 md, CutlistData cd) { Configuration cf = md.ConfigurationManager.ActiveConfiguration; CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty); CustomPropertyManager scpm; bool wasResolved; bool useCached = false; string tempval = string.Empty; string tempresval = string.Empty; if (cf != null) { scpm = md.Extension.get_CustomPropertyManager(cf.Name); } else { scpm = md.Extension.get_CustomPropertyManager(string.Empty); } if (SWCustPropMgr != null) { scpm = SWCustPropMgr; } int res; res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (res == (int)swCustomInfoGetResult_e.swCustomInfoGetResult_NotPresent || tempval == string.Empty) { res = gcpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (tempval != string.Empty) { Value = tempval; ResValue = tempresval; } } else { Value = tempval; ResValue = tempresval; } if (Name.ToUpper().Contains("CUTLIST MATERIAL") || Name.ToUpper().Contains("CLID")) { int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetMaterialByID(Value); Value = ID; } else { ID = cd.GetMaterialID(Value).ToString(); Descr = Value; } } if (Name.Contains("OP")) { int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetOpAbbreviationByID(Value); } else { ID = cd.GetOpIDByName(Value).ToString(); Descr = Value; } } if (Name.ToUpper().Contains("EDGE") || (Name.ToUpper().StartsWith("E") && Name.ToUpper().EndsWith("ID"))) { int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetEdgeByID(Value); } else { ID = cd.GetEdgeID(Value).ToString(); Descr = Value; } } }
/// <summary> /// Directly draws from SW, assinging SwApp. Why do I have all these? /// </summary> /// <param name="md">A ModelDoc2.</param> /// <param name="cd">The Cutlist handler.</param> public virtual void Get(ModelDoc2 md, CutlistData cd) { Configuration cf = md.ConfigurationManager.ActiveConfiguration; CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty); CustomPropertyManager scpm; bool wasResolved; bool useCached = false; string tempval = string.Empty; string tempresval = string.Empty; if (cf != null) { scpm = md.Extension.get_CustomPropertyManager(cf.Name); } else { scpm = md.Extension.get_CustomPropertyManager(string.Empty); } if (SWCustPropMgr != null) { scpm = SWCustPropMgr; } int res; res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (res == (int)swCustomInfoGetResult_e.swCustomInfoGetResult_NotPresent || tempval == string.Empty) { res = gcpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (tempval != string.Empty) { Value = tempval; ResValue = tempresval; } } else { Value = tempval; ResValue = tempresval; } if (Name.ToUpper().Contains("CUTLIST MATERIAL") || Name.ToUpper().Contains("CLID")) { int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetMaterialByID(Value); Value = ID; } else { ID = cd.GetMaterialID(Value).ToString(); Descr = Value; } } if (Name.Contains("OP")) { int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetOpAbbreviationByID(Value); } else { ID = cd.GetOpIDByName(Value).ToString(); Descr = Value; } } if (Name.ToUpper().Contains("EDGE") || (Name.ToUpper().StartsWith("E") && Name.ToUpper().EndsWith("ID"))) { int tp = 0; if (int.TryParse(Value, out tp)) { ID = Value; Descr = cd.GetEdgeByID(Value); } else { ID = cd.GetEdgeID(Value).ToString(); Descr = Value; } } }
/// <summary> /// Directly draws from SW, assinging SwApp. Why do I have all these? /// </summary> /// <param name="md">A ModelDoc2.</param> /// <param name="cd">The Cutlist handler.</param> public void Get2(ModelDoc2 md, CutlistData cd) { Configuration cf = md.ConfigurationManager.ActiveConfiguration; CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty); CustomPropertyManager scpm; bool wasResolved; bool useCached = false; string tempval = string.Empty; string tempresval = string.Empty; if (cf != null) { scpm = md.Extension.get_CustomPropertyManager(cf.Name); } else { scpm = md.Extension.get_CustomPropertyManager(string.Empty); } int res; if (this.Global) { res = gcpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (res == (int)swCustomInfoGetResult_e.swCustomInfoGetResult_NotPresent) { Value = tempval; ResValue = tempresval; Type = (swCustomInfoType_e)gcpm.GetType2(this.Name); } else // check in wrong place; sometimes it's there. { res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (wasResolved) { Value = tempval; ResValue = tempresval; Type = (swCustomInfoType_e)gcpm.GetType2(this.Name); } } if (Type == swCustomInfoType_e.swCustomInfoNumber && Name.ToUpper().Contains("OVER")) { Type = swCustomInfoType_e.swCustomInfoDouble; } if (this.Name.Contains("OP")) { int tp = 0; if (int.TryParse(this._value, out tp)) { ID = _resValue; _descr = cd.GetOpAbbreviationByID(_resValue); } else { ID = cd.GetOpIDByName(_resValue).ToString(); } } } else { res = scpm.Get5(Name, useCached, out tempval, out tempresval, out wasResolved); if (wasResolved) { Value = tempval; ResValue = tempresval; Type = (swCustomInfoType_e)scpm.GetType2(this.Name); } if (Name.ToUpper().Contains("CUTLIST MATERIAL")) { int tp = 0; if (int.TryParse(_value, out tp)) { ID = _resValue; _value = cd.GetMaterialByID(_resValue); } else { ID = cd.GetMaterialID(_value).ToString(); } } if (Name.ToUpper().Contains("EDGE")) { int tp = 0; if (int.TryParse(_value, out tp)) { ID = _resValue; _value = cd.GetEdgeByID(_resValue); } else { ID = cd.GetEdgeID(_value).ToString(); } } } }
private void xInitControlsWithPart(Part p, CutlistData cd, string itemNo, string Rev) { for (int i = 100; i < 100 + Properties.Settings.Default.RevNoLimit; i++) cbRev.Items.Add(i.ToString()); cbRev.SelectedIndex = 0; btnCreate.Text = "Add"; part = p; CutlistData = cd; cbCustomer.DataSource = CutlistData.Customers.Tables[0]; cbCustomer.DisplayMember = "CUSTOMER"; cbCustomer.ValueMember = "CUSTID"; cbSetupBy.DataSource = CutlistData.GetAuthors().Tables[0]; cbSetupBy.DisplayMember = "NAME"; cbSetupBy.ValueMember = "UID"; cbSetupBy.SelectedValue = CutlistData.GetCurrentAuthor(); DataSet dr = CutlistData.GetCutlistData(itemNo, Rev); cbCustomer.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.CUSTID].ToString()); cbItemNo.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.PARTNUM].ToString(); cbDescription.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DESCR].ToString(); tbL.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.LENGTH].ToString(); tbW.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.WIDTH].ToString(); tbH.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.HEIGHT].ToString(); cbDrawingReference.Text = dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.DRAWING].ToString(); cbSetupBy.SelectedValue = int.Parse(dr.Tables[0].Rows[0][(int)CutlistData.CutlistDataFields.SETUP_BY].ToString()); }
int taskpaneView_TaskPaneToolbarButtonClicked(int ButtonIndex) { switch (ButtonIndex) { case 0: taskpaneHost.Write(); if (Properties.Settings.Default.MakeSounds) System.Media.SystemSounds.Beep.Play(); break; case 1: RedbrickConfiguration rbc = new RedbrickConfiguration(); rbc.ShowDialog(); taskpaneHost.ConnectSelection(); break; case 2: taskpaneHost.ReStart(); break; case 3: CutlistData cd = new CutlistData(); cd.IncrementOdometer(CutlistData.Functions.ArchivePDF); cd.Dispose(); cd = null; ArchivePDF.csproj.ArchivePDFWrapper apw = new ArchivePDF.csproj.ArchivePDFWrapper(swApp, GeneratePathSet()); apw.Archive(); break; case 4: System.Diagnostics.Process.Start(Properties.Settings.Default.UsageLink); break; default: break; } return 1; }
private void btnOK_Click(object sender, EventArgs e) { DrawingRev r = null; swCustomInfoType_e tType = swCustomInfoType_e.swCustomInfoText; SwProperty rev = new SwProperty("REVISION " + (char)(nodeCount + 65), tType, cbRev.Text, true); SwProperty eco = new SwProperty("ECO " + (nodeCount + 1).ToString(), tType, tbECO.Text, true); // I usually only apply this filter on insertion, but this field is only ever // displayed on drawings. We only want all caps for that as well. SwProperty desc = new SwProperty("DESCRIPTION " + (nodeCount + 1).ToString(), tType, CutlistData.FilterString(tbDesc.Text, Properties.Settings.Default.FlameWar), true); cbBy.ValueMember = "INITIAL"; SwProperty list; if (cbBy.SelectedValue != null) { list = new SwProperty("LIST " + (nodeCount + 1).ToString(), tType, (cbBy.SelectedValue as string).Substring(0, 2), true); } else { list = new SwProperty("LIST " + (nodeCount + 1).ToString(), tType, string.Empty, true); } SwProperty date = new SwProperty("DATE " + (nodeCount + 1).ToString(), tType, dtpDate.Value.ToShortDateString(), true); if (Revs.Contains("REVISION " + (char)(nodeCount + 65))) { r = Revs.GetRev("REVISION " + (char)(nodeCount + 65)); r.Revision = rev; r.Eco = eco; r.Description = desc; r.List = list; r.Date = date; } else { r = new DrawingRev(rev, eco, desc, list, date); Revs.Add(r); } r.SwApp = Revs.SwApp; if (new_rev) { try { AddECRItem(r); } catch (Exception ex) { r.SwApp.SendMsgToUser2(ex.Message, (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk); } } this.Close(); }