private void Selector_SelectionChanged(object sender, EventArgs e) { ViewerSelectorOption option = viewerSelector.Selected; ThumbnailViewerContent selectedContent = (ThumbnailViewerContent)option.Data; SwitchContent(selectedContent); NotificationCenter.RaiseExplorerTabChanged(this, Convert(selectedContent)); }
public ViewerSelector() { ViewerSelectorOption optionFiles = new ViewerSelectorOption(ScreenManager.Properties.Resources.explorer_video, "", ThumbnailViewerContent.Files); ViewerSelectorOption optionShortcuts = new ViewerSelectorOption(ScreenManager.Properties.Resources.explorer_shortcut, "", ThumbnailViewerContent.Shortcuts); ViewerSelectorOption optionCameras = new ViewerSelectorOption(ScreenManager.Properties.Resources.explorer_camera, "", ThumbnailViewerContent.Cameras); List <ViewerSelectorOption> options = new List <ViewerSelectorOption>(); options.Add(optionFiles); options.Add(optionShortcuts); options.Add(optionCameras); int defaultSelection = 0; InitializeComponent(); this.options = options; int index = 0; int left = 0; int spacing = 8; foreach (ViewerSelectorOption option in options) { Button btn = new Button(); btn.BackgroundImage = option.Image; btn.BackgroundImageLayout = ImageLayout.Center; btn.BackColor = Color.WhiteSmoke; btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.MouseDownBackColor = Color.WhiteSmoke; btn.FlatAppearance.MouseOverBackColor = Color.WhiteSmoke; btn.FlatAppearance.BorderSize = 0; btn.Size = new Size(20, 20); btn.Left = left; btn.Cursor = Cursors.Hand; btn.Tag = option; btn.Click += OptionButton_Click; this.Controls.Add(btn); if (index == defaultSelection) { selected = option; } left = btn.Right + spacing; index++; } this.Size = new Size(left, options[0].Image.Height + 2); this.BackColor = Color.WhiteSmoke; }
private void OptionButton_Click(object sender, EventArgs e) { if (SelectionChanged == null) { return; } Button btn = sender as Button; ViewerSelectorOption option = btn.Tag as ViewerSelectorOption; if (option != null) { selected = option; SelectionChanged(this, EventArgs.Empty); } }