public void MarkElement_SettingFirstValue_StateReturnThatValue(ElementState startingState) { // Setup var element = new GameBoardElement(0, 0); // Call element.MarkElement(startingState); // Assert Assert.AreEqual(startingState, element.State); }
public void PaintCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, ElementState state, FlatStyle style, CheckState checkState) { switch (style) { case FlatStyle.Standard: case FlatStyle.System: switch (state) { case ElementState.Normal: DrawNormalCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Hot: DrawHotCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Pressed: DrawPressedCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Disabled: DrawDisabledCheckBox (g, bounds, backColor, foreColor, checkState); break; } break; case FlatStyle.Flat: switch (state) { case ElementState.Normal: DrawFlatNormalCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Hot: DrawFlatHotCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Pressed: DrawFlatPressedCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Disabled: DrawFlatDisabledCheckBox (g, bounds, backColor, foreColor, checkState); break; } break; case FlatStyle.Popup: switch (state) { case ElementState.Normal: DrawPopupNormalCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Hot: DrawPopupHotCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Pressed: DrawPopupPressedCheckBox (g, bounds, backColor, foreColor, checkState); break; case ElementState.Disabled: DrawPopupDisabledCheckBox (g, bounds, backColor, foreColor, checkState); break; } break; } }
public void SetUnFocus() { if (this.state != ElementState.UnFocus) { HotspotLeft.Visibility = Visibility.Collapsed; HotspotTop.Visibility = Visibility.Collapsed; HotspotRight.Visibility = Visibility.Collapsed; HotspotBottom.Visibility = Visibility.Collapsed; this.state = ElementState.UnFocus; } }
public void PaintRadioButton (Graphics g, Rectangle bounds, Color backColor, Color foreColor, ElementState state, FlatStyle style, bool isChecked) { switch (style) { case FlatStyle.Standard: case FlatStyle.System: switch (state) { case ElementState.Normal: DrawNormalRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Hot: DrawHotRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Pressed: DrawPressedRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Disabled: DrawDisabledRadioButton (g, bounds, backColor, foreColor, isChecked); break; } break; case FlatStyle.Flat: switch (state) { case ElementState.Normal: DrawFlatNormalRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Hot: DrawFlatHotRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Pressed: DrawFlatPressedRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Disabled: DrawFlatDisabledRadioButton (g, bounds, backColor, foreColor, isChecked); break; } break; case FlatStyle.Popup: switch (state) { case ElementState.Normal: DrawPopupNormalRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Hot: DrawPopupHotRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Pressed: DrawPopupPressedRadioButton (g, bounds, backColor, foreColor, isChecked); break; case ElementState.Disabled: DrawPopupDisabledRadioButton (g, bounds, backColor, foreColor, isChecked); break; } break; } }
public void SetFocus() { if (this.state != ElementState.Focus) { SetHotspotStyle(Colors.Blue, 1.0); HotspotLeft.Visibility = Visibility.Visible; HotspotTop.Visibility = Visibility.Visible; HotspotRight.Visibility = Visibility.Visible; HotspotBottom.Visibility = Visibility.Visible; this.state = ElementState.Focus; } }
public void MarkElement_FromYesToAnyNotStates_StateReturnsNewNotState(ElementState newNotState) { // Setup var element = new GameBoardElement(0, 0); element.MarkElement(ElementState.Yes); // Call element.MarkElement(newNotState); // Assert Assert.AreEqual(newNotState, element.State); }
public void MarkElement_FromAnyStateToEmpty_StateReturnsEmpty(ElementState startingState) { // Setup var element = new GameBoardElement(0, 0); element.MarkElement(startingState); // Call element.MarkElement(ElementState.Empty); // Assert Assert.AreEqual(ElementState.Empty, element.State); }
public void SetSelected() { if (this.state != ElementState.Selected) { SetHotspotStyle(Colors.Red, 0.5); HotspotLeft.Visibility = Visibility.Visible; HotspotTop.Visibility = Visibility.Visible; HotspotRight.Visibility = Visibility.Visible; HotspotBottom.Visibility = Visibility.Visible; this.state = ElementState.Selected; } }
/// <summary> /// /// </summary> /// <param name="gr"></param> /// <param name="rect"></param> /// <param name="d"></param> /// <param name="state"></param> protected override void DrawArrow(Graphics gr, Rectangle rect, Direction d, ElementState state) { if (ThemeFactory.VisualStylesEnabled && ThemeFactory.VisualStylesSupported) { ThemeFactory.DrawScrollBar(gr, rect, GetArrowScrollBarStates(d, state), ScrollBarParts.ArrowBtn); } else { ScrollButton sb = DirectionToScrollButton(d); ButtonState bs = ElementStateToButtonState(state); ControlPaint.DrawScrollButton(gr, rect, sb, bs); } }
protected override void DeserializeCore(XmlElement element, SaveContext context) { XmlElementHelper helper = new XmlElementHelper(element); this.GUID = helper.ReadGuid("guid", Guid.NewGuid()); // Resolve node nick name. string nickName = helper.ReadString("nickname", string.Empty); if (!string.IsNullOrEmpty(nickName)) this.nickName = nickName; else { System.Type type = this.GetType(); var attribs = type.GetCustomAttributes(typeof(NodeNameAttribute), true); NodeNameAttribute attrib = attribs[0] as NodeNameAttribute; if (null != attrib) this.nickName = attrib.Name; } this.X = helper.ReadDouble("x", 0.0); this.Y = helper.ReadDouble("y", 0.0); this.isVisible = helper.ReadBoolean("isVisible", true); this.isUpstreamVisible = helper.ReadBoolean("isUpstreamVisible", true); this.argumentLacing = helper.ReadEnum("lacing", LacingStrategy.Disabled); if (context == SaveContext.Undo) { // Fix: MAGN-159 (nodes are not editable after undo/redo). interactionEnabled = helper.ReadBoolean("interactionEnabled", true); this.state = helper.ReadEnum("nodeState", ElementState.ACTIVE); // We only notify property changes in an undo/redo operation. Normal // operations like file loading or copy-paste have the models created // in different ways and their views will always be up-to-date with // respect to their models. RaisePropertyChanged("InteractionEnabled"); RaisePropertyChanged("State"); RaisePropertyChanged("NickName"); RaisePropertyChanged("ArgumentLacing"); RaisePropertyChanged("IsVisible"); RaisePropertyChanged("IsUpstreamVisible"); // Notify listeners that the position of the node has changed, // then all connected connectors will also redraw themselves. this.ReportPosition(); } }
public void SetSelected() { if (this._State != ElementState.Selected) { SetHotspotStyle(Colors.Red, 1.0); ellipseBegin.Visibility = Visibility.Visible; rectangleCenter.Visibility = Visibility.Visible; ellipseEnd.Visibility = Visibility.Visible; this._State = ElementState.Selected; } }
public void SetFocus() { if (this._State != ElementState.Focus) { SetHotspotStyle(Colors.Yellow, 1.0); ellipseBegin.Visibility = Visibility.Visible; rectangleCenter.Visibility = Visibility.Visible; ellipseEnd.Visibility = Visibility.Visible; //直线状态不显示中间点 //if (IsStraightLine() == true) rectangleCenter.Visibility = Visibility.Collapsed; this._State = ElementState.Focus; } }
private bool ReadRoot() { this._elementStack.Push(this._rootElement); if (this._rootElement is OpenXmlMiscNode) { this._elementState = ElementState.MiscNode; } else { this._elementState = ElementState.Start; } return true; }
/// <summary> /// Closes the reader. /// </summary> public override void Close() { ThrowIfObjectDisposed(); this._elementState = ElementState.EOF; this._elementStack.Clear(); this._rootElement = null; }
/// <summary> /// Move to next sibling element /// </summary> /// <returns>true if the next sibling element was read successfully; false if there are no more sibling elements to read. </returns> /// <remarks>Current will move to the end tag of the parent if no more sibling element.</remarks> private bool MoveToNextSibling() { if (this._elementState == ElementState.EOF) { return false; } ThrowIfNull(); if (this._elementStack.Count == 0) { this._elementState = ElementState.EOF; return false; } OpenXmlElement element = this._elementStack.Pop(); // Fix bug #253890, case: the element used to constructor this DOM reader is not root element ( aka. it has parents and siblings. ) // the stack is empty means we should move to EOF. if (this._elementStack.Count == 0) { this._elementState = ElementState.EOF; return false; } element = element.NextSibling(); if (element != null) { this._elementStack.Push(element); if (element is OpenXmlMiscNode) { this._elementState = ElementState.MiscNode; } else { this._elementState = ElementState.Start; } return true; } else { if (this._elementStack.Count > 0) { this._elementState = ElementState.End; } else { // no more element, EOF this._elementState = ElementState.EOF; } return false; } }
/// <summary> /// Move to next element /// </summary> /// <returns>true if the next element was read successfully; false if there are no more elements to read. </returns> private bool MoveToNextElement() { if (this._elementState == ElementState.Null) { return this.ReadRoot(); } OpenXmlElement element; switch (this._elementState) { case ElementState.EOF: return false; case ElementState.Start: { element = this._elementStack.Peek(); if (element.HasChildren) { this._elementStack.Push(element.FirstChild); if (element.FirstChild is OpenXmlMiscNode) { this._elementState = ElementState.MiscNode; } else { this._elementState = ElementState.Start; } } else { // at start state this._elementState = ElementState.End; } } break; case ElementState.End: case ElementState.MiscNode: { // at end state, find next element element = this._elementStack.Pop(); if (this._elementStack.Count > 0) { element = element.NextSibling(); if (element != null) { this._elementStack.Push(element); if (element is OpenXmlMiscNode) { this._elementState = ElementState.MiscNode; } else { this._elementState = ElementState.Start; } } else { this._elementState = ElementState.End; } } else { Debug.Assert(element == this._rootElement); // no more elements this._elementState = ElementState.EOF; return false; } } break; default: Debug.Assert(this._elementState == ElementState.Start || this._elementState == ElementState.End || this._elementState == ElementState.EOF); return false; } return true; }
/// <summary> /// Move to first child /// </summary> /// <returns>true if the first child element was read successfully; false if there are no child elements to read. </returns> /// <remarks>Only can be called on element start. Current will move to the end tag if no child element.</remarks> private bool MoveToFirstChild() { ThrowIfNull(); if (this._elementState != ElementState.Start) { return false; } OpenXmlElement element = this._elementStack.Peek(); if (element.HasChildren) { this._elementStack.Push(element.FirstChild); if (element.FirstChild is OpenXmlMiscNode) { this._elementState = ElementState.MiscNode; } else { this._elementState = ElementState.Start; } return true; } else { this._elementState = ElementState.End; return false; } }
/// <summary> /// Loads the element at the current cursor. /// </summary> /// <returns>The OpenXmlElement object.</returns> /// <exception cref="InvalidOperationException">Thrown when the current element is element end.</exception> /// <remarks>The new current element is the end of the element after LoadCurrentElement().</remarks> public override OpenXmlElement LoadCurrentElement() { ThrowIfObjectDisposed(); OpenXmlElement element; switch (this._elementState) { case ElementState.LeafStart: element = this._elementStack.Pop(); this._elementStack.Push(element.CloneNode(true)); // stop at the end tag. this._elementState = ElementState.LoadEnd; return element; case ElementState.Start: element = this._elementStack.Peek(); element.Load(this._xmlReader, OpenXmlLoadMode.Full); // stop at the end tag. this._elementState = ElementState.LoadEnd; return element; case ElementState.MiscNode: Debug.Assert(this.ReadMiscNodes); element = this._elementStack.Pop(); element.Load(this._xmlReader, OpenXmlLoadMode.Full); // stop at next element. GetElementInformation(); return element; case ElementState.Null: ThrowIfNull(); break; case ElementState.EOF: ThrowIfEof(); break; case ElementState.LoadEnd: case ElementState.End: case ElementState.LeafEnd: throw new InvalidOperationException(ExceptionMessages.ReaderInEndState); default: Debug.Assert(false); break; } return null; }
/// <summary> /// Loads the element at the current cursor. /// </summary> /// <returns>The OpenXmlElement object.</returns> /// <exception cref="InvalidOperationException">Thrown when the current element is element end.</exception> /// <remarks>The new current element is the end of the element after LoadCurrentElement().</remarks> public override OpenXmlElement LoadCurrentElement() { // TODO: should we return a clone? // The user expect the element in the tree returned? Is this assumption correct? ThrowIfObjectDisposed(); ThrowIfNull(); ThrowIfEof(); if (this._elementState == ElementState.Start) { OpenXmlElement element = this._elementStack.Peek(); this._elementState = ElementState.End; return element; } else if (this._elementState == ElementState.MiscNode) { Debug.Assert(this.ReadMiscNodes); OpenXmlElement element = this._elementStack.Peek(); this.Skip(); return element; } else { throw new InvalidOperationException(ExceptionMessages.ReaderInEndState); } }
/// <summary> /// Closes the reader. /// </summary> public override void Close() { ThrowIfObjectDisposed(); this._elementState = ElementState.EOF; this._elementStack.Clear(); this._xmlReader.Close(); }
private void Init(OpenXmlElement openXmlElement) { this._rootElement = openXmlElement; this._elementState = ElementState.Null; }
private void Init(Stream partStream, bool closeInput) { _elementContext.XmlReaderSettings.CloseInput = closeInput; _elementContext.XmlReaderSettings.DtdProcessing = DtdProcessing.Prohibit; // set true explicitly for security fix _elementContext.XmlReaderSettings.IgnoreWhitespace = true; // O15:#3024890, the default is false, but we set it to True for compatibility of OpenXmlPartReader behavior this._xmlReader = XmlConvertingReaderFactory.Create(partStream, _elementContext.XmlReaderSettings); this._xmlReader.Read(); if ( this._xmlReader.NodeType == XmlNodeType.XmlDeclaration) { this._encoding = this._xmlReader["encoding"]; // get the "encoding" attribute //if (!String.IsNullOrEmpty(encoding)) //{ // try // { // this._encoding = Encoding.GetEncoding(encoding); // } // catch (ArgumentException) // { // // should we catch? // this._encoding = Encoding.UTF8; // } //} string standalone = this._xmlReader["standalone"]; // get the "standalone" attribute if (!String.IsNullOrEmpty(standalone)) { if (standalone == "yes") { this._standalone = true; } else { this._standalone = false; } } } this._elementState = ElementState.Null; }
private OpenXmlPartReader(bool readMiscNodes) : base ( readMiscNodes ) { this._attributeList = new List<OpenXmlAttribute>(); this._nsDecls = new List<KeyValuePair<string, string>>(); this._elementStack = new Stack<OpenXmlElement>(); this._elementContext = new OpenXmlElementContext(); this._elementState = ElementState.Null; }
private bool ReadRoot() { Debug.Assert(this._elementState == ElementState.Null); Debug.Assert(this._elementStack.Count == 0); // TODO: should we take care of entity? <!DOCTYPE page [ <!ENTITY company "Microsoft"> ]> // TODO: is it OK that we skip all prolog ( DOCTYPE, Comment, PT ) ? this._xmlReader.MoveToContent(); while (!this._xmlReader.EOF && this._xmlReader.NodeType != XmlNodeType.Element) { this._xmlReader.Skip(); } if (this._xmlReader.EOF || !this._xmlReader.IsStartElement()) { throw new InvalidDataException(ExceptionMessages.PartIsEmpty); } // create the root element object OpenXmlElement rootElement = RootElementFactory.CreateElement(this._xmlReader.NamespaceURI, this._xmlReader.LocalName); if (rootElement == null) { throw new InvalidDataException(ExceptionMessages.PartUnknown); } this._elementStack.Push(rootElement); LoadAttributes(); if (this._xmlReader.IsEmptyElement) { this._elementState = ElementState.LeafStart; rootElement.Load(this._xmlReader, OpenXmlLoadMode.Full); } else { this._elementState = ElementState.Start; } return true; }
public void SetUnFocus() { if (this._State != ElementState.UnFocus) { SetHotspotStyle(Colors.Blue, 0.8); ellipseBegin.Visibility = Visibility.Collapsed; rectangleCenter.Visibility = Visibility.Collapsed; ellipseEnd.Visibility = Visibility.Collapsed; this._State = ElementState.UnFocus; } }
private void GetElementInformation() { if (this._xmlReader.EOF) { Debug.Assert(this._elementStack.Count == 0); this._elementState = ElementState.EOF; return; } Debug.Assert(this._elementStack.Count > 0); OpenXmlElement element; switch (this._xmlReader.NodeType) { case XmlNodeType.EndElement: //#if DEBUG // { // OpenXmlElement top = this._elementStack.Pop(); // element = this.CreateElement(); // this._elementStack.Push(top); // Debug.Assert(element.GetType() == this._elementStack.Peek().GetType()); // } //#endif this._elementState = ElementState.End; break; case XmlNodeType.Element: element = this.CreateChildElement(); LoadAttributes(); if (this._xmlReader.IsEmptyElement) { this._elementState = ElementState.LeafStart; element.Load(this._xmlReader, OpenXmlLoadMode.Full); } else if (element is OpenXmlLeafElement || element is OpenXmlLeafTextElement ) { this._elementState = ElementState.LeafStart; element.Load(this._xmlReader, OpenXmlLoadMode.Full); } else if (element is OpenXmlUnknownElement) { this._elementState = ElementState.Start; } else { Debug.Assert(element is OpenXmlCompositeElement); this._elementState = ElementState.Start; } this._elementStack.Push(element); break; default: // non element ( PI, Comment, Notation, XmlDeclaration ) element = this.CreateChildElement(); (element as OpenXmlMiscNode).LoadOuterXml(this._xmlReader); this._elementStack.Push(element); this._elementState = ElementState.MiscNode; break; } }
/// <summary> /// Sets the element state. The <see cref="Screen"/> must have been assigned before the element state is set to /// <see cref="Visuals.ElementState.Running"/>. /// </summary> /// <param name="state"></param> public void SetElementState(ElementState state) { ForEachElementInTree_BreadthFirst(new SetElementStateAction(state)); }
private OpenXmlDomReader() : base() { this._elementStack = new Stack<OpenXmlElement>(); this._elementState = ElementState.Null; }
void SetState(dynNode el, ElementState state) { el.State = state; }
private OpenXmlDomReader(bool readMiscNodes) : base(readMiscNodes) { this._elementStack = new Stack<OpenXmlElement>(); this._elementState = ElementState.Null; }