Пример #1
0
		public override void Add(Item item)
		{
			base.Add(item);

			var widget = item.UnderlyingWidget as ToolStripButton;
			widget.TextImageRelation = TextImageRelation.ImageBeforeText;
			widget.ImageScaling = ToolStripItemImageScaling.SizeToFit;
			widget.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
			widget.ImageAlign = ContentAlignment.MiddleCenter;
			widget.TextAlign = ContentAlignment.MiddleCenter;
			widget.AutoSize = true;
		}
Пример #2
0
		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);
		}
Пример #3
0
        public void Add(Item item)
        {
            var widget = new ListViewItem
                {
                    Name = item.Name,
                    Text = item.Text,
                    Tag = item,
                };

            if (item.Icon != null)
            {
                _smallImageList.Images.Add(item.Icon);
                _largeImageList.Images.Add(item.Icon);
                // Set widget icon to the one we just added
                widget.ImageIndex = _smallImageList.Images.Count - 1;
            }

            item.UnderlyingWidget = widget;

            base.Items.Add(widget);
            _items.Add(item);
        }
Пример #4
0
        /// <summary>
        /// Handles when the selection of which widget (ListViewItem in the ListView)
        /// in this item area is changed.
        /// </summary>
        void HandleWidgetSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (e == null)
                return;

            // Event fires twice when switching from one item to another. Only handle second event.
            if (!e.IsSelected)
                return;

            var widget = e.Item;
            if (widget == null)
                return;

            var item = widget.Tag as Item;

            _currentItem = item;
            ItemClicked(item);
        }
Пример #5
0
        public void SelectItem(Item item)
        {
            var widget = item.UnderlyingWidget as ListViewItem;
            Debug.Assert(widget != null, "item.UnderlyingWidget as ListViewItem is null");
            if (widget == null)
                return;

            widget.Selected = true;
        }
Пример #6
0
		void sidePane_ItemClicked(Item itemClicked)
		{
			// When an item is clicked, change the label in the main pane.
			this.label1.Text = "Current View: " + itemClicked.Text;
		}