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 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 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 MarkElement_SettingFirstValue_StateReturnThatValue(ElementState startingState) { // Setup var element = new GameBoardElement(0, 0); // Call element.MarkElement(startingState); // Assert Assert.AreEqual(startingState, 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 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 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); } }
/// <summary> /// Performs necessary update logic. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="otherScreenHasFocus">Whether another screen has the focus.</param> /// <param name="coveredByOtherScreen">Whether this screen is covered by another.</param> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); // Save the high-score when exiting the game if (isExiting) { if (!HighScoreScreen.HighscoreSaved) { HighScoreScreen.SaveHighscore(); } else { isExiting = false; // When exiting intentionally, clear the saved game data NinjAcademyGame.CleanIsolatedStorage(); ScreenManager.Game.Exit(); return; } } // Move on to the instruction screen if necessary if (isMovingToLoading) { foreach (GameScreen screen in ScreenManager.GetScreens()) { screen.ExitScreen(); } ScreenManager.AddScreen(new BackgroundScreen("Instructions"), null); ScreenManager.AddScreen(new LoadingScreen(instructionsTexture, loadingTexture), null); AudioManager.StopMusic(); return; } // Cause the ninja and title text to appear gradually ninjaTimer += gameTime.ElapsedGameTime; titleTimer += gameTime.ElapsedGameTime; switch (ninjaState) { case ElementState.Invisible: if (ninjaTimer >= ninjaAppearDelay) { ninjaState = ElementState.Appearing; ninjaTimer = TimeSpan.Zero; } break; case ElementState.Appearing: ninjaOffset = ninjaInitialOffset * (float)Math.Pow(1 - ninjaTimer.TotalMilliseconds / ninjaAppearDuration.TotalMilliseconds, 2); if (ninjaTimer > ninjaAppearDuration) { ninjaState = ElementState.Visible; } break; case ElementState.Visible: // Nothing to do in this state break; default: break; } switch (titleState) { case ElementState.Invisible: if (titleTimer >= titleAppearDelay) { titleState = ElementState.Appearing; titleTimer = TimeSpan.Zero; } break; case ElementState.Appearing: titleOffset = titleInitialOffset * (float)Math.Pow(1 - titleTimer.TotalMilliseconds / titleAppearDuration.TotalMilliseconds, 2); if (titleTimer > titleAppearDuration) { titleState = ElementState.Visible; } break; case ElementState.Visible: // Nothing to do in this state break; default: break; } }
/// <summary> /// Moves 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() { switch (_elementState) { case ElementState.Null: return(ReadRoot()); case ElementState.EOF: return(false); case ElementState.Start: break; case ElementState.End: case ElementState.MiscNode: // cursor is end element, pop stack _elementStack.Pop(); if (_elementStack.Count == 0) { _elementState = ElementState.EOF; return(false); } break; case ElementState.LeafStart: // cursor is leaf element start // just change the state to element end // do not move the cursor _elementState = ElementState.LeafEnd; return(true); case ElementState.LeafEnd: case ElementState.LoadEnd: // cursor is end element, pop stack _elementStack.Pop(); if (_elementStack.Count == 0) { _elementState = ElementState.EOF; return(false); } else { GetElementInformation(); return(true); } default: break; } _elementState = ElementState.Null; if (_xmlReader.EOF || !_xmlReader.Read()) { _elementState = ElementState.EOF; return(false); } else { GetElementInformation(); return(true); } }
public Task WaitForElementStateAsync(ElementState state, ElementHandleWaitForElementStateOptions options = default) => _channel.WaitForElementStateAsync(state, timeout: options?.Timeout);
public ILabel GetHiddenElement(HoverExample example, ElementState state = ElementState.Displayed) { return(ElementFactory.GetLabel(By.XPath(string.Format(HiddenElementTmpLoc, (int)example)), $"Hidden element for {example} example", state)); }
/// <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; } }
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 TextBox(By selector, string name, ElementState state) : base(selector, $"TextBox {name}", state) { }
private OpenXmlDomReader() : base() { this._elementStack = new Stack<OpenXmlElement>(); this._elementState = ElementState.Null; }
public IWebElement FindElement(By selector, ElementState state = ElementState.Exists, TimeSpan?timeout = null) { var elementStates = ResolveState(state); return(FindElement(selector, elementStates.ElementStateCondition, elementStates.StateName, timeout)); }
public Element(By selector, string name, ElementState state) { this.selector = selector; this.name = name; this.state = state; }
public override bool Update(ElementState state) { return(state is State s && s.Update(this)); }
private void CloseContent(HtmlParser htmlParser, string htmlContent) { ElementState elementState = htmlParser.CurrentElementState; switch (elementState.TypeName) { case "a": GuiWidget aWidget = elementsUnderConstruction.Pop(); if (aWidget.Name != "a") { throw new Exception("Should have been 'a'."); } elementsUnderConstruction.Peek().AddChild(aWidget); break; case "body": break; case "h1": case "p": GuiWidget pWidget = elementsUnderConstruction.Pop(); if (pWidget.Name != "p") { throw new Exception("Should have been 'p'."); } elementsUnderConstruction.Peek().AddChild(pWidget); break; case "div": GuiWidget divWidget = elementsUnderConstruction.Pop(); if (divWidget.Name != "div") { throw new Exception("Should have been 'div'."); } elementsUnderConstruction.Peek().AddChild(divWidget); break; case "input": break; case "table": break; case "span": break; case "tr": GuiWidget trWidget = elementsUnderConstruction.Pop(); if (trWidget.Name != "tr") { throw new Exception("Should have been 'tr'."); } elementsUnderConstruction.Peek().AddChild(trWidget); break; case "td": break; case "img": break; default: throw new NotImplementedException(); } }
private void AddContent(HtmlParser htmlParser, string htmlContent) { ElementState elementState = htmlParser.CurrentElementState; htmlContent = replaceMultipleWhiteSpacesWithSingleWhitespaceRegex.Replace(htmlContent, " "); string decodedHtml = HtmlParser.UrlDecode(htmlContent); switch (elementState.TypeName) { case "a": { elementsUnderConstruction.Push(new FlowLayoutWidget()); elementsUnderConstruction.Peek().Name = "a"; if (decodedHtml != null && decodedHtml != "") { Button linkButton = linkButtonFactory.Generate(decodedHtml.Replace("\r\n", "\n")); StyledTypeFace styled = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize); double descentInPixels = styled.DescentInPixels; linkButton.OriginRelativeParent = new VectorMath.Vector2(linkButton.OriginRelativeParent.x, linkButton.OriginRelativeParent.y + descentInPixels); linkButton.Click += (sender, mouseEvent) => { MatterControlApplication.Instance.LaunchBrowser(elementState.Href); }; elementsUnderConstruction.Peek().AddChild(linkButton); } } break; case "h1": case "p": { elementsUnderConstruction.Push(new FlowLayoutWidget()); elementsUnderConstruction.Peek().Name = "p"; elementsUnderConstruction.Peek().HAnchor = HAnchor.ParentLeftRight; if (decodedHtml != null && decodedHtml != "") { WrappingTextWidget content = new WrappingTextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor); //content.VAnchor = VAnchor.ParentTop; elementsUnderConstruction.Peek().AddChild(content); } } break; case "div": { elementsUnderConstruction.Push(new FlowLayoutWidget()); elementsUnderConstruction.Peek().Name = "div"; if (decodedHtml != null && decodedHtml != "") { TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor); elementsUnderConstruction.Peek().AddChild(content); } } break; case "!DOCTYPE": break; case "body": break; case "img": { ImageBuffer image = new ImageBuffer(elementState.SizeFixed.x, elementState.SizeFixed.y, 32, new BlenderBGRA()); ImageWidget_AsyncLoadOnDraw imageWidget = new ImageWidget_AsyncLoadOnDraw(image, elementState.src); // put the image into the widget when it is done downloading. if (elementsUnderConstruction.Peek().Name == "a") { Button linkButton = new Button(0, 0, imageWidget); linkButton.Cursor = Cursors.Hand; linkButton.Click += (sender, mouseEvent) => { MatterControlApplication.Instance.LaunchBrowser(elementState.Href); }; elementsUnderConstruction.Peek().AddChild(linkButton); } else { elementsUnderConstruction.Peek().AddChild(imageWidget); } } break; case "input": break; case "table": break; case "td": case "span": GuiWidget widgetToAdd; if (elementState.Classes.Contains("translate")) { decodedHtml = decodedHtml.Localize(); } if (elementState.Classes.Contains("toUpper")) { decodedHtml = decodedHtml.ToUpper(); } if (elementState.Classes.Contains("versionNumber")) { decodedHtml = VersionInfo.Instance.ReleaseVersion; } if (elementState.Classes.Contains("buildNumber")) { decodedHtml = VersionInfo.Instance.BuildVersion; } Button createdButton = null; if (elementState.Classes.Contains("centeredButton")) { createdButton = textImageButtonFactory.Generate(decodedHtml); widgetToAdd = createdButton; } else if (elementState.Classes.Contains("linkButton")) { double oldFontSize = linkButtonFactory.fontSize; linkButtonFactory.fontSize = elementState.PointSize; createdButton = linkButtonFactory.Generate(decodedHtml); StyledTypeFace styled = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize); double descentInPixels = styled.DescentInPixels; createdButton.OriginRelativeParent = new VectorMath.Vector2(createdButton.OriginRelativeParent.x, createdButton.OriginRelativeParent.y + descentInPixels); widgetToAdd = createdButton; linkButtonFactory.fontSize = oldFontSize; } else { TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor); widgetToAdd = content; } if (createdButton != null) { if (elementState.Id == "sendFeedback") { createdButton.Click += (s, e) => ContactFormWindow.Open(); } else if (elementState.Id == "clearCache") { createdButton.Click += (s, e) => AboutWidget.DeleteCacheData(); } } if (elementState.VerticalAlignment == ElementState.VerticalAlignType.top) { widgetToAdd.VAnchor = VAnchor.ParentTop; } elementsUnderConstruction.Peek().AddChild(widgetToAdd); break; case "tr": elementsUnderConstruction.Push(new FlowLayoutWidget()); elementsUnderConstruction.Peek().Name = "tr"; if (elementState.SizePercent.y == 100) { elementsUnderConstruction.Peek().VAnchor = VAnchor.ParentBottomTop; } if (elementState.Alignment == ElementState.AlignType.center) { elementsUnderConstruction.Peek().HAnchor |= HAnchor.ParentCenter; } break; default: throw new NotImplementedException("Don't know what to do with '{0}'".FormatWith(elementState.TypeName)); } }
/// <summary> /// Closes the reader. /// </summary> public override void Close() { ThrowIfObjectDisposed(); this._elementState = ElementState.EOF; this._elementStack.Clear(); this._xmlReader.Close(); }
private void AddContent(HtmlParser htmlParser, string htmlContent) { ElementState elementState = htmlParser.CurrentElementState; string decodedHtml = HtmlParser.UrlDecode(htmlContent); switch (elementState.TypeName) { case "a": { Button linkButton = linkButtonFactory.Generate(decodedHtml); StyledTypeFace styled = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize); double descentInPixels = styled.DescentInPixels; linkButton.OriginRelativeParent = new VectorMath.Vector2(linkButton.OriginRelativeParent.x, linkButton.OriginRelativeParent.y + descentInPixels); linkButton.Click += (sender, mouseEvent) => { System.Diagnostics.Process.Start(elementState.Href); }; currentRow.AddChild(linkButton); } break; case "table": break; case "td": case "span": GuiWidget widgetToAdd; if (elementState.Classes.Contains("translate")) { decodedHtml = decodedHtml.Localize(); } if (elementState.Classes.Contains("toUpper")) { decodedHtml = decodedHtml.ToUpper(); } if (elementState.Classes.Contains("versionNumber")) { decodedHtml = VersionInfo.Instance.ReleaseVersion; } if (elementState.Classes.Contains("buildNumber")) { decodedHtml = VersionInfo.Instance.BuildVersion; } Button createdButton = null; if (elementState.Classes.Contains("centeredButton")) { createdButton = textImageButtonFactory.Generate(decodedHtml); widgetToAdd = createdButton; } else if (elementState.Classes.Contains("linkButton")) { double oldFontSize = linkButtonFactory.fontSize; linkButtonFactory.fontSize = elementState.PointSize; createdButton = linkButtonFactory.Generate(decodedHtml); StyledTypeFace styled = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize); double descentInPixels = styled.DescentInPixels; createdButton.OriginRelativeParent = new VectorMath.Vector2(createdButton.OriginRelativeParent.x, createdButton.OriginRelativeParent.y + descentInPixels); widgetToAdd = createdButton; linkButtonFactory.fontSize = oldFontSize; } else { TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor); widgetToAdd = content; } if (createdButton != null) { if (elementState.Id == "sendFeedback") { createdButton.Click += (sender, mouseEvent) => { ContactFormWindow.Open(); }; } else if (elementState.Id == "clearCache") { createdButton.Click += (sender, mouseEvent) => { DeleteCacheData(); }; } } if (elementState.VerticalAlignment == ElementState.VerticalAlignType.top) { widgetToAdd.VAnchor = VAnchor.ParentTop; } currentRow.AddChild(widgetToAdd); break; case "tr": currentRow = new FlowLayoutWidget(); if (elementState.HeightPercent == 100) { currentRow.VAnchor = VAnchor.ParentBottomTop; } if (elementState.Alignment == ElementState.AlignType.center) { currentRow.HAnchor |= HAnchor.ParentCenter; } break; default: throw new NotImplementedException("Don't know what to do with {0}".FormatWith(elementState.TypeName)); } }
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 static ElementState <int, string> MakeEditedElement(ElementState <int, string> elementState) => MakeElement(elementState, 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; }
public static ElementState <int, string> MakeRemovedElement(ElementState <int, string> elementState) => MakeElement(elementState, true);
/// <summary> /// Finds element relative to current form. /// </summary> /// <typeparam name="T">Type of the target element.</typeparam> /// <param name="childLocator">Locator of the element relative to current form.</param> /// <param name="childName">Name of the element.</param> /// <param name="supplier">Delegate that defines constructor of element in case of custom element.</param> /// <param name="elementState">Element existance state</param> /// <returns>Instance of element.</returns> protected virtual new T FindChildElement <T>(By childLocator, string childName, ElementSupplier <T> supplier = null, ElementState elementState = ElementState.Displayed) where T : IElement { return(RelativeElementFactory.FindChildElement(this, childLocator, GetChildElementName(childName), supplier, elementState)); }
/// <inheritdoc /> public Task WaitForElementStateAsync(ElementState state, int?timeout = null) => _channel.WaitForElementStateAsync(state, timeout);
private async Task ListDataElements(string org, string app, string instanceGuid, ElementState state) { List <BlobItem> blobs = await _blobService.ListBlobs(org, app, instanceGuid, state); if (blobs.Count == 0) { Console.WriteLine($"No data elements in state {DataState} found for instance {org}/{app}/{instanceGuid} in {Program.Environment}. \n"); return; } Console.WriteLine($"Data elements for instanceGuid {instanceGuid}:"); foreach (BlobItem item in blobs) { Console.WriteLine($"\t {item.Name.Split('/')[4]} \t Deleted:{item.Deleted} "); } Console.WriteLine(string.Empty); }
private OpenXmlDomReader() : base() { _elementStack = new Stack <OpenXmlElement>(); _elementState = ElementState.Null; }
/// <summary> /// Creates a new element item. /// </summary> public ElementItem(Element name, string description, ElementState defaultState, ElementFamily family, Color gasColor, bool isPlaceableBar, ModLiquid liquid, float boilingPoint, float meltingPoint) : base(description, defaultState, gasColor, isPlaceableBar, liquid, boilingPoint, meltingPoint) { ElementName = name; displayName = ElementUtils.ElementName(name, false); Family = family; }
private OpenXmlDomReader(bool readMiscNodes) : base(readMiscNodes) { _elementStack = new Stack <OpenXmlElement>(); _elementState = ElementState.Null; }
/// <summary> /// Registers a new CompoundItem. /// </summary> /// <param name="compound">The enum Compound value for this item.</param> /// <param name="description">The tooltip for this item.</param> /// <param name="recipe">The recipe for this item.</param> /// <param name="stackCrafted">How much of this item is crafted per recipe.</param> /// <param name="defaults">The defaults set for this item's <seealso cref="Item"/> item field.</param> /// <param name="state">The default ElementState for this compound.</param> /// <param name="boilingPoint">The boiling point for this compound in Kelvin. Set to -1 for "unstable".</param> /// <param name="meltingPoint">The melting point for this compound in Kelvin. Set to -1 for "unstable".</param> /// <param name="elements">The Action for adding elements to this compound's recipe.</param> /// <param name="gasColor">Optional. Determines the colour for the gas drawn for this element when in the world.</param> /// <param name="liquid">Optional. The ModLiquid for this element.</param> /// <param name="isPlaceableBar">Optional. Determines if this metal element is a placeable bar.</param> internal static void RegisterCompound(Compound compound, string description, Action <ModRecipe> recipe, int stackCrafted, Action <Item> defaults, ElementState state, CompoundClassification classification, float boilingPoint, float meltingPoint, Action <CompoundItem> elements, Color?gasColor = null, ModLiquid liquid = null, bool isPlaceableBar = false) { string internalName = CompoundName(compound, false); CompoundItem item = new CompoundItem(compound, description, state, classification, gasColor ?? Color.White, isPlaceableBar, liquid, boilingPoint, meltingPoint, elements); mod.AddItem(internalName, item); //Add the corresponding bar tile if it should exist // TODO: make a ScienceBar for compounds if (isPlaceableBar) { mod.AddTile(internalName, new ScienceBar(), $"TerraScience/Content/Tiles/{internalName}"); } //Cache the defaults and recipe so we can use it anytime TerraScience.CachedCompoundDefaults.Add(internalName, defaults); TerraScience.CachedCompoundRecipes.Add(internalName, (r, e) => { recipe(r); for (int i = 0; i < item.Elements.Count; i++) { Tuple <Element, int> pair = item.Elements[i]; r.AddIngredient(mod.ItemType(ElementUtils.ElementName(pair.Item1)), pair.Item2); } r.SetResult(e, stackCrafted); r.AddRecipe(); }); }
private bool MoveToNextElement() { if (_elementState == ElementState.Null) { return(ReadRoot()); } OpenXmlElement element; switch (_elementState) { case ElementState.EOF: return(false); case ElementState.Start: { element = _elementStack.Peek(); if (element.HasChildren) { _elementStack.Push(element.FirstChild); if (element.FirstChild is OpenXmlMiscNode) { _elementState = ElementState.MiscNode; } else { _elementState = ElementState.Start; } } else { // at start state _elementState = ElementState.End; } } break; case ElementState.End: case ElementState.MiscNode: { // at end state, find next element element = _elementStack.Pop(); if (_elementStack.Count > 0) { element = element.NextSibling(); if (element is not null) { _elementStack.Push(element); if (element is OpenXmlMiscNode) { _elementState = ElementState.MiscNode; } else { _elementState = ElementState.Start; } } else { _elementState = ElementState.End; } } else { Debug.Assert(element == _rootElement); // no more elements _elementState = ElementState.EOF; return(false); } } break; default: Debug.Assert(_elementState == ElementState.Start || _elementState == ElementState.End || _elementState == ElementState.EOF); return(false); } return(true); }
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; } }
private void Init(OpenXmlElement openXmlElement) { _rootElement = openXmlElement; _elementState = ElementState.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() { 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; }
public override bool Update(ElementState state) { return(state is TreeViewElement <T> .State s && s.Update(this)); }
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; }
internal XmlBoundElement(string prefix, string localName, string namespaceURI, XmlDocument doc) : base(prefix, localName, namespaceURI, doc) { _state = ElementState.None; }
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> /// Closes the reader. /// </summary> public override void Close() { ThrowIfObjectDisposed(); this._elementState = ElementState.EOF; this._elementStack.Clear(); this._rootElement = null; }
private OpenXmlDomReader(bool readMiscNodes) : base(readMiscNodes) { this._elementStack = new Stack<OpenXmlElement>(); this._elementState = ElementState.Null; }
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> /// 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; } }
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; } }
/// <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> /// Constructor with parameters. /// </summary> /// <param name="locator">Unique locator of the window.</param> /// <param name="name">Name of the window.</param> /// <param name="parentForm">Parent form. If set to null, search context of <see cref="AqualityServices.Application"/> is used.</param> /// <param name="customSessionSupplier">Custom WinAppDriver session supplier.</param> /// <param name="elementState">Element presence state.</param> protected Form(By locator, string name, IForm parentForm = null, Func <WindowsDriver <WindowsElement> > customSessionSupplier = null, ElementState elementState = ElementState.Displayed) : base(locator, name, ResolveSearchContextSupplier(parentForm), customSessionSupplier ?? parentForm?.WindowsDriverSupplier, elementState) { var relativeFinderFromForm = new WindowsElementFinder(LocalizedLogger, ConditionalWait, () => GetElement()); RelativeElementFactory = new ElementFactory(ConditionalWait, relativeFinderFromForm, LocalizationManager); }
private void Init(OpenXmlElement openXmlElement) { this._rootElement = openXmlElement; this._elementState = ElementState.Null; }
protected internal ComboBox(By locator, string name, ElementState state) : base(locator, name, state) { }
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; }
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 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 bool IsAnyElementFound(TimeSpan?timeout, ElementState state) { return(ElementFinder.FindElements(elementLocator, state, timeout).Any()); }
/// <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 void HandleOwnerStateChanged(IElement sender, ElementState which, bool value) => this.Current = this[_owner.State];
void SetState(dynNode el, ElementState state) { el.State = state; }
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; } }