public override void Add(IVisualElement child) { base.Add(child); Rectangle cell = _cells[Children.Count - 1]; Children.Last().Move(cell.X, cell.Y); Children.Last().Resize(cell.Width, cell.Height); }
public async Task OnTextBoxHelperTextFontSize_ChangesHelperTextFontSize() { await using var recorder = new TestRecorder(App); IVisualElement grid = await LoadXaml(@" <Grid Margin=""30""> <TextBox VerticalAlignment=""Top"" Text=""Some Text"" materialDesign:HintAssist.HelperTextFontSize=""20""> </TextBox> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); IVisualElement helpTextBlock = await textBox.GetElement("/Grid/Canvas/TextBlock"); double fontSize = await helpTextBlock.GetProperty <double>(TextBlock.FontSizeProperty.Name); Assert.Equal(20, fontSize); recorder.Success(); }
public async Task ClosingDialogWithIsOpenProperty_ShouldRaiseDialogClosingEvent() { await using var recorder = new TestRecorder(App); IVisualElement dialogHost = await LoadUserControl <ClosingEventCounter>(); IVisualElement showButton = await dialogHost.GetElement("ShowDialogButton"); IVisualElement closeButton = await dialogHost.GetElement("CloseButton"); IVisualElement resultTextBlock = await dialogHost.GetElement("ResultTextBlock"); await showButton.Click(); await Wait.For(async() => await closeButton.GetIsVisible()); await closeButton.Click(); await Wait.For(async() => Assert.Equal("1", await resultTextBlock.GetText())); }
public async Task OnClickChoiceChipListBox_ChangesSelectedItem(string listBoxStyle) { await using var recorder = new TestRecorder(App); IVisualElement listBox = await LoadXaml($@" <ListBox x:Name=""ChipsListBox"" Style=""{{StaticResource {listBoxStyle}}}""> <ListBoxItem>Mercury</ListBoxItem> <ListBoxItem>Venus</ListBoxItem> <ListBoxItem>Earth</ListBoxItem> <ListBoxItem>Pluto</ListBoxItem> </ListBox> "); IVisualElement earth = await listBox.GetElement("/ListBoxItem[2]"); await earth.Click(); await Wait.For(async() => Assert.Equal(2, await listBox.GetProperty <int>(nameof(Selector.SelectedIndex)))); recorder.Success(); }
/** * */ private void DataGroupRendererAddHandler(Event e) { RendererExistenceEvent ree = (RendererExistenceEvent)e; IVisualElement renderer = ree.Renderer; if (null != renderer) { renderer.AddEventListener(MouseEvent.CLICK, ItemClickHandler); var component = renderer as IFocusManagerComponent; if (component != null) { component.FocusEnabled = false; } var button = renderer as ButtonBarButton; if (button != null) { button.AllowDeselection = !RequireSelection; } } }
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { IVisualElement selectedElement = (IVisualElement)((FrameworkElement)sender).DataContext; IVisualBuilding building = (IVisualBuilding)DataContext; if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))) { building.SelectedEntities.Clear(); foreach (VisualFloor floor in building.Floors) { floor.IsSelected = false; } } selectedElement.IsSelected = !selectedElement.IsSelected; if (selectedElement is VisualFloor) { building.CurrentFloor = (VisualFloor)selectedElement; building.FireFloorSelectionEvent(); } }
public async Task OnGetTypedElement_GetsTypedElement() { // Arrange await using TestRecorder recorder = new(App); await Window.SetXamlContent(@" <Grid> <Button x:Name=""MyButton"" IsDefault=""True"" VerticalAlignment=""Center"" HorizontalAlignment=""Center"" /> </Grid>"); //Act IVisualElement <Button> button = await Window.GetElement <Button>("MyButton"); //Assert Assert.IsNotNull(button); Assert.IsTrue(await button.GetActualWidth() > 0); Assert.IsTrue(await button.GetIsDefault()); Assert.IsFalse(await button.GetIsPressed()); recorder.Success(); }
public async Task OnClearButtonWithHintShown_ControlHeighDoesNotChange() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement grid = await LoadXaml(@" <Grid Margin=""30""> <TextBox Style=""{StaticResource MaterialDesignFloatingHintTextBox}"" VerticalAlignment=""Top"" materialDesign:TextFieldAssist.HasClearButton=""True"" materialDesign:TextFieldAssist.PrefixText =""$"" materialDesign:TextFieldAssist.SuffixText = ""mm""> <materialDesign:HintAssist.Hint> <StackPanel Orientation=""Horizontal"" Margin=""-2 0 0 0""> <materialDesign:PackIcon Kind=""AccessPoint"" /> <TextBlock>WiFi</TextBlock> </StackPanel> </materialDesign:HintAssist.Hint > </TextBox> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); IVisualElement clearButton = await grid.GetElement("PART_ClearButton"); double initialHeight = await textBox.GetActualHeight(); //Act await textBox.MoveKeyboardFocus(); //Delay needed to accout for transition storyboard await Task.Delay(MaterialDesignTextBox.FocusedAimationTime); //Assert double height = await textBox.GetActualHeight(); Assert.Equal(initialHeight, height); recorder.Success(); }
public virtual IEnumerable <IStyle> GetStylesForElement(IVisualElement element) { if (_elementStyles.TryGetValue(element.Id, out var elementStyles)) { yield return(elementStyles); } if (_cachedStyles.TryGetValue(element.Id, out var known)) { yield return(known); yield break; } element.Disposed += OnElementDisposed; var buildCached = BuildCachedStyle(element); _cachedStyles[element.Id] = buildCached; yield return(buildCached); }
protected CirclePackingAutoComponent(IEmbeddedResources embeddedResources, IViewService viewService, ICoroutineService coroutineService) { this.embeddedResources = embeddedResources; this.coroutineService = coroutineService; solver = new CirclePackingSolver(); Reset(); borderModel = new ExplicitModel(ResourceVolatility.Stable) { IndexSubranges = new ExplicitModelIndexSubrange[1], Topology = ExplicitModelPrimitiveTopology.LineStrip }; backgroundVisualElement = ModelVisualElement.New(this) .SetModel(embeddedResources.SimplePlaneXyModel()) .SetMaterial(StandardMaterial.New() .SetIgnoreLighting(true) .SetDiffuseColor(Color4.Black) .FromGlobalCache()) .SetRenderState(StandardRenderState.New() .SetZOffset(-GraphicsHelper.MinZOffset)) .SetTransform(x => Transform.Translation(new Vector3(x.border.BoundingRect.Center, 0))) .SetNonUniformScale(x => new Vector3( x.border.BoundingRect.HalfWidth, x.border.BoundingRect.HalfHeight, 1)); borderVisualElement = ModelVisualElement.New(this) .SetModel(x => x.GetRelevantBorderModel()) .SetMaterial(StandardMaterial.New() .SetDiffuseColor(Color4.Yellow) .SetIgnoreLighting(true) .FromGlobalCache()); circleVisualElements = new List <IVisualElement>(); selectOnClickInterationElement = new SelectOnClickInteractionElement(this, viewService); // todo: make precise hittable = new RectangleHittable <CirclePackingAutoComponent>(this, Transform.Identity, x => x.border.BoundingRect, x => 0); }
public async Task OnGetCoordinate_ReturnsScreenCoordinatesOfElement() { await Window.SetXamlContent(@"<Border x:Name=""MyBorder"" Width=""30"" Height=""40"" VerticalAlignment=""Top"" HorizontalAlignment=""Left""/>"); IVisualElement <Border> element = await Window.GetElement <Border>("MyBorder"); Rect initialCoordinates = await element.GetCoordinates(); await element.SetWidth(90); await element.SetHeight(80); await element.SetMargin(new Thickness(30)); Rect newCoordinates = await element.GetCoordinates(); Assert.AreEqual(3.0, Math.Round(newCoordinates.Width / initialCoordinates.Width)); Assert.AreEqual(2.0, Math.Round(newCoordinates.Height / initialCoordinates.Height)); Assert.AreEqual(initialCoordinates.Width, Math.Round(newCoordinates.Left - initialCoordinates.Left)); Assert.AreEqual(initialCoordinates.Width, Math.Round(newCoordinates.Top - initialCoordinates.Top)); }
public async Task OutlinedButton_OnMouseOver_UsesThemeBrush() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement button = await LoadXaml( @"<Button Content=""Button"" Style=""{StaticResource MaterialDesignOutlinedButton}""/>"); Color midColor = await GetThemeColor("PrimaryHueMidBrush"); IVisualElement?internalBorder = await button.GetElement("border"); //Act await button.MoveCursorToElement(Position.Center); SolidColorBrush internalBorderBackground = await internalBorder.GetProperty <SolidColorBrush>(nameof(Border.Background)); //Assert Assert.Equal(midColor, internalBorderBackground.Color); recorder.Success(); }
public async Task OnOpenDialog_OverlayCoversContent() { await using var recorder = new TestRecorder(App); IVisualElement dialogHost = await LoadUserControl <WithCounter>(); IVisualElement resultTextBlock = await dialogHost.GetElement("ResultTextBlock"); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 0"); IVisualElement testOverlayButton = await dialogHost.GetElement("TestOverlayButton"); await testOverlayButton.Click(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); IVisualElement showDialogButton = await dialogHost.GetElement("ShowDialogButton"); await showDialogButton.Click(); IVisualElement closeDialogButton = await dialogHost.GetElement("CloseDialogButton"); await Wait.For(async() => await closeDialogButton.GetIsVisible() == true); await testOverlayButton.Click(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); await closeDialogButton.Click(); await Wait.For(async() => { Output.WriteLine("Input"); await testOverlayButton.Click(); Assert.Equal("Clicks: 2", await resultTextBlock.GetText()); Output.WriteLine("Output"); }); }
public async Task OnGetCoordinate_ReturnsFractionalCoordinatesOfElement() { await Window.SetXamlContent(@"<Border x:Name=""MyBorder"" Width=""30"" Height=""40"" VerticalAlignment=""Top"" HorizontalAlignment=""Left""/>"); IVisualElement <Border> element = await Window.GetElement <Border>("MyBorder"); Rect initialCoordinates = await element.GetCoordinates(); await element.SetWidth(30.7); await element.SetHeight(40.3); await element.SetMargin(new Thickness(0.1)); Rect newCoordinates = await element.GetCoordinates(); Assert.AreEqual(30.7, Math.Round(newCoordinates.Width, 5)); Assert.AreEqual(40.3, Math.Round(newCoordinates.Height, 5)); Assert.AreEqual(0.1, Math.Round(newCoordinates.Left - initialCoordinates.Left, 5)); Assert.AreEqual(0.1, Math.Round(newCoordinates.Top - initialCoordinates.Top, 5)); }
public async Task OnOpenDialog_OverlayCoversContent() { await using var recorder = new TestRecorder(App); IVisualElement dialogHost = await LoadUserControl <WithCounter>(); var overlay = await dialogHost.GetElement <Grid>("PART_ContentCoverGrid"); var resultTextBlock = await dialogHost.GetElement <TextBlock>("ResultTextBlock"); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 0"); var testOverlayButton = await dialogHost.GetElement <Button>("TestOverlayButton"); await testOverlayButton.LeftClick(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); var showDialogButton = await dialogHost.GetElement <Button>("ShowDialogButton"); await showDialogButton.LeftClick(); var closeDialogButton = await dialogHost.GetElement <Button>("CloseDialogButton"); await Wait.For(async() => await closeDialogButton.GetIsVisible() == true); await testOverlayButton.LeftClick(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); await closeDialogButton.LeftClick(); var retry = new Retry(5, TimeSpan.FromSeconds(5)); await Wait.For(async() => await overlay.GetVisibility() != Visibility.Visible, retry); await testOverlayButton.LeftClick(); await Wait.For(async() => Assert.Equal("Clicks: 2", await resultTextBlock.GetText()), retry); }
/// <summary> /// Will draw a border (hollow rectangle) of the given 'thicknessOfBorder' (in pixels) /// of the specified color. /// /// By Sean Colombo, from http://bluelinegamestudios.com/blog /// </summary> /// <param name="rectangleToDraw"></param> /// <param name="thicknessOfBorder"></param> public static void DrawBorder(this IVisualElement element, SpriteBatch spriteBatch, TextureFrameStore textureFrames, int thicknessOfBorder, Color borderColor) { var pixel = textureFrames["pixel"].Texture; var rectangleToDraw = element.BoundaryBox; // Draw top line spriteBatch.Draw(pixel, new Rectangle(rectangleToDraw.X, rectangleToDraw.Y, rectangleToDraw.Width, thicknessOfBorder), borderColor); // Draw left line spriteBatch.Draw(pixel, new Rectangle(rectangleToDraw.X, rectangleToDraw.Y, thicknessOfBorder, rectangleToDraw.Height), borderColor); // Draw right line spriteBatch.Draw(pixel, new Rectangle((rectangleToDraw.X + rectangleToDraw.Width - thicknessOfBorder), rectangleToDraw.Y, thicknessOfBorder, rectangleToDraw.Height), borderColor); // Draw bottom line spriteBatch.Draw(pixel, new Rectangle(rectangleToDraw.X, rectangleToDraw.Y + rectangleToDraw.Height - thicknessOfBorder, rectangleToDraw.Width, thicknessOfBorder), borderColor); }
public async Task OnGetProperty_WhenPropertyIsDependencyObject_GetVisualElement() { // Arrange await using TestRecorder recorder = new(App); await Window.SetXamlContent(@" <StackPanel x:Name=""Panel""> <StackPanel.ContextMenu> <ContextMenu x:Name=""TestContextMenu""/> </StackPanel.ContextMenu> </StackPanel>"); IVisualElement <StackPanel> stackPanel = await Window.GetElement <StackPanel>("Panel"); //Act IVisualElement <ContextMenu>?contextMenu = await stackPanel.GetContextMenu(); //Assert Assert.IsNotNull(contextMenu); Assert.AreEqual("TestContextMenu", await contextMenu.GetName()); recorder.Success(); }
public async Task CanRightClickToShowContextMenu() { await Grid.RightClick(); IVisualElement <ContextMenu>?contextMenu = await Grid.GetContextMenu(); Assert.IsNotNull(contextMenu); var menuItem = await contextMenu.GetElement <MenuItem>("Context1"); await Task.Delay(100); Assert.IsNotNull(menuItem); await using IEventRegistration registration = await menuItem.RegisterForEvent(nameof (MenuItem.Click)); await menuItem.LeftClick(clickTime : TimeSpan.FromMilliseconds(100)); await Wait.For(async() => { var invocations = await registration.GetInvocations(); Assert.AreEqual(1, invocations.Count); }); }
public async Task OnLoad_ThemeBrushesSet() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement <TabControl> tabControl = await LoadXaml <TabControl>(@" <TabControl materialDesign:ColorZoneAssist.Mode=""PrimaryMid"" Style=""{StaticResource MaterialDesignFilledTabControl}""> <TabItem Header=""TAB 1""> <TextBlock Margin=""8"" Text=""PrimaryMid Tab 1"" /> </TabItem> <TabItem Header=""TAB 2""> <TextBlock Margin=""8"" Text=""PrimaryMid Tab 2"" /> </TabItem> </TabControl>"); IVisualElement <TextBlock> textBlock = await tabControl.GetElement <TextBlock>(@"/TabItem[0]/TextBlock[0]"); IVisualElement <Border> selectedTabBorder = await tabControl.GetElement <Border>(@"/TabItem[0]~SelectionHighlightBorder"); //Act Color?foreground = await textBlock.GetForegroundColor(); Color?background = await textBlock.GetEffectiveBackground(); Color?selectedTabUnderline = await selectedTabBorder.GetBorderBrushColor(); //Assert Assert.NotNull(foreground); Assert.NotNull(background); MaterialDesignSpec.AssertContrastRatio(foreground.Value, background.Value, MaterialDesignSpec.MinimumContrastSmallText); Assert.Equal(foreground, selectedTabUnderline); recorder.Success(); }
public async Task OnOpenDialog_OverlayCoversContent() { await using var recorder = new TestRecorder(App); IVisualElement dialogHost = await LoadUserControl <WithCounter>(); IVisualElement overlay = await dialogHost.GetElement("PART_ContentCoverGrid"); IVisualElement resultTextBlock = await dialogHost.GetElement("ResultTextBlock"); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 0"); IVisualElement testOverlayButton = await dialogHost.GetElement("TestOverlayButton"); await testOverlayButton.Click(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); IVisualElement showDialogButton = await dialogHost.GetElement("ShowDialogButton"); await showDialogButton.Click(); IVisualElement closeDialogButton = await dialogHost.GetElement("CloseDialogButton"); await Wait.For(async() => await closeDialogButton.GetIsVisible() == true); await testOverlayButton.Click(); await Wait.For(async() => await resultTextBlock.GetText() == "Clicks: 1"); await closeDialogButton.Click(); await Wait.For(async() => await overlay.GetVisibility() != Visibility.Visible); await testOverlayButton.Click(); await Wait.For(async() => Assert.Equal("Clicks: 2", await resultTextBlock.GetText())); }
///<summary> /// Updates the renderer for reuse ///</summary> ///<param name="renderer"></param> ///<param name="itemIndex"></param> ///<param name="data"></param> public virtual void UpdateRenderer(IVisualElement renderer, int itemIndex, object data) { // set the owner renderer.Owner = this; // Set the index if (renderer is IItemRenderer) { ((IItemRenderer)renderer).ItemIndex = itemIndex; } // set the label to the toString() of the data if (renderer is IItemRenderer) { ((IItemRenderer)renderer).Text = ItemToLabel(data); } // always set the data last if ((renderer is IDataRenderer) && (renderer != data)) { ((IDataRenderer)renderer).Data = data; } }
public async Task CharacterCount_WithMaxLengthSet_IsDisplayed() { await using var recorder = new TestRecorder(App); IVisualElement grid = await LoadXaml(@" <Grid Margin=""30""> <TextBox MaxLength=""10"" /> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); IVisualElement characterCounter = await textBox.GetElement("CharacterCounterTextBlock"); Assert.Equal("0 / 10", await characterCounter.GetText()); await textBox.SetText("12345"); Assert.Equal("5 / 10", await characterCounter.GetText()); recorder.Success(); }
public async Task OutlinedButton_UsesThemeColorForBorder() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement button = await LoadXaml( @"<Button Content=""Button"" Style=""{StaticResource MaterialDesignOutlinedButton}""/>"); Color midColor = await GetThemeColor("PrimaryHueMidBrush"); IVisualElement?internalBorder = await button.GetElement("border"); //Act Color?borderColor = await button.GetProperty <Color?>(nameof(WpfButton.BorderBrush)); Color?internalBorderColor = await internalBorder.GetProperty <Color?>(nameof(Border.BorderBrush)); //Assert Assert.Equal(midColor, borderColor); Assert.Equal(midColor, internalBorderColor); recorder.Success(); }
public static ITransition BuildTransition(IVisualElement visual, IDependencyProperty property, TimeSpan duration, TimeSpan delay, TransitionFunctionType fn) { switch (property) { case IDependencyProperty <Double> dbl: var r = new DoublePropertyTransition(visual, dbl, duration, delay, fn); return(r); case IDependencyProperty <IBrush> brush: return(new BrushTransition(visual, brush, duration, delay, fn)); case IDependencyProperty <TransformationMatrix> matrix: return(new TransformTransition(visual, matrix, duration, delay, fn)); default: throw new NotImplementedException(); } }
public ValueSize MeasureMainView <TRenderSize>(IVisualElement element, TRenderSize availableSpace, IViewState viewState) where TRenderSize : IRenderSize { //Debug.WriteLine("********** BEGIN MEASURE ***********"); ViewState = viewState; if (viewState.ZoomLevel.AreDifferent(1.0)) { var zoomWidth = availableSpace.Width / viewState.ZoomLevel; var zoomHeight = availableSpace.Height / viewState.ZoomLevel; if (_contextBounds.Width.AreDifferent(zoomWidth) || _contextBounds.Height.AreDifferent(zoomHeight)) { _contextBounds = new ValueSize(zoomWidth, zoomHeight); } var availableSpace2 = new ValueRenderSize(zoomWidth, zoomHeight, availableSpace.Offset); //Debug.WriteLine("********** END MEASURE ***********"); return(MeasureElement(element, availableSpace2)); } if (_contextBounds.Width.AreDifferent(availableSpace.Width) || _contextBounds.Height.AreDifferent(availableSpace.Height)) { _contextBounds = new ValueSize(availableSpace); } var res = MeasureElement(element, availableSpace); //Debug.WriteLine("********** END MEASURE ***********"); return(res); }
public async Task OnOutlinedTextBox_FloatingHintOffsetWithinRange() { await using var recorder = new TestRecorder(App); IVisualElement grid = await LoadXaml(@" <Grid Margin=""30""> <TextBox Style=""{StaticResource MaterialDesignOutlinedTextBox}"" VerticalAlignment=""Top"" materialDesign:HintAssist.Hint=""This is a hint"" /> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); IVisualElement hint = await textBox.GetElement("Hint"); Point floatingOffset = await hint.GetProperty <Point>(SmartHint.FloatingOffsetProperty); Assert.Equal(0, floatingOffset.X); Assert.InRange(floatingOffset.Y, -22, -20); recorder.Success(); }
public async Task HelperText_CanSetFontColorWithAttachedStyle() { await using var recorder = new TestRecorder(App); IVisualElement grid = await LoadXaml(@" <Grid Margin=""30""> <TextBox materialDesign:HintAssist.HelperText=""Test""> <materialDesign:HintAssist.HelperTextStyle> <Style TargetType=""TextBlock"" BasedOn=""{StaticResource MaterialDesignHelperTextBlock}""> <Setter Property=""Foreground"" Value=""Red"" /> </Style> </materialDesign:HintAssist.HelperTextStyle> </TextBox> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); IVisualElement helperText = await textBox.GetElement("HelperTextTextBlock"); Assert.Equal(Colors.Red, await helperText.GetForegroundColor()); recorder.Success(); }
/// <summary> /// Returns the root visual and/or any child visuals that meet the /// requirements of the selector /// </summary> public static IEnumerable <IVisualElement> GetSelectableVisuals(IVisualElement rootVisual, IStyleSelector selector, IVisualLineage visualLineage) { switch (selector) { case AndStyleSelector andy: var selectables = GetSelectableVisualsImpl(rootVisual, andy, visualLineage, 0); foreach (var selectable in selectables) { yield return(selectable); } break; default: if (IsVisualSelectable(rootVisual, selector, visualLineage)) { yield return(rootVisual); } break; } }
public static async Task <Point> SendClick(IVisualElement element, MouseInput down, MouseInput up, Position position, int xOffset, int yOffset, TimeSpan?clickTime) { List <MouseInput> inputs = new(); inputs.Add(MouseInput.MoveToElement(position)); if (xOffset != 0 || yOffset != 0) { inputs.Add(MouseInput.MoveRelative(xOffset, yOffset)); } inputs.Add(down); if (clickTime != null) { inputs.Add(MouseInput.Delay(clickTime.Value)); } inputs.Add(up); return(await element.SendInput(new MouseInput(inputs.ToArray()))); }
public async Task OnClearButtonShown_ControlHeighDoesNotChange() { await using var recorder = new TestRecorder(App); //Arrange IVisualElement grid = await LoadXaml(@" <Grid Margin=""30""> <TextBox VerticalAlignment=""Top"" Text=""Some Text"" materialDesign:TextFieldAssist.HasClearButton=""True""> </TextBox> </Grid>"); IVisualElement textBox = await grid.GetElement("/TextBox"); IVisualElement clearButton = await grid.GetElement("PART_ClearButton"); await textBox.MoveKeyboardFocus(); //Delay needed to accout for transition storyboard await Task.Delay(MaterialDesignTextBox.FocusedAimationTime); double initialHeight = await textBox.GetActualHeight(); //Act await clearButton.Click(); //Assert await Task.Delay(MaterialDesignTextBox.FocusedAimationTime); double height = await textBox.GetActualHeight(); Assert.Equal(initialHeight, height); recorder.Success(); }
/** * * Sets the renderer's data, owner and label properties. * It does this by calling rendererUpdateDelegate.UpdateRenderer(). * By default, rendererUpdateDelegate points to ourselves, but if * the "true owner" of the item renderer is a List, then the * rendererUpdateDelegate points to that object. The * rendererUpdateDelegate.UpdateRenderer() call is in charge of * setting all the properties on the renderer, like owner, itemIndex, * data, selected, etc... Note that data should be the last property * set in this lifecycle. */ private void SetUpItemRenderer(IVisualElement renderer, int itemIndex, object data) { if (null == renderer) return; // keep track of whether we are actively updating an renderers // so we can ignore any collectionChange.UPDATE events _renderersBeingUpdated = true; // Defer to the rendererUpdateDelegate // to update the renderer. By default, the delegate is DataGroup _rendererUpdateDelegate.UpdateRenderer(renderer, itemIndex, data); // technically if this got called "recursively", this _renderersBeingUpdated flag // would be prematurely set to false, but in most cases, this check should be // good enough. _renderersBeingUpdated = false; }
///<summary> /// Updates the renderer for reuse ///</summary> ///<param name="renderer"></param> ///<param name="itemIndex"></param> ///<param name="data"></param> public virtual void UpdateRenderer(IVisualElement renderer, int itemIndex, object data) { // set the owner renderer.Owner = this; // Set the index if (renderer is IItemRenderer) ((IItemRenderer)renderer).ItemIndex = itemIndex; // set the label to the toString() of the data if (renderer is IItemRenderer) ((IItemRenderer)renderer).Text = ItemToLabel(data); // always set the data last if ((renderer is IDataRenderer) && (renderer != data)) ((IDataRenderer)renderer).Data = data; }
public virtual void Add(IVisualElement child) { if(!Children.Contains(child)) { child.Parent = this; Children.Add(child); } }
private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e) { IVisualElement selectedElement = (IVisualElement)((FrameworkElement)sender).DataContext; _vm.LastSelected = selectedElement; }
public virtual void Remove(IVisualElement child) { if (Children.Contains(child)) { child.Parent = null; Children.Remove(child); child.Dispose(); } }
//--------------------------------- // Utility methods for subclasses //--------------------------------- /** * * * Utility method to calculate a skin part's position relative to our component. * * Param: part The skin part instance to obtain coordinates of. * * Returns: The component relative position of the part. */ /// <summary> /// /// </summary> /// <param name="part"></param> /// <returns></returns> protected Point GetSkinPartPosition(IVisualElement part) { return (null == part || null == part.Parent) ? new Point(0, 0) : GlobalToLocal(part.Parent.LocalToGlobal(new Point(LayoutUtil.GetLayoutBoundsX((InvalidationManagerClient)part), LayoutUtil.GetLayoutBoundsY((InvalidationManagerClient)part)))); }
/*protected override void PartAdded(string partName, object instance) { base.PartAdded(partName, instance); if (instance == DataGroup) { // Not your typical delegation, see 'set useVirtualLayout' if (_useVirtualLayout && null != DataGroup.Layout) DataGroup.Layout.UseVirtualLayout = true; } }*/ public override void UpdateRenderer(IVisualElement renderer, int itemIndex, object data) { //var transitions; // First clean up any old, stale properties like selected and caret if (renderer is IItemRenderer) { //IItemRenderer(renderer).selected = false; ((IItemRenderer)renderer).ShowsCaret = false; } // Set any new properties on the renderer now that it's going to // come back into use. ItemSelected(itemIndex, IsItemIndexSelected(itemIndex)); /* if (IsItemIndexSelected(itemIndex)) ItemSelected(itemIndex, true); */ if (IsItemIndexShowingCaret(itemIndex)) ItemShowingCaret(itemIndex, true); // Now run through and initialize the renderer correctly. We // call super.updateRenderer() last because super.updateRenderer() // sets the data on the item renderer, and that should be done last. base.UpdateRenderer(renderer, itemIndex, data); }