public void TabTest_basic() { #pragma warning disable 0219 Tab tab1 = new Tab("name"); Tab tab2 = new Tab(""); #pragma warning restore 0219 }
public void IsStripListItemArea() { Assert.AreEqual(_sidePane.ItemAreaStyle, SidePaneItemAreaStyle.StripList); var tab = new Tab("tabname"); _sidePane.AddTab(tab); var itemAreas = TestUtilities.GetPrivateField(_sidePane, "_itemAreas") as Dictionary<Tab, IItemArea>; Assert.IsNotNull(itemAreas); foreach (var area in itemAreas.Values) Assert.IsInstanceOf<ToolStrip>(area); }
public TestWindow() { InitializeComponent(); sidePane = new SidePane(this.splitContainer1.Panel1, SidePaneItemAreaStyle.List); // Add some tabs Tab scriptureTab = new Tab("Scripture"); Tab backTab = new Tab("Back"); Tab printTab = new Tab("Print"); sidePane.AddTab(scriptureTab); sidePane.AddTab(backTab); sidePane.AddTab(printTab); // Add items to certain tabs var itemIcon = new Bitmap(32, 32); for (int x = 0; x < itemIcon.Width; ++x) for (int y = 0; y < itemIcon.Height; ++y) itemIcon.SetPixel(x, y, Color.Blue); Item scriptureDraftItem = new Item("Draft") { Icon = itemIcon, }; Item scripturePrintItem = new Item("Print Scr Layout") { Icon = itemIcon, }; Item backDraftItem = new Item("Draft") { Icon = itemIcon, }; Item backPrintItem = new Item("Print Back Layout") { Icon = itemIcon, }; sidePane.AddItem(scriptureTab, scriptureDraftItem); sidePane.AddItem(scriptureTab, scripturePrintItem); sidePane.AddItem(backTab, backDraftItem); sidePane.AddItem(backTab, backPrintItem); // Set up click handling - make main pane look different upon item click sidePane.ItemClicked += new SidePane.ItemClickedEventHandler(sidePane_ItemClicked); }
public void MakeSidePaneWithManyItems() { // Put sidepane on a window using (Form window = new Form()) { window.Height = 600; window.Width = 600; SplitContainer container = new SplitContainer(); container.Dock = DockStyle.Fill; container.SplitterWidth = 100; window.Controls.Add(container); using (SidePane sidepane = new SidePane(container.Panel1, ItemAreaStyle)) { // Add a tab and a lot of items Tab tab = new Tab("tabname"); sidepane.AddTab(tab); for (int i = 0; i < 50; ++i) { sidepane.AddItem(tab, new Item("item" + i.ToString())); } try { // Display the window and its contents window.Show(); Application.DoEvents(); Assert.IsTrue(window.Visible); } finally { window.Hide(); Application.DoEvents(); } } } }
/// <summary> /// Handle when a tab on the sidepane is clicked. /// </summary> private void SidePaneTabClickedHandler(Tab tabClicked) { var choice = tabClicked.Tag as ChoiceBase; Debug.Assert(choice != null, "SidePaneTabClickedHandler received a Tab with an invalid Tag."); if (choice != null) choice.OnClick(this, null); }
public void SelectTab_thatDoesntExist() { Tab tab = new Tab("tabname"); _sidePane.SelectTab(tab); }
/// <summary> /// Whether this sidepane contains tab. /// </summary> private bool ContainsTab(Tab tab) { return _itemAreas.ContainsKey(tab); }
/// <summary> /// Whether this sidepane contains tab. /// </summary> private bool ContainsTab(Tab tab) { return(_itemAreas.ContainsKey(tab)); }
/// <summary>Select a tab.</summary> /// <returns>true upon success. false if tab is disabled (and exists in this sidepane).</returns> public bool SelectTab(Tab tab, bool andSelectAnItemOnThatTab) { if (tab == null) throw new ArgumentNullException("tab"); if (!ContainsTab(tab)) throw new ArgumentOutOfRangeException("tab", tab, "sidepane does not contain tab"); if (tab.Enabled == false) return false; _generateItemEvents = andSelectAnItemOnThatTab; // Optionally suppress selecting an item _tabArea.SetSelectionChanged(tab.UnderlyingWidget); InvokeTabClicked(tab); _generateItemEvents = true; return true; }
/// <remarks>tab must be a tab in this sidepane</remarks> private bool TabContainsItem(Tab tab, Item item) { if (tab == null) throw new ArgumentNullException("tab"); if (item == null) throw new ArgumentNullException("item"); if (!ContainsTab(tab)) throw new ArgumentOutOfRangeException("tab", tab, "tab is not a tab in this sidepane."); return _itemAreas[tab].Items.Contains(item); }
public void ItemClickEvent_basic() { _sidePane.ItemClicked += ItemClickedHandler; Tab tab = new Tab("tabname"); Item item = new Item("itemname"); _sidePane.AddTab(tab); _sidePane.AddItem(tab, item); Assert.IsFalse(_itemClickedHappened); _sidePane.SelectItem(tab, item.Name); Assert.IsTrue(_itemClickedHappened); }
public void SelectItem_onNonexistentTab() { Tab tab = new Tab("tabname"); string itemName = "itemName"; _sidePane.SelectItem(tab, itemName); }
public void CurrentItem() { Tab tab = new Tab("tabname"); Item item = new Item("itemname"); _sidePane.AddTab(tab); _sidePane.AddItem(tab, item); _sidePane.SelectItem(tab, item.Name); Item currentItem = _sidePane.CurrentItem; Assert.AreSame(item, currentItem); }
public void GetTabByName() { Tab tab = new Tab("tabname"); _sidePane.AddTab(tab); Tab result = _sidePane.GetTabByName(tab.Name); Assert.AreSame(tab, result); }
public void CurrentTab() { Tab tab = new Tab("tabname"); _sidePane.AddTab(tab); _sidePane.SelectTab(tab); Tab result = _sidePane.CurrentTab; Assert.AreSame(tab, result); }
public void SelectItem_basic() { Tab tab = new Tab("tabname"); Item item = new Item("itemname"); _sidePane.AddTab(tab); _sidePane.AddItem(tab, item); var result = _sidePane.SelectItem(tab, item.Name); Assert.IsTrue(result); }
public void SelectItem_thatDoesNotExist() { Tab tab = new Tab("tabname"); string itemName = "non-existent itemname"; _sidePane.AddTab(tab); var result = _sidePane.SelectItem(tab, itemName); Assert.IsFalse(result); }
public void CurrentTab_whenNoneSelected() { Tab currentTab = _sidePane.CurrentTab; Assert.IsNull(currentTab); }
private void TabClickedHandler(Tab tabClicked) { _tabClickedHappened = true; }
public void TabClickEvent_basic() { Tab tab = new Tab("tabname"); _sidePane.AddTab(tab); _sidePane.TabClicked += TabClickedHandler; Assert.IsFalse(_tabClickedHappened); _sidePane.SelectTab(tab); Assert.IsTrue(_tabClickedHappened); }
/// <summary>Select a tab and an item on that tab</summary> /// <returns>true upon success. false if tab is disabled (and exists in this sidepane).</returns> public bool SelectTab(Tab tab) { return SelectTab(tab, true); }
public void CanDisableTab() { Tab tab = new Tab("tabname"); _sidePane.AddTab(tab); tab.Enabled = false; bool success = _sidePane.SelectTab(tab); Assert.IsFalse(success); Tab currentTab = _sidePane.CurrentTab; Assert.AreNotSame(tab, currentTab); }
/// <summary> /// Select item on tab, by item name /// </summary> public bool SelectItem(Tab tab, string itemName) { if (null == tab) throw new ArgumentNullException("tab"); if (null == itemName) throw new ArgumentNullException("itemName"); if (!ContainsTab(tab)) throw new ArgumentOutOfRangeException("tab", tab, "sidepane does not contain tab"); SelectTab(tab, false); // Switch to tab, but don't let it auto-select an item on that tab var item = _itemAreas[tab].Items.Find(someItem => someItem.Name == itemName); if (item == null) { //throw new ArgumentOutOfRangeException("itemName", itemName, "tab does not contain item of name itemName"); // FWR-2895 (and another) are situations where and item was deleted // so we shouldn't be so dogmatic about finding the submitted itemName SelectTab(tab, true); return false; // but we can tell the caller that we weren't successful } _itemAreas[tab].SelectItem(item); return true; }
public void TrySelectingDisabledTabThatDoesNotExist() { Tab tab = new Tab("tabname"); tab.Enabled = false; _sidePane.SelectTab(tab); }
/// <remarks>tab must be a tab in this sidepane</remarks> private bool TabContainsItemWithName(Tab tab, string itemName) { if (tab == null) throw new ArgumentNullException("tab"); if (itemName == null) throw new ArgumentNullException("itemName"); if (!ContainsTab(tab)) throw new ArgumentOutOfRangeException("tab", tab, "tab is not a tab in this sidepane."); if (_itemAreas[tab].Items.Find(item => item.Name == itemName) != null) return true; return false; }
public void DisablingTabDisablesUnderlyingOutlookBarButton() { Tab tab = new Tab("tabname"); _sidePane.AddTab(tab); using (var underlyingButton = TestUtilities.GetUnderlyingButtonCorrespondingToTab(tab)) { Assert.IsTrue(underlyingButton.Enabled); tab.Enabled = false; Assert.IsFalse(underlyingButton.Enabled); } }
/// <summary> /// Notify clients that a tab was selected. /// </summary> protected void InvokeTabClicked(Tab tabClicked) { if (TabClicked != null) TabClicked.Invoke(tabClicked); }
public void MakeSidePaneWithManyItems() { // Put sidepane on a window using (Form window = new Form()) { window.Height = 600; window.Width = 600; SplitContainer container = new SplitContainer(); container.Dock = DockStyle.Fill; container.SplitterWidth = 100; window.Controls.Add(container); using (SidePane sidepane = new SidePane(container.Panel1, ItemAreaStyle)) { // Add a tab and a lot of items Tab tab = new Tab("tabname"); sidepane.AddTab(tab); for (int i = 0; i < 50; ++i) sidepane.AddItem(tab, new Item("item" + i.ToString())); try { // Display the window and its contents window.Show(); Application.DoEvents(); Assert.IsTrue(window.Visible); } finally { window.Hide(); Application.DoEvents(); } } } }
/// <summary> /// Create a tab on the sidebar from a choice. /// </summary> protected void MakeAreaButton(ListPropertyChoice choice) { string tabname = GetListIdFromListPropertyChoice(choice); Tab tab = new Tab(tabname) { Enabled = choice.Enabled, Text = choice.Label, Icon = m_largeImages.GetImage(choice.ImageName), Tag = choice, }; choice.ReferenceWidget = tab; m_sidepane.AddTab(tab); }
public void AddItem_null3() { Tab tab = new Tab("tabname"); _sidePane.AddItem(tab, null); }
/// <summary>Select a tab and an item on that tab</summary> /// <returns>true upon success. false if tab is disabled (and exists in this sidepane).</returns> public bool SelectTab(Tab tab) { return(SelectTab(tab, true)); }
public void SelectItem_null3() { Tab tab = new Tab("tabname"); _sidePane.SelectItem(tab, null); }
/// <remarks>Cannot add the same tab more than once. Cannot add a tab with the same name as /// an existing tab.</remarks> public void AddTab(Tab tab) { if (tab == null) throw new ArgumentNullException("tab"); if (_itemAreas.Keys.Where(existingTab => existingTab.Name == tab.Name).Count() > 0) throw new ArgumentException("cannot add a tab with the same name as an existing tab"); var tabButton = new OutlookBarButton { Name = tab.Name, Text = tab.Text, Image = tab.Icon, Enabled = tab.Enabled, Tag = tab }; _tabArea.Buttons.Add(tabButton); tab.UnderlyingWidget = tabButton; IItemArea itemArea; switch (ItemAreaStyle) { case SidePaneItemAreaStyle.StripList: itemArea = new StripListItemArea(); break; case SidePaneItemAreaStyle.List: itemArea = new ListViewItemArea(); break; case SidePaneItemAreaStyle.Buttons: default: itemArea = new OutlookButtonPanelItemArea { Dock = DockStyle.Fill }; break; } itemArea.ItemClicked += HandleClickFromItemArea; _itemAreas.Add(tab, itemArea); _itemAreaContainer.Controls.Add(itemArea.AsControl()); // Expand tab area to show this tab _tabArea.ShowAnotherButton(); }
public void GetTabByName_nonexistentTab() { Tab tab = _sidePane.GetTabByName("nonexistentTabName"); Assert.IsNull(tab); }
/// <summary> /// Add item to targetTab /// </summary> public void AddItem(Tab targetTab, Item item) { if (targetTab == null) throw new ArgumentNullException("targetTab"); if (item == null) throw new ArgumentNullException("item"); if (!_itemAreas.ContainsKey(targetTab)) throw new ArgumentOutOfRangeException("targetTab", targetTab, "targetTab is not a tab on this SidePane"); if (TabContainsItem(targetTab, item)) throw new ArgumentException("targetTab already contains item"); if (TabContainsItemWithName(targetTab, item.Name)) throw new ArgumentException("targetTab already contains an item of the same name"); _itemAreas[targetTab].Add(item); }
/// <summary> /// Show a specific Tab's item area, and hide others. /// </summary> private void ShowOnlyCertainItemArea(Tab tab) { if (tab == null) throw new ArgumentNullException("tab"); foreach (var area in _itemAreas.Values) area.Visible = false; _itemAreas[tab].Visible = true; }