public virtual void RatingPeerGetSelectionChanged() { Rating acc = new Rating(); acc.ItemsSource = null; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionProvider provider = null; IRawElementProviderSimple[] selection = null; TestAsync( acc, () => acc.Value = 1.0, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(acc) as ISelectionProvider, () => FrameworkElementAutomationPeer.CreatePeerForElement(second), () => selection = provider.GetSelection(), () => Assert.AreEqual(1, selection.Length, "Expected a selection!"), () => acc.Value = 0.0, () => selection = provider.GetSelection(), () => Assert.IsNotNull(selection, "An empty selection was expected!"), () => Assert.AreEqual(0, selection.Length, "No items should be selected!")); }
public virtual void RatingItemPeerAddSelectionNoRating() { RatingItem item = new RatingItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => provider.AddToSelection()); }
public virtual void RatingItemPeerSelectionContainerNoParent() { RatingItem item = new RatingItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => Assert.IsNull(provider.SelectionContainer, "RatingItemAutomationPeer should not have a SelectionContainer!")); }
/// <summary> /// Retrieves a UI Automation provider for each child element that is /// selected. /// </summary> /// <returns>An array of UI Automation providers.</returns> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> public IRawElementProviderSimple[] GetSelection() { RatingItem selectedRatingItem = OwnerRating.GetRatingItems().LastOrDefault(ratingItem => ratingItem.Value > 0.0); if (selectedRatingItem != null) { return(new[] { ProviderFromPeer(FromElement(selectedRatingItem)) }); } return(new IRawElementProviderSimple[] { }); }
public virtual void RatingItemPeerIsISelectionItemProvider() { RatingItem item = new RatingItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => Assert.IsNotNull(provider, "RatingItemAutomationPeer should implement ISelectionItemProvider!")); }
public virtual void RatingItemCreatesAutomationPeer() { RatingItem item = new RatingItem(); RatingItemAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as RatingItemAutomationPeer, () => Assert.IsNotNull(peer, "RatingItem peer should not be null!"), () => Assert.AreEqual(item, peer.Owner, "RatingItem should be owner of the peer!")); }
public virtual void RatingItemAutomationPeerTypeAndClass() { RatingItem item = new RatingItem(); RatingItemAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as RatingItemAutomationPeer, () => Assert.AreEqual(AutomationControlType.ListItem, peer.GetAutomationControlType(), "Unexpected AutomationControlType!"), () => Assert.AreEqual("RatingItem", peer.GetClassName(), "Unexpected ClassType!")); }
/// <summary> /// Adds the RatingItem to the collection of selected items. /// </summary> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> void ISelectionItemProvider.AddToSelection() { RatingItem owner = OwnerRatingItem; Rating parent = owner.ParentRating; if (parent == null || parent.Value != null) { throw new InvalidOperationException(); } owner.SelectValue(); }
public virtual void RatingItemPeerSupportsSelection() { RatingItem item = new RatingItem(); RatingItemAutomationPeer peer = null; ISelectionItemProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as RatingItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider, () => Assert.IsNotNull(provider, "ISelectionItemProvider peer should not be null!")); }
/// <summary> /// Adds the RatingItem to the collection of selected items. /// </summary> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> void ISelectionItemProvider.AddToSelection() { RatingItem owner = OwnerRatingItem; Rating parent = owner.ParentRating; if (parent == null || parent.Value != null) { throw new InvalidOperationException(Controls.Properties.Resources.Automation_OperationCannotBePerformed); } owner.SelectValue(); }
/// <summary> /// Initializes a new instance of the Rating class. /// </summary> public RatingStar() { this.SetStyle(ControlStyles.Selectable, false); _RatingItem = new RatingItem(); _RatingItem.Style = eDotNetBarStyle.Office2007; _RatingItem.RatingChanging += new RatingChangeEventHandler(RatingItemRatingChanging); _RatingItem.RatingChanged += new EventHandler(RatingItemRatingChanged); _RatingItem.AverageRatingChanged += new EventHandler(RatingItemAverageRatingChanged); _RatingItem.ParseAverageRatingValue += new DevComponents.Editors.ParseDoubleValueEventHandler(RatingItemParseAverageRatingValue); _RatingItem.ParseRatingValue += new DevComponents.Editors.ParseIntegerValueEventHandler(RatingItemParseRatingValue); this.HostItem = _RatingItem; }
/// <summary> /// Removes the current Rating from the collection of selected /// items. /// </summary> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> void ISelectionItemProvider.RemoveFromSelection() { RatingItem owner = OwnerRatingItem; Rating parent = owner.ParentRating; if (parent == null) { throw new InvalidOperationException(); } if (!parent.IsReadOnly) { parent.Value = null; } }
/// <summary> /// Removes the current Rating from the collection of selected /// items. /// </summary> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> void ISelectionItemProvider.RemoveFromSelection() { RatingItem owner = OwnerRatingItem; Rating parent = owner.ParentRating; if (parent == null) { throw new InvalidOperationException(Controls.Properties.Resources.Automation_OperationCannotBePerformed); } if (!parent.IsReadOnly) { parent.Value = null; } }
public virtual void RatingItemPeerSelectionContainer() { RatingItem item = new RatingItem(); Rating acc = new Rating(); acc.ItemsSource = null; acc.Items.Add(item); ISelectionItemProvider provider = null; TestAsync( acc, () => FrameworkElementAutomationPeer.CreatePeerForElement(acc), () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => Assert.IsNotNull(provider.SelectionContainer, "RatingItemAutomationPeer should have a SelectionContainer!")); }
public virtual void RatingItemPeerIsSelected() { Rating rating = new Rating(); rating.ItemsSource = null; RatingItem item = new RatingItem(); rating.Items.Add(item); ISelectionItemProvider provider = null; TestAsync( rating, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => Assert.IsFalse(provider.IsSelected, "RatingItemAutomationPeer should not be selected!"), () => rating.Value = 1.0, () => Assert.IsTrue(provider.IsSelected, "RatingItemAutomationPeer should be selected!")); }
public virtual void RatingItemPeerSelect() { Rating acc = new Rating(); acc.ItemsSource = null; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(first.DisplayValue == 1.0, "First item should have been selected!")); }
public virtual void RatingItemPeerAddSelection() { Rating acc = new Rating(); acc.ItemsSource = null; acc.SelectionMode = RatingSelectionMode.Continuous; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(second) as ISelectionItemProvider, () => provider.AddToSelection(), () => Thread.Sleep(40), () => Assert.IsTrue(second.DisplayValue == 1.0, "Second item should have been selected!")); }
public virtual void RatingItemPeerRemoveSelectionNoRating() { Rating acc = new Rating(); acc.ItemsSource = null; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => acc.Value = 1.0, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.RemoveFromSelection(), () => Thread.Sleep(40), () => Assert.IsFalse(first.DisplayValue == 1.0, "Item should be not selected!")); }
public virtual void RatingPeerGetSelectionNoPeer() { Rating acc = new Rating(); acc.ItemsSource = null; acc.SelectionMode = RatingSelectionMode.Individual; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionProvider provider = null; IRawElementProviderSimple[] selection = null; TestAsync( acc, () => acc.Value = 0.0, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(acc) as ISelectionProvider, () => selection = provider.GetSelection(), () => Assert.AreEqual(0, selection.Length, "No items should be selected!")); }
private void GenerateRatingItems() { // Clean up old items foreach (var item in ratingItems) { item.MouseEnter -= ItemMouseEnter; item.MouseLeave -= ItemMouseLeave; item.Click -= ItemClick; } // Create new items var items = new List<RatingItem>(); for (int i = 0; i < Convert.ToInt32(GetValue(MaximumProperty), CultureInfo.InvariantCulture); i++) { var item = new RatingItem() { ItemValue = i + 1, Value = Value }; item.MouseEnter += ItemMouseEnter; item.MouseLeave += ItemMouseLeave; item.Click += ItemClick; items.Add(item); } ratingItems = new ReadOnlyCollection<RatingItem>(items); itemsControl.ItemsSource = ratingItems; }
protected override List <AutomationPeer> GetChildrenCore() { Controls.Rating owner = OwnerRating; ItemCollection items = owner.Items; if (items.Count <= 0) { return(null); } List <AutomationPeer> peers = new List <AutomationPeer>(items.Count); for (int i = 0; i < items.Count; i++) { RatingItem element = owner.ItemContainerGenerator.ContainerFromIndex(i) as RatingItem; if (element != null) { peers.Add(FromElement(element) ?? CreatePeerForElement(element)); } } return(peers); }
public virtual void RatingItemPeerOnlySupportsSelectionAndExpandCollapse() { RatingItem item = new RatingItem(); RatingItemAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as RatingItemAutomationPeer, () => Assert.IsNull(peer.GetPattern(PatternInterface.Dock), "RatingItemAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Grid), "RatingItemAutomationPeer should not support the Grid pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.GridItem), "RatingItemAutomationPeer should not support the GridItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Invoke), "RatingItemAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.MultipleView), "RatingItemAutomationPeer should not support the MultipleView pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.RangeValue), "RatingItemAutomationPeer should support the RangeValue pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "RatingItemAutomationPeer should not support the Scroll pattern!"), () => Assert.IsNotNull(peer.GetPattern(PatternInterface.SelectionItem), "RatingItemAutomationPeer should support the SelectionItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.ExpandCollapse), "RatingItemAutomationPeer should not support the ExpandCollapse pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Table), "RatingItemAutomationPeer should not support the Table pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.TableItem), "RatingItemAutomationPeer should not support the TableItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Toggle), "RatingItemAutomationPeer should not support the Toggle pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Transform), "RatingItemAutomationPeer should not support the Transform pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Value), "RatingItemAutomationPeer should not support the Value pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Window), "RatingItemAutomationPeer should not support the Window pattern!")); }
//In den SendStatsBlock setzen, damit wirklich nur erfasst wird, wenn auch gesendet private void RatingChanged(object sender, EventArgs e) { RatingItem ri = (sender as RatingItem); if (_settings.ContainsKey(ri.Name)) { _settings[ri.Name] = ri.Rating.ToString(); } else { _settings.Add(ri.Name, ri.Rating.ToString()); } DataManager.SaveSettings(_settings); switch (ri.Name) { case "riGUI": SendStats.SendRating("gui", ri.Rating); break; case "riStability": SendStats.SendRating("stability", ri.Rating); break; case "riSupport": SendStats.SendRating("support", ri.Rating); break; case "riUsability": SendStats.SendRating("usability", ri.Rating); break; case "riFunctions": SendStats.SendRating("functions", ri.Rating); break; } }
public virtual void CreateRatingItemPeer() { RatingItem item = new RatingItem(); new RatingItemAutomationPeer(item); }
/// <summary> /// Initializes a new instance of the RatingAutomationPeer class. /// </summary> /// <param name="owner"> /// The Rating that is associated with this /// RatingAutomationPeer. /// </param> public RatingItemAutomationPeer(RatingItem owner) : base(owner) { }
/// <summary> /// Builds a new RatingItem, taking in an optional Style to be applied to it. /// </summary> /// <param name="s">An optional style to apply to the RatingItem</param> /// <returns></returns> private static RatingItem BuildNewRatingItem(Style s) { RatingItem ri = new RatingItem(); if (s != null) { ri.Style = s; } return ri; }
private void OnRatingItemHotSpotChanged(object sender, EventArgs e) { HotSpottedItem = sender as RatingItem; RatingControl.UpdateItems(this, RatingItemUpdateAction.Preview); }