public usrUserInformation() { InitializeComponent(); DataContext = this; navUser = addDetailControl(new usrUserInfo()); navSizes = addDetailControl(new usrUserSizes()); //InvitationListHost wpfHost = new InvitationListHost(); //wpfHost.Child = new InvitationListControl(); //wpfHost.Dock = DockStyle.Fill; navNewInvitations = addDetailControl(new InvitationListControl()); navMessages = addDetailControl(new usrMessagesBoard()); //this.SuspendLayout(); //naviBar1.ActiveBand = navUser; accordionCtrl.Items.Add(navUser); accordionCtrl.Items.Add(navSizes); accordionCtrl.Items.Add(navNewInvitations); accordionCtrl.Items.Add(navMessages); foreach (var detailControl in PluginsManager.Instance.UserDetailControls) { var item = addDetailControl(detailControl.Create()); accordionCtrl.Items.Add(item); } updateButtons(false); }
public void AddNewNoteAccordionItem() { // Create a item with a note AccordionItem item = new AccordionItem(Lang.Get("note_new"), imgNote.Images[0]); item.Tag = new Note(); // New note // Setup the new text box RichTextBox text = new RichTextBox(); text.LinkClicked += NoteLinkClicked; text.BorderStyle = BorderStyle.None; text.Multiline = true; text.WordWrap = chkWordWrap.Checked; text.ScrollBars = RichTextBoxScrollBars.Both; text.Font = (chkMonospace.Checked ? new Font(notes_monospace_font, 10) : new Font(this.Font.FontFamily, 10)); text.Validated += delegate { try { ((Note)item.Tag).Text = text.Text; item.Text = ShortenString(((Note)item.Tag).Text, 50); } catch { } }; item.Resize += delegate { try { text.SetBounds(0, 1, item.SpaceAvailable.Width, item.SpaceAvailable.Height - 1); } catch {} }; item.AddControl(text); // Add item to the accordion, select it accordion.AddAccordionItem(item); accordion.SelectItemWithAnimation(item); text.Focus(); // Adjust scrolling RedrawNotesScroll(); }
public virtual void AccordionItemPeerSelectAlreadySelected() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.One; AccordionItem first = new AccordionItem { Header = "First" }; AccordionItem second = new AccordionItem { Header = "Second" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => second.IsSelected = true, () => Assert.IsFalse(first.IsSelected, "First item should not be selected!"), () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Thread.Sleep(40), () => Assert.IsTrue(first.IsSelected, "First item should be selected!"), () => Assert.IsFalse(second.IsSelected, "Second item should not be selected!")); }
private AccordionItem GenerateInvoiceHeaderAccordion() { var item = new AccordionItem(); var headerGrid = new Grid() { Padding = new Thickness(10, 0, 0, 10) }; var headerLabel = new Label() { Text = "Invoice Date", HeightRequest = 50, VerticalTextAlignment = TextAlignment.Center }; headerGrid.Children.Add(headerLabel); var contentGrid = new Grid() { Padding = new Thickness(10, 0, 0, 10), BackgroundColor = Color.NavajoWhite }; var contentLabel = new Label() { Text = "11.03 AM, 15 January 2019", HeightRequest = 50, VerticalTextAlignment = TextAlignment.Center }; contentGrid.Children.Add(contentLabel); item.Header = headerGrid; item.Content = contentGrid; return(item); }
void CreateModuleItem(AccordionItem AcorItems, ServiceAuthenInitialize.CsDesktopItem moduleItem, StackPanel bodyPanel) { StackPanel panel = new StackPanel(); panel.Height = Double.NaN; panel.Width = Double.NaN; panel.Background = new SolidColorBrush(Colors.Red); //panel.b= new Thickness(0, 0, 0, 1); panel.Background = new SolidColorBrush(Color.FromArgb(250, 74, 74, 74)); //ligne ou se trouve le carré ou se trouve icone de menu gauche AcorItems.Background = new SolidColorBrush(Color.FromArgb(250, 74, 74, 74)); AcorItems.FontSize = 13; AcorItems.FontWeight = FontWeights.Bold; AcorItems.Foreground = new SolidColorBrush(Colors.White); AcorItems.BorderBrush = new SolidColorBrush(Color.FromArgb(200, 102, 102, 102)); AcorItems.BorderThickness = new Thickness(0, 0, 0, 1); //Image Image image = new Image(); image.Height = 20; image.Name = moduleItem.Process; image.Margin = new Thickness(50, 8, 50, 5); image.Width = 20; image.Stretch = Stretch.Fill; string urlImage = "/Galatee.ModuleLoader;component/Image/" + moduleItem.Process + ".png"; string defaultImage = "/Galatee.ModuleLoader;component/Image/mnuToolbox.png"; Uri uriImage; try { uriImage = new Uri(urlImage, UriKind.Relative); } catch (Exception ex) { uriImage = new Uri(defaultImage, UriKind.Relative); string error = ex.Message; } image.Source = new BitmapImage(uriImage); image.SetValue(Canvas.LeftProperty, 42.0); image.SetValue(Canvas.TopProperty, 15.0); image.MouseLeftButtonDown += new MouseButtonEventHandler(button_Click); panel.Children.Add(image); //TextBlock TextBlock textb = new TextBlock(); textb.Text = moduleItem.LIBELLE_FONCTION; textb.SetValue(Canvas.LeftProperty, 30.0); textb.SetValue(Canvas.TopProperty, 86.0); textb.Foreground = new SolidColorBrush(Colors.Red); bodyPanel.Children.Add(panel); }
public virtual void AccordionItemPeerRemoveSelectionNoAccordion() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.ZeroOrMore; AccordionItem first = new AccordionItem { Header = "First" }; AccordionItem second = new AccordionItem { Header = "Second" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => first.IsSelected = true, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.RemoveFromSelection(), () => Thread.Sleep(40), () => Assert.IsFalse(first.IsSelected, "Item should be not selected!")); }
public virtual void AccordionPeerGetSelectionChanged() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.ZeroOrMore; AccordionItem first = new AccordionItem { Header = "First", Content = "a" }; AccordionItem second = new AccordionItem { Header = "Second", Content = "b" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionProvider provider = null; IRawElementProviderSimple[] selection = null; TestAsync( acc, () => second.IsSelected = true, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(acc) as ISelectionProvider, () => FrameworkElementAutomationPeer.CreatePeerForElement(second), () => selection = provider.GetSelection(), () => Assert.AreEqual(1, selection.Length, "Expected a selection!"), () => second.IsSelected = false, () => selection = provider.GetSelection(), () => Assert.IsNotNull(selection, "An empty selection was expected!"), () => Assert.AreEqual(0, selection.Length, "No items should be selected!")); }
private void LoadAcc() { string sql = "select * from tbl_Contents"; SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnectionString"].ToString()); SqlCommand cmd = new SqlCommand(sql, myConnection); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count != 0) { Label lbTitle; Label lbContent; AccordionItem acc; int i = 0; foreach (DataRow dr in ds.Tables[0].Rows) { lbTitle = new Label(); lbContent = new Label(); lbTitle.Text = dr["Title"].ToString(); lbContent.Text = dr["Detail"].ToString(); acc = new AccordionItem(); acc.Text = lbTitle.Text; acc.ID = "Pane" + i; acc.ContentSection.Controls.Add(lbContent); Accordion.Items.Add(acc); ++i; } } }
public AccordionGettingStartedCSharp() { // >> accordion-gettingstarted-csharp var accordion = new RadAccordion(); var attachmentsSection = new AccordionItem { HeaderText = "Attachments" }; attachmentsSection.Content = new Label { Text = "Attach files", Margin = 30 }; accordion.Children.Add(attachmentsSection); var commentsSection = new AccordionItem { HeaderText = "Comments" }; commentsSection.Content = new Label { Text = "Add your comment here", Margin = 30 }; accordion.Children.Add(commentsSection); var ratingSection = new AccordionItem { IsExpanded = true, HeaderText = "Rating" }; ratingSection.Content = new RadShapeRating { Margin = 20 }; accordion.Children.Add(ratingSection); // << accordion-gettingstarted-csharp Content = accordion; }
void CreateModuleMenu(List <ServiceAuthenInitialize.CsDesktopGroup> modules, Accordion accordian) { try { //AccordionItem foreach (ServiceAuthenInitialize.CsDesktopGroup module in modules) { AccordionItem AcorItems = new AccordionItem(); AcorItems.Header = module.NOM; //AcorItems.Background = new SolidColorBrush(bgColor); StackPanel bodyPanel = new StackPanel(); //panel.Height = Double.NaN; //panel.Width = Double.NaN; bodyPanel.Height = Double.NaN; bodyPanel.Width = Double.NaN; //bodyPanel.Height = 150; //bodyPanel.Width = 150; bodyPanel.Background = new SolidColorBrush(Colors.White); //bodyPanel.Background = new SolidColorBrush(Colors.LightGray); foreach (ServiceAuthenInitialize.CsDesktopItem item in module.SubItems) { CreateModuleItem(AcorItems, item, bodyPanel); } // peupler l'accordian AcorItems.Content = bodyPanel; accordian.Items.Add(AcorItems); } } catch (Exception ex) { throw ex; } }
public virtual void ShouldAllowContentToResizeInNonFixedSizeScenario() { Accordion acc = new Accordion(); AccordionItem item = new AccordionItem(); item.Content = new Shapes.Rectangle() { Width = 100, Height = 100 }; acc.Items.Add(item); TestAsync( acc, () => item.IsSelected = true, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item.ActualWidth < 110), () => Assert.IsTrue(item.ActualHeight < 110), () => Assert.IsTrue(item.ActualHeight > 60), () => ((Shapes.Rectangle)item.Content).Height = 400, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item.ActualHeight > 230)); }
void f_ServicesLoaded(object sender, EventArgs e) { ArcServerFolder f = sender as ArcServerFolder; AccordionItem itm = new AccordionItem(); itm.Header = f.folderName; ScrollViewer scroll = new ScrollViewer(); scroll.Width = this.accordion1.ActualWidth - 10; StackPanel stack = new StackPanel(); foreach (ServiceDef svc in f.Services) { if (svc.Type.ToLower() == "mapserver") { CheckBox chk = new CheckBox(); chk.Content = svc.Name.Replace(f.folderName + "/", ""); chk.Tag = f.parentUrl + "/" + svc.Name + "/MapServer"; chk.Checked += new RoutedEventHandler(chk_Checked); chk.Unchecked += new RoutedEventHandler(chk_Unchecked); stack.Children.Add(chk); } } scroll.Content = stack; itm.Content = scroll; if (stack.Children.Count > 0) { this.accordion1.Items.Add(itm); } }
public virtual void ShouldBindContentAlignments() { Accordion acc = new Accordion(); AccordionItem item = new AccordionItem(); item.Content = new Button() { Content = "content" }; acc.Width = 300; acc.Height = 300; acc.Items.Add(item); TestAsync( acc, () => item.IsSelected = true, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(((Button)item.Content).ActualWidth < 200), () => Assert.IsTrue(((Button)item.Content).ActualHeight < 200), () => item.VerticalContentAlignment = VerticalAlignment.Stretch, () => item.HorizontalContentAlignment = HorizontalAlignment.Stretch, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(((Button)item.Content).ActualWidth > 200), () => Assert.IsTrue(((Button)item.Content).ActualHeight > 200)); }
private void SetMouseEvents(object sender, RoutedEventArgs e) { foreach (KeyValuePair <string, string> keyValuePair in accordionAccordionItem.Items) { AccordionItem container = accordionAccordionItem.ItemContainerGenerator.ContainerFromItem(keyValuePair) as AccordionItem; if (container != null) { container.MouseEnter += (s, args) => { if (!container.IsLocked) { container.IsSelected = true; } }; container.MouseLeave += (s, args) => { if (!container.IsLocked) { container.IsSelected = false; } }; } } }
public void AddChild(AccordionItem item) { Items.Add(item); if (AlwaysOpen) { item.Open(); } }
public List <Common.AccordionItem> GetCurrentUserMenu(System.Web.Mvc.Controller controller) { List <AccordionItem> menulist = new List <AccordionItem>(); IList <SmartBox.Console.Common.Privilege> list = GetList(controller); if (list != null) { var topmenu = list.Where(x => x.ParentID == "0"); if (topmenu != null) { foreach (SmartBox.Console.Common.Privilege p in topmenu) { AccordionItem item = new AccordionItem(); item.Text = p.PrivilegeName; item.Code = p.PrivilegeCode; item.IsExpand = false; item.Url = p.Uri; item.ID = p.ID; item.IcoSrc = ""; SmartBox.Console.Common.Privilege privilege = p; var child = list.Where(x => x.ParentID == privilege.ID.ToString()); if (child != null) { foreach (SmartBox.Console.Common.Privilege pc in child) { AccordionItem citem = new AccordionItem(); citem.Text = pc.PrivilegeName; citem.Code = pc.PrivilegeCode; citem.Url = pc.Uri; citem.IcoSrc = ""; citem.ID = pc.ID; citem.Type = pc.PrivilegeType.ToString(); //检查citem的节点,如有则添加 SmartBox.Console.Common.Privilege lefprivilege = pc; var childleaf = list.Where(x => x.ParentID == pc.ID.ToString()); foreach (SmartBox.Console.Common.Privilege pcleaf in childleaf) { AccordionItem litem = new AccordionItem(); litem.Text = pcleaf.PrivilegeName; litem.Code = pcleaf.PrivilegeCode; litem.Url = pcleaf.Uri; litem.IcoSrc = ""; litem.ID = pcleaf.ID; citem.Children.Add(litem); } item.Children.Add(citem); } } menulist.Add(item); } } } return(menulist); }
private void BuildControls() { CalculationsAccordion.Items.Clear(); AccordionItems.Clear(); LabelLabels.Clear(); ValueLabels.Clear(); string[] displayLabelConfigurationStrings = null; if (Calculations.Instance != null) { displayLabelConfigurationStrings = Calculations.CharacterDisplayCalculationLabels; } else { displayLabelConfigurationStrings = new string[0]; } foreach (string displayLabelConfigurationString in displayLabelConfigurationStrings) { string[] displayLabelConfigurationSplit = displayLabelConfigurationString.Split(':'); string group = displayLabelConfigurationSplit[0]; if (!AccordionItems.ContainsKey(group)) { AccordionItem accordionItem = new AccordionItem(); accordionItem.Header = group; accordionItem.Tag = group; accordionItem.IsSelected = true; StackPanel accordionSp = new StackPanel(); accordionSp.Margin = new Thickness(4); accordionItem.Content = accordionSp; AccordionItems[group] = accordionItem; CalculationsAccordion.Items.Add(accordionItem); } string name = displayLabelConfigurationSplit[1]; string[] nameSplit = name.Split('*'); name = nameSplit[0]; StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; TextBlock labelLabel = new TextBlock(); labelLabel.Width = 160; labelLabel.Text = name + (nameSplit.Length > 1 ? ": *" : ":"); sp.Children.Add(labelLabel); LabelLabels[name] = labelLabel; if (nameSplit.Length > 1) { ToolTipService.SetToolTip(labelLabel, nameSplit[1]); } TextBlock labelValue = new TextBlock(); ValueLabels[name] = labelValue; sp.Children.Add(labelValue); ((StackPanel)AccordionItems[group].Content).Children.Add(sp); } }
internal void AddItem(AccordionItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } _items.Add(item); }
private List <AccordionItem> GetCurrentUserMenuByBUA() { List <AccordionItem> menulist = new List <AccordionItem>(); string privilegeTree = AuthorizationService.QueryAllPrivilegeTree(base.CurrentUser.UserUId); //根据用户得顶级权限 Beyondbit.BUA.Client.Privilege[] privilegeParent = AuthorizationService.QuerySubPrivileges(base.CurrentUser.UserUId); //根据用户和顶级权限,得第2级权限 if (privilegeParent != null && privilegeParent.Length > 0) { foreach (Beyondbit.BUA.Client.Privilege pp in privilegeParent) { AccordionItem _item = new AccordionItem(); _item.Text = pp.PrivilegeName; _item.Code = pp.PrivilegeCode; _item.IsExpand = false; _item.Url = pp.MenuUrl; _item.IcoSrc = ""; Beyondbit.BUA.Client.Privilege[] privilege = AuthorizationService.QuerySubPrivileges(base.CurrentUser.UserUId, privilegeParent[0].PrivilegeCode); if (privilege.Length > 0 && privilege != null) { foreach (Beyondbit.BUA.Client.Privilege p in privilege) { //二级 AccordionItem item = new AccordionItem(); item.Text = p.PrivilegeName; item.Code = p.PrivilegeCode; item.IsExpand = false; item.Url = p.MenuUrl; item.IcoSrc = ""; // Beyondbit.BUA.Client.Privilege[] child = AuthorizationService.QuerySubPrivileges(base.CurrentUser.UserUId, p.PrivilegeCode); if (child != null) { foreach (Beyondbit.BUA.Client.Privilege pc in child) { //三级 AccordionItem citem = new AccordionItem(); citem.Text = pc.PrivilegeName; citem.Code = pc.PrivilegeCode; citem.Url = pc.MenuUrl; citem.IcoSrc = ""; item.Children.Add(citem); } } _item.Children.Add(item); } } menulist.Add(_item); } } return(menulist); }
public virtual void AccordionItemAutomationPeerTypeAndClass() { AccordionItem item = new AccordionItem(); AccordionItemAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => Assert.AreEqual(AutomationControlType.ListItem, peer.GetAutomationControlType(), "Unexpected AutomationControlType!"), () => Assert.AreEqual("AccordionItem", peer.GetClassName(), "Unexpected ClassType!")); }
public virtual void AccordionItemPeerSelectionContainerNoParent() { AccordionItem item = new AccordionItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => Assert.IsNull(provider.SelectionContainer, "AccordionItemAutomationPeer should not have a SelectionContainer!")); }
public virtual void AccordionItemPeerIsIExpandCollapseProvider() { AccordionItem item = new AccordionItem(); IExpandCollapseProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as IExpandCollapseProvider, () => Assert.IsNotNull(provider, "AccordionItemAutomationPeer should implement IExpandCollapseProvider!")); }
public virtual void AccordionItemCreatesAutomationPeer() { AccordionItem item = new AccordionItem(); AccordionItemAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => Assert.IsNotNull(peer, "AccordionItem peer should not be null!"), () => Assert.AreEqual(item, peer.Owner, "AccordionItem should be owner of the peer!")); }
public virtual void AccordionItemPeerAddSelectionNoAccordion() { AccordionItem item = new AccordionItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => provider.AddToSelection()); }
/// <summary> /// Adds all the tool panels to the control, after all the MEF /// imports have been satisfied /// </summary> public void OnImportsSatisfied() { // Sort the extensions by index this.Extensions.Sort(delegate(IToolPanelItemViewExtension item1, IToolPanelItemViewExtension item2) { return(item1.ViewModel.Index.CompareTo(item2.ViewModel.Index)); }); // Loop through all extensions and created an AccordionItem for each foreach (IToolPanelItemViewExtension toolPanelItemViewExtension in this.Extensions) { AccordionItem newItem; bool alreadyContains = false; // Make sure we don't try to add the item twice // TODO: This is a bit of a hack becaue OnImportsSatisfied() is getting called more than once foreach (AccordionItem item in parentToolPanel.Items) { if ((string)item.Header == toolPanelItemViewExtension.ViewModel.ToolName) { alreadyContains = true; break; } } if (!alreadyContains) { try { // Create the AccordionItem newItem = new AccordionItem(); newItem.Header = toolPanelItemViewExtension.ViewModel.ToolName; newItem.Content = toolPanelItemViewExtension; } catch { newItem = null; } // Define binding for IsEnabled property Binding binding = new Binding() { Source = toolPanelItemViewExtension.ViewModel, Path = new PropertyPath("IsEnabled") }; newItem.SetBinding(AccordionItem.IsEnabledProperty, binding); //ToolTipService.SetToolTip(newItem, toolPanelItemViewExtension.ViewModel.Description); // Add the AccordionItem to the Accordion parentToolPanel.Items.Add(newItem); } } }
public virtual void AccordionItemPeerSelectNoAccordion() { AccordionItem item = new AccordionItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(item.IsSelected, "Item should be selected!")); }
/// <summary> /// Removes the current Accordion 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() { AccordionItem owner = OwnerAccordionItem; Accordion parent = owner.ParentAccordion; if (parent == null) { throw new InvalidOperationException(Controls.Properties.Resources.Automation_OperationCannotBePerformed); } parent.SelectedItems.Remove(owner); }
public void CloseAll(AccordionItem exceptItem = null) { foreach (var item in Items) { if (item == exceptItem) { continue; } item.Close(); } }
public AccordionItem GetAccordionItemHyperlink(object header, int menuId, string uriLink, string uriIcon, Style style) { AccordionItem Items3 = new AccordionItem(); Items3.Header = header; Items3.Content = uriLink; Items3.Selected += new RoutedEventHandler(accoclick); Items3.Style = style; Items3.TabIndex = menuId; return(Items3); }
public virtual void AccordionItemPeerExpandStateCollapsed() { AccordionItem item = new AccordionItem(); AccordionItemAutomationPeer peer = null; IExpandCollapseProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider, () => Assert.AreEqual(ExpandCollapseState.Collapsed, provider.ExpandCollapseState, "Unexpected ExpandCollapseState!")); }
public Accordion AddItem(string id, bool active, Func<dynamic, HelperResult> headerTemplate, Func<dynamic, HelperResult> contentTemplate) { AccordionItem item = new AccordionItem() { Id = id, Content = contentTemplate(null).ToHtmlString(), Title = string.Empty, HeaderContent = headerTemplate(null).ToHtmlString(), Active = active }; _items.Add(item); return this; }
public virtual void ShouldResizeItemsWhenAccordionIsResized() { // todo: This test should be rewritten once RX comes online. // the below is too fragile, so I do not want to enable this test at this point. Accordion acc = new Accordion(); AccordionItem item1 = new AccordionItem(); AccordionItem item2 = new AccordionItem(); acc.Height = 200; acc.SelectionMode = AccordionSelectionMode.ZeroOrMore; acc.Items.Add(item1); acc.Items.Add(item2); item1.IsSelected = true; item2.IsSelected = true; TestAsync( acc, () => Thread.Sleep(10), // make sure the expand animation has finished () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item1.ActualHeight > 30 && item1.ActualHeight < 105), () => acc.Height = 400, () => Thread.Sleep(10), // make sure the expand animation has finished () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item1.ActualHeight > 105 && item1.ActualHeight < 220), () => acc.Height = 200, () => Thread.Sleep(10), // make sure the expand animation has finished () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item1.ActualHeight > 30 && item1.ActualHeight < 105)); }
public virtual void AccordionItemPeerCollapseDisabled() { AccordionItem item = new AccordionItem { IsEnabled = false }; AccordionItemAutomationPeer peer = null; IExpandCollapseProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider, () => provider.Collapse()); }
public virtual void AccordionItemPeerSupportsExpandCollapse() { AccordionItem item = new AccordionItem(); AccordionItemAutomationPeer peer = null; IExpandCollapseProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider, () => Assert.IsNotNull(provider, "IExpandCollapseProvider peer should not be null!")); }
public virtual void AccordionItemPeerOnlySupportsSelectionAndExpandCollapse() { AccordionItem item = new AccordionItem(); AccordionItemAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => Assert.IsNull(peer.GetPattern(PatternInterface.Dock), "AccordionItemAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Grid), "AccordionItemAutomationPeer should not support the Grid pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.GridItem), "AccordionItemAutomationPeer should not support the GridItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Invoke), "AccordionItemAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.MultipleView), "AccordionItemAutomationPeer should not support the MultipleView pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.RangeValue), "AccordionItemAutomationPeer should not support the RangeValue pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "AccordionItemAutomationPeer should not support the Scroll pattern!"), () => Assert.IsNotNull(peer.GetPattern(PatternInterface.SelectionItem), "AccordionItemAutomationPeer should support the SelectionItem pattern!"), () => Assert.IsNotNull(peer.GetPattern(PatternInterface.ExpandCollapse), "AccordionItemAutomationPeer should support the ExpandCollapse pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Table), "AccordionItemAutomationPeer should not support the Table pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.TableItem), "AccordionItemAutomationPeer should not support the TableItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Toggle), "AccordionItemAutomationPeer should not support the Toggle pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Transform), "AccordionItemAutomationPeer should not support the Transform pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Value), "AccordionItemAutomationPeer should not support the Value pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Window), "AccordionItemAutomationPeer should not support the Window pattern!")); }
public virtual void ShouldThrowExceptionWhenSettingContentTargetSize() { AccordionItem item = new AccordionItem(); item.SetValue(AccordionItem.ContentTargetSizeProperty, new Size(3, 3)); }
public virtual void AccordionItemPeerExpandStateExpanded() { AccordionItem item = new AccordionItem { IsSelected = true }; AccordionItemAutomationPeer peer = null; IExpandCollapseProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider, () => Assert.AreEqual(ExpandCollapseState.Expanded, provider.ExpandCollapseState, "Unexpected ExpandCollapseState!")); }
/// <summary> /// Called when an AccordionItem selected. /// </summary> /// <param name="accordionItem">The accordion item that was selected.</param> internal void OnAccordionItemSelected(AccordionItem accordionItem) { SelectItem(ItemContainerGenerator.IndexFromContainer(accordionItem)); }
/// <summary> /// Starts the next action in the list, in a particular order. /// </summary> /// <remarks>An AccordionItem is should always signal that it is /// finished with an action.</remarks> private void StartNextAction() { if (_currentActioningItem != null) { return; } // First do collapses, then resizes and finally expands. AccordionItem next = _scheduledActions.FirstOrDefault(item => item.ScheduledAction == AccordionAction.Collapse); if (next == null) { next = _scheduledActions.FirstOrDefault(item => item.ScheduledAction == AccordionAction.Resize); } if (next == null) { next = _scheduledActions.FirstOrDefault(item => item.ScheduledAction == AccordionAction.Expand); } if (next != null) { _currentActioningItem = next; _scheduledActions.Remove(next); next.StartAction(); } }
/// <summary> /// Signals the finish of an action by an item. /// </summary> /// <param name="item">The AccordionItem that finishes an action.</param> /// <remarks>An AccordionItem should always signal a finish, for this call /// will start the next scheduled action.</remarks> internal virtual void OnActionFinish(AccordionItem item) { if (SelectionSequence == SelectionSequence.CollapseBeforeExpand) { lock (this) { if (!_currentActioningItem.Equals(item)) { throw new InvalidOperationException("Properties.Resources.Accordion_OnActionFinish_InvalidFinish"); } _currentActioningItem = null; StartNextAction(); } } }
/// <summary> /// Allows an AccordionItem to signal the need for a visual action /// (resize, collapse, expand). /// </summary> /// <param name="item">The AccordionItem that signals for a schedule.</param> /// <param name="action">The action it is scheduling for.</param> /// <returns>True if the item is allowed to proceed without scheduling, /// false if the item needs to wait for a signal to execute the action.</returns> internal virtual bool ScheduleAction(AccordionItem item, AccordionAction action) { if (SelectionSequence == SelectionSequence.CollapseBeforeExpand) { lock (this) { if (!_scheduledActions.Contains(item)) { _scheduledActions.Add(item); } } if (_currentActioningItem == null) { Dispatcher.BeginInvoke(StartNextAction); } return false; } else { return true; } }
internal void OnHeaderSizeChange(AccordionItem item) { LayoutChildren(); }
/// <summary> /// Add a new AccordionItem /// </summary> /// <param name="item"></param> /// <returns></returns> public AccordionControl AddAccordionItem(AccordionItem item) { this.AccordionItems.Add(item); return this; }
public virtual void AccordionItemPeerCollapseCollapsed() { AccordionItem item = new AccordionItem(); AccordionItemAutomationPeer peer = null; IExpandCollapseProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider, () => provider.Collapse(), () => Thread.Sleep(40), () => Assert.IsFalse(item.IsSelected, "Item should be collapsed!")); }
public virtual void ShouldIgnoreTemplatesSpecificallySet() { Accordion acc = new Accordion(); DataTemplate itemTemplate = new XamlBuilder<DataTemplate> { Name = "itemtemplate" } .Load(); DataTemplate contentTemplate = new XamlBuilder<DataTemplate> { Name = "contenttemplate" } .Load(); acc.ItemTemplate = itemTemplate; acc.ContentTemplate = contentTemplate; DataTemplate customHeaderTemplate = new XamlBuilder<DataTemplate> { Name = "customheadertemplate" } .Load(); DataTemplate customContentTemplate = new XamlBuilder<DataTemplate> { Name = "customcontenttemplate" } .Load(); AccordionItem withTemplates = new AccordionItem() { HeaderTemplate = customHeaderTemplate, ContentTemplate = customContentTemplate }; AccordionItem withoutTemplates = new AccordionItem(); TestAsync( acc, () => acc.Items.Add(withTemplates), () => acc.Items.Add(withoutTemplates), () => Assert.AreNotEqual(itemTemplate, ((AccordionItem)acc.Items[0]).HeaderTemplate), () => Assert.AreNotEqual(contentTemplate, ((AccordionItem)acc.Items[0]).ContentTemplate), () => Assert.AreEqual(itemTemplate, ((AccordionItem)acc.Items[1]).HeaderTemplate), () => Assert.AreEqual(contentTemplate, ((AccordionItem)acc.Items[1]).ContentTemplate), () => Assert.AreEqual(customHeaderTemplate, ((AccordionItem)acc.Items[0]).HeaderTemplate), () => Assert.AreEqual(customContentTemplate, ((AccordionItem)acc.Items[0]).ContentTemplate)); }
public virtual void CreateAccordionItemPeer() { AccordionItem item = new AccordionItem(); new AccordionItemAutomationPeer(item); }
public virtual void AccordionItemPeerSelectionContainer() { AccordionItem item = new AccordionItem { Header = "Item", Content = "a" }; Accordion acc = new Accordion(); acc.Items.Add(item); ISelectionItemProvider provider = null; TestAsync( acc, () => FrameworkElementAutomationPeer.CreatePeerForElement(acc), () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => Assert.IsNotNull(provider.SelectionContainer, "AccordionItemAutomationPeer should have a SelectionContainer!")); }
public virtual void ShouldAllowContentToResizeInNonFixedSizeScenario() { Accordion acc = new Accordion(); AccordionItem item = new AccordionItem(); item.Content = new Shapes.Rectangle() { Width = 100, Height = 100 }; acc.Items.Add(item); TestAsync( acc, () => item.IsSelected = true, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item.ActualWidth < 110), () => Assert.IsTrue(item.ActualHeight < 110), () => Assert.IsTrue(item.ActualHeight > 60), () => ((Shapes.Rectangle) item.Content).Height = 400, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(item.ActualHeight > 230)); }
public virtual void ShouldThrowExceptionWhenSettingExpandDirectionOnAccordionItem() { AccordionItem item = new AccordionItem(); item.SetValue(AccordionItem.ExpandDirectionProperty, ExpandDirection.Left); }
public virtual void ShouldBindContentAlignments() { Accordion acc = new Accordion(); AccordionItem item = new AccordionItem(); item.Content = new Button() { Content = "content" }; acc.Width = 300; acc.Height = 300; acc.Items.Add(item); TestAsync( acc, () => item.IsSelected = true, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(((Button) item.Content).ActualWidth < 200), () => Assert.IsTrue(((Button) item.Content).ActualHeight < 200), () => item.VerticalContentAlignment = VerticalAlignment.Stretch, () => item.HorizontalContentAlignment = HorizontalAlignment.Stretch, () => Thread.Sleep(10), () => Thread.Sleep(10), () => Thread.Sleep(10), () => Assert.IsTrue(((Button) item.Content).ActualWidth > 200), () => Assert.IsTrue(((Button) item.Content).ActualHeight > 200)); }
public virtual void AccordionItemPeerExpandsExpanded() { AccordionItem item = new AccordionItem { IsSelected = true }; AccordionItemAutomationPeer peer = null; IExpandCollapseProvider provider = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer, () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider, () => provider.Expand(), () => Assert.IsTrue(item.IsSelected, "Item should be expanded!")); }
public virtual void ShouldAllowTemplateWithUIElements() { // this tests adds back the coverage lost by the exclusion of // test: Content*DataTemplateWithUIElementsFails (see GetDPTests()) AccordionItem instance = new AccordionItem(); instance.Width = 300; instance.Height = 300; TestAsync( instance, () => { StackPanel element = new StackPanel(); element.SetValue(FrameworkElement.NameProperty, "UIElementContent"); element.Children.Add(new Ellipse { Fill = new SolidColorBrush(Colors.Red), Width = 20, Height = 20 }); element.Children.Add(new TextBlock { Text = "UIElement Content" }); element.Children.Add(new Ellipse { Fill = new SolidColorBrush(Colors.Blue), Width = 20, Height = 20 }); instance.SetValue(ContentControl.ContentProperty, element); }, () => instance.IsSelected = true, () => { // Create the DataTemplate XamlBuilder<DataTemplate> xamlTemplate = new XamlBuilder<DataTemplate> { Name = "template", Children = new List<XamlBuilder> { new XamlBuilder<StackPanel> { Children = new List<XamlBuilder> { new XamlBuilder<StackPanel> { AttributeProperties = new Dictionary<string, string> { { "Orientation", "Horizontal" } }, Children = new List<XamlBuilder> { new XamlBuilder<TextBlock> { AttributeProperties = new Dictionary<string, string> { { "Text", "{}{Binding Name}: " } } }, new XamlBuilder<TextBlock> { Name = "nameBinding", AttributeProperties = new Dictionary<string, string> { { "Text", "{Binding Name}" } } } } }, new XamlBuilder<StackPanel> { AttributeProperties = new Dictionary<string, string> { { "Orientation", "Horizontal" } }, Children = new List<XamlBuilder> { new XamlBuilder<TextBlock> { AttributeProperties = new Dictionary<string, string> { { "Text", "{}{Binding}: " } } }, new XamlBuilder<ContentControl> { Name = "contentBinding", AttributeProperties = new Dictionary<string, string> { { "Content", "{Binding}" } } } } } } } } }; // Generate the DataTemplate and set it instance.SetValue(ContentControl.ContentTemplateProperty, xamlTemplate.Load()); }, () => { // Verify the bindings didn't work TextBlock text = instance.GetVisualChild("nameBinding") as TextBlock; Assert.IsNotNull(text, "Failed to find nameBinding TextBlock!"); TestExtensions.AssertIsNullOrEmpty(text.Text); ContentControl content = instance.GetVisualChild("contentBinding") as ContentControl; Assert.IsNotNull(content, "Failed to find contentBinding ContentControl!"); Assert.IsNull(content.Content, "The bound Content should be null!"); }); }
public virtual void AccordionItemPeerSelect() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.ZeroOrMore; AccordionItem first = new AccordionItem { Header = "First" }; AccordionItem second = new AccordionItem { Header = "Second" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(first.IsSelected, "First item should have been selected!")); }