/// <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; }