void Form1_Shown(object sender, System.EventArgs e) { listView1.SelectedIndexChanged += new System.EventHandler(listView1_SelectedIndexChanged); buttonFirst = new ThumbnailToolbarButton(Properties.Resources.first, "First Image"); buttonFirst.Enabled = false; buttonFirst.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonFirst_Click); buttonPrevious = new ThumbnailToolbarButton(Properties.Resources.prevArrow, "Previous Image"); buttonPrevious.Enabled = false; buttonPrevious.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPrevious_Click); buttonNext = new ThumbnailToolbarButton(Properties.Resources.nextArrow, "Next Image"); buttonNext.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonNext_Click); buttonLast = new ThumbnailToolbarButton(Properties.Resources.last, "Last Image"); buttonLast.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonLast_Click); TaskbarManager.Instance.ThumbnailToolbars.AddButtons(this.Handle, buttonFirst, buttonPrevious, buttonNext, buttonLast); if (listView1.Items.Count > 0) listView1.Items[0].Selected = true; // TaskbarManager.Instance.TabbedThumbnail.SetThumbnailClip(this.Handle, new Rectangle(pictureBox1.Location, pictureBox1.Size)); }
private void CreateToolbarButtons() { if (m_buttonsAdded) return; var favorite = new ThumbnailToolbarButton(Properties.Resources.Favorite, "Add to Favorites"); favorite.Click += (sender, args) => m_player.FavoriteSong(); var next = new ThumbnailToolbarButton(Properties.Resources.Next, "Next Song"); next.Click += (sender, args) => m_player.NextSong(); var previous = new ThumbnailToolbarButton(Properties.Resources.Previous, "Previous Song"); previous.Click += (sender, args) => m_player.PreviousSong(); var playback = new ThumbnailToolbarButton(Properties.Resources.Play, "Play"); playback.Click += (sender, args) => m_player.TogglePlayback(); m_player.PlayerStatusChanged += (sender, args) => { if (args.CurrentStatus == PlayerStatus.Playing || args.CurrentStatus == PlayerStatus.Loading) { playback.Icon = Properties.Resources.Pause; playback.Tooltip = "Pause"; } else { playback.Icon = Properties.Resources.Play; playback.Tooltip = "Play"; } }; m_player.SongChanged += (sender, args) => { if (args.CurrentSong == null) { Title = "Grooveshark"; return; } Title = String.Format("{0} - {1} - {2}", args.CurrentSong.Name, args.CurrentSong.ArtistName, args.CurrentSong.AlbumName); }; if (TaskbarManager.IsPlatformSupported) TaskbarManager.Instance.ThumbnailToolbars.AddButtons( new WindowInteropHelper(Application.Current.MainWindow).Handle, previous, playback, favorite, next); m_buttonsAdded = true; }
public Pomodo7oWindow(ITaskbarManager taskbarManager, ViewModel viewModel) { _taskbarManager = taskbarManager; _viewModel = viewModel; DataContext = viewModel; InitializeComponent(); _btnReset = Button(Res.icon_reset, Res.ToolTip_Reset, () => Reset()); _btnPlay = Button(Res.icon_play, Res.ToolTip_Play, () => Play()); _btnPause = Button(Res.icon_pause, Res.ToolTip_Pause, () => Pause()); _btnGoToWork = Button(Res.icon_tomato, Res.ToolTip_GoToWork, () => GoToWork()); _btnGoToRest = Button(Res.icon_tomato_rest, Res.ToolTip_GoToRest, () => TakeABreak()); }
internal ThumbnailToolbarProxyWindow(System.Windows.UIElement windowsControl, ThumbnailToolbarButton[] buttons) { if (windowsControl == null) throw new ArgumentNullException("Control cannot be null", "windowsControl"); if (buttons != null && buttons.Length == 0) throw new ArgumentException("Null or empty arrays are not allowed.", "buttons"); // internalWindowHandle = IntPtr.Zero; WindowsControl = windowsControl; thumbnailButtons = buttons; // Set the window handle on the buttons (for future updates) Array.ForEach(thumbnailButtons, new Action<ThumbnailToolbarButton>(UpdateHandle)); }
public TaskbarWindow(IntPtr userWindowHandle, ThumbnailToolbarButton[] buttons) { if (userWindowHandle == IntPtr.Zero) throw new ArgumentException("userWindowHandle"); if (buttons == null || buttons.Length == 0) throw new ArgumentException("buttons"); // Create our proxy window _thumbnailToolbarProxyWindow = new ThumbnailToolbarProxyWindow(userWindowHandle, buttons) { TaskbarWindow = this }; // Set our current state ThumbnailButtons = buttons; WindowHandle = userWindowHandle; }
internal ThumbnailToolbarProxyWindow(IntPtr windowHandle, ThumbnailToolbarButton[] buttons) { if (windowHandle == IntPtr.Zero) throw new ArgumentException("Window handle cannot be empty", "windowHandle"); if (buttons != null && buttons.Length == 0) throw new ArgumentException("Null or empty arrays are not allowed.", "buttons"); // internalWindowHandle = windowHandle; thumbnailButtons = buttons; // Set the window handle on the buttons (for future updates) Array.ForEach(thumbnailButtons, new Action<ThumbnailToolbarButton>(UpdateHandle)); // Assign the window handle (coming from the user) to this native window // so we can intercept the window messages sent from the taskbar to this window. this.AssignHandle(windowHandle); }
public Form1() { InitializeComponent(); // Listen for specific events on the tab control tabControl1.Selecting += new TabControlCancelEventHandler(tabControl1_Selecting); tabControl1.SelectedIndexChanged += new EventHandler(tabControl1_SelectedIndexChanged); // When the size of our form changes, invalidate the thumbnails so we can capture them again // when user requests a peek or thumbnail preview. this.SizeChanged += new EventHandler(Form1_SizeChanged); // Set our minimum size so the form will not have 0 height/width when user tries to resize it all the way this.MinimumSize = new Size(500, 100); // Show the Favorites window favsWindow = new FavoritesWindow(this); favsWindow.Show(); // Create our Thumbnail toolbar buttons for the Browser doc thumbButtonBack = new ThumbnailToolbarButton(Properties.Resources.prevArrow, "Back"); thumbButtonBack.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonBack_Click); thumbButtonForward = new ThumbnailToolbarButton(Properties.Resources.nextArrow, "Forward"); thumbButtonForward.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonForward_Click); thumbButtonRefresh = new ThumbnailToolbarButton(Properties.Resources.refresh, "Refresh"); thumbButtonRefresh.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonRefresh_Click); // Create our thumbnail toolbar buttons for the RichTextBox doc thumbButtonCut = new ThumbnailToolbarButton(Properties.Resources.cut, "Cut"); thumbButtonCut.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonCut_Click); thumbButtonCopy = new ThumbnailToolbarButton(Properties.Resources.copy, "Copy"); thumbButtonCopy.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonCopy_Click); thumbButtonPaste = new ThumbnailToolbarButton(Properties.Resources.paste, "Paste"); thumbButtonPaste.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonPaste_Click); thumbButtonSelectAll = new ThumbnailToolbarButton(Properties.Resources.selectAll, "SelectAll"); thumbButtonSelectAll.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(thumbButtonSelectAll_Click); this.FormClosing += new FormClosingEventHandler(Form1_FormClosing); }
public void AddThumbnailButtons(IntPtr windowHandle, ThumbnailToolbarButton[] buttons) { // Try to get an existing taskbar window for this user windowhandle, // or get one that is created for us var taskbarWindow = GetTaskbarWindow(windowHandle); if (taskbarWindow == null) { taskbarWindow = new TaskbarWindow(windowHandle, buttons); _taskbarWindowList.Add(taskbarWindow); } else if (taskbarWindow.ThumbnailButtons == null) taskbarWindow.ThumbnailButtons = buttons; else { // We already have buttons assigned throw new InvalidOperationException("Toolbar buttons for this window are already added. Once added, neither the order of the buttons cannot be changed, nor can they be added or removed."); } }
//OK protected override void OnShown(EventArgs e) { if (TaskbarManager.IsPlatformSupported) { btnPlay = new ThumbnailToolbarButton(Resources.iplay, TITLE_LISTENING); btnPlay.Click += ibtnPlay_Click; btnRecord = new ThumbnailToolbarButton(Resources.irecord, TITLE_RECORD); btnRecord.Click += ibtnRecord_Click; TaskbarManager.Instance.ThumbnailToolbars.AddButtons(Handle, btnPlay, btnRecord); } base.OnShown(e); }
private void MainWindow_Shown(object sender, EventArgs e) { Helper H = new Helper(); ThumbEnc = new ThumbnailToolbarButton(H.GetIcon(Properties.Resources.Pic_Lock, 128, true), "Encrypt"); ThumbEnc.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ThumbEnc_Click); ThumbDec = new ThumbnailToolbarButton(H.GetIcon(Properties.Resources.Pic_UnLock, 128, true), "Decrypt"); ThumbDec.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ThumbDec_Click); TaskbarManager.Instance.ThumbnailToolbars.AddButtons(this.Handle, ThumbEnc, ThumbDec); }
public MainForm() { InitializeComponent(); appNotifyIcon.Text = AboutForm.AssemblyTitle; levelComboBox.SelectedIndex = 0; Minimized += OnMinimized; // Init Log Manager Singleton LogManager.Instance.Initialize(new TreeViewLoggerView(loggerTreeView), logListView); _dockExtender = new DockExtender(this); // Dockable Log Detail View _logDetailsPanelFloaty = _dockExtender.Attach(logDetailPanel, logDetailToolStrip, logDetailSplitter); _logDetailsPanelFloaty.DontHideHandle = true; _logDetailsPanelFloaty.Docking += OnFloatyDocking; // Dockable Logger Tree _loggersPanelFloaty = _dockExtender.Attach(loggerPanel, loggersToolStrip, loggerSplitter); _loggersPanelFloaty.DontHideHandle = true; _loggersPanelFloaty.Docking += OnFloatyDocking; // Settings _firstStartup = !UserSettings.Load(); if (_firstStartup) { // Initialize default layout UserSettings.Instance.Layout.Set(DesktopBounds, WindowState, logDetailPanel, loggerPanel); // Force panel to visible UserSettings.Instance.Layout.ShowLogDetailView = true; UserSettings.Instance.Layout.ShowLoggerTree = true; UserSettings.Instance.DefaultFont = Environment.OSVersion.Version.Major >= 6 ? new Font("Segoe UI", 9F) : new Font("Tahoma", 8.25F); } Font = UserSettings.Instance.DefaultFont ?? Font; _windowRestorer = new WindowRestorer(this, UserSettings.Instance.Layout.WindowPosition, UserSettings.Instance.Layout.WindowState); // Windows 7 CodePack (Taskbar icons and progress) _isWin7orLater = TaskbarManager.IsPlatformSupported; if (_isWin7orLater) { try { // Taskbar Progress TaskbarManager.Instance.ApplicationId = Text; _taskbarProgressTimer = new Timer(OnTaskbarProgressTimer, null, _taskbarProgressTimerPeriod, _taskbarProgressTimerPeriod); // Pause Btn _pauseWinbarBtn = new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)pauseBtn.Image).GetHicon()), pauseBtn.ToolTipText); _pauseWinbarBtn.Click += pauseBtn_Click; // Auto Scroll Btn _autoScrollWinbarBtn = new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)autoLogToggleBtn.Image).GetHicon()), autoLogToggleBtn.ToolTipText); _autoScrollWinbarBtn.Click += autoLogToggleBtn_Click; // Clear All Btn this._clearLogWinbarBtn = new ThumbnailToolbarButton(Icon.FromHandle(((Bitmap)clearBtn.Image).GetHicon()), clearBtn.ToolTipText); this._clearLogWinbarBtn.Click += clearBtn_Click; // Add Btns TaskbarManager.Instance.ThumbnailToolbars.AddButtons(Handle, _pauseWinbarBtn, _autoScrollWinbarBtn, this._clearLogWinbarBtn); } catch (Exception) { // Not running on Win 7? _isWin7orLater = false; } } ApplySettings(true); _eventQueue = new Queue<LogMessage>(); // Initialize Receivers foreach (IReceiver receiver in UserSettings.Instance.Receivers) InitializeReceiver(receiver); // Start the timer to process event logs in batch mode _logMsgTimer = new Timer(OnLogMessageTimer, null, 1000, 100); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); this.webBrowser1 = new System.Windows.Forms.WebBrowser(); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.HideShow = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.About = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.Previous = new System.Windows.Forms.ToolStripMenuItem(); this.Next = new System.Windows.Forms.ToolStripMenuItem(); this.Play = new System.Windows.Forms.ToolStripMenuItem(); this.Like = new System.Windows.Forms.ToolStripMenuItem(); this.Dislike = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.Exit = new System.Windows.Forms.ToolStripMenuItem(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton4 = new System.Windows.Forms.ToolStripButton(); this.currentSongTimer = new System.Windows.Forms.Timer(this.components); this.alwaysListeningTimer = new System.Windows.Forms.Timer(this.components); this.contextMenuStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // webBrowser1 // this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; this.webBrowser1.Location = new System.Drawing.Point(0, 25); this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); this.webBrowser1.Name = "webBrowser1"; this.webBrowser1.ScriptErrorsSuppressed = true; this.webBrowser1.Size = new System.Drawing.Size(1517, 690); this.webBrowser1.TabIndex = 9; this.webBrowser1.Url = new System.Uri("", System.UriKind.Relative); this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted); // // notifyIcon1 // this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1; this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); this.notifyIcon1.Text = "WinGrooves"; this.notifyIcon1.Visible = true; this.notifyIcon1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick); // // contextMenuStrip1 // this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.HideShow, this.toolStripMenuItem1, this.About, this.toolStripSeparator2, this.Previous, this.Next, this.Play, this.Like, this.Dislike, this.toolStripSeparator1, this.Exit}); this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Size = new System.Drawing.Size(182, 236); // // HideShow // this.HideShow.Name = "HideShow"; this.HideShow.Size = new System.Drawing.Size(181, 22); this.HideShow.Text = "Show/Hide"; this.HideShow.Click += new System.EventHandler(this.HideShow_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Size = new System.Drawing.Size(181, 22); this.toolStripMenuItem1.Text = "Options"; this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click_1); // // About // this.About.Name = "About"; this.About.Size = new System.Drawing.Size(181, 22); this.About.Text = "About"; this.About.Click += new System.EventHandler(this.About_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new System.Drawing.Size(178, 6); // // Previous // this.Previous.Name = "Previous"; this.Previous.Size = new System.Drawing.Size(181, 22); this.Previous.Text = "Previous Song"; this.Previous.Click += new System.EventHandler(this.Previous_Click); // // Next // this.Next.Name = "Next"; this.Next.Size = new System.Drawing.Size(181, 22); this.Next.Text = "Next Song"; this.Next.Click += new System.EventHandler(this.Next_Click); // // Play // this.Play.Name = "Play"; this.Play.Size = new System.Drawing.Size(181, 22); this.Play.Text = "Play/Pause"; this.Play.Click += new System.EventHandler(this.Play_Click); // // Like // this.Like.Name = "Like"; this.Like.Size = new System.Drawing.Size(181, 22); this.Like.Text = "Like Current Song"; this.Like.Click += new System.EventHandler(this.Like_Click); // // Dislike // this.Dislike.Name = "Dislike"; this.Dislike.Size = new System.Drawing.Size(181, 22); this.Dislike.Text = "Dislike Current Song"; this.Dislike.Click += new System.EventHandler(this.Dislike_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(178, 6); // // Exit // this.Exit.Name = "Exit"; this.Exit.Size = new System.Drawing.Size(181, 22); this.Exit.Text = "Exit"; this.Exit.Click += new System.EventHandler(this.Exit_Click); // // toolStrip1 // this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton1, this.toolStripButton2, this.toolStripButton3, this.toolStripButton4}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(1517, 25); this.toolStrip1.TabIndex = 10; this.toolStrip1.Text = "toolStrip1"; // // toolStripButton1 // this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Size = new System.Drawing.Size(23, 22); this.toolStripButton1.Text = "Go back one page"; this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click); // // toolStripButton2 // this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(23, 22); this.toolStripButton2.Text = "Go forward one page"; // // toolStripButton3 // this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(23, 22); this.toolStripButton3.Text = "Options"; this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click); // // toolStripButton4 // this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image"))); this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton4.Name = "toolStripButton4"; this.toolStripButton4.Size = new System.Drawing.Size(23, 22); this.toolStripButton4.Text = "About"; this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton4_Click); // // currentSongTimer // this.currentSongTimer.Interval = 3000; this.currentSongTimer.Tick += new System.EventHandler(this.currentSongTimer_Tick); // // alwaysListeningTimer // this.alwaysListeningTimer.Enabled = true; this.alwaysListeningTimer.Interval = 600000; this.alwaysListeningTimer.Tick += new System.EventHandler(this.alwaysListeningTimer_Tick); // // Win 7 toolbar buttons // this.buttonPrev = new ThumbnailToolbarButton(Properties.Resources.PlayerPrev, "Previous Music"); this.buttonPause = new ThumbnailToolbarButton(Properties.Resources.PlayerPlay, "Pause/Play Music"); this.isbuttonPaused = true; this.isMusicPlaying = false; this.buttonNext = new ThumbnailToolbarButton(Properties.Resources.PlayerNext, "Next Music"); // // FrmMain // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CausesValidation = false; this.ClientSize = new System.Drawing.Size(1517, 715); this.Controls.Add(this.webBrowser1); this.Controls.Add(this.toolStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "FrmMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "WinGrooves"; this.Activated += new System.EventHandler(this.FrmMain_Activated); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing); this.Load += new System.EventHandler(this.FrmMain_Load); this.contextMenuStrip1.ResumeLayout(false); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); }
private void UpdateHandle(ThumbnailToolbarButton button) { button.WindowHandle = WindowToTellTaskbarAbout; button.AddedToTaskbar = false; }
private void UpdateHandle(ThumbnailToolbarButton button) { button.WindowHandle = internalWindowHandle; button.AddedToTaskbar = false; }
private TabbedThumbnail _customThumbnail; //Taskbar image icon #endregion Fields #region Constructors public FrmMain() { // // Required for Windows Form Designer support // InitializeComponent(); this.Resize += new EventHandler(FrmMain_Resize); //code to remember window size and position // this is the default this.WindowState = FormWindowState.Normal; this.StartPosition = FormStartPosition.WindowsDefaultBounds; // check if the saved bounds are nonzero and visible on any screen if (Properties.Settings.Default.WindowPosition != Rectangle.Empty && IsVisibleOnAnyScreen(Properties.Settings.Default.WindowPosition)) { // first set the bounds this.StartPosition = FormStartPosition.Manual; this.DesktopBounds = Properties.Settings.Default.WindowPosition; // afterwards set the window state to the saved value (which could be Maximized) this.WindowState = Properties.Settings.Default.WindowState; } else { // this resets the upper left corner of the window to windows standards this.StartPosition = FormStartPosition.WindowsDefaultLocation; // we can still apply the saved size // msorens: added gatekeeper, otherwise first time appears as just a title bar! if (Properties.Settings.Default.WindowPosition != Rectangle.Empty) { this.Size = Properties.Settings.Default.WindowPosition.Size; } } // // Win 7 toolbar buttons // //Moved here from initializeComponent method because it is recreated after adding any controls to the form buttonPrev = new ThumbnailToolbarButton(Properties.Resources.PlayerPrev, "Previous Music"); buttonPause = new ThumbnailToolbarButton(Properties.Resources.PlayerPlay, "Pause/Play Music"); isbuttonPaused = false; isMusicPlaying = false; buttonNext = new ThumbnailToolbarButton(Properties.Resources.PlayerNext, "Next Music"); windowInitialized = true; }
/// <summary> /// Creates a Event Args for the TabbedThumbnailButton.Click event /// </summary> /// <param name="windowHandle">Window handle for the control/window related to the event</param> /// <param name="button">Thumbnail toolbar button that was clicked</param> public ThumbnailButtonClickedEventArgs(IntPtr windowHandle, ThumbnailToolbarButton button) { ThumbnailButton = button; WindowHandle = windowHandle; WindowsControl = null; }
private void UpdateHandle(ThumbnailToolbarButton button) { button.AddedToTaskbar = buttonsAdded; }
private void initToolbar() { //System.Drawing.Icon i = new System.Drawing.Icon(@"assets\play.ico", 16, 16); ThumbnailToolbarButton buttonPause = new ThumbnailToolbarButton(new System.Drawing.Icon(@"assets\play.ico", 16, 16), "Pause song"); buttonPause.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPlayPause_Click); ThumbnailToolbarButton buttonStop = new ThumbnailToolbarButton(new System.Drawing.Icon(@"assets\stop.ico", 16, 16), "Stop song"); buttonStop.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonStop_Click); ThumbnailToolbarButton buttonPlay = new ThumbnailToolbarButton(new System.Drawing.Icon(@"assets\pause.ico", 16, 16), "Play song"); buttonPlay.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPlay_Click); tbManager.ThumbnailToolbars.AddButtons(this.Handle, buttonPause, buttonPlay, buttonStop); //tbManager.TabbedThumbnail.SetThumbnailClip(this.Handle, new Rectangle(pictureBox1.Location, pictureBox1.Size)); }
/// <summary> /// Initializes the GUI /// </summary> private void InitGUI() { // create glass effect RefreshGlassEffect(); #region Events handlers NavigationPane.GotFocus += new RoutedEventHandler(NavigationPane_GotFocus); SettingsManager.QueueTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(QueueTracks_CollectionChanged); SettingsManager.HistoryTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(HistoryTracks_CollectionChanged); SettingsManager.FileTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(LibraryTracks_CollectionChanged); SettingsManager.RadioTracks.CollectionChanged += new NotifyCollectionChangedEventHandler(RadioTracks_CollectionChanged); if (SettingsManager.FileListConfig != null) SettingsManager.FileListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); if (SettingsManager.YouTubeListConfig != null) SettingsManager.YouTubeListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); if (SettingsManager.SoundCloudListConfig != null) SettingsManager.SoundCloudListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); if (SettingsManager.RadioListConfig != null) SettingsManager.RadioListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); if (SettingsManager.JamendoListConfig != null) SettingsManager.JamendoListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); if (SettingsManager.QueueListConfig != null) SettingsManager.QueueListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); if (SettingsManager.HistoryListConfig != null) SettingsManager.HistoryListConfig.PropertyChanged += new PropertyChangedEventHandler(ViewDetailsConfig_PropertyChanged); FilesystemManager.SourceModified += new SourceModifiedEventHandler(FilesystemManager_SourceModified); FilesystemManager.TrackModified += new PropertyChangedEventHandler(FilesystemManager_TrackModified); FilesystemManager.PathModified += new PathModifiedEventHandler(FilesystemManager_PathModified); FilesystemManager.PathRenamed += new RenamedEventHandler(FilesystemManager_PathRenamed); FilesystemManager.ProgressChanged += new ProgressChangedEventHandler(FilesystemManager_ProgressChanged); FilesystemManager.SourceAdded += new SourcesModifiedEventHandler(FilesystemManager_SourceAdded); FilesystemManager.SourceRemoved += new SourcesModifiedEventHandler(FilesystemManager_SourceRemoved); MediaManager.TrackSwitched += new TrackSwitchedEventHandler(MediaManager_TrackSwitched); MediaManager.LoadedTrack += new LoadedTrackDelegate(MediaManager_LoadedTrack); MediaManager.Started += new EventHandler(MediaManager_Started); MediaManager.SearchMatch = TrackList_SearchMatch; UpgradeManager.Checked += new EventHandler(UpgradeManager_Checked); UpgradeManager.ErrorOccured += new Core.ErrorEventHandler(UpgradeManager_ErrorOccured); UpgradeManager.ProgressChanged += new ProgressChangedEventHandler(UpgradeManager_ProgressChanged); UpgradeManager.Upgraded += new EventHandler(UpgradeManager_Upgraded); UpgradeManager.UpgradeFound += new EventHandler(UpgradeManager_UpgradeFound); PluginManager.RefreshVisualizerSelector += new EventHandler(PluginManager_RefreshVisualizerSelector); PluginManager.Installed += new EventHandler<PluginEventArgs>(PluginManager_Installed); PluginManager.Uninstalled += new EventHandler<PluginEventArgs>(PluginManager_Uninstalled); PluginManager.Initialize(); SettingsManager.PropertyChanged += new PropertyChangedWithValuesEventHandler(SettingsManager_PropertyChanged); ServiceManager.ModifyTracks += new EventHandler<ModifiedEventArgs>(ServiceManager_ModifyTracks); NavigationPane.CreateNewPlaylistETB.EnteredEditMode += new EventHandler(EditableTextBlock_EnteredEditMode); SystemEvents.SessionSwitch += new SessionSwitchEventHandler(SystemEvents_SessionSwitch); resortDelay.Interval = new TimeSpan(0, 0, 0, 0, 500); resortDelay.Tick += new EventHandler(ResortDelay_Tick); sourceModifiedDelay.Tick += new EventHandler(SourceModifiedDelay_Tick); sourceModifiedDelay.Interval = new TimeSpan(0, 0, 0, 1, 500); #endregion #region Tray icon // create system tray icon trayIcon = (TaskbarIcon)FindResource("NotifyIcon"); trayIcon.TrayToolTip = new TrayToolTip(this); trayIcon.TrayLeftMouseUp += TaskbarClicked; trayMenu = new ContextMenu(); trayMenuShow = new MenuItem(); trayMenuExit = new MenuItem(); trayMenuPlay = new MenuItem(); trayMenuNext = new MenuItem(); trayMenuPrev = new MenuItem(); trayMenuShow.Header = U.T("TrayShow"); trayMenuExit.Header = U.T("TrayExit"); trayMenuPlay.Header = U.T("TrayPlay"); trayMenuNext.Header = U.T("TrayNext"); trayMenuPrev.Header = U.T("TrayPrev"); trayMenuShow.Click += TrayShow_Clicked; trayMenuExit.Click += TrayExit_Clicked; trayMenuPlay.Click += TrayPlayPause_Clicked; trayMenuNext.Click += TrayNext_Clicked; trayMenuPrev.Click += TrayPrevious_Clicked; trayMenu.Items.Add(trayMenuShow); trayMenu.Items.Add(new Separator()); trayMenu.Items.Add(trayMenuPlay); trayMenu.Items.Add(trayMenuNext); trayMenu.Items.Add(trayMenuPrev); trayMenu.Items.Add(new Separator()); trayMenu.Items.Add(trayMenuExit); trayIcon.ContextMenu = trayMenu; #endregion #region Thumbnail buttons //// create thumbnail buttons taskbarPrev = new ThumbnailToolbarButton(Properties.Resources.Previous, U.T("TaskbarPrev")); taskbarPrev.Enabled = true; taskbarPrev.Click += TaskbarPrevious_Clicked; taskbarPlay = new ThumbnailToolbarButton(Properties.Resources.Play, U.T("TaskbarPlay")); taskbarPlay.Enabled = true; taskbarPlay.Click += TaskbarPlayPause_Clicked; taskbarNext = new ThumbnailToolbarButton(Properties.Resources.Next, U.T("TaskbarNext")); taskbarNext.Enabled = true; taskbarNext.Click += TaskbarNext_Clicked; TaskbarManager.Instance.ThumbnailToolbars.AddButtons( new WindowInteropHelper(this).Handle, new ThumbnailToolbarButton[] { taskbarPrev, taskbarPlay, taskbarNext } ); #endregion #region Jump lists jumpTaskPlay = new JumpTask() { Title = U.T("JumpPlay", "Title"), Arguments = "/play", Description = U.T("JumpPlay", "Description"), IconResourceIndex = -1, ApplicationPath = Assembly.GetEntryAssembly().CodeBase, }; jumpTaskNext = new JumpTask() { Title = U.T("JumpNext", "Title"), Arguments = "/next", Description = U.T("JumpNext", "Description"), IconResourceIndex = -1, ApplicationPath = Assembly.GetEntryAssembly().CodeBase, }; jumpTaskPrev = new JumpTask() { Title = U.T("JumpPrev", "Title"), Arguments = "/previous", Description = U.T("JumpPrev", "Description"), IconResourceIndex = -1, ApplicationPath = Assembly.GetEntryAssembly().CodeBase, }; jumpList = new System.Windows.Shell.JumpList(); jumpList.JumpItems.Add(jumpTaskPlay); jumpList.JumpItems.Add(jumpTaskNext); jumpList.JumpItems.Add(jumpTaskPrev); jumpList.ShowRecentCategory = true; jumpList.ShowFrequentCategory = true; System.Windows.Shell.JumpList.SetJumpList(Application.Current, jumpList); #endregion #region Style Utilities.DefaultAlbumArt = "/Platform/Windows 7/GUI/Images/AlbumArt/Default.jpg"; // rough detection of aero vs classic // you'll se a lot more of these around the code if (System.Windows.Forms.VisualStyles.VisualStyleInformation.DisplayName == "") { // applying classic theme SolidColorBrush scb = (SolidColorBrush)FindResource("DetailsPaneKey"); scb.Color = SystemColors.ControlTextColor; scb = (SolidColorBrush)FindResource("DetailsPaneValue"); scb.Color = SystemColors.ControlTextColor; scb = (SolidColorBrush)FindResource("InfoPaneTitle"); scb.Color = SystemColors.ControlTextColor; scb = (SolidColorBrush)FindResource("InfoPaneText"); scb.Color = SystemColors.ControlTextColor; MainFrame.BorderBrush = SystemColors.ControlBrush; MainFrame.Background = SystemColors.ControlBrush; MainContainer.Background = SystemColors.ControlBrush; InfoPane.Background = SystemColors.WindowBrush; VerticalSplitter.Background = SystemColors.ControlBrush; TopToolbar.Style = null; DetailsPane.Style = (Style)FindResource("ClassicDetailsPaneStyle"); OuterBottomRight.BorderBrush = SystemColors.ControlLightLightBrush; OuterTopLeft.BorderBrush = SystemColors.ControlDarkBrush; InnerBottomRight.BorderBrush = SystemColors.ControlDarkBrush; InnerTopLeft.BorderBrush = SystemColors.ControlLightLightBrush; ControlPanel.AboutTitle.Style = (Style)FindResource("ClassicControlPanelTitleStyle"); ControlPanel.ShortcutTitle.Style = (Style)FindResource("ClassicControlPanelTitleStyle"); ControlPanel.GeneralTitle.Style = (Style)FindResource("ClassicControlPanelTitleStyle"); Utilities.DefaultAlbumArt = "/Platform/Windows 7/GUI/Images/AlbumArt/Classic.jpg"; } #endregion VisualizerList.ItemsSource = PluginManager.VisualizerSelector; LibraryTime = 0; QueueTime = 0; HistoryTime = 0; if (SettingsManager.FileTracks != null) foreach (TrackData track in SettingsManager.FileTracks) LibraryTime += track.Length; if (SettingsManager.QueueTracks != null) foreach (TrackData track in SettingsManager.QueueTracks) QueueTime += track.Length; if (SettingsManager.HistoryTracks != null) foreach (TrackData track in SettingsManager.HistoryTracks) HistoryTime += track.Length; NavigationColumn.Width = new GridLength(SettingsManager.NavigationPaneWidth); double h = SettingsManager.DetailsPaneHeight; DetailsRow.Height = new GridLength(h); UpdateVisibility("menubar"); UpdateVisibility("details"); RefreshStrings(); U.ListenForShortcut = true; FilesystemManager.AddSystemFolders(true); #region Create playlists foreach (PlaylistData playlist in SettingsManager.Playlists) CreatePlaylist(playlist, false); PlaylistManager.PlaylistModified += new ModifiedEventHandler(PlaylistManager_PlaylistModified); PlaylistManager.PlaylistRenamed += new RenamedEventHandler(PlaylistManager_PlaylistRenamed); if (SettingsManager.CurrentSelectedNavigation == "YouTube") NavigationPane.Youtube.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "SoundCloud") NavigationPane.SoundCloud.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "Radio") NavigationPane.Radio.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "Jamendo") NavigationPane.Jamendo.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "Queue") NavigationPane.Queue.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "History") NavigationPane.History.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "Video") NavigationPane.Video.Focus(); else if (SettingsManager.CurrentSelectedNavigation == "Visualizer") NavigationPane.Visualizer.Focus(); else if (!SettingsManager.CurrentSelectedNavigation.StartsWith("Playlist:")) NavigationPane.Files.Focus(); else { string name = SettingsManager.CurrentSelectedNavigation.Split(new[] { ':' }, 2)[1]; foreach (TreeViewItem tvi in NavigationPane.Playlists.Items) { if ((string)tvi.Tag == name) { tvi.Focus(); break; } } } #endregion #region Load track lists U.L(LogLevel.Debug, "main", "Initialize track lists"); switch (SettingsManager.CurrentActiveNavigation) { case "Queue": if (FileTracks == null) FileTracks = InitTrackList(new ViewDetails(), SettingsManager.FileListConfig, SettingsManager.FileTracks); break; case "Radio": if (RadioTracks == null) RadioTracks = InitTrackList(new ViewDetails(), SettingsManager.RadioListConfig, SettingsManager.RadioTracks); break; case "YouTube": if (YouTubeTracks == null) YouTubeTracks = (YouTubeTracks)InitTrackList(new YouTubeTracks(), SettingsManager.YouTubeListConfig); break; case "SoundCloud": if (SoundCloudTracks == null) SoundCloudTracks = (SoundCloudTracks)InitTrackList(new SoundCloudTracks(), SettingsManager.SoundCloudListConfig); break; case "Jamendo": if (JamendoTracks == null) JamendoTracks = (JamendoTracks)InitTrackList(new JamendoTracks(), SettingsManager.JamendoListConfig); break; default: if (SettingsManager.CurrentActiveNavigation.StartsWith("Playlist:")) { string pname = SettingsManager.CurrentActiveNavigation.Split(new[] { ':' }, 2)[1]; PlaylistData p = PlaylistManager.FindPlaylist(pname); if (p != null) { ViewDetails vd = (ViewDetails)PlaylistTrackLists[pname]; if (vd == null) vd = InitTrackList(new ViewDetails(), p.ListConfig, p.Tracks); } } break; } if (FileTracks == null) FileTracks = InitTrackList(new ViewDetails(), SettingsManager.FileListConfig, SettingsManager.FileTracks); #endregion #region File association prompt if (SettingsManager.FirstRun) { Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate() { // Show welcome dialog TaskDialogResult tdr = Welcome.Show(new WindowInteropHelper(this).Handle); Associations a = new Associations(); ProcessStartInfo assProcInfo = new ProcessStartInfo(); assProcInfo.FileName = U.FullPath; assProcInfo.Verb = "runas"; string assProcArgs = "--associate {0}"; try { switch (tdr) { case TaskDialogResult.Yes: assProcInfo.Arguments = String.Format(assProcArgs, string.Join(",", a.FullFileList.ToArray())); Process.Start(assProcInfo); break; case TaskDialogResult.CustomButtonClicked: a.ShowDialog(); assProcInfo.Arguments = String.Format(assProcArgs, string.Join(",", a.FileList.ToArray())); Process.Start(assProcInfo); break; case TaskDialogResult.Cancel: break; } } catch (Exception e) { U.L(LogLevel.Warning, "MAIN", "Could not set associations: " + e.Message); } })); SettingsManager.FirstRun = false; } #endregion #region Commented //System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal); #endregion }
private void UpdateHandle(ThumbnailToolbarButton button) { button.WindowHandle = WindowToTellTaskbarAbout; button.AddedToTaskbar = false; }
void UpdateHandle(ThumbnailToolbarButton button) { button.WindowHandle = _thumbnailToolbarProxyWindow.WindowHandle; button.AddedToTaskbar = false; }
private void UpdateHandle(ThumbnailToolbarButton button) { button.AddedToTaskbar = buttonsAdded; }
/// <summary> /// Creates a Event Args for the TabbedThumbnailButton.Click event /// </summary> /// <param name="windowsControl">WPF Control (UIElement) related to the event</param> /// <param name="button">Thumbnail toolbar button that was clicked</param> public ThumbnailButtonClickedEventArgs(UIElement windowsControl, ThumbnailToolbarButton button) { ThumbnailButton = button; WindowHandle = IntPtr.Zero; WindowsControl = windowsControl; }
/// <summary> /// Creates a Event Args for the TabbedThumbnailButton.Click event /// </summary> /// <param name="windowsControl">WPF Control (UIElement) related to the event</param> /// <param name="button">Thumbnail toolbar button that was clicked</param> public ThumbnailButtonClickedEventArgs(UIElement windowsControl, ThumbnailToolbarButton button) { ThumbnailButton = button; WindowHandle = IntPtr.Zero; WindowsControl = windowsControl; }
private void UpdateHandle(ThumbnailToolbarButton button) { button.WindowHandle = internalWindowHandle; button.AddedToTaskbar = false; }
private void FrmMain_Load(object sender, System.EventArgs e) { webBrowser1.Navigate("http://listen.grooveshark.com"); // register the event that is fired after a key press. hook.KeyPressed += new EventHandler<KeyPressedEventArgs>(hook_KeyPressed); webBrowser1.ObjectForScripting = this; //needed to capture JavaScript events //disable the IE "click sound" int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS; CoInternetSetFeatureEnabled(feature, SET_FEATURE_ON_PROCESS, true); if (Properties.Settings.Default.startMinimized) { showHideWindow(); } //Thumbnail buttons for win7 users if (TaskbarManager.IsPlatformSupported) { buttonPrev.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(Previous_Click); buttonPause.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(Play_Click); buttonNext.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(Next_Click); //Add the buttons (kinda of ugly tough) ThumbnailToolbarButton[] buttonList = new ThumbnailToolbarButton[3]; buttonList[0] = buttonPrev; buttonList[1] = buttonPause; buttonList[2] = buttonNext; TaskbarManager.Instance.ThumbnailToolbars.AddButtons(this.Handle, buttonList); } }
/// <summary> /// Creates a Event Args for the TabbedThumbnailButton.Click event /// </summary> /// <param name="windowHandle">Window handle for the control/window related to the event</param> /// <param name="button">Thumbnail toolbar button that was clicked</param> public ThumbnailButtonClickedEventArgs(IntPtr windowHandle, ThumbnailToolbarButton button) { ThumbnailButton = button; WindowHandle = windowHandle; WindowsControl = null; }
void Window1_Loaded(object sender, RoutedEventArgs e) { buttonFirst = new ThumbnailToolbarButton(Properties.Resources.first, "First Image"); buttonFirst.Enabled = false; buttonFirst.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonFirst_Click); buttonPrevious = new ThumbnailToolbarButton(Properties.Resources.prevArrow, "Previous Image"); buttonPrevious.Enabled = false; buttonPrevious.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPrevious_Click); buttonNext = new ThumbnailToolbarButton(Properties.Resources.nextArrow, "Next Image"); buttonNext.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonNext_Click); buttonLast = new ThumbnailToolbarButton(Properties.Resources.last, "Last Image"); buttonLast.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonLast_Click); TaskbarManager.Instance.ThumbnailToolbars.AddButtons(new WindowInteropHelper(this).Handle, buttonFirst, buttonPrevious, buttonNext, buttonLast); // Set our selection ImageList.SelectedIndex = 0; ImageList.Focus(); if (ImageList.SelectedItem != null) ImageList.ScrollIntoView(ImageList.SelectedItem); }