-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor, automatically adapt window size to screen size. Add Design …
…Time data.
- Loading branch information
Christian Rondeau
committed
Sep 1, 2014
1 parent
b0e46ff
commit 4b90f0e
Showing
7 changed files
with
204 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Windows.Controls; | ||
using GoToWindow.Api; | ||
using GoToWindow.Commands; | ||
using Hardcodet.Wpf.TaskbarNotification; | ||
|
||
namespace GoToWindow.Components | ||
{ | ||
public class GoToWindowTrayIcon : IDisposable | ||
{ | ||
private readonly IGoToWindowContext _context; | ||
private TaskbarIcon _trayIcon; | ||
|
||
public GoToWindowTrayIcon(IGoToWindowContext context) | ||
{ | ||
_context = context; | ||
|
||
_trayIcon = new TaskbarIcon | ||
{ | ||
Icon = Properties.Resources.AppIcon, | ||
ToolTipText = "Go To Window", | ||
DoubleClickCommand = new OpenMainWindowCommand(_context), | ||
ContextMenu = CreateContextMenu() | ||
}; | ||
} | ||
|
||
private ContextMenu CreateContextMenu() | ||
{ | ||
var contextMenu = new ContextMenu(); | ||
var showMenu = new MenuItem { Header = "_Show", Command = new OpenMainWindowCommand(_context) }; | ||
contextMenu.Items.Add(showMenu); | ||
|
||
var settingsMenu = new MenuItem { Header = "S_ettings", Command = new ShowSettingsCommand(_context) }; | ||
contextMenu.Items.Add(settingsMenu); | ||
|
||
contextMenu.Items.Add(new Separator()); | ||
|
||
var exitMenuItem = new MenuItem { Header = "E_xit", Command = new ExitCommand() }; | ||
contextMenu.Items.Add(exitMenuItem); | ||
|
||
return contextMenu; | ||
} | ||
|
||
public void ShowStartupTooltip() | ||
{ | ||
var shortcutPressesBeforeOpen = Properties.Settings.Default.ShortcutPressesBeforeOpen; | ||
var openShortcutDescription = shortcutPressesBeforeOpen == 1 | ||
? "Alt + Tab" | ||
: "Alt + Tab + Tab"; | ||
|
||
var tooltipMessage = string.Format("Press {0} and start typing to find a window.", openShortcutDescription); | ||
|
||
if (!WindowsRuntimeHelper.GetHasElevatedPrivileges()) | ||
{ | ||
tooltipMessage += Environment.NewLine + Environment.NewLine + "NOTE: Not running with elevated privileges. Performance will be affected; Will not work in applications running as an administrator."; | ||
} | ||
|
||
_trayIcon.ShowBalloonTip( | ||
"Go To Window", | ||
tooltipMessage, | ||
BalloonIcon.Info); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (_trayIcon != null) | ||
{ | ||
_trayIcon.Dispose(); | ||
_trayIcon = null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Media.Imaging; | ||
using GoToWindow.Extensibility; | ||
using GoToWindow.Extensibility.Controls; | ||
using GoToWindow.Extensibility.ViewModel; | ||
|
||
namespace GoToWindow.ViewModels | ||
{ | ||
public class DesignTimeMainViewModel : MainViewModel | ||
{ | ||
private class DesignTimeSearchResult : ISearchResult, IBasicSearchResult | ||
{ | ||
public UserControl View { get; private set; } | ||
|
||
public BitmapFrame Icon { get; private set; } | ||
public string Title { get; private set; } | ||
public string ProcessName { get; private set; } | ||
|
||
public DesignTimeSearchResult(string processName, string title) | ||
{ | ||
View = new BasicListEntry(); | ||
ProcessName = processName; | ||
Title = title; | ||
} | ||
|
||
public void Select() | ||
{ | ||
} | ||
|
||
public bool IsShown(string searchQuery) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
public DesignTimeMainViewModel() | ||
{ | ||
IsEmpty = false; | ||
AvailableWindowWidth = 640; | ||
AvailableWindowHeight = 320; | ||
//SearchText = "User Query..."; | ||
Windows = new CollectionViewSource | ||
{ | ||
Source = new List<ISearchResult> | ||
{ | ||
new DesignTimeSearchResult("process", "Window Title"), | ||
new DesignTimeSearchResult("very long process name", "Very very long window title that should end up with ellipsis because it is so very long"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title"), | ||
new DesignTimeSearchResult("filler", "Some Window Title") | ||
} | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters