/// <summary> /// Check for an existing hash. We basically want it to be fresh every time. /// This would be a good place to abuse the Redbrick, if you had a mind to. /// </summary> private void AddHash() { System.IO.FileInfo fi; try { if (!string.IsNullOrWhiteSpace(Document.GetPathName())) { fi = new System.IO.FileInfo(Document.GetPathName()); prop.PartFileInfo = fi; if (!prop.Contains("CRC32")) { prop.Hash = Redbrick.GetHash(string.Format("{0}\\{1}", prop.PartFileInfo.Directory.FullName, prop.PartFileInfo.Name)); SwProperty p = new SwProperty("CRC32", swCustomInfoType_e.swCustomInfoNumber, prop.Hash.ToString(), true); p.Old = false; prop.Add(p); } else { } } else { //this.prop.PartName = "New Document"; // <-- stack overflow? weird } } catch (ArgumentException ae) { prop.PartName = ae.HResult.ToString(); } catch (Exception e) { prop.PartName = e.HResult.ToString(); } }
public void Update(ref SwProperties p) { dirtTracker.Besmirched -= dirtTracker_Besmirched; //if (ch.CutlistComboBox.SelectedItem != null && ch.RevComboBox.Text != string.Empty) { // Properties.Settings.Default.CurrentCutlist = int.Parse((ch.CutlistComboBox.SelectedItem as DataRowView)[0].ToString()); // Properties.Settings.Default.CurrentRev = int.Parse(ch.RevComboBox.Text); // Properties.Settings.Default.Save(); //} TearDownDeptSelectEvent(); // Order matters here. The first thing SwProperties does informs what ds // does. Ds informs these other guys. props = p; ds.Update(ref p); cs.Update(ref p); gbSpecProp.Text = p.PartName + " - " + p.configName; gp.Update(ref p); op.Update(ref p); mp.Update(ref p, cs.EdgeDiffL, cs.EdgeDiffW); //ch.Update(ref p); if (props.PartFileInfo != null) { int hash = Redbrick.GetHash(string.Format("{0}\\{1}", props.PartFileInfo.Directory.FullName, props.PartFileInfo.Name)); if (int.Parse(props.GetProperty("CRC32").Value) != hash) { props.GetProperty("CRC32").Value = hash.ToString(); } } SetupDeptSelectEvent(); IsDirty = false; dirtTracker.Besmirched += dirtTracker_Besmirched; }
/// <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); }
private void Init() { cbDepartment.ValueMember = "TYPEID"; cbDepartment.DisplayMember = "TYPEDESC"; cbDepartment.DataSource = this.PropertySet.cutlistData.OpTypes.Tables[0]; cbDepartment.SelectedIndexChanged += cbDepartment_SelectedIndexChanged; Selected = new DepartmentSelected(OnSelected); Redbrick.unselect(this.Controls); }
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 { // } }
private double WorkDays() { System.IO.FileInfo pi = new System.IO.FileInfo(Properties.Settings.Default.InstallerNetworkPath); odometerStart = Redbrick.GetOdometerStart(pi.DirectoryName + @"\version.xml"); DateTime end = DateTime.Now; int dowStart = ((int)odometerStart.DayOfWeek == 0 ? 7 : (int)odometerStart.DayOfWeek); int dowEnd = ((int)end.DayOfWeek == 0 ? 7 : (int)end.DayOfWeek); TimeSpan tSpan = end - odometerStart; if (dowStart <= dowEnd) { return(((tSpan.Days / 7) * 5) + Math.Max((Math.Min((dowEnd + 1), 6) - dowStart), 0)); } return(((tSpan.Days / 7) * 5) + Math.Min((dowEnd + 6) - Math.Min(dowStart, 6), 5)); }
/// <summary> /// Add/Update a cutlist. /// </summary> /// <param name="sender">Who clicked?</param> /// <param name="e">Any args?</param> private void button1_Click(object sender, EventArgs e) { string descr = get_description(Redbrick.GetFirstView(_swApp)); if (comboBox1.SelectedItem == null) { CutlistHeaderInfo chi = new CutlistHeaderInfo(PropertySet, descr, _swApp); ShowCutlistHeaderInfo(chi); } else { CutlistHeaderInfo chi = new CutlistHeaderInfo(PropertySet, descr, (int)comboBox1.SelectedValue, _swApp); ShowCutlistHeaderInfo(chi); } FillBoxes(); }
private void label6_Click(object sender, EventArgs e) { string clipping = string.Format("{0} X {1}", tbBlankL.Text, tbBlankW.Text); Redbrick.Clip(clipping); }
/// <summary> /// Gotta manually unselect programatically selected ComboBoxes. Why? I dunno. /// </summary> public void unselect() { Redbrick.unselect(tableLayoutPanel2.Controls); Redbrick.unselect(tableLayoutPanel3.Controls); Redbrick.unselect(tableLayoutPanel5.Controls); }
/// <summary> /// Send leRColor contents to clipboard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void leRColor_Click(object sender, EventArgs e) { Redbrick.Clip(leRColor.Text); }
/// <summary> /// Send lMat contents to clipboard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lMat_Click(object sender, EventArgs e) { Redbrick.Clip(cbMat.Text); }
/// <summary> /// Send lEf contents to clipboard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lEf_Click(object sender, EventArgs e) { Redbrick.Clip(cbEf.Text); }
/// <summary> /// Send label1 contents to clipboard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void label1_Click(object sender, EventArgs e) { Redbrick.Clip(cbCutlist.Text.Split(new string[] { "REV" }, StringSplitOptions.None)[0].Trim()); }
private void label5_Click(object sender, EventArgs e) { Redbrick.Clip(tbOverW.Text); }
private void label2_Click(object sender, EventArgs e) { Redbrick.Clip(tbCNC2.Text); }
/// <summary> /// Copy label content to the clipboard. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void label4_Click(object sender, EventArgs e) { Redbrick.Clip(label4.Text.Split(new string[] { " - " }, StringSplitOptions.None)[0]); }
//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); } }
/// <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); } }
void gbSpecProp_Click(object sender, EventArgs e) { Redbrick.Clip(gbSpecProp.Text.Split(new char[] { ' ' })[0]); }