private DatumList m_Changed = new DatumList(); // list of the ones which have changed internal void WrittenToCurrent() { if (!m_Changed.Contains(m_Config)) { m_Changed.Add(m_Config); } }
public void lnkShare_Click(object sender, EventArgs e) { if (m_Style.IsShared) { // The link is un-sharing. need to detect if any buttons except this one use this style m_Button.SetStyleObject(null); DatumList list = new DatumList(); Globals.Root.CurrentDocument.IterateEx(obj => obj.AddRequiredReferences(list.Add, Mapping.Ignore), false, false); m_Button.SetStyleObject(m_OriginalStyle); // either way we put the object back in the button itself in case the user cancels this screen if (list.Contains(m_Style) || m_Style.IsUserDefault) { // this style is referenced elsewhere. Need to make a copy ButtonStyle newStyle = (ButtonStyle)m_Style.Clone(Mapping.Ignore); newStyle.Name = ""; newStyle.IsShared = false; m_Style = newStyle; } else { // this style is not used elsewhere; we can just make it shared m_Style.IsShared = false; Globals.Root.CurrentDocument.RemoveButtonStyle(m_Style); // can keep the name } } else // otherwise we are sharing a previously custom style { string name = frmButtonStyleName.Display(m_Style); // Name will only be set if this was previously shared if (string.IsNullOrEmpty(name)) { return; } m_Style.IsShared = true; m_Style.Name = name; m_Transaction.Edit(Globals.Root.CurrentDocument); Globals.Root.CurrentDocument.AddButtonStyle(m_Style); } FillStylesList(); ReflectCustomState(); ctrStyle.DisplayStyle(m_Style); }