public Object( IPropertyComponent property, IMethodComponent method, IFieldComponent field, IConstructorComponent constructor, ITransposeComponent transformation, IAttributeComponent attribute, IDynamicComponent dynamicComponent, IEqualityComponent equality) { if (property == null) { throw new ArgumentNullException("property"); } if (method == null) { throw new ArgumentNullException("method"); } if (field == null) { throw new ArgumentNullException("field"); } if (constructor == null) { throw new ArgumentNullException("constructor"); } if (transformation == null) { throw new ArgumentNullException("transformation"); } if (attribute == null) { throw new ArgumentNullException("attribute"); } if (dynamicComponent == null) { throw new ArgumentNullException("dynamicComponent"); } if (equality == null) { throw new ArgumentNullException("equality"); } _property = property; _field = field; _method = method; _transformation = transformation; _constructor = constructor; _attribute = attribute; _dynamic = dynamicComponent; _equality = equality; }
public override void HoverOut(Point offset, Point position) { if (this._HoverComponent != null) { this._HoverComponent?.HoverOut(GetMyOffset(offset), position); this._HoverComponent = null; } }
protected virtual void UpdateFocus(IDynamicComponent component) { if (this._FocusComponent != component) { this._FocusComponent?.FocusLost(); this._FocusComponent = component; component?.FocusGained(); } }
protected bool GetTarget(Point offset, Point position, out IDynamicComponent component) { component = null; foreach (IDynamicComponent comp in this._EventComponents) { if (comp.Visible && comp.Enabled && comp.InBounds(offset, position)) { component = comp; return(true); } } return(false); }
private void UpdateFocus(IDynamicComponent component) { if (this._FocusComponent != component) { this._FocusComponent?.FocusLost(); if (this._FocusComponent is IInputComponent) { KeyboardResolver.CharReceived -= this.ReceiveInput; } this._FocusComponent = component; component?.FocusGained(); if (component is IInputComponent) { KeyboardResolver.CharReceived += this.ReceiveInput; } } }
public bool TabBack() { if (this.FocusComponent == null) { if (this.EventComponents.Count == 0) { return(false); } this.FocusComponent = this.EventComponents[0]; } else if (!(this.FocusComponent is IComponentContainer) || !((IComponentContainer)this.FocusComponent).TabBack()) { int index = this.EventComponents.IndexOf(this.FocusComponent) - 1; if (index < 0) { index = this.EventComponents.Count - 1; } this.FocusComponent = this.EventComponents[index]; } return(true); }
public bool TabNext() { if (this.FocusComponent == null) { if (this.EventComponents.Count == 0) { return(false); } this.FocusComponent = this.EventComponents[0]; } else if (!(this.FocusComponent is IComponentContainer) || !(this.FocusComponent as IComponentContainer).TabNext()) { int index = this.EventComponents.IndexOf(this.FocusComponent) + 1; if (index >= this.EventComponents.Count) { index = 0; } this.FocusComponent = this.EventComponents[index]; } return(true); }
public override void HoverOver(Point offset, Point position) { var myOffset = GetMyOffset(offset); if (GetTarget(myOffset, position, out IDynamicComponent component)) { if (component == this._HoverComponent) { component.HoverOver(myOffset, position); } else { this._HoverComponent?.HoverOut(myOffset, position); this._HoverComponent = component; component.HoverIn(myOffset, position); } } else if (this._HoverComponent != null) { this._HoverComponent?.HoverOut(myOffset, position); this._HoverComponent = null; } }
private bool GetTarget(Point offset, Point position, out IDynamicComponent component, out bool floating) { component = null; floating = false; if ((this._FocusComponent as IFloatComponent)?.FloatComponent?.InBounds(offset, position) == true) { floating = true; component = (this._FocusComponent as IFloatComponent).FloatComponent; return(true); } else { foreach (IDynamicComponent comp in this._EventComponents) { if (comp.Visible && comp.Enabled && comp.InBounds(offset, position)) { floating = false; component = comp; return(true); } } } return(false); }
/********* ** Public methods *********/ public abstract bool HasFocus(IDynamicComponent component);
/// <summary> /// Загрузить представление из потока /// </summary> public override void LoadFromStream(Stream stream) { // очистка представления Clear(); // загрузка XML-документа XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(stream); // проверка формата файла (потока) XmlElement rootElem = xmlDoc.DocumentElement; if (!rootElem.Name.Equals("SchemeView", StringComparison.OrdinalIgnoreCase)) { throw new ScadaException(SchemePhrases.IncorrectFileFormat); } // загрузка документа схемы XmlNode documentNode = rootElem.SelectSingleNode("Document") ?? rootElem.SelectSingleNode("Scheme"); if (documentNode != null) { SchemeDoc.LoadFromXml(documentNode); // загрузка заголовка схемы для старого формата if (SchemeDoc.Title == "") { SchemeDoc.Title = rootElem.GetAttribute("title"); } // установка заголовка представления Title = SchemeDoc.Title; // загрузка фильтра по входным каналам для старого формата XmlNode cnlsFilterNode = rootElem.SelectSingleNode("CnlsFilter"); if (cnlsFilterNode != null) { SchemeDoc.CnlFilter.ParseCnlFilter(cnlsFilterNode.InnerText); } // добавление входных каналов представления foreach (int cnlNum in SchemeDoc.CnlFilter) { AddCnlNum(cnlNum); } } // загрузка компонентов схемы XmlNode componentsNode = rootElem.SelectSingleNode("Components") ?? rootElem.SelectSingleNode("Elements"); if (componentsNode != null) { HashSet <string> errNodeNames = new HashSet <string>(); // имена узлов незагруженных компонентов CompManager compManager = CompManager.GetInstance(); LoadErrors.AddRange(compManager.LoadErrors); foreach (XmlNode compNode in componentsNode.ChildNodes) { // создание компонента string errMsg; BaseComponent component = compManager.CreateComponent(compNode, out errMsg); if (component == null) { component = new UnknownComponent() { XmlNode = compNode }; if (errNodeNames.Add(compNode.Name)) { LoadErrors.Add(errMsg); } } // загрузка компонента и добавление его в представление component.SchemeDoc = SchemeDoc; component.LoadFromXml(compNode); Components[component.ID] = component; // добавление входных каналов представления if (component is IDynamicComponent) { IDynamicComponent dynamicComponent = (IDynamicComponent)component; AddCnlNum(dynamicComponent.InCnlNum); AddCtrlCnlNum(dynamicComponent.CtrlCnlNum); } // определение макс. идентификатора компонентов if (component.ID > maxComponentID) { maxComponentID = component.ID; } } } // загрузка изображений схемы XmlNode imagesNode = rootElem.SelectSingleNode("Images"); if (imagesNode != null) { Dictionary <string, Image> images = SchemeDoc.Images; XmlNodeList imageNodes = imagesNode.SelectNodes("Image"); foreach (XmlNode imageNode in imageNodes) { Image image = new Image(); image.LoadFromXml(imageNode); if (!string.IsNullOrEmpty(image.Name)) { images[image.Name] = image; } } } }
public override void clickAway() { this.FocusComponent?.FocusLost(); this.FocusComponent = null; }