#pragma warning restore protected override IOAttribute DefinePin(FormularFieldDescriptor configuration) { var attr = new InputAttribute(configuration.Name); attr.BinVisibility = PinVisibility.Hidden; attr.BinSize = configuration.DefaultSize; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; return attr; }
protected override IOAttribute DefinePin(FormularFieldDescriptor field) { var attr = new OutputAttribute("Field"); attr.BinVisibility = PinVisibility.Hidden; attr.Order = 1; attr.BinOrder = 3; attr.AutoFlush = false; // need to sync all pins manually return(attr); }
protected override IOAttribute SetPinAttributes(FormularFieldDescriptor configuration) { var attr = new OutputAttribute(configuration.Name); attr.BinVisibility = PinVisibility.Hidden; attr.AutoFlush = false; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; return(attr); }
#pragma warning restore protected override IOAttribute DefinePin(FormularFieldDescriptor configuration) { var attr = new InputAttribute(configuration.Name); attr.BinVisibility = PinVisibility.Hidden; attr.BinSize = configuration.DefaultSize; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; return(attr); }
protected override IOAttribute SetPinAttributes(FormularFieldDescriptor field) { var attr = new InputAttribute(field.Name); attr.BinVisibility = PinVisibility.Hidden; attr.BinSize = field.DefaultSize; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; attr.CheckIfChanged = true; return(attr); }
#pragma warning restore protected override IOAttribute DefinePin(FormularFieldDescriptor field) { var attr = new InputAttribute("Field"); attr.BinVisibility = PinVisibility.Hidden; attr.Order = 4; attr.BinOrder = 5; attr.BinSize = 1; attr.CheckIfChanged = true; return(attr); }
protected override void OnMouseDoubleClick(MouseEventArgs e) { if (!CanEditFields) { return; } var desc = new FormularFieldDescriptor("string Foo"); desc.IsRequired = false; var field = AddNewFieldPanel(desc); field.CanEdit = true; }
protected override IOAttribute SetPinAttributes(FormularFieldDescriptor field) { var attr = new InputAttribute(field.Name); attr.BinVisibility = PinVisibility.Hidden; attr.BinSize = field.DefaultSize; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; attr.CheckIfChanged = false; // very lazy inputs. only do something when New is hit. attr.AutoValidate = false; return attr; }
/// <summary> /// Creates a binsized pin according to the information in the desciptor. Ignores IsRequired. /// </summary> /// <param name="field"></param> /// <exception cref="InvalidComObjectException">PluginInterface: Internal COM disconnect</exception> /// <returns>The container around the pin.</returns> protected virtual IIOContainer CreatePin(FormularFieldDescriptor field) { IOAttribute attr = SetPinAttributes(field); // each implementation of DynamicPinsNode must create its own InputAttribute or OutputAttribute ( Type pinType = typeof(ISpread <>).MakeGenericType((typeof(ISpread <>)).MakeGenericType(field.Type)); // the Pin is always a binsized one IIOContainer pin = null; pin = FPins[field.Name] = FIOFactory.CreateIOContainer(pinType, attr); DynPinCount += 2; // total pincount. always add two to account for data pin and binsize pin return(pin); }
#pragma warning restore protected override IOAttribute SetPinAttributes(FormularFieldDescriptor field) { var attr = new InputAttribute(field.Name); attr.BinVisibility = PinVisibility.Hidden; attr.BinSize = field.DefaultSize; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; attr.CheckIfChanged = false; // very lazy inputs. only do something when New is hit. attr.AutoValidate = false; return(attr); }
private FieldPanel AddNewFieldPanel(FormularFieldDescriptor desc) { var field = new FieldPanel(desc); field.CanEdit = CanEditFields; Controls.Add(field); field.Locked = Locked; field.Change += (sender, args) => { if (Changed != null) { Changed(this, Formular); } }; return(field); }
protected virtual void OnChange(EventArgs e) { var oldDescription = _descriptor == null ? "" : _descriptor.ToString(); // failsafe if (!CanEdit) { Description = oldDescription; // stick to the plan! Invalidate(); return; } // generate new Descriptor, if (manual) description from textbox does not match if (oldDescription != Description) { try { var desc = new FormularFieldDescriptor(Description); // assume this is even a wanted pin, so autocheck desc.IsRequired = true; Descriptor = desc; if (Change != null && !IsFaulty) { Change(this, e); } } catch (ParseFormularException) { IsFaulty = true; } Invalidate(); } }
protected override IOAttribute DefinePin(FormularFieldDescriptor field) { var attr = new OutputAttribute("Field"); attr.BinVisibility = PinVisibility.Hidden; attr.Order = 1; attr.BinOrder = 2; attr.AutoFlush = false; // need to sync all pins manually return attr; }
public DuplicateFieldException(string text, FormularFieldDescriptor fresh, FormularFieldDescriptor old) : base(text) { this.Fresh = fresh; this.Old = old; }
protected abstract IOAttribute SetPinAttributes(FormularFieldDescriptor config);
/// <summary> /// Creates a binsized pin according to the information in the desciptor. Ignores IsRequired. /// </summary> /// <param name="field"></param> /// <exception cref="InvalidComObjectException">PluginInterface: Internal COM disconnect</exception> /// <returns>The container around the pin.</returns> protected virtual IIOContainer CreatePin(FormularFieldDescriptor field) { IOAttribute attr = SetPinAttributes(field); // each implementation of DynamicPinsNode must create its own InputAttribute or OutputAttribute ( Type pinType = typeof(ISpread<>).MakeGenericType((typeof(ISpread<>)).MakeGenericType(field.Type)); // the Pin is always a binsized one IIOContainer pin = null; pin = FPins[field.Name] = FIOFactory.CreateIOContainer(pinType, attr); DynPinCount += 2; // total pincount. always add two to account for data pin and binsize pin return pin; }
protected override IIOContainer CreatePin(FormularFieldDescriptor field) { LayoutChanged = true; // this forces Evaluate to push data to output, even though no new messages got pushed return(base.CreatePin(field)); }
private FieldPanel AddNewFieldPanel(FormularFieldDescriptor desc) { var field = new FieldPanel(desc); field.CanEdit = CanEditFields; Controls.Add(field); field.Locked = Locked; field.Change += (sender, args) => { if (Changed != null) Changed(this, Formular); }; return field; }
protected virtual void OnChange(EventArgs e) { var oldDescription = _descriptor == null ? "" : _descriptor.ToString(); // failsafe if (!CanEdit) { Description = oldDescription; // stick to the plan! Invalidate(); return; } // generate new Descriptor, if (manual) description from textbox does not match if (oldDescription != Description) { try { var desc = new FormularFieldDescriptor(Description); // assume this is even a wanted pin, so autocheck desc.IsRequired = true; Descriptor = desc; if (Change != null && !IsFaulty) Change(this, e); } catch (ParseFormularException) { IsFaulty = true; } Invalidate(); } }
protected override IIOContainer CreatePin(FormularFieldDescriptor field) { LayoutChanged = true; // this forces Evaluate to push data to output, even though no new messages got pushed return base.CreatePin(field); }
public void Evaluate(int SpreadMax) { if (FConfiguration.IsAnyInvalid() || FName.IsAnyInvalid()) return; ForceUpdate |= !FUpdate.IsAnyInvalid() && FUpdate[0]; var change = ForceUpdate || FInherits.IsChanged || FName.IsChanged || FConfiguration.IsChanged; if (!ForceUpdate && !change) { if (_lastException != null) { FError.FlushItem(_lastException.ToString()); throw _lastException; } } // untoggle exception. if (_lastException != null) { var tmp = _lastException; FError.FlushItem(_lastException.ToString()); _lastException = null; // assume innocence throw tmp; } if (!change && !ForceUpdate) return; FOutput.SliceCount = SpreadMax = FName.SliceCount; var id = this.PluginHost.GetNodePath(false); var reg = MessageFormularRegistry.Context; for (int i = 0; i < SpreadMax; i++) { if (string.IsNullOrWhiteSpace(FName[i])) { _lastException = new ParseFormularException("A Formular cannot have an empty Name."); return; } var config = string.Join(", ", FConfiguration[i]).Split(','); var fields = new List<FormularFieldDescriptor>(); foreach (var def in config) { FormularFieldDescriptor field; try { field = new FormularFieldDescriptor(def.Trim(), true); } catch (ParseFormularException e) { _lastException = e; return; } var match = ( from f in fields where f.Name == field.Name select f ).FirstOrDefault(); if (match != null) { _lastException = new DuplicateFieldException("Cannot add \"" + def + "\" in Formular for [" + FName[i] + "]. Field with the same name already defined.", match, field); return; } else fields.Add(field); } var formular = new MessageFormular(FName[i], fields); if (!FInherits.IsAnyInvalid()) { // flatten var allFields = ( from form in FInherits from field in form.FieldDescriptors select field ).Distinct(); foreach (var field in allFields) { if (!formular.CanAppend(field)) { var duplicate = formular[field.Name]; _lastException = new DuplicateFieldException("Cannot add new Field \"" + field.ToString() + "\" to Formular [" + formular.Name + "]. Field is already defined as \"" + duplicate.ToString() + "\".", field, duplicate); return; } else { try { formular.Append(field, true); } catch (DuplicateFieldException e) { _lastException = e; return; } } } } // only register, when update has been hit! if (ForceUpdate) try { var defined = reg.Define(id, formular); // will raise Change events to inform all formularable nodes if (defined) FOutput[i] = formular; } catch (RegistryException e) { _lastException = e; return; } catch (ArgumentNullException e) { _lastException = e; return; } } // only register, when update has been hit! if (ForceUpdate) { foreach (var form in reg.GetFormularsFrom(id).ToList()) { if (!FName.Contains(form.Name)) reg.Undefine(id, form); } FOutput.Flush(); EnumManager.UpdateEnum(MessageFormularRegistry.RegistryName, reg.AllFormularNames.First(), reg.AllFormularNames.ToArray()); } ForceUpdate = false; }
protected abstract IOAttribute DefinePin(FormularFieldDescriptor field);
public FieldPanel(FormularFieldDescriptor descriptor) : this() { Descriptor = descriptor; }
protected override IOAttribute SetPinAttributes(FormularFieldDescriptor field) { var attr = new InputAttribute(field.Name); attr.BinVisibility = PinVisibility.Hidden; attr.BinSize = field.DefaultSize; attr.Order = DynPinCount; attr.BinOrder = DynPinCount+1; attr.CheckIfChanged = true; return attr; }
public void Evaluate(int SpreadMax) { if (FConfiguration.IsAnyInvalid() || FName.IsAnyInvalid()) { return; } ForceUpdate |= !FUpdate.IsAnyInvalid() && FUpdate[0]; var change = ForceUpdate || FInherits.IsChanged || FName.IsChanged || FConfiguration.IsChanged; if (!ForceUpdate && !change) { if (_lastException != null) { FError.FlushItem(_lastException.ToString()); throw _lastException; } } // untoggle exception. if (_lastException != null) { var tmp = _lastException; FError.FlushItem(_lastException.ToString()); _lastException = null; // assume innocence throw tmp; } if (!change && !ForceUpdate) { return; } FOutput.SliceCount = SpreadMax = FName.SliceCount; var id = this.PluginHost.GetNodePath(false); var reg = MessageFormularRegistry.Context; for (int i = 0; i < SpreadMax; i++) { if (string.IsNullOrWhiteSpace(FName[i])) { _lastException = new ParseFormularException("A Formular cannot have an empty Name."); return; } var config = string.Join(", ", FConfiguration[i]).Split(','); var fields = new List <FormularFieldDescriptor>(); foreach (var def in config) { FormularFieldDescriptor field; try { field = new FormularFieldDescriptor(def.Trim(), true); } catch (ParseFormularException e) { _lastException = e; return; } var match = ( from f in fields where f.Name == field.Name select f ).FirstOrDefault(); if (match != null) { _lastException = new DuplicateFieldException("Cannot add \"" + def + "\" in Formular for [" + FName[i] + "]. Field with the same name already defined.", match, field); return; } else { fields.Add(field); } } var formular = new MessageFormular(FName[i], fields); if (!FInherits.IsAnyInvalid()) { // flatten var allFields = ( from form in FInherits from field in form.FieldDescriptors select field ).Distinct(); foreach (var field in allFields) { if (!formular.CanAppend(field)) { var duplicate = formular[field.Name]; _lastException = new DuplicateFieldException("Cannot add new Field \"" + field.ToString() + "\" to Formular [" + formular.Name + "]. Field is already defined as \"" + duplicate.ToString() + "\".", field, duplicate); return; } else { try { formular.Append(field, true); } catch (DuplicateFieldException e) { _lastException = e; return; } } } } // only register, when update has been hit! if (ForceUpdate) { try { var defined = reg.Define(id, formular); // will raise Change events to inform all formularable nodes if (defined) { FOutput[i] = formular; } } catch (RegistryException e) { _lastException = e; return; } }
protected override void OnMouseDoubleClick(MouseEventArgs e) { if (!CanEditFields) return; var desc = new FormularFieldDescriptor("string Foo"); desc.IsRequired = false; var field = AddNewFieldPanel(desc); field.CanEdit = true; }
protected override IOAttribute SetPinAttributes(FormularFieldDescriptor configuration) { var attr = new OutputAttribute(configuration.Name); attr.BinVisibility = PinVisibility.Hidden; attr.AutoFlush = false; attr.Order = DynPinCount; attr.BinOrder = DynPinCount + 1; return attr; }
protected override IOAttribute DefinePin(FormularFieldDescriptor field) { var attr = new InputAttribute("Field"); attr.BinVisibility = PinVisibility.Hidden; attr.Order = 4; attr.BinOrder = 5; attr.BinSize = 1; attr.CheckIfChanged = true; return attr; }