Merge branch 'initial-code-cleanup' into develop
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
bin/*
|
bin/
|
||||||
obj/*
|
obj/
|
||||||
*.suo
|
*.suo
|
||||||
|
*.user
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 14.00
|
||||||
# Visual Studio 2013
|
# Visual Studio 2015
|
||||||
VisualStudioVersion = 12.0.31101.0
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Eve-O-Preview", "Eve-O-Preview\Eve-O-Preview.csproj", "{6CA62DF3-8589-484C-8BC8-F763CA66BBB1}"
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "preview toy", "preview toy.csproj", "{6CA62DF3-8589-484C-8BC8-F763CA66BBB1}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExeFile", "ExeFile\ExeFile.csproj", "{BE2C3A13-CC19-4525-895F-381DD71C5833}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Eve-O-Mock", "Eve-O-Mock\Eve-O-Mock.csproj", "{BE2C3A13-CC19-4525-895F-381DD71C5833}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Application x:Class="ExeFile.App"
|
<Application x:Class="EveOMock.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
StartupUri="MainWindow.xaml">
|
StartupUri="MainWindow.xaml">
|
||||||
8
Eve-O-Mock/App.xaml.cs
Normal file
8
Eve-O-Mock/App.xaml.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace EveOMock
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<ProjectGuid>{BE2C3A13-CC19-4525-895F-381DD71C5833}</ProjectGuid>
|
<ProjectGuid>{BE2C3A13-CC19-4525-895F-381DD71C5833}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>ExeFile</RootNamespace>
|
<RootNamespace>EveOMock</RootNamespace>
|
||||||
<AssemblyName>ExeFile</AssemblyName>
|
<AssemblyName>ExeFile</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Window x:Class="ExeFile.MainWindow"
|
<Window x:Class="EveOMock.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="Mock " Height="480" Width="640">
|
Title="Mock " Height="480" Width="640">
|
||||||
17
Eve-O-Mock/MainWindow.xaml.cs
Normal file
17
Eve-O-Mock/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace EveOMock
|
||||||
|
{
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Random random = new Random();
|
||||||
|
this.Title += random.Next().ToString("X");
|
||||||
|
this.grid.Background = new SolidColorBrush(Color.FromArgb(255, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Eve-O-Mock/Properties/AssemblyInfo.cs
Normal file
28
Eve-O-Mock/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("EVE Online mock executable for the EVE-O Preview project")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("EVE-O Mock")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
||||||
|
[assembly: CLSCompliant(true)]
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.18444
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace ExeFile.Properties
|
namespace EveOMock.Properties {
|
||||||
{
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,29 +22,24 @@ namespace ExeFile.Properties
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources
|
internal class Resources {
|
||||||
{
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal Resources()
|
internal Resources() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
{
|
get {
|
||||||
get
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
{
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EveOMock.Properties.Resources", typeof(Resources).Assembly);
|
||||||
if ((resourceMan == null))
|
|
||||||
{
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ExeFile.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
@@ -56,14 +51,11 @@ namespace ExeFile.Properties
|
|||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,24 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.18444
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace ExeFile.Properties
|
namespace EveOMock.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
7
Eve-O-Preview/Configuration/Configuration.cs
Normal file
7
Eve-O-Preview/Configuration/Configuration.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public class Configuration
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Eve-O-Preview/Configuration/ConfigurationStorage.cs
Normal file
7
Eve-O-Preview/Configuration/ConfigurationStorage.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace EveOPreview.Managers
|
||||||
|
{
|
||||||
|
public class ConfigurationStorage
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs
Normal file
20
Eve-O-Preview/DwmAPI/DWM_BLURBEHIND.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
class DWM_BLURBEHIND
|
||||||
|
{
|
||||||
|
public uint dwFlags;
|
||||||
|
[MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public bool fEnable;
|
||||||
|
public IntPtr hRegionBlur;
|
||||||
|
[MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public bool fTransitionOnMaximized;
|
||||||
|
|
||||||
|
public const uint DWM_BB_ENABLE = 0x00000001;
|
||||||
|
public const uint DWM_BB_BLURREGION = 0x00000002;
|
||||||
|
public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs
Normal file
17
Eve-O-Preview/DwmAPI/DWM_THUMBNAIL_PROPERTIES.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
class DWM_THUMBNAIL_PROPERTIES
|
||||||
|
{
|
||||||
|
public uint dwFlags;
|
||||||
|
public RECT rcDestination;
|
||||||
|
public RECT rcSource;
|
||||||
|
public byte opacity;
|
||||||
|
[MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public bool fVisible;
|
||||||
|
[MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public bool fSourceClientAreaOnly;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs
Normal file
11
Eve-O-Preview/DwmAPI/DWM_TNP_CONSTANTS.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
static class DWM_TNP_CONSTANTS
|
||||||
|
{
|
||||||
|
public const uint DWM_TNP_RECTDESTINATION = 0x00000001;
|
||||||
|
public const uint DWM_TNP_RECTSOURCE = 0x00000002;
|
||||||
|
public const uint DWM_TNP_OPACITY = 0x00000004;
|
||||||
|
public const uint DWM_TNP_VISIBLE = 0x00000008;
|
||||||
|
public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace PreviewToy
|
namespace EveOPreview
|
||||||
{
|
{
|
||||||
// Desktop Windows Manager APIs
|
// Desktop Windows Manager APIs
|
||||||
internal class DwmApi
|
static class DwmApiNativeMethods
|
||||||
{
|
{
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern IntPtr GetForegroundWindow();
|
public static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
@@ -44,63 +42,6 @@ namespace PreviewToy
|
|||||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||||
public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
|
public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public class DWM_THUMBNAIL_PROPERTIES
|
|
||||||
{
|
|
||||||
public uint dwFlags;
|
|
||||||
public RECT rcDestination;
|
|
||||||
public RECT rcSource;
|
|
||||||
public byte opacity;
|
|
||||||
[MarshalAs(UnmanagedType.Bool)]
|
|
||||||
public bool fVisible;
|
|
||||||
[MarshalAs(UnmanagedType.Bool)]
|
|
||||||
public bool fSourceClientAreaOnly;
|
|
||||||
|
|
||||||
public const uint DWM_TNP_RECTDESTINATION = 0x00000001;
|
|
||||||
public const uint DWM_TNP_RECTSOURCE = 0x00000002;
|
|
||||||
public const uint DWM_TNP_OPACITY = 0x00000004;
|
|
||||||
public const uint DWM_TNP_VISIBLE = 0x00000008;
|
|
||||||
public const uint DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public class MARGINS
|
|
||||||
{
|
|
||||||
public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight;
|
|
||||||
|
|
||||||
public MARGINS(int left, int top, int right, int bottom)
|
|
||||||
{
|
|
||||||
cxLeftWidth = left; cyTopHeight = top;
|
|
||||||
cxRightWidth = right; cyBottomHeight = bottom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public class DWM_BLURBEHIND
|
|
||||||
{
|
|
||||||
public uint dwFlags;
|
|
||||||
[MarshalAs(UnmanagedType.Bool)]
|
|
||||||
public bool fEnable;
|
|
||||||
public IntPtr hRegionBlur;
|
|
||||||
[MarshalAs(UnmanagedType.Bool)]
|
|
||||||
public bool fTransitionOnMaximized;
|
|
||||||
|
|
||||||
public const uint DWM_BB_ENABLE = 0x00000001;
|
|
||||||
public const uint DWM_BB_BLURREGION = 0x00000002;
|
|
||||||
public const uint DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct RECT
|
|
||||||
{
|
|
||||||
public int left, top, right, bottom;
|
|
||||||
|
|
||||||
public RECT(int left, int top, int right, int bottom)
|
|
||||||
{
|
|
||||||
this.left = left; this.top = top; this.right = right; this.bottom = bottom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public const int SW_SHOWNORMAL = 1;
|
public const int SW_SHOWNORMAL = 1;
|
||||||
public const int SW_SHOWMINIMIZED = 2;
|
public const int SW_SHOWMINIMIZED = 2;
|
||||||
public const int SW_SHOWMAXIMIZED = 3;
|
public const int SW_SHOWMAXIMIZED = 3;
|
||||||
@@ -110,8 +51,10 @@ namespace PreviewToy
|
|||||||
|
|
||||||
public const int WM_NCLBUTTONDOWN = 0xA1;
|
public const int WM_NCLBUTTONDOWN = 0xA1;
|
||||||
public const int HTCAPTION = 0x2;
|
public const int HTCAPTION = 0x2;
|
||||||
|
|
||||||
[DllImport("User32.dll")]
|
[DllImport("User32.dll")]
|
||||||
public static extern bool ReleaseCapture();
|
public static extern bool ReleaseCapture();
|
||||||
|
|
||||||
[DllImport("User32.dll")]
|
[DllImport("User32.dll")]
|
||||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||||
|
|
||||||
@@ -175,5 +118,17 @@ namespace PreviewToy
|
|||||||
public const UInt32 WS_EX_COMPOSITED = 0x02000000;
|
public const UInt32 WS_EX_COMPOSITED = 0x02000000;
|
||||||
public const UInt32 WS_EX_NOACTIVATE = 0x08000000;
|
public const UInt32 WS_EX_NOACTIVATE = 0x08000000;
|
||||||
|
|
||||||
|
public const int WM_SIZE = 5;
|
||||||
|
public const int SIZE_RESTORED = 0;
|
||||||
|
public const int SIZE_MINIMIZED = 1;
|
||||||
|
public const int SIZE_MAXIMIZED = 2;
|
||||||
|
public const int SIZE_MAXSHOW = 3;
|
||||||
|
public const int SIZE_MAXHIDE = 4;
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern int GetWindowRect(IntPtr hwnd, out RECT rect);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21
Eve-O-Preview/DwmAPI/MARGINS.cs
Normal file
21
Eve-O-Preview/DwmAPI/MARGINS.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
class MARGINS
|
||||||
|
{
|
||||||
|
public int cxLeftWidth;
|
||||||
|
public int cxRightWidth;
|
||||||
|
public int cyTopHeight;
|
||||||
|
public int cyBottomHeight;
|
||||||
|
|
||||||
|
public MARGINS(int left, int top, int right, int bottom)
|
||||||
|
{
|
||||||
|
cxLeftWidth = left;
|
||||||
|
cyTopHeight = top;
|
||||||
|
cxRightWidth = right;
|
||||||
|
cyBottomHeight = bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Eve-O-Preview/DwmAPI/RECT.cs
Normal file
21
Eve-O-Preview/DwmAPI/RECT.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct RECT
|
||||||
|
{
|
||||||
|
public int Left;
|
||||||
|
public int Top;
|
||||||
|
public int Right;
|
||||||
|
public int Bottom;
|
||||||
|
|
||||||
|
public RECT(int left, int top, int right, int bottom)
|
||||||
|
{
|
||||||
|
this.Left = left;
|
||||||
|
this.Top = top;
|
||||||
|
this.Right = right;
|
||||||
|
this.Bottom = bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
<ProjectGuid>{6CA62DF3-8589-484C-8BC8-F763CA66BBB1}</ProjectGuid>
|
<ProjectGuid>{6CA62DF3-8589-484C-8BC8-F763CA66BBB1}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>PreviewToy</RootNamespace>
|
<RootNamespace>EveOPreview</RootNamespace>
|
||||||
<AssemblyName>eve-o preview</AssemblyName>
|
<AssemblyName>Eve-O Preview</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
</FileUpgradeFlags>
|
</FileUpgradeFlags>
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
@@ -57,7 +58,7 @@
|
|||||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<StartupObject>PreviewToy.Program</StartupObject>
|
<StartupObject>EveOPreview.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManifestCertificateThumbprint>4B29FD125BFAD24FF900FC81CCE0B0AD37464FDB</ManifestCertificateThumbprint>
|
<ManifestCertificateThumbprint>4B29FD125BFAD24FF900FC81CCE0B0AD37464FDB</ManifestCertificateThumbprint>
|
||||||
@@ -81,6 +82,13 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<NoWin32Manifest>true</NoWin32Manifest>
|
<NoWin32Manifest>true</NoWin32Manifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SignAssembly>false</SignAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<AssemblyOriginatorKeyFile>
|
||||||
|
</AssemblyOriginatorKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
@@ -95,36 +103,49 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Hotkey.cs" />
|
<Compile Include="DwmAPI\DWM_BLURBEHIND.cs" />
|
||||||
<Compile Include="PreviewHandler.cs">
|
<Compile Include="DwmAPI\DWM_THUMBNAIL_PROPERTIES.cs" />
|
||||||
|
<Compile Include="DwmAPI\DWM_TNP_CONSTANTS.cs" />
|
||||||
|
<Compile Include="DwmAPI\MARGINS.cs" />
|
||||||
|
<Compile Include="DwmAPI\RECT.cs" />
|
||||||
|
<Compile Include="GUI\ClientLocation.cs" />
|
||||||
|
<Compile Include="GUI\ZoomAnchor.cs" />
|
||||||
|
<Compile Include="Configuration\Configuration.cs" />
|
||||||
|
<Compile Include="Hotkeys\Hotkey.cs" />
|
||||||
|
<Compile Include="Hotkeys\HotkeyNativeMethods.cs" />
|
||||||
|
<Compile Include="GUI\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="PreviewHandler.Designer.cs">
|
<Compile Include="GUI\MainForm.Designer.cs">
|
||||||
<DependentUpon>PreviewHandler.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="PreviewOverlay.cs">
|
<Compile Include="Configuration\ConfigurationStorage.cs" />
|
||||||
|
<Compile Include="Thumbnail\IThumbnail.cs" />
|
||||||
|
<Compile Include="Thumbnail\ThumbnailFactory.cs" />
|
||||||
|
<Compile Include="Thumbnail\ThumbnailManager.cs" />
|
||||||
|
<Compile Include="Thumbnail\ThumbnailOverlay.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="PreviewOverlay.Designer.cs">
|
<Compile Include="Thumbnail\ThumbnailOverlay.Designer.cs">
|
||||||
<DependentUpon>PreviewOverlay.cs</DependentUpon>
|
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="PreviewHandler.resx">
|
<EmbeddedResource Include="GUI\MainForm.resx">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<DependentUpon>PreviewHandler.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="PreviewOverlay.resx">
|
<EmbeddedResource Include="Thumbnail\ThumbnailOverlay.resx">
|
||||||
<DependentUpon>PreviewOverlay.cs</DependentUpon>
|
<DependentUpon>ThumbnailOverlay.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Preview.resx">
|
<EmbeddedResource Include="Thumbnail\ThumbnailWindow.resx">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<DependentUpon>Preview.cs</DependentUpon>
|
<DependentUpon>ThumbnailWindow.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
@@ -134,8 +155,6 @@
|
|||||||
<None Include="app.config">
|
<None Include="app.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</None>
|
</None>
|
||||||
<None Include="preview toy_TemporaryKey.pfx" />
|
|
||||||
<None Include="Properties\DataSources\PreviewToyMain.datasource" />
|
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
@@ -145,13 +164,13 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Preview.cs">
|
<Compile Include="Thumbnail\ThumbnailWindow.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Preview.Designer.cs">
|
<Compile Include="Thumbnail\ThumbnailWindow.Designer.cs">
|
||||||
<DependentUpon>Preview.cs</DependentUpon>
|
<DependentUpon>ThumbnailWindow.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Win32api.cs" />
|
<Compile Include="DwmAPI\DwmApiNativeMethods.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||||
10
Eve-O-Preview/GUI/ClientLocation.cs
Normal file
10
Eve-O-Preview/GUI/ClientLocation.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public struct ClientLocation
|
||||||
|
{
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
public int Width;
|
||||||
|
public int Height;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,9 @@ using System;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace PreviewToy
|
namespace EveOPreview
|
||||||
{
|
{
|
||||||
partial class PreviewToyHandler
|
partial class MainForm
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@@ -37,7 +37,7 @@ namespace PreviewToy
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.components = new System.ComponentModel.Container();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PreviewToyHandler));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.option_hide_active = new System.Windows.Forms.CheckBox();
|
this.option_hide_active = new System.Windows.Forms.CheckBox();
|
||||||
this.option_hide_all_if_not_right_type = new System.Windows.Forms.CheckBox();
|
this.option_hide_all_if_not_right_type = new System.Windows.Forms.CheckBox();
|
||||||
this.option_unique_layout = new System.Windows.Forms.CheckBox();
|
this.option_unique_layout = new System.Windows.Forms.CheckBox();
|
||||||
@@ -566,7 +566,7 @@ namespace PreviewToy
|
|||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Margin = new System.Windows.Forms.Padding(0);
|
this.Margin = new System.Windows.Forms.Padding(0);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "PreviewToyHandler";
|
this.Name = "MainForm";
|
||||||
this.Text = "EVE Online previewer";
|
this.Text = "EVE Online previewer";
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
|
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
|
||||||
482
Eve-O-Preview/GUI/MainForm.cs
Normal file
482
Eve-O-Preview/GUI/MainForm.cs
Normal file
@@ -0,0 +1,482 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public partial class MainForm : Form
|
||||||
|
{
|
||||||
|
public event EventHandler Minimized;
|
||||||
|
public event EventHandler Maximized;
|
||||||
|
public event EventHandler Restored;
|
||||||
|
|
||||||
|
private readonly bool _isInitialized;
|
||||||
|
private readonly ThumbnailManager _manager;
|
||||||
|
|
||||||
|
|
||||||
|
private Dictionary<ZoomAnchor, RadioButton> _zoomAnchorButtonMap;
|
||||||
|
|
||||||
|
public MainForm()
|
||||||
|
{
|
||||||
|
_isInitialized = false;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
init_options();
|
||||||
|
|
||||||
|
// TODO Fix this
|
||||||
|
previews_check_listbox.DisplayMember = "Text";
|
||||||
|
|
||||||
|
this._manager = new ThumbnailManager(add_thumbnail,remove_thumbnail, set_aero_status, set_size);
|
||||||
|
|
||||||
|
_isInitialized = true;
|
||||||
|
|
||||||
|
this._manager.Activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void add_thumbnail(IList<string> thumbnails)
|
||||||
|
{
|
||||||
|
this.previews_check_listbox.BeginUpdate();
|
||||||
|
foreach (string th in thumbnails)
|
||||||
|
{
|
||||||
|
previews_check_listbox.Items.Add(th);
|
||||||
|
}
|
||||||
|
this.previews_check_listbox.EndUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void remove_thumbnail(IList<string> thumbnails)
|
||||||
|
{
|
||||||
|
this.previews_check_listbox.BeginUpdate();
|
||||||
|
foreach (string th in thumbnails)
|
||||||
|
{
|
||||||
|
previews_check_listbox.Items.Remove(th);
|
||||||
|
}
|
||||||
|
this.previews_check_listbox.EndUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_aero_status(bool value)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
aero_status_label.Text = "AERO is ON";
|
||||||
|
aero_status_label.ForeColor = Color.Black;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aero_status_label.Text = "AERO is OFF";
|
||||||
|
aero_status_label.ForeColor = Color.Red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set_size(int x, int y)
|
||||||
|
{
|
||||||
|
option_sync_size_x.Text = x.ToString();
|
||||||
|
option_sync_size_y.Text = y.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GlassForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init_options()
|
||||||
|
{
|
||||||
|
this.Minimized += MainForm_Minimized;
|
||||||
|
|
||||||
|
option_zoom_on_hover.Checked = Properties.Settings.Default.zoom_on_hover;
|
||||||
|
_zoomAnchorButtonMap = new Dictionary<ZoomAnchor, RadioButton>();
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.NW] = option_zoom_anchor_NW;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.N] = option_zoom_anchor_N;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.NE] = option_zoom_anchor_NE;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.W] = option_zoom_anchor_W;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.C] = option_zoom_anchor_C;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.E] = option_zoom_anchor_E;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.SW] = option_zoom_anchor_SW;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.S] = option_zoom_anchor_S;
|
||||||
|
_zoomAnchorButtonMap[ZoomAnchor.SE] = option_zoom_anchor_SE;
|
||||||
|
_zoomAnchorButtonMap[(ZoomAnchor)Properties.Settings.Default.zoom_anchor].Checked = true;
|
||||||
|
option_zoom_factor.Text = Properties.Settings.Default.zoom_amount.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
option_always_on_top.Checked = Properties.Settings.Default.always_on_top;
|
||||||
|
option_hide_active.Checked = Properties.Settings.Default.hide_active;
|
||||||
|
option_hide_all_if_not_right_type.Checked = Properties.Settings.Default.hide_all;
|
||||||
|
|
||||||
|
option_unique_layout.Checked = Properties.Settings.Default.unique_layout;
|
||||||
|
|
||||||
|
option_sync_size.Checked = Properties.Settings.Default.sync_resize;
|
||||||
|
option_sync_size_x.Text = Properties.Settings.Default.sync_resize_x.ToString();
|
||||||
|
option_sync_size_y.Text = Properties.Settings.Default.sync_resize_y.ToString();
|
||||||
|
|
||||||
|
option_show_thumbnail_frames.Checked = Properties.Settings.Default.show_thumb_frames;
|
||||||
|
|
||||||
|
option_show_overlay.Checked = Properties.Settings.Default.show_overlay;
|
||||||
|
|
||||||
|
option_track_client_windows.Checked = Properties.Settings.Default.track_client_windows;
|
||||||
|
|
||||||
|
option_minToTray.Checked = Properties.Settings.Default.minimizeToTray;
|
||||||
|
|
||||||
|
// disable/enable zoom suboptions
|
||||||
|
option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover;
|
||||||
|
foreach (var kv in _zoomAnchorButtonMap)
|
||||||
|
{
|
||||||
|
kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
opacity_bar.Value = Math.Min(100, (int)(100.0 * Properties.Settings.Default.opacity));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void option_hide_all_if_noneve_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.hide_all = option_hide_all_if_not_right_type.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_unique_layout_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.unique_layout = option_unique_layout.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_hide_active_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.hide_active = option_hide_active.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_sync_size_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.sync_resize = option_sync_size.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void parse_size_entry()
|
||||||
|
{
|
||||||
|
UInt32 x = 0, y = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
y = Convert.ToUInt32(option_sync_size_y.Text);
|
||||||
|
x = Convert.ToUInt32(option_sync_size_x.Text);
|
||||||
|
}
|
||||||
|
catch (System.FormatException)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 64 || y < 64)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.sync_resize_y = y;
|
||||||
|
Properties.Settings.Default.sync_resize_x = x;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
|
||||||
|
// resize
|
||||||
|
this._manager.SyncPreviewSize(new Size((int)Properties.Settings.Default.sync_resize_x,
|
||||||
|
(int)Properties.Settings.Default.sync_resize_y));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_sync_size_x_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_size_entry();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_sync_size_y_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_size_entry();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_always_on_top_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.always_on_top = option_always_on_top.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void option_show_thumbnail_frames_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties.Settings.Default.show_thumb_frames = option_show_thumbnail_frames.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
|
||||||
|
this._manager.set_frames();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void list_running_clients_SelectedIndexChanged(object sender, EventArgs e) { }
|
||||||
|
|
||||||
|
|
||||||
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
string url = "https://bitbucket.org/ulph/eve-o-preview-git";
|
||||||
|
ProcessStartInfo sInfo = new ProcessStartInfo(new Uri(url).AbsoluteUri);
|
||||||
|
Process.Start(sInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void previewToyMainBindingSource_CurrentChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void option_zoom_on_hover_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized) return;
|
||||||
|
|
||||||
|
Properties.Settings.Default.zoom_on_hover = option_zoom_on_hover.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover;
|
||||||
|
|
||||||
|
foreach (var kv in _zoomAnchorButtonMap)
|
||||||
|
{
|
||||||
|
kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void option_show_overlay_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Properties.Settings.Default.show_overlay = option_show_overlay.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void handle_zoom_anchor_setting()
|
||||||
|
{
|
||||||
|
foreach (var kv in _zoomAnchorButtonMap)
|
||||||
|
{
|
||||||
|
if (kv.Value.Checked == true)
|
||||||
|
Properties.Settings.Default.zoom_anchor = (byte)kv.Key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void option_zoom_anchor_X_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
handle_zoom_anchor_setting();
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void option_zoom_factor_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
float tmp = (float)Convert.ToDouble(option_zoom_factor.Text);
|
||||||
|
if (tmp < 1)
|
||||||
|
{
|
||||||
|
tmp = 1;
|
||||||
|
}
|
||||||
|
else if (tmp > 10)
|
||||||
|
{
|
||||||
|
tmp = 10;
|
||||||
|
}
|
||||||
|
Properties.Settings.Default.zoom_amount = tmp;
|
||||||
|
option_zoom_factor.Text = tmp.ToString();
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// do naught
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkedListBox1_SelectedIndexChanged2(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
System.Windows.Forms.ItemCheckEventArgs arg = (System.Windows.Forms.ItemCheckEventArgs)e;
|
||||||
|
((ThumbnailWindow)this.previews_check_listbox.Items[arg.Index]).IsPreviewEnabled = (arg.NewValue != System.Windows.Forms.CheckState.Checked);
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Properties.Settings.Default.track_client_windows = option_track_client_windows.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void opacity_bar_Scroll(object sender, ScrollEventArgs e)
|
||||||
|
{
|
||||||
|
if (!_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// fire off opacity change
|
||||||
|
Properties.Settings.Default.opacity = Math.Min((float)e.NewValue / 100.0f, 1.0f);
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
this._manager.refresh_thumbnails();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnMinimized(EventArgs e)
|
||||||
|
{
|
||||||
|
if (Minimized != null && Properties.Settings.Default.minimizeToTray)
|
||||||
|
{
|
||||||
|
this.Hide();
|
||||||
|
}
|
||||||
|
else if (Minimized != null && !Properties.Settings.Default.minimizeToTray)
|
||||||
|
{
|
||||||
|
Minimized(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMaximized(EventArgs e)
|
||||||
|
{
|
||||||
|
if (Maximized != null)
|
||||||
|
{
|
||||||
|
Maximized(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRestored(EventArgs e)
|
||||||
|
{
|
||||||
|
Restored?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void WndProc(ref Message m)
|
||||||
|
{
|
||||||
|
switch (m.Msg)
|
||||||
|
{
|
||||||
|
case DwmApiNativeMethods.WM_SIZE:
|
||||||
|
switch (m.WParam.ToInt32())
|
||||||
|
{
|
||||||
|
case DwmApiNativeMethods.SIZE_RESTORED:
|
||||||
|
OnRestored(EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
case DwmApiNativeMethods.SIZE_MINIMIZED:
|
||||||
|
OnMinimized(EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
case DwmApiNativeMethods.SIZE_MAXIMIZED:
|
||||||
|
OnMaximized(EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.WndProc(ref m);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainForm_Minimized(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// TODO: do something here
|
||||||
|
}
|
||||||
|
|
||||||
|
private void option_minToTray_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Properties.Settings.Default.minimizeToTray = option_minToTray.Checked;
|
||||||
|
Properties.Settings.Default.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!this.Visible)
|
||||||
|
{
|
||||||
|
this.Show();
|
||||||
|
}
|
||||||
|
else if (Restored != null)
|
||||||
|
{
|
||||||
|
Restored(this, e);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.BringToFront();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (!this.Visible)
|
||||||
|
{
|
||||||
|
this.Show();
|
||||||
|
}
|
||||||
|
else if (Restored != null)
|
||||||
|
{
|
||||||
|
Restored(this, e);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.BringToFront();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Eve-O-Preview/GUI/ZoomAnchor.cs
Normal file
15
Eve-O-Preview/GUI/ZoomAnchor.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public enum ZoomAnchor
|
||||||
|
{
|
||||||
|
NW = 0,
|
||||||
|
N,
|
||||||
|
NE,
|
||||||
|
W,
|
||||||
|
C,
|
||||||
|
E,
|
||||||
|
SW,
|
||||||
|
S,
|
||||||
|
SE
|
||||||
|
}
|
||||||
|
}
|
||||||
332
Eve-O-Preview/Hotkeys/Hotkey.cs
Normal file
332
Eve-O-Preview/Hotkeys/Hotkey.cs
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public class Hotkey : IMessageFilter
|
||||||
|
{
|
||||||
|
private static int _currentId;
|
||||||
|
private const int MaxId = 0xBFFF;
|
||||||
|
|
||||||
|
[XmlElement("keyCode")]
|
||||||
|
private Keys _keyCode;
|
||||||
|
[XmlElement("shift")]
|
||||||
|
private bool _shift;
|
||||||
|
[XmlElement("control")]
|
||||||
|
private bool _control;
|
||||||
|
[XmlElement("alt")]
|
||||||
|
private bool _alt;
|
||||||
|
[XmlElement("windows")]
|
||||||
|
private bool _windows;
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
private int _id;
|
||||||
|
[XmlIgnore]
|
||||||
|
private bool _isRegistered;
|
||||||
|
[XmlIgnore]
|
||||||
|
private Control _windowControl;
|
||||||
|
|
||||||
|
public event HandledEventHandler Pressed;
|
||||||
|
|
||||||
|
public Hotkey()
|
||||||
|
: this(Keys.None, false, false, false, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotkey(Keys keyCode, bool shift, bool control, bool alt, bool windows)
|
||||||
|
{
|
||||||
|
// Assign properties
|
||||||
|
this.KeyCode = keyCode;
|
||||||
|
this.Shift = shift;
|
||||||
|
this.Control = control;
|
||||||
|
this.Alt = alt;
|
||||||
|
this.Windows = windows;
|
||||||
|
|
||||||
|
// Register us as a message filter
|
||||||
|
Application.AddMessageFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
~Hotkey()
|
||||||
|
{
|
||||||
|
// Unregister the hotkey if necessary
|
||||||
|
if (this.IsRegistered)
|
||||||
|
{
|
||||||
|
this.Unregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hotkey Clone()
|
||||||
|
{
|
||||||
|
// Clone the whole object
|
||||||
|
return new Hotkey(this._keyCode, this._shift, this._control, this._alt, this._windows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetCanRegister(Control windowControl)
|
||||||
|
{
|
||||||
|
// Handle any exceptions: they mean "no, you can't register" :)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Attempt to register
|
||||||
|
if (this.Register(windowControl))
|
||||||
|
{
|
||||||
|
// Unregister and say we managed it
|
||||||
|
this.Unregister();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Win32Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (NotSupportedException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Register(Control windowControl)
|
||||||
|
{
|
||||||
|
// Check that we have not registered
|
||||||
|
if (this._isRegistered)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("You cannot register a hotkey that is already registered");
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can't register an empty hotkey
|
||||||
|
if (this.IsEmpty)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("You cannot register an empty hotkey");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get an ID for the hotkey and increase current ID
|
||||||
|
this._id = Hotkey._currentId;
|
||||||
|
Hotkey._currentId = Hotkey._currentId + 1 % Hotkey.MaxId;
|
||||||
|
|
||||||
|
// Translate modifier keys into unmanaged version
|
||||||
|
uint modifiers = (this.Alt ? HotkeyNativeMethods.MOD_ALT : 0) | (this.Control ? HotkeyNativeMethods.MOD_CONTROL : 0) |
|
||||||
|
(this.Shift ? HotkeyNativeMethods.MOD_SHIFT : 0) | (this.Windows ? HotkeyNativeMethods.MOD_WIN : 0);
|
||||||
|
|
||||||
|
// Register the hotkey
|
||||||
|
if (HotkeyNativeMethods.RegisterHotKey(windowControl.Handle, this._id, modifiers, _keyCode) == 0)
|
||||||
|
{
|
||||||
|
// Is the error that the hotkey is registered?
|
||||||
|
if (Marshal.GetLastWin32Error() != HotkeyNativeMethods.ERROR_HOTKEY_ALREADY_REGISTERED)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the control reference and register state
|
||||||
|
this._isRegistered = true;
|
||||||
|
this._windowControl = windowControl;
|
||||||
|
|
||||||
|
// We successfully registered
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unregister()
|
||||||
|
{
|
||||||
|
// Check that we have registered
|
||||||
|
if (!this._isRegistered)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("You cannot unregister a hotkey that is not registered");
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's possible that the control itself has died: in that case, no need to unregister!
|
||||||
|
if (!this._windowControl.IsDisposed)
|
||||||
|
{
|
||||||
|
// Clean up after ourselves
|
||||||
|
if (HotkeyNativeMethods.UnregisterHotKey(this._windowControl.Handle, this._id) == 0)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the control reference and register state
|
||||||
|
this._isRegistered = false;
|
||||||
|
this._windowControl = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Reregister()
|
||||||
|
{
|
||||||
|
// Only do something if the key is already registered
|
||||||
|
if (!this._isRegistered)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save control reference
|
||||||
|
Control windowControl = this._windowControl;
|
||||||
|
|
||||||
|
// Unregister and then reregister again
|
||||||
|
this.Unregister();
|
||||||
|
this.Register(windowControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool PreFilterMessage(ref Message message)
|
||||||
|
{
|
||||||
|
// Only process WM_HOTKEY messages
|
||||||
|
if (message.Msg != HotkeyNativeMethods.WM_HOTKEY)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the ID is our key and we are registerd
|
||||||
|
return this._isRegistered && (message.WParam.ToInt32() == this._id) && this.OnPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool OnPressed()
|
||||||
|
{
|
||||||
|
// Fire the event if we can
|
||||||
|
HandledEventArgs handledEventArgs = new HandledEventArgs(false);
|
||||||
|
this.Pressed?.Invoke(this, handledEventArgs);
|
||||||
|
|
||||||
|
// Return whether we handled the event or not
|
||||||
|
return handledEventArgs.Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
// We can be empty
|
||||||
|
if (this.IsEmpty)
|
||||||
|
{
|
||||||
|
return "(none)";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build key name
|
||||||
|
string keyName = Enum.GetName(typeof(Keys), this._keyCode) ?? " ";
|
||||||
|
switch (this._keyCode)
|
||||||
|
{
|
||||||
|
case Keys.D0:
|
||||||
|
case Keys.D1:
|
||||||
|
case Keys.D2:
|
||||||
|
case Keys.D3:
|
||||||
|
case Keys.D4:
|
||||||
|
case Keys.D5:
|
||||||
|
case Keys.D6:
|
||||||
|
case Keys.D7:
|
||||||
|
case Keys.D8:
|
||||||
|
case Keys.D9:
|
||||||
|
// Strip the first character
|
||||||
|
keyName = keyName.Substring(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build modifiers
|
||||||
|
string modifiers = "";
|
||||||
|
if (this._shift)
|
||||||
|
{
|
||||||
|
modifiers += "Shift+";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._control)
|
||||||
|
{
|
||||||
|
modifiers += "Control+";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._alt)
|
||||||
|
{
|
||||||
|
modifiers += "Alt+";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._windows)
|
||||||
|
{
|
||||||
|
modifiers += "Windows+";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return result
|
||||||
|
return modifiers + keyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._keyCode == Keys.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRegistered
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._isRegistered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Keys KeyCode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._keyCode;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Save and reregister
|
||||||
|
this._keyCode = value;
|
||||||
|
this.Reregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Shift
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._shift;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Save and reregister
|
||||||
|
this._shift = value;
|
||||||
|
this.Reregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Control
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._control;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Save and reregister
|
||||||
|
this._control = value;
|
||||||
|
this.Reregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Alt
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._alt;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Save and reregister
|
||||||
|
this._alt = value;
|
||||||
|
this.Reregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Windows
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._windows;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Save and reregister
|
||||||
|
this._windows = value;
|
||||||
|
this.Reregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs
Normal file
24
Eve-O-Preview/Hotkeys/HotkeyNativeMethods.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
static class HotkeyNativeMethods
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
public static extern int RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, Keys vk);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
public static extern int UnregisterHotKey(IntPtr hWnd, int id);
|
||||||
|
|
||||||
|
public const uint WM_HOTKEY = 0x312;
|
||||||
|
|
||||||
|
public const uint MOD_ALT = 0x1;
|
||||||
|
public const uint MOD_CONTROL = 0x2;
|
||||||
|
public const uint MOD_SHIFT = 0x4;
|
||||||
|
public const uint MOD_WIN = 0x8;
|
||||||
|
|
||||||
|
public const uint ERROR_HOTKEY_ALREADY_REGISTERED = 1409;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Eve-O-Preview/Program.cs
Normal file
17
Eve-O-Preview/Program.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>The main entry point for the application.</summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(true);
|
||||||
|
Application.Run(new MainForm());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Eve-O-Preview/Properties/AssemblyInfo.cs
Normal file
21
Eve-O-Preview/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("EVE-O Preview")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("EVE-O Preview")]
|
||||||
|
[assembly: AssemblyCopyright("")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
[assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")]
|
||||||
|
[assembly: AssemblyVersion("1.18.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.18.0.0")]
|
||||||
|
|
||||||
|
// Provide your own key name to build the app locally
|
||||||
|
[assembly: AssemblyKeyName("Phrynohyas")]
|
||||||
|
|
||||||
|
[assembly: CLSCompliant(true)]
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.34014
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace PreviewToy.Properties {
|
namespace EveOPreview.Properties {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ namespace PreviewToy.Properties {
|
|||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PreviewToy.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EveOPreview.Properties.Resources", typeof(Resources).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.34014
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace PreviewToy.Properties {
|
namespace EveOPreview.Properties {
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
31
Eve-O-Preview/Thumbnail/IThumbnail.cs
Normal file
31
Eve-O-Preview/Thumbnail/IThumbnail.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public interface IThumbnail
|
||||||
|
{
|
||||||
|
bool IsZoomEnabled { get; set; }
|
||||||
|
bool IsPreviewEnabled { get; set; }
|
||||||
|
bool IsOverlayEnabled { get; set; }
|
||||||
|
|
||||||
|
bool IsPreviewHandle(IntPtr handle);
|
||||||
|
|
||||||
|
void ShowThumbnail();
|
||||||
|
void HideThumbnail();
|
||||||
|
void CloseThumbnail();
|
||||||
|
|
||||||
|
void RegisterShortcut(string shortcut);
|
||||||
|
|
||||||
|
void SetLabel(string label);
|
||||||
|
string GetLabel();
|
||||||
|
|
||||||
|
void SetLocation(Point location);
|
||||||
|
Point GetLocation();
|
||||||
|
|
||||||
|
void SetOpacity(double opacity);
|
||||||
|
void SetTopMost(bool topmost);
|
||||||
|
void SetWindowFrames(bool enable);
|
||||||
|
void SetSize(Size size);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Eve-O-Preview/Thumbnail/ThumbnailFactory.cs
Normal file
13
Eve-O-Preview/Thumbnail/ThumbnailFactory.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public class ThumbnailFactory
|
||||||
|
{
|
||||||
|
public IThumbnail Create(ThumbnailManager manager, IntPtr sourceWindow, string title, Size size)
|
||||||
|
{
|
||||||
|
return new ThumbnailWindow(manager, sourceWindow, title, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
507
Eve-O-Preview/Thumbnail/ThumbnailManager.cs
Normal file
507
Eve-O-Preview/Thumbnail/ThumbnailManager.cs
Normal file
@@ -0,0 +1,507 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public class ThumbnailManager
|
||||||
|
{
|
||||||
|
private readonly Stopwatch _ignoringSizeSync;
|
||||||
|
private DispatcherTimer _dispatcherTimer;
|
||||||
|
private readonly ThumbnailFactory _thumbnailFactory;
|
||||||
|
private readonly Dictionary<IntPtr, IThumbnail> _previews;
|
||||||
|
|
||||||
|
private IntPtr _activeClientHandle;
|
||||||
|
private string _activeClientTitle;
|
||||||
|
|
||||||
|
private readonly Dictionary<string, Dictionary<string, Point>> _uniqueLayouts;
|
||||||
|
private readonly Dictionary<string, Point> _flatLayout;
|
||||||
|
private readonly Dictionary<string, string> _flatLayoutShortcuts;
|
||||||
|
private readonly Dictionary<string, ClientLocation> _clientLayout;
|
||||||
|
|
||||||
|
private readonly Dictionary<string, string> _xmlBadToOkChars;
|
||||||
|
|
||||||
|
private readonly Action<IList<string>> _addThumbnail;
|
||||||
|
private readonly Action<IList<string>> _removeThumbnail;
|
||||||
|
private readonly Action<bool> _setAeroStatus;
|
||||||
|
private readonly Action<int,int> _sizeChange;
|
||||||
|
|
||||||
|
public ThumbnailManager(Action<IList<string>> addThumbnail, Action<IList<string>> removeThumbnail, Action<bool> setAeroStatus, Action<int,int> sizeChange)
|
||||||
|
{
|
||||||
|
_addThumbnail = addThumbnail;
|
||||||
|
_removeThumbnail = removeThumbnail;
|
||||||
|
_setAeroStatus = setAeroStatus;
|
||||||
|
_sizeChange = sizeChange;
|
||||||
|
|
||||||
|
_ignoringSizeSync = new Stopwatch();
|
||||||
|
_ignoringSizeSync.Start();
|
||||||
|
|
||||||
|
this._activeClientHandle = (IntPtr)0;
|
||||||
|
this._activeClientTitle = "";
|
||||||
|
|
||||||
|
_xmlBadToOkChars = new Dictionary<string, string>();
|
||||||
|
_xmlBadToOkChars["<"] = "---lt---";
|
||||||
|
_xmlBadToOkChars["&"] = "---amp---";
|
||||||
|
_xmlBadToOkChars[">"] = "---gt---";
|
||||||
|
_xmlBadToOkChars["\""] = "---quot---";
|
||||||
|
_xmlBadToOkChars["\'"] = "---apos---";
|
||||||
|
_xmlBadToOkChars[","] = "---comma---";
|
||||||
|
_xmlBadToOkChars["."] = "---dot---";
|
||||||
|
|
||||||
|
_uniqueLayouts = new Dictionary<string, Dictionary<string, Point>>();
|
||||||
|
_flatLayout = new Dictionary<string, Point>();
|
||||||
|
_flatLayoutShortcuts = new Dictionary<string, string>();
|
||||||
|
_clientLayout = new Dictionary<string, ClientLocation>();
|
||||||
|
|
||||||
|
this._previews = new Dictionary<IntPtr, IThumbnail>();
|
||||||
|
|
||||||
|
// DispatcherTimer setup
|
||||||
|
_dispatcherTimer = new DispatcherTimer();
|
||||||
|
_dispatcherTimer.Tick += dispatcherTimer_Tick;
|
||||||
|
_dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
|
||||||
|
|
||||||
|
this._thumbnailFactory = new ThumbnailFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Activate()
|
||||||
|
{
|
||||||
|
this.load_layout();
|
||||||
|
this._dispatcherTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Deactivate()
|
||||||
|
{
|
||||||
|
this._dispatcherTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spawn_and_kill_previews()
|
||||||
|
{
|
||||||
|
// TODO Extract this!
|
||||||
|
Process[] processes = Process.GetProcessesByName("ExeFile");
|
||||||
|
List<IntPtr> processHandles = new List<IntPtr>();
|
||||||
|
List<string> addedList=new List<string>();
|
||||||
|
List<string> removedList = new List<string>();
|
||||||
|
// pop new previews
|
||||||
|
|
||||||
|
foreach (Process process in processes)
|
||||||
|
{
|
||||||
|
processHandles.Add(process.MainWindowHandle);
|
||||||
|
|
||||||
|
Size sync_size = new Size();
|
||||||
|
sync_size.Width = (int)Properties.Settings.Default.sync_resize_x;
|
||||||
|
sync_size.Height = (int)Properties.Settings.Default.sync_resize_y;
|
||||||
|
|
||||||
|
if (!_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "")
|
||||||
|
{
|
||||||
|
_previews[process.MainWindowHandle] = this._thumbnailFactory.Create(this, process.MainWindowHandle, "...", sync_size);
|
||||||
|
|
||||||
|
// apply more thumbnail specific options
|
||||||
|
_previews[process.MainWindowHandle].SetTopMost(Properties.Settings.Default.always_on_top);
|
||||||
|
_previews[process.MainWindowHandle].SetWindowFrames(Properties.Settings.Default.show_thumb_frames);
|
||||||
|
|
||||||
|
// add a preview also
|
||||||
|
addedList.Add(_previews[process.MainWindowHandle].GetLabel());
|
||||||
|
|
||||||
|
refresh_client_window_locations(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (_previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != _previews[process.MainWindowHandle].GetLabel()) //or update the preview titles
|
||||||
|
{
|
||||||
|
_previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle);
|
||||||
|
string key = _previews[process.MainWindowHandle].GetLabel();
|
||||||
|
string value;
|
||||||
|
if (_flatLayoutShortcuts.TryGetValue(key, out value))
|
||||||
|
{
|
||||||
|
_previews[process.MainWindowHandle].RegisterShortcut(value);
|
||||||
|
}
|
||||||
|
refresh_client_window_locations(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.MainWindowHandle == DwmApiNativeMethods.GetForegroundWindow())
|
||||||
|
{
|
||||||
|
_activeClientHandle = process.MainWindowHandle;
|
||||||
|
_activeClientTitle = process.MainWindowTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Check for empty list
|
||||||
|
_addThumbnail(addedList);
|
||||||
|
|
||||||
|
// clean up old previews
|
||||||
|
List<IntPtr> to_be_pruned = new List<IntPtr>();
|
||||||
|
foreach (IntPtr processHandle in _previews.Keys)
|
||||||
|
{
|
||||||
|
if (!(processHandles.Contains(processHandle)))
|
||||||
|
{
|
||||||
|
to_be_pruned.Add(processHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (IntPtr processHandle in to_be_pruned)
|
||||||
|
{
|
||||||
|
removedList.Add(_previews[processHandle].GetLabel());
|
||||||
|
|
||||||
|
_previews[processHandle].CloseThumbnail();
|
||||||
|
_previews.Remove(processHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeThumbnail(removedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refresh_client_window_locations(Process process)
|
||||||
|
{
|
||||||
|
if (Properties.Settings.Default.track_client_windows && _clientLayout.ContainsKey(process.MainWindowTitle))
|
||||||
|
{
|
||||||
|
DwmApiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X,
|
||||||
|
_clientLayout[process.MainWindowTitle].Y, _clientLayout[process.MainWindowTitle].Width,
|
||||||
|
_clientLayout[process.MainWindowTitle].Height, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatcherTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
spawn_and_kill_previews();
|
||||||
|
refresh_thumbnails();
|
||||||
|
if (_ignoringSizeSync.ElapsedMilliseconds > 500) { _ignoringSizeSync.Stop(); };
|
||||||
|
|
||||||
|
// TODO Do this once in 10 seconds
|
||||||
|
_setAeroStatus(DwmApiNativeMethods.DwmIsCompositionEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifyPreviewSwitch()
|
||||||
|
{
|
||||||
|
update_client_locations();
|
||||||
|
store_layout(); //todo: check if it actually changed ...
|
||||||
|
foreach (KeyValuePair<IntPtr, IThumbnail> entry in _previews)
|
||||||
|
{
|
||||||
|
entry.Value.SetTopMost(Properties.Settings.Default.always_on_top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SyncPreviewSize(Size sync_size)
|
||||||
|
{
|
||||||
|
if (Properties.Settings.Default.sync_resize &&
|
||||||
|
Properties.Settings.Default.show_thumb_frames &&
|
||||||
|
_ignoringSizeSync.ElapsedMilliseconds > 500)
|
||||||
|
{
|
||||||
|
_ignoringSizeSync.Stop();
|
||||||
|
|
||||||
|
_sizeChange(sync_size.Width, sync_size.Height);
|
||||||
|
|
||||||
|
foreach (KeyValuePair<IntPtr, IThumbnail> entry in _previews)
|
||||||
|
{
|
||||||
|
if (entry.Value.IsPreviewHandle(DwmApiNativeMethods.GetForegroundWindow()))
|
||||||
|
{
|
||||||
|
entry.Value.SetSize(sync_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdatePreviewPosition(string preview_title, Point position)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Properties.Settings.Default.unique_layout)
|
||||||
|
{
|
||||||
|
Dictionary<string, Point> layout;
|
||||||
|
if (_uniqueLayouts.TryGetValue(_activeClientTitle, out layout))
|
||||||
|
{
|
||||||
|
layout[preview_title] = position;
|
||||||
|
}
|
||||||
|
else if (_activeClientTitle == "")
|
||||||
|
{
|
||||||
|
_uniqueLayouts[_activeClientTitle] = new Dictionary<string, Point>();
|
||||||
|
_uniqueLayouts[_activeClientTitle][preview_title] = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_flatLayout[preview_title] = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private string remove_nonconform_xml_characters(string entry)
|
||||||
|
{
|
||||||
|
foreach (var kv in _xmlBadToOkChars)
|
||||||
|
{
|
||||||
|
entry = entry.Replace(kv.Key, kv.Value);
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string restore_nonconform_xml_characters(string entry)
|
||||||
|
{
|
||||||
|
foreach (var kv in _xmlBadToOkChars)
|
||||||
|
{
|
||||||
|
entry = entry.Replace(kv.Value, kv.Key);
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
private XElement MakeXElement(string input)
|
||||||
|
{
|
||||||
|
string clean = remove_nonconform_xml_characters(input).Replace(" ", "_");
|
||||||
|
return new XElement(clean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ParseXElement(XElement input)
|
||||||
|
{
|
||||||
|
return restore_nonconform_xml_characters(input.Name.ToString()).Replace("_", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load_layout()
|
||||||
|
{
|
||||||
|
if (File.Exists("layout.xml"))
|
||||||
|
{
|
||||||
|
XElement rootElement = XElement.Load("layout.xml");
|
||||||
|
foreach (var el in rootElement.Elements())
|
||||||
|
{
|
||||||
|
Dictionary<string, Point> inner = new Dictionary<string, Point>();
|
||||||
|
foreach (var inner_el in el.Elements())
|
||||||
|
{
|
||||||
|
inner[ParseXElement(inner_el)] = new Point(Convert.ToInt32(inner_el.Element("x")?.Value), Convert.ToInt32(inner_el.Element("y")?.Value));
|
||||||
|
}
|
||||||
|
_uniqueLayouts[ParseXElement(el)] = inner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists("flat_layout.xml"))
|
||||||
|
{
|
||||||
|
XElement rootElement = XElement.Load("flat_layout.xml");
|
||||||
|
foreach (var el in rootElement.Elements())
|
||||||
|
{
|
||||||
|
_flatLayout[ParseXElement(el)] = new Point(Convert.ToInt32(el.Element("x").Value), Convert.ToInt32(el.Element("y").Value));
|
||||||
|
_flatLayoutShortcuts[ParseXElement(el)] = "";
|
||||||
|
|
||||||
|
if (el.Element("shortcut") != null)
|
||||||
|
{
|
||||||
|
_flatLayoutShortcuts[ParseXElement(el)] = el.Element("shortcut").Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists("client_layout.xml"))
|
||||||
|
{
|
||||||
|
XElement rootElement = XElement.Load("client_layout.xml");
|
||||||
|
foreach (var el in rootElement.Elements())
|
||||||
|
{
|
||||||
|
ClientLocation clientLocation = new ClientLocation();
|
||||||
|
clientLocation.X = Convert.ToInt32(el.Element("x").Value);
|
||||||
|
clientLocation.Y = Convert.ToInt32(el.Element("y").Value);
|
||||||
|
clientLocation.Width = Convert.ToInt32(el.Element("width").Value);
|
||||||
|
clientLocation.Height = Convert.ToInt32(el.Element("height").Value);
|
||||||
|
|
||||||
|
_clientLayout[ParseXElement(el)] = clientLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store_layout()
|
||||||
|
{
|
||||||
|
XElement el = new XElement("layouts");
|
||||||
|
foreach (var client in _uniqueLayouts.Keys)
|
||||||
|
{
|
||||||
|
if (client == "")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
XElement layout = MakeXElement(client);
|
||||||
|
foreach (var thumbnail_ in _uniqueLayouts[client])
|
||||||
|
{
|
||||||
|
string thumbnail = thumbnail_.Key;
|
||||||
|
if (thumbnail == "" || thumbnail == "...")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
XElement position = MakeXElement(thumbnail);
|
||||||
|
position.Add(new XElement("x", thumbnail_.Value.X));
|
||||||
|
position.Add(new XElement("y", thumbnail_.Value.Y));
|
||||||
|
layout.Add(position);
|
||||||
|
}
|
||||||
|
el.Add(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
el.Save("layout.xml");
|
||||||
|
|
||||||
|
XElement el2 = new XElement("flat_layout");
|
||||||
|
foreach (var clientKV in _flatLayout)
|
||||||
|
{
|
||||||
|
if (clientKV.Key == "" || clientKV.Key == "...")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
XElement layout = MakeXElement(clientKV.Key);
|
||||||
|
layout.Add(new XElement("x", clientKV.Value.X));
|
||||||
|
layout.Add(new XElement("y", clientKV.Value.Y));
|
||||||
|
|
||||||
|
string shortcut;
|
||||||
|
if (_flatLayoutShortcuts.TryGetValue(clientKV.Key, out shortcut))
|
||||||
|
{
|
||||||
|
layout.Add(new XElement("shortcut", shortcut));
|
||||||
|
}
|
||||||
|
el2.Add(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
el2.Save("flat_layout.xml");
|
||||||
|
|
||||||
|
XElement el3 = new XElement("client_layout");
|
||||||
|
foreach (var clientKV in _clientLayout)
|
||||||
|
{
|
||||||
|
if (clientKV.Key == "" || clientKV.Key == "...")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
XElement layout = MakeXElement(clientKV.Key);
|
||||||
|
layout.Add(new XElement("x", clientKV.Value.X));
|
||||||
|
layout.Add(new XElement("y", clientKV.Value.Y));
|
||||||
|
layout.Add(new XElement("width", clientKV.Value.Width));
|
||||||
|
layout.Add(new XElement("height", clientKV.Value.Height));
|
||||||
|
el3.Add(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
el3.Save("client_layout.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handle_unique_layout(IThumbnail thumbnailWindow, string last_known_active_window)
|
||||||
|
{
|
||||||
|
Dictionary<string, Point> layout;
|
||||||
|
if (_uniqueLayouts.TryGetValue(last_known_active_window, out layout))
|
||||||
|
{
|
||||||
|
Point new_loc;
|
||||||
|
if (Properties.Settings.Default.unique_layout && layout.TryGetValue(thumbnailWindow.GetLabel(), out new_loc))
|
||||||
|
{
|
||||||
|
thumbnailWindow.SetLocation(new_loc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// create inner dict
|
||||||
|
layout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (last_known_active_window != "")
|
||||||
|
{
|
||||||
|
// create outer dict
|
||||||
|
_uniqueLayouts[last_known_active_window] = new Dictionary<string, Point>();
|
||||||
|
_uniqueLayouts[last_known_active_window][thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_client_locations()
|
||||||
|
{
|
||||||
|
Process[] processes = Process.GetProcessesByName("ExeFile");
|
||||||
|
List<IntPtr> processHandles = new List<IntPtr>();
|
||||||
|
|
||||||
|
foreach (Process process in processes)
|
||||||
|
{
|
||||||
|
RECT rect = new RECT();
|
||||||
|
DwmApiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect);
|
||||||
|
|
||||||
|
int left = Math.Abs(rect.Left);
|
||||||
|
int right = Math.Abs(rect.Right);
|
||||||
|
int client_width = Math.Abs(left - right);
|
||||||
|
|
||||||
|
int top = Math.Abs(rect.Top);
|
||||||
|
int bottom = Math.Abs(rect.Bottom);
|
||||||
|
int client_height = Math.Abs(top - bottom);
|
||||||
|
|
||||||
|
ClientLocation clientLocation = new ClientLocation();
|
||||||
|
clientLocation.X = rect.Left;
|
||||||
|
clientLocation.Y = rect.Top;
|
||||||
|
clientLocation.Width = client_width;
|
||||||
|
clientLocation.Height = client_height;
|
||||||
|
|
||||||
|
|
||||||
|
_clientLayout[process.MainWindowTitle] = clientLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handle_flat_layout(IThumbnail thumbnailWindow)
|
||||||
|
{
|
||||||
|
Point layout;
|
||||||
|
if (_flatLayout.TryGetValue(thumbnailWindow.GetLabel(), out layout))
|
||||||
|
{
|
||||||
|
thumbnailWindow.SetLocation(layout);
|
||||||
|
}
|
||||||
|
else if (thumbnailWindow.GetLabel() != "")
|
||||||
|
{
|
||||||
|
_flatLayout[thumbnailWindow.GetLabel()] = thumbnailWindow.GetLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool window_is_preview_or_client(IntPtr window)
|
||||||
|
{
|
||||||
|
bool active_window_is_right_type = false;
|
||||||
|
foreach (KeyValuePair<IntPtr, IThumbnail> entry in _previews)
|
||||||
|
{
|
||||||
|
if (entry.Key == window || entry.Value.IsPreviewHandle(window))
|
||||||
|
{
|
||||||
|
active_window_is_right_type = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return active_window_is_right_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh_thumbnails()
|
||||||
|
{
|
||||||
|
|
||||||
|
IntPtr active_window = DwmApiNativeMethods.GetForegroundWindow();
|
||||||
|
|
||||||
|
// hide, show, resize and move
|
||||||
|
foreach (KeyValuePair<IntPtr, IThumbnail> entry in _previews)
|
||||||
|
{
|
||||||
|
if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all)
|
||||||
|
{
|
||||||
|
entry.Value.HideThumbnail();
|
||||||
|
}
|
||||||
|
else if (entry.Key == _activeClientHandle && Properties.Settings.Default.hide_active)
|
||||||
|
{
|
||||||
|
entry.Value.HideThumbnail();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entry.Value.ShowThumbnail();
|
||||||
|
if (Properties.Settings.Default.unique_layout)
|
||||||
|
{
|
||||||
|
handle_unique_layout(entry.Value, _activeClientTitle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handle_flat_layout(entry.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.Value.IsZoomEnabled = Properties.Settings.Default.zoom_on_hover;
|
||||||
|
entry.Value.IsOverlayEnabled = Properties.Settings.Default.show_overlay;
|
||||||
|
entry.Value.SetOpacity(Properties.Settings.Default.opacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
DwmApiNativeMethods.DwmIsCompositionEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set_frames()
|
||||||
|
{
|
||||||
|
if (Properties.Settings.Default.show_thumb_frames)
|
||||||
|
{
|
||||||
|
_ignoringSizeSync.Stop();
|
||||||
|
_ignoringSizeSync.Reset();
|
||||||
|
_ignoringSizeSync.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var thumbnail in _previews)
|
||||||
|
{
|
||||||
|
thumbnail.Value.SetWindowFrames(Properties.Settings.Default.show_thumb_frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
90
Eve-O-Preview/Thumbnail/ThumbnailOverlay.Designer.cs
generated
Normal file
90
Eve-O-Preview/Thumbnail/ThumbnailOverlay.Designer.cs
generated
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
partial class ThumbnailOverlay
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.Windows.Forms.PictureBox OverlayAreaPictureBox;
|
||||||
|
this.OverlayLabel = new System.Windows.Forms.Label();
|
||||||
|
OverlayAreaPictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// OverlayAreaPictureBox
|
||||||
|
//
|
||||||
|
OverlayAreaPictureBox.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
OverlayAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
OverlayAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
OverlayAreaPictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
|
OverlayAreaPictureBox.Name = "OverlayAreaPictureBox";
|
||||||
|
OverlayAreaPictureBox.Size = new System.Drawing.Size(284, 262);
|
||||||
|
OverlayAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
OverlayAreaPictureBox.TabIndex = 0;
|
||||||
|
OverlayAreaPictureBox.TabStop = false;
|
||||||
|
OverlayAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OverlayArea_Click);
|
||||||
|
//
|
||||||
|
// OverlayLabel
|
||||||
|
//
|
||||||
|
this.OverlayLabel.AutoSize = true;
|
||||||
|
this.OverlayLabel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.OverlayLabel.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.OverlayLabel.ForeColor = System.Drawing.Color.DarkGray;
|
||||||
|
this.OverlayLabel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.OverlayLabel.Name = "OverlayLabel";
|
||||||
|
this.OverlayLabel.Size = new System.Drawing.Size(25, 13);
|
||||||
|
this.OverlayLabel.TabIndex = 1;
|
||||||
|
this.OverlayLabel.Text = "...";
|
||||||
|
//
|
||||||
|
// PreviewOverlay
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.ClientSize = new System.Drawing.Size(284, 262);
|
||||||
|
this.ControlBox = false;
|
||||||
|
this.Controls.Add(this.OverlayLabel);
|
||||||
|
this.Controls.Add(OverlayAreaPictureBox);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "ThumbnailOverlay";
|
||||||
|
this.ShowIcon = false;
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
|
this.Text = "PreviewOverlay";
|
||||||
|
this.TransparencyKey = System.Drawing.Color.Black;
|
||||||
|
((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label OverlayLabel;
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Eve-O-Preview/Thumbnail/ThumbnailOverlay.cs
Normal file
36
Eve-O-Preview/Thumbnail/ThumbnailOverlay.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public partial class ThumbnailOverlay : Form
|
||||||
|
{
|
||||||
|
private readonly Action<object, MouseEventArgs> _areaClickAction;
|
||||||
|
|
||||||
|
public ThumbnailOverlay(Action<object, MouseEventArgs> areaClickAction)
|
||||||
|
{
|
||||||
|
this._areaClickAction = areaClickAction;
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OverlayArea_Click(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
this._areaClickAction(sender, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetOverlayLabel(string label)
|
||||||
|
{
|
||||||
|
this.OverlayLabel.Text = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override CreateParams CreateParams
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var Params = base.CreateParams;
|
||||||
|
Params.ExStyle |= (int)DwmApiNativeMethods.WS_EX_TOOLWINDOW;
|
||||||
|
return Params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="OverlayAreaPictureBox.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>False</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
68
Eve-O-Preview/Thumbnail/ThumbnailWindow.Designer.cs
generated
Normal file
68
Eve-O-Preview/Thumbnail/ThumbnailWindow.Designer.cs
generated
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
partial class ThumbnailWindow
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.RenderAreaPictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// RenderAreaPictureBox
|
||||||
|
//
|
||||||
|
this.RenderAreaPictureBox.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.RenderAreaPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||||
|
this.RenderAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.RenderAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.RenderAreaPictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.RenderAreaPictureBox.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.RenderAreaPictureBox.Name = "RenderAreaPictureBox";
|
||||||
|
this.RenderAreaPictureBox.Size = new System.Drawing.Size(153, 89);
|
||||||
|
this.RenderAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.RenderAreaPictureBox.TabIndex = 0;
|
||||||
|
this.RenderAreaPictureBox.TabStop = false;
|
||||||
|
this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.Preview_MouseLeave);
|
||||||
|
this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.Preview_MouseHover);
|
||||||
|
this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Preview_Click);
|
||||||
|
//
|
||||||
|
// Preview
|
||||||
|
//
|
||||||
|
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(153, 89);
|
||||||
|
this.ControlBox = false;
|
||||||
|
this.Controls.Add(this.RenderAreaPictureBox);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.MinimumSize = new System.Drawing.Size(64, 64);
|
||||||
|
this.Name = "ThumbnailWindow";
|
||||||
|
this.Opacity = 0.1D;
|
||||||
|
this.ShowIcon = false;
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
|
this.Text = "Preview";
|
||||||
|
this.TopMost = true;
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.PictureBox RenderAreaPictureBox;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
437
Eve-O-Preview/Thumbnail/ThumbnailWindow.cs
Normal file
437
Eve-O-Preview/Thumbnail/ThumbnailWindow.cs
Normal file
@@ -0,0 +1,437 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace EveOPreview
|
||||||
|
{
|
||||||
|
public partial class ThumbnailWindow : Form, IThumbnail
|
||||||
|
{
|
||||||
|
#region Private fields
|
||||||
|
private readonly bool _isInitializing;
|
||||||
|
private readonly IntPtr _sourceWindow;
|
||||||
|
private readonly ThumbnailManager _manager;
|
||||||
|
private readonly ThumbnailOverlay _overlay;
|
||||||
|
private Hotkey _hotkey; // This field stores the hotkey reference
|
||||||
|
|
||||||
|
private Size _baseSize;
|
||||||
|
private Point _basePosition;
|
||||||
|
|
||||||
|
private bool _isThumbnailSetUp;
|
||||||
|
private DWM_THUMBNAIL_PROPERTIES _Thumbnail;
|
||||||
|
private IntPtr _ThumbnailHandle;
|
||||||
|
|
||||||
|
private bool _ignoreMouseOverEvent;
|
||||||
|
private bool _isHoverEffectActive;
|
||||||
|
private bool _isZoomActive;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// This constructor should never be used directly
|
||||||
|
public ThumbnailWindow(ThumbnailManager manager, IntPtr sourceWindow, string title, Size size)
|
||||||
|
{
|
||||||
|
this._isInitializing = true;
|
||||||
|
|
||||||
|
this.IsPreviewEnabled = true;
|
||||||
|
this.IsOverlayEnabled = true;
|
||||||
|
|
||||||
|
this._sourceWindow = sourceWindow;
|
||||||
|
this._manager = manager;
|
||||||
|
|
||||||
|
this._isThumbnailSetUp = false;
|
||||||
|
this._ignoreMouseOverEvent = false;
|
||||||
|
this._isHoverEffectActive = false;
|
||||||
|
this._isZoomActive = false;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
this.Text = title;
|
||||||
|
|
||||||
|
this._overlay = new ThumbnailOverlay(this.Preview_Click);
|
||||||
|
|
||||||
|
this._isInitializing = false;
|
||||||
|
|
||||||
|
this.SetSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsZoomEnabled { get; set; }
|
||||||
|
|
||||||
|
public bool IsPreviewEnabled { get; set; }
|
||||||
|
|
||||||
|
public bool IsOverlayEnabled { get; set; }
|
||||||
|
|
||||||
|
public bool IsPreviewHandle(IntPtr handle)
|
||||||
|
{
|
||||||
|
return (this.Handle == handle) || (this._overlay.Handle == handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowThumbnail()
|
||||||
|
{
|
||||||
|
if (this.IsPreviewEnabled)
|
||||||
|
{
|
||||||
|
this.Show();
|
||||||
|
if (this.IsOverlayEnabled)
|
||||||
|
{
|
||||||
|
this._overlay.Show();
|
||||||
|
this.MakeOverlayTopMost();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._overlay.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.HideThumbnail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HideThumbnail()
|
||||||
|
{
|
||||||
|
this.Hide();
|
||||||
|
this._overlay.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseThumbnail()
|
||||||
|
{
|
||||||
|
this._overlay.Close();
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLabel(string label)
|
||||||
|
{
|
||||||
|
this.Text = label;
|
||||||
|
this._overlay.SetOverlayLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetLabel()
|
||||||
|
{
|
||||||
|
return this.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSize(Size size)
|
||||||
|
{
|
||||||
|
this.Size = size;
|
||||||
|
this._baseSize = this.Size;
|
||||||
|
this._basePosition = this.Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLocation(Point location)
|
||||||
|
{
|
||||||
|
if (!(this._isInitializing || this._ignoreMouseOverEvent))
|
||||||
|
{
|
||||||
|
this.Location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point GetLocation()
|
||||||
|
{
|
||||||
|
return this.Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetOpacity(double opacity)
|
||||||
|
{
|
||||||
|
if (this._isHoverEffectActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Opacity = opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterShortcut(string shortcut)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(shortcut))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeysConverter converter = new KeysConverter();
|
||||||
|
object keysObject = converter.ConvertFrom(shortcut);
|
||||||
|
if (keysObject == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys key = (Keys)keysObject;
|
||||||
|
|
||||||
|
Hotkey hotkey = new Hotkey();
|
||||||
|
|
||||||
|
if ((key & Keys.Shift) == Keys.Shift)
|
||||||
|
{
|
||||||
|
hotkey.Shift = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((key & Keys.Alt) == Keys.Alt)
|
||||||
|
{
|
||||||
|
hotkey.Alt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((key & Keys.Control) == Keys.Control)
|
||||||
|
{
|
||||||
|
hotkey.Control = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control;
|
||||||
|
hotkey.KeyCode = key;
|
||||||
|
hotkey.Pressed += Hotkey_Pressed;
|
||||||
|
hotkey.Register(this);
|
||||||
|
|
||||||
|
this._hotkey = hotkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTopMost(bool topmost)
|
||||||
|
{
|
||||||
|
if (!this.IsPreviewEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.TopMost = topmost;
|
||||||
|
this.MakeOverlayTopMost();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetWindowFrames(bool enable)
|
||||||
|
{
|
||||||
|
this.FormBorderStyle = enable ? FormBorderStyle.SizableToolWindow : FormBorderStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override CreateParams CreateParams
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var Params = base.CreateParams;
|
||||||
|
Params.ExStyle |= (int)DwmApiNativeMethods.WS_EX_TOOLWINDOW;
|
||||||
|
return Params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Preview_MouseHover(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!this._ignoreMouseOverEvent)
|
||||||
|
{
|
||||||
|
this._ignoreMouseOverEvent = true;
|
||||||
|
if (this.IsZoomEnabled)
|
||||||
|
{
|
||||||
|
this.ZoomIn();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SetTopMost(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Opacity = 1.0f;
|
||||||
|
this._isHoverEffectActive = true;
|
||||||
|
|
||||||
|
this.RefreshPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Preview_MouseLeave(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this._ignoreMouseOverEvent)
|
||||||
|
{
|
||||||
|
if (this.IsZoomEnabled)
|
||||||
|
{
|
||||||
|
this.ZoomOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
this._ignoreMouseOverEvent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._isHoverEffectActive = false;
|
||||||
|
this.Opacity = Properties.Settings.Default.opacity; // TODO Use local object
|
||||||
|
|
||||||
|
this.RefreshPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Preview_Click(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Button == MouseButtons.Left)
|
||||||
|
{
|
||||||
|
this.ActivateClient();
|
||||||
|
this._manager.NotifyPreviewSwitch();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Button == MouseButtons.Right)
|
||||||
|
{
|
||||||
|
// do smth cool?
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Button == MouseButtons.Middle)
|
||||||
|
{
|
||||||
|
// do smth cool?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Hotkey_Pressed(Object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.ActivateClient();
|
||||||
|
this._manager.NotifyPreviewSwitch();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnResize(EventArgs e)
|
||||||
|
{
|
||||||
|
this.RefreshPreview();
|
||||||
|
|
||||||
|
base.OnResize(e);
|
||||||
|
|
||||||
|
if (!(this._isInitializing || this._ignoreMouseOverEvent))
|
||||||
|
{
|
||||||
|
this._manager.SyncPreviewSize(this.Size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMove(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMove(e);
|
||||||
|
|
||||||
|
if (!(this._isInitializing || this._ignoreMouseOverEvent))
|
||||||
|
{
|
||||||
|
this._manager.UpdatePreviewPosition(this.Text, this.Location);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.RefreshPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeOverlayTopMost()
|
||||||
|
{
|
||||||
|
this._overlay.TopMost = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshPreview()
|
||||||
|
{
|
||||||
|
if (this._isInitializing)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DwmApiNativeMethods.DwmIsCompositionEnabled())
|
||||||
|
{
|
||||||
|
if (this._isThumbnailSetUp == false)
|
||||||
|
{
|
||||||
|
this.SetUpThumbnail();
|
||||||
|
}
|
||||||
|
|
||||||
|
this._Thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom);
|
||||||
|
DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._ThumbnailHandle, this._Thumbnail);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this._isThumbnailSetUp = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Size overlaySize = this.RenderAreaPictureBox.Size;
|
||||||
|
overlaySize.Width -= 2 * 5;
|
||||||
|
overlaySize.Height -= 2 * 5;
|
||||||
|
|
||||||
|
Point overlayLocation = this.Location;
|
||||||
|
overlayLocation.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2;
|
||||||
|
overlayLocation.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2;
|
||||||
|
|
||||||
|
this._overlay.Size = overlaySize;
|
||||||
|
this._overlay.Location = overlayLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetUpThumbnail()
|
||||||
|
{
|
||||||
|
if (this._isThumbnailSetUp || !DwmApiNativeMethods.DwmIsCompositionEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._ThumbnailHandle = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, this._sourceWindow);
|
||||||
|
|
||||||
|
this._Thumbnail = new DWM_THUMBNAIL_PROPERTIES();
|
||||||
|
this._Thumbnail.dwFlags = DWM_TNP_CONSTANTS.DWM_TNP_VISIBLE
|
||||||
|
+ DWM_TNP_CONSTANTS.DWM_TNP_OPACITY
|
||||||
|
+ DWM_TNP_CONSTANTS.DWM_TNP_RECTDESTINATION
|
||||||
|
+ DWM_TNP_CONSTANTS.DWM_TNP_SOURCECLIENTAREAONLY;
|
||||||
|
this._Thumbnail.opacity = 255;
|
||||||
|
this._Thumbnail.fVisible = true;
|
||||||
|
this._Thumbnail.fSourceClientAreaOnly = true;
|
||||||
|
this._Thumbnail.rcDestination = new RECT(0, 0, this.ClientRectangle.Right, this.ClientRectangle.Bottom);
|
||||||
|
|
||||||
|
DwmApiNativeMethods.DwmUpdateThumbnailProperties(this._ThumbnailHandle, this._Thumbnail);
|
||||||
|
|
||||||
|
this._isThumbnailSetUp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomIn()
|
||||||
|
{
|
||||||
|
if (this._isZoomActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._isZoomActive = true;
|
||||||
|
|
||||||
|
// TODO Use global settings object
|
||||||
|
float zoomFactor = Properties.Settings.Default.zoom_amount;
|
||||||
|
|
||||||
|
this._baseSize = this.Size;
|
||||||
|
this._basePosition = this.Location;
|
||||||
|
|
||||||
|
this.Size = new Size((int)(zoomFactor * this.Size.Width), (int)(zoomFactor * this.Size.Height));
|
||||||
|
|
||||||
|
// TODO Use global settings object
|
||||||
|
switch ((ZoomAnchor)Properties.Settings.Default.zoom_anchor)
|
||||||
|
{
|
||||||
|
case ZoomAnchor.NW:
|
||||||
|
break;
|
||||||
|
case ZoomAnchor.N:
|
||||||
|
this.Location = new Point(this.Location.X - this.Size.Width / 2 + this._baseSize.Width / 2, this.Location.Y);
|
||||||
|
break;
|
||||||
|
case ZoomAnchor.NE:
|
||||||
|
this.Location = new Point(this.Location.X - this.Size.Width + this._baseSize.Width, this.Location.Y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZoomAnchor.W:
|
||||||
|
this.Location = new Point(this.Location.X, this.Location.Y - this.Size.Height / 2 + this._baseSize.Height / 2);
|
||||||
|
break;
|
||||||
|
case ZoomAnchor.C:
|
||||||
|
this.Location = new Point(this.Location.X - this.Size.Width / 2 + this._baseSize.Width / 2, this.Location.Y - this.Size.Height / 2 + this._baseSize.Height / 2);
|
||||||
|
break;
|
||||||
|
case ZoomAnchor.E:
|
||||||
|
this.Location = new Point(this.Location.X - this.Size.Width + this._baseSize.Width, this.Location.Y - this.Size.Height / 2 + this._baseSize.Height / 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZoomAnchor.SW:
|
||||||
|
this.Location = new Point(this.Location.X, this.Location.Y - this.Size.Height + this._baseSize.Height);
|
||||||
|
break;
|
||||||
|
case ZoomAnchor.S:
|
||||||
|
this.Location = new Point(this.Location.X - this.Size.Width / 2 + this._baseSize.Width / 2, this.Location.Y - this.Size.Height + this._baseSize.Height);
|
||||||
|
break;
|
||||||
|
case ZoomAnchor.SE:
|
||||||
|
this.Location = new Point(this.Location.X - this.Size.Width + this._baseSize.Width, this.Location.Y - this.Size.Height + this._baseSize.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomOut()
|
||||||
|
{
|
||||||
|
if (!this._isZoomActive)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Size = this._baseSize;
|
||||||
|
this.Location = this._basePosition;
|
||||||
|
|
||||||
|
this._isZoomActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ActivateClient()
|
||||||
|
{
|
||||||
|
DwmApiNativeMethods.SetForegroundWindow(this._sourceWindow);
|
||||||
|
|
||||||
|
int style = DwmApiNativeMethods.GetWindowLong(this._sourceWindow, DwmApiNativeMethods.GWL_STYLE);
|
||||||
|
if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE)
|
||||||
|
{
|
||||||
|
// Client is already maximized, no action is required
|
||||||
|
}
|
||||||
|
else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE)
|
||||||
|
{
|
||||||
|
DwmApiNativeMethods.ShowWindowAsync(this._sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
3
ExeFile/.gitignore
vendored
3
ExeFile/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
bin/*
|
|
||||||
obj/*
|
|
||||||
*.suo
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
syntax: glob
|
|
||||||
bin/*
|
|
||||||
obj/*
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace ExeFile
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for App.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class App : Application
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace ExeFile
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for MainWindow.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class MainWindow : Window
|
|
||||||
{
|
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
Random random = new Random();
|
|
||||||
this.Title += random.Next().ToString("X");
|
|
||||||
this.grid.Background = new SolidColorBrush(
|
|
||||||
Color.FromArgb((byte)255,
|
|
||||||
(byte)random.Next(0, 255),
|
|
||||||
(byte)random.Next(0, 255),
|
|
||||||
(byte)random.Next(0, 255)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Resources;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("ExeFile")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("")]
|
|
||||||
[assembly: AssemblyProduct("ExeFile")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
//In order to begin building localizable applications, set
|
|
||||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
|
||||||
//inside a <PropertyGroup>. For example, if you are using US english
|
|
||||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
|
||||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
|
||||||
//the line below to match the UICulture setting in the project file.
|
|
||||||
|
|
||||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
|
||||||
|
|
||||||
|
|
||||||
[assembly: ThemeInfo(
|
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// or application resource dictionaries)
|
|
||||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
|
||||||
//(used if a resource is not found in the page,
|
|
||||||
// app, or any theme specific resource dictionaries)
|
|
||||||
)]
|
|
||||||
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
||||||
302
Hotkey.cs
302
Hotkey.cs
@@ -1,302 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace MovablePython
|
|
||||||
{
|
|
||||||
public class Hotkey : IMessageFilter
|
|
||||||
{
|
|
||||||
#region Interop
|
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
|
||||||
private static extern int RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, Keys vk);
|
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError=true)]
|
|
||||||
private static extern int UnregisterHotKey(IntPtr hWnd, int id);
|
|
||||||
|
|
||||||
private const uint WM_HOTKEY = 0x312;
|
|
||||||
|
|
||||||
private const uint MOD_ALT = 0x1;
|
|
||||||
private const uint MOD_CONTROL = 0x2;
|
|
||||||
private const uint MOD_SHIFT = 0x4;
|
|
||||||
private const uint MOD_WIN = 0x8;
|
|
||||||
|
|
||||||
private const uint ERROR_HOTKEY_ALREADY_REGISTERED = 1409;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private static int currentID;
|
|
||||||
private const int maximumID = 0xBFFF;
|
|
||||||
|
|
||||||
private Keys keyCode;
|
|
||||||
private bool shift;
|
|
||||||
private bool control;
|
|
||||||
private bool alt;
|
|
||||||
private bool windows;
|
|
||||||
|
|
||||||
[XmlIgnore]
|
|
||||||
private int id;
|
|
||||||
[XmlIgnore]
|
|
||||||
private bool registered;
|
|
||||||
[XmlIgnore]
|
|
||||||
private Control windowControl;
|
|
||||||
|
|
||||||
public event HandledEventHandler Pressed;
|
|
||||||
|
|
||||||
public Hotkey() : this(Keys.None, false, false, false, false)
|
|
||||||
{
|
|
||||||
// No work done here!
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hotkey(Keys keyCode, bool shift, bool control, bool alt, bool windows)
|
|
||||||
{
|
|
||||||
// Assign properties
|
|
||||||
this.KeyCode = keyCode;
|
|
||||||
this.Shift = shift;
|
|
||||||
this.Control = control;
|
|
||||||
this.Alt = alt;
|
|
||||||
this.Windows = windows;
|
|
||||||
|
|
||||||
// Register us as a message filter
|
|
||||||
Application.AddMessageFilter(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Hotkey()
|
|
||||||
{
|
|
||||||
// Unregister the hotkey if necessary
|
|
||||||
if (this.Registered)
|
|
||||||
{ this.Unregister(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Hotkey Clone()
|
|
||||||
{
|
|
||||||
// Clone the whole object
|
|
||||||
return new Hotkey(this.keyCode, this.shift, this.control, this.alt, this.windows);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetCanRegister(Control windowControl)
|
|
||||||
{
|
|
||||||
// Handle any exceptions: they mean "no, you can't register" :)
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Attempt to register
|
|
||||||
if (!this.Register(windowControl))
|
|
||||||
{ return false; }
|
|
||||||
|
|
||||||
// Unregister and say we managed it
|
|
||||||
this.Unregister();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Win32Exception)
|
|
||||||
{ return false; }
|
|
||||||
catch (NotSupportedException)
|
|
||||||
{ return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Register(Control windowControl)
|
|
||||||
{
|
|
||||||
// Check that we have not registered
|
|
||||||
if (this.registered)
|
|
||||||
{ throw new NotSupportedException("You cannot register a hotkey that is already registered"); }
|
|
||||||
|
|
||||||
// We can't register an empty hotkey
|
|
||||||
if (this.Empty)
|
|
||||||
{ throw new NotSupportedException("You cannot register an empty hotkey"); }
|
|
||||||
|
|
||||||
// Get an ID for the hotkey and increase current ID
|
|
||||||
this.id = Hotkey.currentID;
|
|
||||||
Hotkey.currentID = Hotkey.currentID + 1 % Hotkey.maximumID;
|
|
||||||
|
|
||||||
// Translate modifier keys into unmanaged version
|
|
||||||
uint modifiers = (this.Alt ? Hotkey.MOD_ALT : 0) | (this.Control ? Hotkey.MOD_CONTROL : 0) |
|
|
||||||
(this.Shift ? Hotkey.MOD_SHIFT : 0) | (this.Windows ? Hotkey.MOD_WIN : 0);
|
|
||||||
|
|
||||||
// Register the hotkey
|
|
||||||
if (Hotkey.RegisterHotKey(windowControl.Handle, this.id, modifiers, keyCode) == 0)
|
|
||||||
{
|
|
||||||
// Is the error that the hotkey is registered?
|
|
||||||
if (Marshal.GetLastWin32Error() == ERROR_HOTKEY_ALREADY_REGISTERED)
|
|
||||||
{ return false; }
|
|
||||||
else
|
|
||||||
{ throw new Win32Exception(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the control reference and register state
|
|
||||||
this.registered = true;
|
|
||||||
this.windowControl = windowControl;
|
|
||||||
|
|
||||||
// We successfully registered
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Unregister()
|
|
||||||
{
|
|
||||||
// Check that we have registered
|
|
||||||
if (!this.registered)
|
|
||||||
{ throw new NotSupportedException("You cannot unregister a hotkey that is not registered"); }
|
|
||||||
|
|
||||||
// It's possible that the control itself has died: in that case, no need to unregister!
|
|
||||||
if (!this.windowControl.IsDisposed)
|
|
||||||
{
|
|
||||||
// Clean up after ourselves
|
|
||||||
if (Hotkey.UnregisterHotKey(this.windowControl.Handle, this.id) == 0)
|
|
||||||
{ throw new Win32Exception(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the control reference and register state
|
|
||||||
this.registered = false;
|
|
||||||
this.windowControl = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Reregister()
|
|
||||||
{
|
|
||||||
// Only do something if the key is already registered
|
|
||||||
if (!this.registered)
|
|
||||||
{ return; }
|
|
||||||
|
|
||||||
// Save control reference
|
|
||||||
Control windowControl = this.windowControl;
|
|
||||||
|
|
||||||
// Unregister and then reregister again
|
|
||||||
this.Unregister();
|
|
||||||
this.Register(windowControl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool PreFilterMessage(ref Message message)
|
|
||||||
{
|
|
||||||
// Only process WM_HOTKEY messages
|
|
||||||
if (message.Msg != Hotkey.WM_HOTKEY)
|
|
||||||
{ return false; }
|
|
||||||
|
|
||||||
// Check that the ID is our key and we are registerd
|
|
||||||
if (this.registered && (message.WParam.ToInt32() == this.id))
|
|
||||||
{
|
|
||||||
// Fire the event and pass on the event if our handlers didn't handle it
|
|
||||||
return this.OnPressed();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool OnPressed()
|
|
||||||
{
|
|
||||||
// Fire the event if we can
|
|
||||||
HandledEventArgs handledEventArgs = new HandledEventArgs(false);
|
|
||||||
if (this.Pressed != null)
|
|
||||||
{ this.Pressed(this, handledEventArgs); }
|
|
||||||
|
|
||||||
// Return whether we handled the event or not
|
|
||||||
return handledEventArgs.Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
// We can be empty
|
|
||||||
if (this.Empty)
|
|
||||||
{ return "(none)"; }
|
|
||||||
|
|
||||||
// Build key name
|
|
||||||
string keyName = Enum.GetName(typeof(Keys), this.keyCode);;
|
|
||||||
switch (this.keyCode)
|
|
||||||
{
|
|
||||||
case Keys.D0:
|
|
||||||
case Keys.D1:
|
|
||||||
case Keys.D2:
|
|
||||||
case Keys.D3:
|
|
||||||
case Keys.D4:
|
|
||||||
case Keys.D5:
|
|
||||||
case Keys.D6:
|
|
||||||
case Keys.D7:
|
|
||||||
case Keys.D8:
|
|
||||||
case Keys.D9:
|
|
||||||
// Strip the first character
|
|
||||||
keyName = keyName.Substring(1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Leave everything alone
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build modifiers
|
|
||||||
string modifiers = "";
|
|
||||||
if (this.shift)
|
|
||||||
{ modifiers += "Shift+"; }
|
|
||||||
if (this.control)
|
|
||||||
{ modifiers += "Control+"; }
|
|
||||||
if (this.alt)
|
|
||||||
{ modifiers += "Alt+"; }
|
|
||||||
if (this.windows)
|
|
||||||
{ modifiers += "Windows+"; }
|
|
||||||
|
|
||||||
// Return result
|
|
||||||
return modifiers + keyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Empty
|
|
||||||
{
|
|
||||||
get { return this.keyCode == Keys.None; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Registered
|
|
||||||
{
|
|
||||||
get { return this.registered; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Keys KeyCode
|
|
||||||
{
|
|
||||||
get { return this.keyCode; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Save and reregister
|
|
||||||
this.keyCode = value;
|
|
||||||
this.Reregister();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Shift
|
|
||||||
{
|
|
||||||
get { return this.shift; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Save and reregister
|
|
||||||
this.shift = value;
|
|
||||||
this.Reregister();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Control
|
|
||||||
{
|
|
||||||
get { return this.control; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Save and reregister
|
|
||||||
this.control = value;
|
|
||||||
this.Reregister();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Alt
|
|
||||||
{
|
|
||||||
get { return this.alt; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Save and reregister
|
|
||||||
this.alt = value;
|
|
||||||
this.Reregister();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Windows
|
|
||||||
{
|
|
||||||
get { return this.windows; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Save and reregister
|
|
||||||
this.windows = value;
|
|
||||||
this.Reregister();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
67
Preview.Designer.cs
generated
67
Preview.Designer.cs
generated
@@ -1,67 +0,0 @@
|
|||||||
namespace PreviewToy
|
|
||||||
{
|
|
||||||
partial class Preview
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.render_area = new System.Windows.Forms.PictureBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.render_area)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// render_area
|
|
||||||
//
|
|
||||||
this.render_area.BackColor = System.Drawing.Color.Transparent;
|
|
||||||
this.render_area.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
|
||||||
this.render_area.Cursor = System.Windows.Forms.Cursors.Hand;
|
|
||||||
this.render_area.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.render_area.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.render_area.Margin = new System.Windows.Forms.Padding(0);
|
|
||||||
this.render_area.Name = "render_area";
|
|
||||||
this.render_area.Size = new System.Drawing.Size(153, 89);
|
|
||||||
this.render_area.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
|
||||||
this.render_area.TabIndex = 0;
|
|
||||||
this.render_area.TabStop = false;
|
|
||||||
this.render_area.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click);
|
|
||||||
//
|
|
||||||
// Preview
|
|
||||||
//
|
|
||||||
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(153, 89);
|
|
||||||
this.ControlBox = false;
|
|
||||||
this.Controls.Add(this.render_area);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.MinimizeBox = false;
|
|
||||||
this.MinimumSize = new System.Drawing.Size(64, 64);
|
|
||||||
this.Name = "Preview";
|
|
||||||
this.Opacity = 0.1D;
|
|
||||||
this.ShowIcon = false;
|
|
||||||
this.ShowInTaskbar = false;
|
|
||||||
this.Text = "Preview";
|
|
||||||
this.TopMost = true;
|
|
||||||
this.Load += new System.EventHandler(this.Preview_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.render_area)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.PictureBox render_area;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
355
Preview.cs
355
Preview.cs
@@ -1,355 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using MovablePython;
|
|
||||||
|
|
||||||
namespace PreviewToy
|
|
||||||
{
|
|
||||||
public partial class Preview : Form
|
|
||||||
{
|
|
||||||
public bool show_overlay = true;
|
|
||||||
public bool hover_zoom = true;
|
|
||||||
public bool is_zoomed = false;
|
|
||||||
public bool is_hovered_over = false;
|
|
||||||
|
|
||||||
private bool mouse_over_lock = false;
|
|
||||||
private Size old_size;
|
|
||||||
private Point old_position;
|
|
||||||
|
|
||||||
private IntPtr m_hThumbnail;
|
|
||||||
public IntPtr sourceWindow;
|
|
||||||
private DwmApi.DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties;
|
|
||||||
private bool has_been_set_up = false;
|
|
||||||
private bool thumbnail_has_been_set_up = false;
|
|
||||||
private PreviewToyHandler spawner;
|
|
||||||
private Hotkey hotkey;
|
|
||||||
|
|
||||||
private bool hide = false;
|
|
||||||
|
|
||||||
public PreviewOverlay overlay;
|
|
||||||
|
|
||||||
public void MakeHidden(bool wha)
|
|
||||||
{
|
|
||||||
hide = wha;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return this.Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void MakeTopMost(bool topmost)
|
|
||||||
{
|
|
||||||
this.TopMost = topmost && !(this.hide);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Preview(IntPtr sourceWindow, String title, PreviewToyHandler spawner, Size size)
|
|
||||||
{
|
|
||||||
has_been_set_up = false;
|
|
||||||
|
|
||||||
this.sourceWindow = sourceWindow;
|
|
||||||
this.spawner = spawner;
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
this.Text = title;
|
|
||||||
|
|
||||||
this.overlay = new PreviewOverlay(this);
|
|
||||||
|
|
||||||
this.render_area.MouseHover += new System.EventHandler(this.preview_MouseHover);
|
|
||||||
this.render_area.MouseLeave += new System.EventHandler(this.preview_MouseLeave);
|
|
||||||
|
|
||||||
this.old_size = this.Size;
|
|
||||||
this.old_position = this.Location;
|
|
||||||
|
|
||||||
has_been_set_up = true;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void preview_MouseHover(object sender, System.EventArgs e)
|
|
||||||
{
|
|
||||||
if (!mouse_over_lock)
|
|
||||||
{
|
|
||||||
mouse_over_lock = true;
|
|
||||||
if (hover_zoom)
|
|
||||||
doZoom();
|
|
||||||
|
|
||||||
TopMost = true;
|
|
||||||
overlay.TopMost = true;
|
|
||||||
}
|
|
||||||
this.Opacity = 1.0f;
|
|
||||||
this.is_hovered_over = true;
|
|
||||||
RefreshPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override CreateParams CreateParams
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var Params = base.CreateParams;
|
|
||||||
Params.ExStyle |= 0x80;
|
|
||||||
return Params;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerShortcut(string shortcut)
|
|
||||||
{
|
|
||||||
if (shortcut == "")
|
|
||||||
return;
|
|
||||||
var cvt = new KeysConverter();
|
|
||||||
var key = (Keys)cvt.ConvertFrom(shortcut);
|
|
||||||
|
|
||||||
Hotkey hotkey = new Hotkey();
|
|
||||||
|
|
||||||
if ((key & Keys.Shift) == Keys.Shift)
|
|
||||||
{
|
|
||||||
hotkey.Shift = true;
|
|
||||||
}
|
|
||||||
if ((key & Keys.Alt) == Keys.Alt)
|
|
||||||
{
|
|
||||||
hotkey.Alt = true;
|
|
||||||
}
|
|
||||||
if ((key & Keys.Control) == Keys.Control)
|
|
||||||
{
|
|
||||||
hotkey.Control = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control;
|
|
||||||
hotkey.KeyCode = key;
|
|
||||||
hotkey.Register(this);
|
|
||||||
hotkey.Pressed += delegate { bring_client_to_foreground(); spawner.preview_did_switch(); };
|
|
||||||
|
|
||||||
this.hotkey = hotkey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doZoom()
|
|
||||||
{
|
|
||||||
if (is_zoomed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
is_zoomed = true;
|
|
||||||
|
|
||||||
float hover_zoom_factor = Properties.Settings.Default.zoom_amount;
|
|
||||||
|
|
||||||
old_size = Size;
|
|
||||||
old_position = Location;
|
|
||||||
|
|
||||||
Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height));
|
|
||||||
|
|
||||||
switch ((PreviewToyHandler.zoom_anchor_t)Properties.Settings.Default.zoom_anchor)
|
|
||||||
{
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.NW):
|
|
||||||
break;
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.N):
|
|
||||||
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y);
|
|
||||||
break;
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.NE):
|
|
||||||
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.W):
|
|
||||||
Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2);
|
|
||||||
break;
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.C):
|
|
||||||
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2);
|
|
||||||
break;
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.E):
|
|
||||||
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.SW):
|
|
||||||
Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height);
|
|
||||||
break;
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.S):
|
|
||||||
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height);
|
|
||||||
break;
|
|
||||||
case (PreviewToyHandler.zoom_anchor_t.SE):
|
|
||||||
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restoreZoom()
|
|
||||||
{
|
|
||||||
if (!is_zoomed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Size = old_size;
|
|
||||||
Location = old_position;
|
|
||||||
is_zoomed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void preview_MouseLeave(object sender, System.EventArgs e)
|
|
||||||
{
|
|
||||||
if (mouse_over_lock)
|
|
||||||
{
|
|
||||||
if (hover_zoom)
|
|
||||||
{
|
|
||||||
restoreZoom();
|
|
||||||
}
|
|
||||||
mouse_over_lock = false;
|
|
||||||
}
|
|
||||||
this.is_hovered_over = false;
|
|
||||||
this.Opacity = Properties.Settings.Default.opacity;
|
|
||||||
RefreshPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnResize(EventArgs e)
|
|
||||||
{
|
|
||||||
RefreshPreview();
|
|
||||||
base.OnResize(e);
|
|
||||||
if (has_been_set_up && !mouse_over_lock)
|
|
||||||
this.spawner.syncronize_preview_size(this.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnMove(EventArgs e)
|
|
||||||
{
|
|
||||||
base.OnMove(e);
|
|
||||||
if (has_been_set_up && !mouse_over_lock)
|
|
||||||
this.spawner.register_preview_position(this.Text, this.Location);
|
|
||||||
|
|
||||||
RefreshPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doMove(Point position)
|
|
||||||
{
|
|
||||||
if (has_been_set_up && !mouse_over_lock)
|
|
||||||
Location = position;
|
|
||||||
|
|
||||||
RefreshPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetLabel(String label)
|
|
||||||
{
|
|
||||||
this.Text = label;
|
|
||||||
this.overlay.client_label.Text = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RefreshPreview()
|
|
||||||
{
|
|
||||||
if (has_been_set_up)
|
|
||||||
{
|
|
||||||
if (DwmApi.DwmIsCompositionEnabled())
|
|
||||||
{
|
|
||||||
if (thumbnail_has_been_set_up == false)
|
|
||||||
{
|
|
||||||
this.SetUpThumbnail();
|
|
||||||
}
|
|
||||||
m_ThumbnailProperties.rcDestination = new DwmApi.RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
|
||||||
DwmApi.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
thumbnail_has_been_set_up = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Size overlay_size = this.render_area.Size;
|
|
||||||
overlay_size.Width -= 2 * 5;
|
|
||||||
overlay_size.Height -= 2 * 5;
|
|
||||||
|
|
||||||
Point overlay_location = this.Location;
|
|
||||||
overlay_location.X += 5 + (this.Size.Width - this.render_area.Size.Width) / 2;
|
|
||||||
overlay_location.Y += 5 + (this.Size.Height - this.render_area.Size.Height) - (this.Size.Width - this.render_area.Size.Width) / 2;
|
|
||||||
|
|
||||||
this.overlay.Size = overlay_size;
|
|
||||||
this.overlay.Location = overlay_location;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new public void Show()
|
|
||||||
{
|
|
||||||
if (!hide)
|
|
||||||
{
|
|
||||||
base.Show();
|
|
||||||
if (show_overlay)
|
|
||||||
this.overlay.Show();
|
|
||||||
else
|
|
||||||
this.overlay.Hide();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.Hide();
|
|
||||||
this.overlay.Hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new public void Hide()
|
|
||||||
{
|
|
||||||
base.Hide();
|
|
||||||
this.overlay.Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetUpThumbnail()
|
|
||||||
{
|
|
||||||
if (DwmApi.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up)
|
|
||||||
{
|
|
||||||
m_hThumbnail = DwmApi.DwmRegisterThumbnail(this.Handle, sourceWindow);
|
|
||||||
|
|
||||||
m_ThumbnailProperties = new DwmApi.DWM_THUMBNAIL_PROPERTIES();
|
|
||||||
m_ThumbnailProperties.dwFlags = DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE
|
|
||||||
+ DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY
|
|
||||||
+ DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION
|
|
||||||
+ DwmApi.DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY;
|
|
||||||
m_ThumbnailProperties.opacity = 255;
|
|
||||||
m_ThumbnailProperties.fVisible = true;
|
|
||||||
m_ThumbnailProperties.fSourceClientAreaOnly = true;
|
|
||||||
m_ThumbnailProperties.rcDestination = new DwmApi.RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
|
|
||||||
|
|
||||||
DwmApi.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
|
|
||||||
|
|
||||||
thumbnail_has_been_set_up = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Preview_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void bring_client_to_foreground()
|
|
||||||
{
|
|
||||||
DwmApi.SetForegroundWindow(sourceWindow);
|
|
||||||
int style = DwmApi.GetWindowLong(sourceWindow, DwmApi.GWL_STYLE);
|
|
||||||
if ((style & DwmApi.WS_MAXIMIZE) == DwmApi.WS_MAXIMIZE)
|
|
||||||
{
|
|
||||||
//It's maximized
|
|
||||||
}
|
|
||||||
else if ((style & DwmApi.WS_MINIMIZE) == DwmApi.WS_MINIMIZE)
|
|
||||||
{
|
|
||||||
DwmApi.ShowWindowAsync(sourceWindow, DwmApi.SW_SHOWNORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render_area_Click(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Button == MouseButtons.Left)
|
|
||||||
{
|
|
||||||
bring_client_to_foreground();
|
|
||||||
spawner.preview_did_switch();
|
|
||||||
}
|
|
||||||
if (e.Button == MouseButtons.Right)
|
|
||||||
{
|
|
||||||
// do smth cool?
|
|
||||||
}
|
|
||||||
if (e.Button == MouseButtons.Middle)
|
|
||||||
{
|
|
||||||
// do smth cool?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set_render_area_size(Size size)
|
|
||||||
{
|
|
||||||
this.Size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,948 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing.Text;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace PreviewToy
|
|
||||||
{
|
|
||||||
|
|
||||||
public partial class PreviewToyHandler : Form
|
|
||||||
{
|
|
||||||
private const int WM_SIZE = 5;
|
|
||||||
private const int SIZE_RESTORED = 0;
|
|
||||||
private const int SIZE_MINIMIZED = 1;
|
|
||||||
private const int SIZE_MAXIMIZED = 2;
|
|
||||||
private const int SIZE_MAXSHOW = 3;
|
|
||||||
private const int SIZE_MAXHIDE = 4;
|
|
||||||
|
|
||||||
public event EventHandler Minimized;
|
|
||||||
public event EventHandler Maximized;
|
|
||||||
public event EventHandler Restored;
|
|
||||||
|
|
||||||
|
|
||||||
private Dictionary<IntPtr, Preview> previews;
|
|
||||||
private DispatcherTimer dispatcherTimer;
|
|
||||||
|
|
||||||
private IntPtr active_client_handle = (IntPtr)0;
|
|
||||||
private String active_client_title = "";
|
|
||||||
|
|
||||||
private Dictionary<String, Dictionary<String, Point>> unique_layouts;
|
|
||||||
private Dictionary<String, Point> flat_layout;
|
|
||||||
private Dictionary<String, String> flat_layout_shortcuts;
|
|
||||||
private Dictionary<String, ClientLocation> client_layout;
|
|
||||||
|
|
||||||
private bool is_initialized;
|
|
||||||
|
|
||||||
private Stopwatch ignoring_size_sync;
|
|
||||||
|
|
||||||
Dictionary<string, string> xml_bad_to_ok_chars;
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
private static extern int GetWindowRect(IntPtr hwnd, out Rect rect);
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
|
||||||
|
|
||||||
private struct Rect
|
|
||||||
{
|
|
||||||
public int Left;
|
|
||||||
public int Top;
|
|
||||||
public int Right;
|
|
||||||
public int Bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct ClientLocation
|
|
||||||
{
|
|
||||||
public int X;
|
|
||||||
public int Y;
|
|
||||||
public int Width;
|
|
||||||
public int Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum zoom_anchor_t
|
|
||||||
{
|
|
||||||
NW = 0,
|
|
||||||
N,
|
|
||||||
NE,
|
|
||||||
W,
|
|
||||||
C,
|
|
||||||
E,
|
|
||||||
SW,
|
|
||||||
S,
|
|
||||||
SE
|
|
||||||
};
|
|
||||||
|
|
||||||
private Dictionary<zoom_anchor_t, RadioButton> zoom_anchor_button_map;
|
|
||||||
|
|
||||||
public PreviewToyHandler()
|
|
||||||
{
|
|
||||||
is_initialized = false;
|
|
||||||
|
|
||||||
previews = new Dictionary<IntPtr, Preview>();
|
|
||||||
|
|
||||||
xml_bad_to_ok_chars = new Dictionary<string, string>();
|
|
||||||
xml_bad_to_ok_chars["<"] = "---lt---";
|
|
||||||
xml_bad_to_ok_chars["&"] = "---amp---";
|
|
||||||
xml_bad_to_ok_chars[">"] = "---gt---";
|
|
||||||
xml_bad_to_ok_chars["\""] = "---quot---";
|
|
||||||
xml_bad_to_ok_chars["\'"] = "---apos---";
|
|
||||||
xml_bad_to_ok_chars[","] = "---comma---";
|
|
||||||
xml_bad_to_ok_chars["."] = "---dot---";
|
|
||||||
|
|
||||||
unique_layouts = new Dictionary<String, Dictionary<String, Point>>();
|
|
||||||
flat_layout = new Dictionary<String, Point>();
|
|
||||||
flat_layout_shortcuts = new Dictionary<String, String>();
|
|
||||||
client_layout = new Dictionary<String, ClientLocation>();
|
|
||||||
|
|
||||||
ignoring_size_sync = new Stopwatch();
|
|
||||||
ignoring_size_sync.Start();
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
init_options();
|
|
||||||
|
|
||||||
// DispatcherTimer setup
|
|
||||||
dispatcherTimer = new DispatcherTimer();
|
|
||||||
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
|
|
||||||
dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
|
|
||||||
dispatcherTimer.Start();
|
|
||||||
|
|
||||||
is_initialized = true;
|
|
||||||
|
|
||||||
previews_check_listbox.DisplayMember = "Text";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void GlassForm_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init_options()
|
|
||||||
{
|
|
||||||
this.Minimized += new EventHandler(MainForm_Minimized);
|
|
||||||
|
|
||||||
option_zoom_on_hover.Checked = Properties.Settings.Default.zoom_on_hover;
|
|
||||||
zoom_anchor_button_map = new Dictionary<zoom_anchor_t, RadioButton>();
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.NW] = option_zoom_anchor_NW;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.N] = option_zoom_anchor_N;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.NE] = option_zoom_anchor_NE;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.W] = option_zoom_anchor_W;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.C] = option_zoom_anchor_C;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.E] = option_zoom_anchor_E;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.SW] = option_zoom_anchor_SW;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.S] = option_zoom_anchor_S;
|
|
||||||
zoom_anchor_button_map[zoom_anchor_t.SE] = option_zoom_anchor_SE;
|
|
||||||
zoom_anchor_button_map[(zoom_anchor_t)Properties.Settings.Default.zoom_anchor].Checked = true;
|
|
||||||
option_zoom_factor.Text = Properties.Settings.Default.zoom_amount.ToString();
|
|
||||||
|
|
||||||
option_always_on_top.Checked = Properties.Settings.Default.always_on_top;
|
|
||||||
option_hide_active.Checked = Properties.Settings.Default.hide_active;
|
|
||||||
option_hide_all_if_not_right_type.Checked = Properties.Settings.Default.hide_all;
|
|
||||||
|
|
||||||
option_unique_layout.Checked = Properties.Settings.Default.unique_layout;
|
|
||||||
|
|
||||||
option_sync_size.Checked = Properties.Settings.Default.sync_resize;
|
|
||||||
option_sync_size_x.Text = Properties.Settings.Default.sync_resize_x.ToString();
|
|
||||||
option_sync_size_y.Text = Properties.Settings.Default.sync_resize_y.ToString();
|
|
||||||
|
|
||||||
option_show_thumbnail_frames.Checked = Properties.Settings.Default.show_thumb_frames;
|
|
||||||
|
|
||||||
option_show_overlay.Checked = Properties.Settings.Default.show_overlay;
|
|
||||||
|
|
||||||
option_track_client_windows.Checked = Properties.Settings.Default.track_client_windows;
|
|
||||||
|
|
||||||
option_minToTray.Checked = Properties.Settings.Default.minimizeToTray;
|
|
||||||
|
|
||||||
// disable/enable zoom suboptions
|
|
||||||
option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover;
|
|
||||||
foreach (var kv in zoom_anchor_button_map)
|
|
||||||
{
|
|
||||||
kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover;
|
|
||||||
}
|
|
||||||
|
|
||||||
opacity_bar.Value = Math.Min(100, (int)(100.0 * Properties.Settings.Default.opacity));
|
|
||||||
|
|
||||||
load_layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void spawn_and_kill_previews()
|
|
||||||
{
|
|
||||||
if (!is_initialized) { return; }
|
|
||||||
|
|
||||||
Process[] processes = Process.GetProcessesByName("ExeFile");
|
|
||||||
List<IntPtr> processHandles = new List<IntPtr>();
|
|
||||||
|
|
||||||
// pop new previews
|
|
||||||
|
|
||||||
foreach (Process process in processes)
|
|
||||||
{
|
|
||||||
processHandles.Add(process.MainWindowHandle);
|
|
||||||
|
|
||||||
Size sync_size = new Size();
|
|
||||||
sync_size.Width = (int)Properties.Settings.Default.sync_resize_x;
|
|
||||||
sync_size.Height = (int)Properties.Settings.Default.sync_resize_y;
|
|
||||||
|
|
||||||
if (!previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != "")
|
|
||||||
{
|
|
||||||
previews[process.MainWindowHandle] = new Preview(process.MainWindowHandle, "...", this, sync_size);
|
|
||||||
previews[process.MainWindowHandle].set_render_area_size(sync_size);
|
|
||||||
|
|
||||||
// apply more thumbnail specific options
|
|
||||||
previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top);
|
|
||||||
set_thumbnail_frame_style(previews[process.MainWindowHandle], Properties.Settings.Default.show_thumb_frames);
|
|
||||||
|
|
||||||
// add a preview also
|
|
||||||
previews_check_listbox.BeginUpdate();
|
|
||||||
previews_check_listbox.Items.Add(previews[process.MainWindowHandle]);
|
|
||||||
previews_check_listbox.EndUpdate();
|
|
||||||
|
|
||||||
refresh_client_window_locations(process);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (previews.ContainsKey(process.MainWindowHandle) && process.MainWindowTitle != previews[process.MainWindowHandle].Text) //or update the preview titles
|
|
||||||
{
|
|
||||||
previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle);
|
|
||||||
string key = previews[process.MainWindowHandle].Text;
|
|
||||||
string value;
|
|
||||||
if (flat_layout_shortcuts.TryGetValue(key, out value))
|
|
||||||
{
|
|
||||||
previews[process.MainWindowHandle].registerShortcut(value);
|
|
||||||
}
|
|
||||||
refresh_client_window_locations(process);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.MainWindowHandle == DwmApi.GetForegroundWindow())
|
|
||||||
{
|
|
||||||
active_client_handle = process.MainWindowHandle;
|
|
||||||
active_client_title = process.MainWindowTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean up old previews
|
|
||||||
List<IntPtr> to_be_pruned = new List<IntPtr>();
|
|
||||||
foreach (IntPtr processHandle in previews.Keys)
|
|
||||||
{
|
|
||||||
if (!(processHandles.Contains(processHandle)))
|
|
||||||
{
|
|
||||||
to_be_pruned.Add(processHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (IntPtr processHandle in to_be_pruned)
|
|
||||||
{
|
|
||||||
previews_check_listbox.BeginUpdate();
|
|
||||||
previews_check_listbox.Items.Remove(previews[processHandle]);
|
|
||||||
previews_check_listbox.EndUpdate();
|
|
||||||
|
|
||||||
previews[processHandle].overlay.Close();
|
|
||||||
previews[processHandle].Close();
|
|
||||||
previews.Remove(processHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
previews_check_listbox.Update();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refresh_client_window_locations(Process process)
|
|
||||||
{
|
|
||||||
if (Properties.Settings.Default.track_client_windows && client_layout.ContainsKey(process.MainWindowTitle))
|
|
||||||
{
|
|
||||||
MoveWindow(
|
|
||||||
process.MainWindowHandle,
|
|
||||||
client_layout[process.MainWindowTitle].X,
|
|
||||||
client_layout[process.MainWindowTitle].Y,
|
|
||||||
client_layout[process.MainWindowTitle].Width,
|
|
||||||
client_layout[process.MainWindowTitle].Height,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private string remove_nonconform_xml_characters(string entry)
|
|
||||||
{
|
|
||||||
foreach (var kv in xml_bad_to_ok_chars)
|
|
||||||
{
|
|
||||||
entry = entry.Replace(kv.Key, kv.Value);
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string restore_nonconform_xml_characters(string entry)
|
|
||||||
{
|
|
||||||
foreach (var kv in xml_bad_to_ok_chars)
|
|
||||||
{
|
|
||||||
entry = entry.Replace(kv.Value, kv.Key);
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
private XElement MakeXElement(string input)
|
|
||||||
{
|
|
||||||
string clean = remove_nonconform_xml_characters(input).Replace(" ", "_");
|
|
||||||
return new XElement(clean);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ParseXElement(XElement input)
|
|
||||||
{
|
|
||||||
return restore_nonconform_xml_characters(input.Name.ToString()).Replace("_", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void load_layout()
|
|
||||||
{
|
|
||||||
if (File.Exists("layout.xml"))
|
|
||||||
{
|
|
||||||
XElement rootElement = XElement.Load("layout.xml");
|
|
||||||
foreach (var el in rootElement.Elements())
|
|
||||||
{
|
|
||||||
Dictionary<String, Point> inner = new Dictionary<String, Point>();
|
|
||||||
foreach (var inner_el in el.Elements())
|
|
||||||
{
|
|
||||||
inner[ParseXElement(inner_el)] = new Point(Convert.ToInt32(inner_el.Element("x").Value), Convert.ToInt32(inner_el.Element("y").Value));
|
|
||||||
}
|
|
||||||
unique_layouts[ParseXElement(el)] = inner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists("flat_layout.xml"))
|
|
||||||
{
|
|
||||||
XElement rootElement = XElement.Load("flat_layout.xml");
|
|
||||||
foreach (var el in rootElement.Elements())
|
|
||||||
{
|
|
||||||
flat_layout[ParseXElement(el)] = new Point(Convert.ToInt32(el.Element("x").Value), Convert.ToInt32(el.Element("y").Value));
|
|
||||||
flat_layout_shortcuts[ParseXElement(el)] = "";
|
|
||||||
|
|
||||||
if (el.Element("shortcut") != null)
|
|
||||||
{
|
|
||||||
flat_layout_shortcuts[ParseXElement(el)] = el.Element("shortcut").Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists("client_layout.xml"))
|
|
||||||
{
|
|
||||||
XElement rootElement = XElement.Load("client_layout.xml");
|
|
||||||
foreach (var el in rootElement.Elements())
|
|
||||||
{
|
|
||||||
ClientLocation clientLocation = new ClientLocation();
|
|
||||||
clientLocation.X = Convert.ToInt32(el.Element("x").Value);
|
|
||||||
clientLocation.Y = Convert.ToInt32(el.Element("y").Value);
|
|
||||||
clientLocation.Width = Convert.ToInt32(el.Element("width").Value);
|
|
||||||
clientLocation.Height = Convert.ToInt32(el.Element("height").Value);
|
|
||||||
|
|
||||||
client_layout[ParseXElement(el)] = clientLocation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void store_layout()
|
|
||||||
{
|
|
||||||
XElement el = new XElement("layouts");
|
|
||||||
foreach (var client in unique_layouts.Keys)
|
|
||||||
{
|
|
||||||
if (client == "")
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
XElement layout = MakeXElement(client);
|
|
||||||
foreach (var thumbnail_ in unique_layouts[client])
|
|
||||||
{
|
|
||||||
String thumbnail = thumbnail_.Key;
|
|
||||||
if (thumbnail == "" || thumbnail == "...")
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
XElement position = MakeXElement(thumbnail);
|
|
||||||
position.Add(new XElement("x", thumbnail_.Value.X));
|
|
||||||
position.Add(new XElement("y", thumbnail_.Value.Y));
|
|
||||||
layout.Add(position);
|
|
||||||
}
|
|
||||||
el.Add(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
el.Save("layout.xml");
|
|
||||||
|
|
||||||
XElement el2 = new XElement("flat_layout");
|
|
||||||
foreach (var clientKV in flat_layout)
|
|
||||||
{
|
|
||||||
if (clientKV.Key == "" || clientKV.Key == "...")
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
XElement layout = MakeXElement(clientKV.Key);
|
|
||||||
layout.Add(new XElement("x", clientKV.Value.X));
|
|
||||||
layout.Add(new XElement("y", clientKV.Value.Y));
|
|
||||||
|
|
||||||
string shortcut;
|
|
||||||
if (flat_layout_shortcuts.TryGetValue(clientKV.Key, out shortcut))
|
|
||||||
{
|
|
||||||
layout.Add(new XElement("shortcut", shortcut));
|
|
||||||
}
|
|
||||||
el2.Add(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
el2.Save("flat_layout.xml");
|
|
||||||
|
|
||||||
XElement el3 = new XElement("client_layout");
|
|
||||||
foreach (var clientKV in client_layout)
|
|
||||||
{
|
|
||||||
if (clientKV.Key == "" || clientKV.Key == "...")
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
XElement layout = MakeXElement(clientKV.Key);
|
|
||||||
layout.Add(new XElement("x", clientKV.Value.X));
|
|
||||||
layout.Add(new XElement("y", clientKV.Value.Y));
|
|
||||||
layout.Add(new XElement("width", clientKV.Value.Width));
|
|
||||||
layout.Add(new XElement("height", clientKV.Value.Height));
|
|
||||||
el3.Add(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
el3.Save("client_layout.xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handle_unique_layout(Preview preview, String last_known_active_window)
|
|
||||||
{
|
|
||||||
Dictionary<String, Point> layout;
|
|
||||||
if (unique_layouts.TryGetValue(last_known_active_window, out layout))
|
|
||||||
{
|
|
||||||
Point new_loc;
|
|
||||||
if (Properties.Settings.Default.unique_layout && layout.TryGetValue(preview.Text, out new_loc))
|
|
||||||
{
|
|
||||||
preview.doMove(new_loc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// create inner dict
|
|
||||||
layout[preview.Text] = preview.Location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (last_known_active_window != "")
|
|
||||||
{
|
|
||||||
// create outer dict
|
|
||||||
unique_layouts[last_known_active_window] = new Dictionary<String, Point>();
|
|
||||||
unique_layouts[last_known_active_window][preview.Text] = preview.Location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void update_client_locations()
|
|
||||||
{
|
|
||||||
Process[] processes = Process.GetProcessesByName("ExeFile");
|
|
||||||
List<IntPtr> processHandles = new List<IntPtr>();
|
|
||||||
|
|
||||||
foreach (Process process in processes)
|
|
||||||
{
|
|
||||||
Rect rect = new Rect();
|
|
||||||
GetWindowRect(process.MainWindowHandle, out rect);
|
|
||||||
|
|
||||||
int left = Math.Abs(rect.Left);
|
|
||||||
int right = Math.Abs(rect.Right);
|
|
||||||
int client_width = Math.Abs(left - right);
|
|
||||||
|
|
||||||
int top = Math.Abs(rect.Top);
|
|
||||||
int bottom = Math.Abs(rect.Bottom);
|
|
||||||
int client_height = Math.Abs(top - bottom);
|
|
||||||
|
|
||||||
ClientLocation clientLocation = new ClientLocation();
|
|
||||||
clientLocation.X = rect.Left;
|
|
||||||
clientLocation.Y = rect.Top;
|
|
||||||
clientLocation.Width = client_width;
|
|
||||||
clientLocation.Height = client_height;
|
|
||||||
|
|
||||||
|
|
||||||
client_layout[process.MainWindowTitle] = clientLocation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void preview_did_switch()
|
|
||||||
{
|
|
||||||
update_client_locations();
|
|
||||||
store_layout(); //todo: check if it actually changed ...
|
|
||||||
foreach (KeyValuePair<IntPtr, Preview> entry in previews)
|
|
||||||
{
|
|
||||||
entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top);
|
|
||||||
//makes the PreviewOverlay topmost
|
|
||||||
entry.Value.overlay.makeTopMost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void handle_flat_layout(Preview preview)
|
|
||||||
{
|
|
||||||
Point layout;
|
|
||||||
if (flat_layout.TryGetValue(preview.Text, out layout))
|
|
||||||
{
|
|
||||||
preview.doMove(layout);
|
|
||||||
}
|
|
||||||
else if (preview.Text != "")
|
|
||||||
{
|
|
||||||
flat_layout[preview.Text] = preview.Location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool window_is_preview_or_client(IntPtr window)
|
|
||||||
{
|
|
||||||
bool active_window_is_right_type = false;
|
|
||||||
foreach (KeyValuePair<IntPtr, Preview> entry in previews)
|
|
||||||
{
|
|
||||||
if (entry.Key == window || entry.Value.Handle == window || this.Handle == window || entry.Value.overlay.Handle == window)
|
|
||||||
{
|
|
||||||
active_window_is_right_type = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return active_window_is_right_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void refresh_thumbnails()
|
|
||||||
{
|
|
||||||
|
|
||||||
IntPtr active_window = DwmApi.GetForegroundWindow();
|
|
||||||
|
|
||||||
// hide, show, resize and move
|
|
||||||
foreach (KeyValuePair<IntPtr, Preview> entry in previews)
|
|
||||||
{
|
|
||||||
if (!window_is_preview_or_client(active_window) && Properties.Settings.Default.hide_all)
|
|
||||||
{
|
|
||||||
entry.Value.Hide();
|
|
||||||
}
|
|
||||||
else if (entry.Key == active_client_handle && Properties.Settings.Default.hide_active)
|
|
||||||
{
|
|
||||||
entry.Value.Hide();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entry.Value.Show();
|
|
||||||
if (Properties.Settings.Default.unique_layout)
|
|
||||||
{
|
|
||||||
handle_unique_layout(entry.Value, active_client_title);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handle_flat_layout(entry.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
entry.Value.hover_zoom = Properties.Settings.Default.zoom_on_hover;
|
|
||||||
entry.Value.show_overlay = Properties.Settings.Default.show_overlay;
|
|
||||||
//makes the PreviewOverlay TopMost
|
|
||||||
entry.Value.overlay.makeTopMost();
|
|
||||||
if (!entry.Value.is_hovered_over)
|
|
||||||
{
|
|
||||||
entry.Value.Opacity = Properties.Settings.Default.opacity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DwmApi.DwmIsCompositionEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void syncronize_preview_size(Size sync_size)
|
|
||||||
{
|
|
||||||
if (!is_initialized) { return; }
|
|
||||||
|
|
||||||
if (Properties.Settings.Default.sync_resize &&
|
|
||||||
Properties.Settings.Default.show_thumb_frames &&
|
|
||||||
ignoring_size_sync.ElapsedMilliseconds > 500)
|
|
||||||
{
|
|
||||||
ignoring_size_sync.Stop();
|
|
||||||
|
|
||||||
option_sync_size_x.Text = sync_size.Width.ToString();
|
|
||||||
option_sync_size_y.Text = sync_size.Height.ToString();
|
|
||||||
|
|
||||||
foreach (KeyValuePair<IntPtr, Preview> entry in previews)
|
|
||||||
{
|
|
||||||
if (entry.Value.Handle != DwmApi.GetForegroundWindow())
|
|
||||||
{
|
|
||||||
entry.Value.set_render_area_size(sync_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void register_preview_position(String preview_title, Point position)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Properties.Settings.Default.unique_layout)
|
|
||||||
{
|
|
||||||
Dictionary<String, Point> layout;
|
|
||||||
if (unique_layouts.TryGetValue(active_client_title, out layout))
|
|
||||||
{
|
|
||||||
layout[preview_title] = position;
|
|
||||||
}
|
|
||||||
else if (active_client_title == "")
|
|
||||||
{
|
|
||||||
unique_layouts[active_client_title] = new Dictionary<String, Point>();
|
|
||||||
unique_layouts[active_client_title][preview_title] = position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
flat_layout[preview_title] = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void dispatcherTimer_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
spawn_and_kill_previews();
|
|
||||||
refresh_thumbnails();
|
|
||||||
if (ignoring_size_sync.ElapsedMilliseconds > 500) { ignoring_size_sync.Stop(); };
|
|
||||||
|
|
||||||
if (DwmApi.DwmIsCompositionEnabled())
|
|
||||||
{
|
|
||||||
aero_status_label.Text = "AERO is ON";
|
|
||||||
aero_status_label.ForeColor = Color.Black;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aero_status_label.Text = "AERO is OFF";
|
|
||||||
aero_status_label.ForeColor = Color.Red;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_hide_all_if_noneve_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.hide_all = option_hide_all_if_not_right_type.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_unique_layout_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.unique_layout = option_unique_layout.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_hide_active_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.hide_active = option_hide_active.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_sync_size_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.sync_resize = option_sync_size.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void parse_size_entry()
|
|
||||||
{
|
|
||||||
UInt32 x = 0, y = 0;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
y = Convert.ToUInt32(option_sync_size_y.Text);
|
|
||||||
x = Convert.ToUInt32(option_sync_size_x.Text);
|
|
||||||
}
|
|
||||||
catch (System.FormatException)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x < 64 || y < 64)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Properties.Settings.Default.sync_resize_y = y;
|
|
||||||
Properties.Settings.Default.sync_resize_x = x;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
|
|
||||||
// resize
|
|
||||||
syncronize_preview_size(new Size((int)Properties.Settings.Default.sync_resize_x,
|
|
||||||
(int)Properties.Settings.Default.sync_resize_y));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_sync_size_x_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
parse_size_entry();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_sync_size_y_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
parse_size_entry();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void option_always_on_top_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.always_on_top = option_always_on_top.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void set_thumbnail_frame_style(Preview preview, bool show_frames)
|
|
||||||
{
|
|
||||||
if (show_frames)
|
|
||||||
{
|
|
||||||
preview.FormBorderStyle = FormBorderStyle.SizableToolWindow;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
preview.FormBorderStyle = FormBorderStyle.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void option_show_thumbnail_frames_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.show_thumb_frames = option_show_thumbnail_frames.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
|
|
||||||
if (Properties.Settings.Default.show_thumb_frames)
|
|
||||||
{
|
|
||||||
ignoring_size_sync.Stop();
|
|
||||||
ignoring_size_sync.Reset();
|
|
||||||
ignoring_size_sync.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var thumbnail in previews)
|
|
||||||
{
|
|
||||||
set_thumbnail_frame_style(thumbnail.Value, Properties.Settings.Default.show_thumb_frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void list_running_clients_SelectedIndexChanged(object sender, EventArgs e) { }
|
|
||||||
|
|
||||||
|
|
||||||
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
||||||
{
|
|
||||||
string url = "https://bitbucket.org/ulph/eve-o-preview-git";
|
|
||||||
ProcessStartInfo sInfo = new ProcessStartInfo(new Uri(url).AbsoluteUri);
|
|
||||||
Process.Start(sInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void previewToyMainBindingSource_CurrentChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void option_zoom_on_hover_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.zoom_on_hover = option_zoom_on_hover.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover;
|
|
||||||
if (is_initialized)
|
|
||||||
{
|
|
||||||
foreach (var kv in zoom_anchor_button_map)
|
|
||||||
{
|
|
||||||
kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void option_show_overlay_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.show_overlay = option_show_overlay.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void handle_zoom_anchor_setting()
|
|
||||||
{
|
|
||||||
foreach (var kv in zoom_anchor_button_map)
|
|
||||||
{
|
|
||||||
if (kv.Value.Checked == true)
|
|
||||||
Properties.Settings.Default.zoom_anchor = (byte)kv.Key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void option_zoom_anchor_X_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
handle_zoom_anchor_setting();
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void option_zoom_factor_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
float tmp = (float)Convert.ToDouble(option_zoom_factor.Text);
|
|
||||||
if (tmp < 1)
|
|
||||||
{
|
|
||||||
tmp = 1;
|
|
||||||
}
|
|
||||||
else if (tmp > 10)
|
|
||||||
{
|
|
||||||
tmp = 10;
|
|
||||||
}
|
|
||||||
Properties.Settings.Default.zoom_amount = tmp;
|
|
||||||
option_zoom_factor.Text = tmp.ToString();
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// do naught
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkedListBox1_SelectedIndexChanged2(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
System.Windows.Forms.ItemCheckEventArgs arg = (System.Windows.Forms.ItemCheckEventArgs)e;
|
|
||||||
((Preview)this.previews_check_listbox.Items[arg.Index]).MakeHidden(arg.NewValue == System.Windows.Forms.CheckState.Checked);
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.track_client_windows = option_track_client_windows.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void opacity_bar_Scroll(object sender, ScrollEventArgs e)
|
|
||||||
{
|
|
||||||
// fire off opacity change
|
|
||||||
Properties.Settings.Default.opacity = Math.Min((float)e.NewValue / 100.0f, 1.0f);
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
refresh_thumbnails();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void OnMinimized(EventArgs e)
|
|
||||||
{
|
|
||||||
if (Minimized != null && Properties.Settings.Default.minimizeToTray)
|
|
||||||
{
|
|
||||||
this.Hide();
|
|
||||||
}
|
|
||||||
else if (Minimized != null && !Properties.Settings.Default.minimizeToTray)
|
|
||||||
{
|
|
||||||
Minimized(this, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMaximized(EventArgs e)
|
|
||||||
{
|
|
||||||
if (Maximized != null)
|
|
||||||
{
|
|
||||||
Maximized(this, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRestored(EventArgs e)
|
|
||||||
{
|
|
||||||
if (Restored != null)
|
|
||||||
{
|
|
||||||
Restored(this, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
|
||||||
{
|
|
||||||
switch (m.Msg)
|
|
||||||
{
|
|
||||||
case WM_SIZE:
|
|
||||||
switch (m.WParam.ToInt32())
|
|
||||||
{
|
|
||||||
case SIZE_RESTORED:
|
|
||||||
OnRestored(EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
case SIZE_MINIMIZED:
|
|
||||||
OnMinimized(EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
case SIZE_MAXIMIZED:
|
|
||||||
OnMaximized(EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
base.WndProc(ref m);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainForm_Minimized(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// TODO: do something here
|
|
||||||
}
|
|
||||||
|
|
||||||
private void option_minToTray_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Properties.Settings.Default.minimizeToTray = option_minToTray.Checked;
|
|
||||||
Properties.Settings.Default.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Application.Exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!this.Visible)
|
|
||||||
{
|
|
||||||
this.Show();
|
|
||||||
}
|
|
||||||
else if (Restored != null)
|
|
||||||
{
|
|
||||||
Restored(this, e);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.BringToFront();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (!this.Visible)
|
|
||||||
{
|
|
||||||
this.Show();
|
|
||||||
}
|
|
||||||
else if (Restored != null)
|
|
||||||
{
|
|
||||||
Restored(this, e);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.BringToFront();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
93
PreviewOverlay.Designer.cs
generated
93
PreviewOverlay.Designer.cs
generated
@@ -1,93 +0,0 @@
|
|||||||
namespace PreviewToy
|
|
||||||
{
|
|
||||||
partial class PreviewOverlay
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
this.overlay_area = new System.Windows.Forms.PictureBox();
|
|
||||||
this.client_label = new System.Windows.Forms.Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.overlay_area)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// overlay_area
|
|
||||||
//
|
|
||||||
this.overlay_area.BackColor = System.Drawing.Color.Transparent;
|
|
||||||
this.overlay_area.Cursor = System.Windows.Forms.Cursors.Hand;
|
|
||||||
this.overlay_area.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.overlay_area.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.overlay_area.Name = "overlay_area";
|
|
||||||
this.overlay_area.Size = new System.Drawing.Size(284, 262);
|
|
||||||
this.overlay_area.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
|
||||||
this.overlay_area.TabIndex = 0;
|
|
||||||
this.overlay_area.TabStop = false;
|
|
||||||
this.overlay_area.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_Click);
|
|
||||||
//
|
|
||||||
// client_label
|
|
||||||
//
|
|
||||||
this.client_label.AutoSize = true;
|
|
||||||
this.client_label.Dock = System.Windows.Forms.DockStyle.Top;
|
|
||||||
this.client_label.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.client_label.ForeColor = System.Drawing.Color.DarkGray;
|
|
||||||
this.client_label.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.client_label.Name = "client_label";
|
|
||||||
this.client_label.Size = new System.Drawing.Size(25, 13);
|
|
||||||
this.client_label.TabIndex = 1;
|
|
||||||
this.client_label.Text = "...";
|
|
||||||
this.client_label.Click += new System.EventHandler(this.client_label_Click);
|
|
||||||
//
|
|
||||||
// PreviewOverlay
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.BackColor = System.Drawing.Color.Black;
|
|
||||||
this.ClientSize = new System.Drawing.Size(284, 262);
|
|
||||||
this.ControlBox = false;
|
|
||||||
this.Controls.Add(this.client_label);
|
|
||||||
this.Controls.Add(this.overlay_area);
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
|
||||||
this.MaximizeBox = false;
|
|
||||||
this.MinimizeBox = false;
|
|
||||||
this.Name = "PreviewOverlay";
|
|
||||||
this.ShowIcon = false;
|
|
||||||
this.ShowInTaskbar = false;
|
|
||||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
|
||||||
this.Text = "PreviewOverlay";
|
|
||||||
this.TransparencyKey = System.Drawing.Color.Black;
|
|
||||||
this.Load += new System.EventHandler(this.PreviewOverlay_Load);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.overlay_area)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public System.Windows.Forms.PictureBox overlay_area;
|
|
||||||
public System.Windows.Forms.Label client_label;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace PreviewToy
|
|
||||||
{
|
|
||||||
public partial class PreviewOverlay : Form
|
|
||||||
{
|
|
||||||
private Preview parent;
|
|
||||||
private Color original_color;
|
|
||||||
public PreviewOverlay(Preview parent)
|
|
||||||
{
|
|
||||||
this.parent = parent;
|
|
||||||
InitializeComponent();
|
|
||||||
original_color = overlay_area.BackColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PreviewOverlay_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBox1_Click(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
this.parent.render_area_Click(sender, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void makeTopMost()
|
|
||||||
{
|
|
||||||
this.TopMost = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void client_label_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override CreateParams CreateParams
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var Params = base.CreateParams;
|
|
||||||
Params.ExStyle |= 0x80;
|
|
||||||
return Params;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
18
Program.cs
18
Program.cs
@@ -1,18 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace PreviewToy
|
|
||||||
{
|
|
||||||
static class Program
|
|
||||||
{
|
|
||||||
/// <summary>The main entry point for the application.</summary>
|
|
||||||
[STAThread]
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
Application.EnableVisualStyles();
|
|
||||||
Application.SetCompatibleTextRenderingDefault(true);
|
|
||||||
Application.Run(new PreviewToyHandler());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("PreviewToy")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("?")]
|
|
||||||
[assembly: AssemblyProduct("PreviewToy")]
|
|
||||||
[assembly: AssemblyCopyright("")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
[assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")]
|
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
This file is automatically generated by Visual Studio .Net. It is
|
|
||||||
used to store generic object data source configuration information.
|
|
||||||
Renaming the file extension or editing the content of this file may
|
|
||||||
cause the file to be unrecognizable by the program.
|
|
||||||
-->
|
|
||||||
<GenericObjectDataSource DisplayName="PreviewToyMain" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
|
|
||||||
<TypeInfo>PreviewToy.PreviewToyMain, eve-o preview test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
|
|
||||||
</GenericObjectDataSource>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<PublishUrlHistory>publish\</PublishUrlHistory>
|
|
||||||
<InstallUrlHistory />
|
|
||||||
<SupportUrlHistory />
|
|
||||||
<UpdateUrlHistory />
|
|
||||||
<BootstrapperUrlHistory />
|
|
||||||
<ErrorReportUrlHistory />
|
|
||||||
<FallbackCulture>en-US</FallbackCulture>
|
|
||||||
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<EnableSecurityDebugging>false</EnableSecurityDebugging>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
BIN
preview toy.suo
BIN
preview toy.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user