/// <summary> /// This will be called when a Formular is changed in the registry, to make all affected nodes comply with potential re-configuration /// </summary> /// <param name="sender">Usually Context</param> /// <param name="e">Contains the new Formular</param> protected virtual void FormularRemotelyChanged(MessageFormularRegistry sender, MessageFormular formular) { if (FFormularSelection.IsAnyInvalid()) { return; // before and during first frame input pins might not be valid yet } if (formular.IsDynamic) { return; } if (FFormularSelection[0] == formular.Name) { formular = formular.Clone() as MessageFormular; // keep a copy if (CustomizeFormular) { formular.Require(RequireEnum.NoneBut, Formular); // never automatically add anything. e.g never add pins without user consent } else { formular.Require(RequireEnum.All); // always add all. } Formular = formular; } }
/// <summary> /// /// </summary> /// <param name="newFormular"></param> /// <param name="append"></param> /// private void UpdateWindow(MessageFormular newFormular, bool append = false) { if (newFormular == null) { return; } var old = LayoutPanel.Formular; // retrieve copy newFormular = newFormular.Clone() as MessageFormular; // act on copy if (append) { // overwrite all existing fields, and hand back the result foreach (var field in newFormular.FieldDescriptors) { old[field.Name] = field; // hard overwrite } old.Require(RequireEnum.NoneButBoth, newFormular); old.Name = newFormular.Name; newFormular = old; } else { newFormular.Require(RequireEnum.NoneButBoth, old); } LayoutPanel.Changed -= ReadLayoutPanel; LayoutPanel.Formular = newFormular; LayoutPanel.Changed += ReadLayoutPanel; LayoutPanel.CanEditFields = newFormular.IsDynamic; }
/// <summary> /// This will be called when a Formular is changed in the registry, to make all affected nodes comply with potential re-configuration /// </summary> /// <param name="sender">Usually Context</param> /// <param name="e">Contains the new Formular</param> protected virtual void FormularRemotelyChanged(MessageFormularRegistry sender, MessageFormular formular) { if (FFormularSelection.IsAnyInvalid()) { return; // before and during first frame input pins might not be valid yet } if (formular.IsDynamic) { return; } if (FFormularSelection[0] == formular.Name) { formular = RetrieveAdoptedFormular(formular.Name); if (!CustomizeFormular) { formular.Require(RequireEnum.All); // always add all. } Formular = formular; } }
private MessageFormular RetrieveAdoptedFormular(string formularName) { MessageFormular reg; try { reg = RetrieveRegisteredFormular(formularName); } catch (RegistryException) { reg = new MessageFormular(MessageFormular.DYNAMIC, FConfig[0]); // i.e. not found. might happen during first frame } reg.Require(RequireEnum.NoneBut, Formular); var formular = new MessageFormular(formularName, ""); // all required fields, in order as the old one // overwrites any type differences, or sizes var oldNames = Formular.FieldNames.ToList(); var required = reg.FieldDescriptors.Where(f => f.IsRequired).OrderBy(f => oldNames.IndexOf(f.Name)); foreach (var field in required) { formular.Append(field, true); } // all non-required fields, in order as from registry var extraNames = reg.FieldNames.ToList(); var extra = reg.FieldDescriptors.Where(f => !f.IsRequired).OrderBy(f => extraNames.IndexOf(f.Name)); foreach (var field in extra) { formular.Append(field, false); } return(formular); }
/// <summary> /// /// </summary> /// <param name="newFormular"></param> /// <param name="append"></param> /// private void UpdateWindow(MessageFormular newFormular, bool append = false) { if (newFormular == null) return; var old = LayoutPanel.Formular; // retrieve copy newFormular = newFormular.Clone() as MessageFormular; // act on copy if (append) { // overwrite all existing fields, and hand back the result foreach (var field in newFormular.FieldDescriptors) { old[field.Name] = field; // hard overwrite } old.Require(RequireEnum.NoneButBoth, newFormular); old.Name = newFormular.Name; newFormular = old; } else { newFormular.Require(RequireEnum.NoneButBoth, old); } LayoutPanel.Changed -= ReadLayoutPanel; LayoutPanel.Formular = newFormular; LayoutPanel.Changed += ReadLayoutPanel; LayoutPanel.CanEditFields = newFormular.IsDynamic; }
/// <summary> /// This will be called when a Formular is changed in the registry, to make all affected nodes comply with potential re-configuration /// </summary> /// <param name="sender">Usually Context</param> /// <param name="e">Contains the new Formular</param> protected virtual void FormularRemotelyChanged(MessageFormularRegistry sender, MessageFormular formular) { if (FFormularSelection.IsAnyInvalid()) return; // before and during first frame input pins might not be valid yet if (formular.IsDynamic) return; if (FFormularSelection[0] == formular.Name) { formular = formular.Clone() as MessageFormular; // keep a copy if (CustomizeFormular) formular.Require(RequireEnum.NoneBut, Formular); // never automatically add anything. e.g never add pins without user consent else formular.Require(RequireEnum.All); // always add all. Formular = formular; } }