Initial Code Cleanup - 1st phase completed

This commit is contained in:
Anton Kasyanov
2016-05-13 23:27:46 +03:00
parent 95b10a352c
commit b3c4536407
15 changed files with 1347 additions and 1355 deletions

View File

@@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EveOMock</RootNamespace> <RootNamespace>EveOMock</RootNamespace>
<AssemblyName>exefile</AssemblyName> <AssemblyName>ExeFile</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@@ -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>

View File

@@ -51,8 +51,10 @@ namespace EveOPreview
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);

View File

@@ -5,17 +5,17 @@ namespace EveOPreview
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
struct RECT struct RECT
{ {
public int left; public int Left;
public int top; public int Top;
public int right; public int Right;
public int bottom; public int Bottom;
public RECT(int left, int top, int right, int bottom) public RECT(int left, int top, int right, int bottom)
{ {
this.left = left; this.Left = left;
this.top = top; this.Top = top;
this.right = right; this.Right = right;
this.bottom = bottom; this.Bottom = bottom;
} }
} }
} }

View File

@@ -82,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" />
@@ -100,6 +107,9 @@
<Compile Include="DwmAPI\DWM_THUMBNAIL_PROPERTIES.cs" /> <Compile Include="DwmAPI\DWM_THUMBNAIL_PROPERTIES.cs" />
<Compile Include="DwmAPI\MARGINS.cs" /> <Compile Include="DwmAPI\MARGINS.cs" />
<Compile Include="DwmAPI\RECT.cs" /> <Compile Include="DwmAPI\RECT.cs" />
<Compile Include="GUI\ClientLocation.cs" />
<Compile Include="GUI\GuiNativeMethods.cs" />
<Compile Include="GUI\ZoomAnchor.cs" />
<Compile Include="Hotkeys\Hotkey.cs" /> <Compile Include="Hotkeys\Hotkey.cs" />
<Compile Include="Hotkeys\HotkeyNativeMethods.cs" /> <Compile Include="Hotkeys\HotkeyNativeMethods.cs" />
<Compile Include="GUI\MainForm.cs"> <Compile Include="GUI\MainForm.cs">
@@ -140,7 +150,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\DataSources\PreviewToyMain.datasource" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>

View File

@@ -0,0 +1,10 @@
namespace EveOPreview
{
public struct ClientLocation
{
public int X;
public int Y;
public int Width;
public int Height;
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Runtime.InteropServices;
namespace EveOPreview
{
// TODO This is a really bad name for this class
static class GuiNativeMethods
{
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);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
namespace EveOPreview
{
public enum ZoomAnchor
{
NW = 0,
N,
NE,
W,
C,
E,
SW,
S,
SE
}
}

View File

@@ -14,53 +14,53 @@ namespace EveOPreview
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.render_area = new System.Windows.Forms.PictureBox(); this.RenderAreaPictureBox = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.render_area)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// render_area // RenderAreaPictureBox
// //
this.render_area.BackColor = System.Drawing.Color.Transparent; this.RenderAreaPictureBox.BackColor = System.Drawing.Color.Transparent;
this.render_area.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.RenderAreaPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.render_area.Cursor = System.Windows.Forms.Cursors.Hand; this.RenderAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.render_area.Dock = System.Windows.Forms.DockStyle.Fill; this.RenderAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.render_area.Location = new System.Drawing.Point(0, 0); this.RenderAreaPictureBox.Location = new System.Drawing.Point(0, 0);
this.render_area.Margin = new System.Windows.Forms.Padding(0); this.RenderAreaPictureBox.Margin = new System.Windows.Forms.Padding(0);
this.render_area.Name = "render_area"; this.RenderAreaPictureBox.Name = "RenderAreaPictureBox";
this.render_area.Size = new System.Drawing.Size(153, 89); this.RenderAreaPictureBox.Size = new System.Drawing.Size(153, 89);
this.render_area.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.RenderAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.render_area.TabIndex = 0; this.RenderAreaPictureBox.TabIndex = 0;
this.render_area.TabStop = false; this.RenderAreaPictureBox.TabStop = false;
this.render_area.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click); this.RenderAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.render_area_Click);
// //
// Preview // Preview
// //
this.AccessibleRole = System.Windows.Forms.AccessibleRole.None; this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(153, 89); this.ClientSize = new System.Drawing.Size(153, 89);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.render_area); this.Controls.Add(this.RenderAreaPictureBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(64, 64); this.MinimumSize = new System.Drawing.Size(64, 64);
this.Name = "Preview"; this.Name = "Preview";
this.Opacity = 0.1D; this.Opacity = 0.1D;
this.ShowIcon = false; this.ShowIcon = false;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.Text = "Preview"; this.Text = "Preview";
this.TopMost = true; this.TopMost = true;
this.Load += new System.EventHandler(this.Preview_Load); this.Load += new System.EventHandler(this.Preview_Load);
((System.ComponentModel.ISupportInitialize)(this.render_area)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.PictureBox render_area; private System.Windows.Forms.PictureBox RenderAreaPictureBox;
} }

View File

@@ -4,346 +4,342 @@ using System.Windows.Forms;
namespace EveOPreview namespace EveOPreview
{ {
public partial class Preview : Form public partial class Preview : Form
{ {
public bool show_overlay = true; public bool show_overlay = true;
public bool hover_zoom = true; public bool hover_zoom = true;
public bool is_zoomed = false; public bool is_zoomed = false;
public bool is_hovered_over = false; public bool is_hovered_over = false;
private bool mouse_over_lock = false; private bool mouse_over_lock = false;
private Size old_size; private Size old_size;
private Point old_position; private Point old_position;
private IntPtr m_hThumbnail; private IntPtr m_hThumbnail;
public IntPtr sourceWindow; public IntPtr sourceWindow;
private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties; private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties;
private bool has_been_set_up = false; private bool has_been_set_up = false;
private bool thumbnail_has_been_set_up = false; private bool thumbnail_has_been_set_up = false;
private MainForm spawner; private MainForm spawner;
private Hotkey hotkey; private Hotkey hotkey;
private bool hide = false; private bool hide = false;
public PreviewOverlay overlay; public PreviewOverlay overlay;
public void MakeHidden(bool wha)
{
hide = wha;
}
public override string ToString()
{
return this.Text;
}
public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size)
{
has_been_set_up = false;
public void MakeTopMost(bool topmost) this.sourceWindow = sourceWindow;
{ this.spawner = spawner;
this.TopMost = topmost && !(this.hide);
}
public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size) InitializeComponent();
{
has_been_set_up = false;
this.sourceWindow = sourceWindow; this.Text = title;
this.spawner = spawner;
InitializeComponent(); this.overlay = new PreviewOverlay(this);
this.Text = title; this.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.preview_MouseHover);
this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.preview_MouseLeave);
this.overlay = new PreviewOverlay(this); this.old_size = this.Size;
this.old_position = this.Location;
this.render_area.MouseHover += new System.EventHandler(this.preview_MouseHover); has_been_set_up = true;
this.render_area.MouseLeave += new System.EventHandler(this.preview_MouseLeave); }
this.old_size = this.Size; public void MakeHidden(bool wha)
this.old_position = this.Location; {
hide = wha;
}
has_been_set_up = true; public override string ToString()
{
return this.Text;
}
public void MakeTopMost(bool topmost)
{
this.TopMost = topmost && !(this.hide);
}
} public void preview_MouseHover(object sender, System.EventArgs e)
{
if (!mouse_over_lock)
{
mouse_over_lock = true;
if (hover_zoom)
doZoom();
public void preview_MouseHover(object sender, System.EventArgs e) TopMost = true;
{ overlay.TopMost = true;
if (!mouse_over_lock) }
{ this.Opacity = 1.0f;
mouse_over_lock = true; this.is_hovered_over = true;
if (hover_zoom) RefreshPreview();
doZoom(); }
TopMost = true; protected override CreateParams CreateParams
overlay.TopMost = true; {
} get
this.Opacity = 1.0f; {
this.is_hovered_over = true; var Params = base.CreateParams;
RefreshPreview(); Params.ExStyle |= 0x80;
} return Params;
}
}
protected override CreateParams CreateParams public void registerShortcut(string shortcut)
{ {
get if (shortcut == "")
{ return;
var Params = base.CreateParams; var cvt = new KeysConverter();
Params.ExStyle |= 0x80; var key = (Keys)cvt.ConvertFrom(shortcut);
return Params;
}
}
public void registerShortcut(string shortcut) Hotkey hotkey = new Hotkey();
{
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;
}
if ((key & Keys.Shift) == Keys.Shift) key = key & ~Keys.Shift & ~Keys.Alt & ~Keys.Control;
{ hotkey.KeyCode = key;
hotkey.Shift = true; hotkey.Register(this);
} hotkey.Pressed += delegate { bring_client_to_foreground(); spawner.preview_did_switch(); };
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; this.hotkey = hotkey;
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;
public void doZoom() is_zoomed = true;
{
if (is_zoomed)
return;
is_zoomed = true;
float hover_zoom_factor = Properties.Settings.Default.zoom_amount; float hover_zoom_factor = Properties.Settings.Default.zoom_amount;
old_size = Size; old_size = Size;
old_position = Location; old_position = Location;
Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height)); Size = new Size((int)(hover_zoom_factor * (float)Size.Width), (int)(hover_zoom_factor * (float)Size.Height));
switch ((MainForm.zoom_anchor_t)Properties.Settings.Default.zoom_anchor) switch ((ZoomAnchor)Properties.Settings.Default.zoom_anchor)
{ {
case (MainForm.zoom_anchor_t.NW): case (ZoomAnchor.NW):
break; break;
case (MainForm.zoom_anchor_t.N): case (ZoomAnchor.N):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y); Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y);
break; break;
case (MainForm.zoom_anchor_t.NE): case (ZoomAnchor.NE):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y); Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y);
break; break;
case (MainForm.zoom_anchor_t.W): case (ZoomAnchor.W):
Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2); Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2);
break; break;
case (MainForm.zoom_anchor_t.C): case (ZoomAnchor.C):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2); Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2);
break; break;
case (MainForm.zoom_anchor_t.E): case (ZoomAnchor.E):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2); Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2);
break; break;
case (MainForm.zoom_anchor_t.SW): case (ZoomAnchor.SW):
Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height); Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height);
break; break;
case (MainForm.zoom_anchor_t.S): case (ZoomAnchor.S):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height); Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height);
break; break;
case (MainForm.zoom_anchor_t.SE): case (ZoomAnchor.SE):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height); Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height);
break; break;
} }
} }
public void restoreZoom() public void restoreZoom()
{ {
if (!is_zoomed) if (!is_zoomed)
return; return;
Size = old_size; Size = old_size;
Location = old_position; Location = old_position;
is_zoomed = false; is_zoomed = false;
} }
public void preview_MouseLeave(object sender, System.EventArgs e) public void preview_MouseLeave(object sender, System.EventArgs e)
{ {
if (mouse_over_lock) if (mouse_over_lock)
{ {
if (hover_zoom) if (hover_zoom)
{ {
restoreZoom(); restoreZoom();
} }
mouse_over_lock = false; mouse_over_lock = false;
} }
this.is_hovered_over = false; this.is_hovered_over = false;
this.Opacity = Properties.Settings.Default.opacity; this.Opacity = Properties.Settings.Default.opacity;
RefreshPreview(); RefreshPreview();
} }
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
{ {
RefreshPreview(); RefreshPreview();
base.OnResize(e); base.OnResize(e);
if (has_been_set_up && !mouse_over_lock) if (has_been_set_up && !mouse_over_lock)
this.spawner.syncronize_preview_size(this.Size); this.spawner.syncronize_preview_size(this.Size);
} }
protected override void OnMove(EventArgs e) protected override void OnMove(EventArgs e)
{ {
base.OnMove(e); base.OnMove(e);
if (has_been_set_up && !mouse_over_lock) if (has_been_set_up && !mouse_over_lock)
this.spawner.register_preview_position(this.Text, this.Location); this.spawner.register_preview_position(this.Text, this.Location);
RefreshPreview(); RefreshPreview();
} }
public void doMove(Point position) public void doMove(Point position)
{ {
if (has_been_set_up && !mouse_over_lock) if (has_been_set_up && !mouse_over_lock)
Location = position; Location = position;
RefreshPreview(); RefreshPreview();
} }
public void SetLabel(String label) public void SetLabel(String label)
{ {
this.Text = label; this.Text = label;
this.overlay.client_label.Text = label; this.overlay.SetOverlayLabel(label);
} }
public void RefreshPreview() public void RefreshPreview()
{ {
if (has_been_set_up) if (has_been_set_up)
{ {
if (DwmApiNativeMethods.DwmIsCompositionEnabled()) if (DwmApiNativeMethods.DwmIsCompositionEnabled())
{ {
if (thumbnail_has_been_set_up == false) if (thumbnail_has_been_set_up == false)
{ {
this.SetUpThumbnail(); this.SetUpThumbnail();
} }
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
} }
else else
{ {
thumbnail_has_been_set_up = false; thumbnail_has_been_set_up = false;
} }
Size overlay_size = this.render_area.Size; Size overlay_size = this.RenderAreaPictureBox.Size;
overlay_size.Width -= 2 * 5; overlay_size.Width -= 2 * 5;
overlay_size.Height -= 2 * 5; overlay_size.Height -= 2 * 5;
Point overlay_location = this.Location; Point overlay_location = this.Location;
overlay_location.X += 5 + (this.Size.Width - this.render_area.Size.Width) / 2; overlay_location.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2;
overlay_location.Y += 5 + (this.Size.Height - this.render_area.Size.Height) - (this.Size.Width - this.render_area.Size.Width) / 2; overlay_location.Y += 5 + (this.Size.Height - this.RenderAreaPictureBox.Size.Height) - (this.Size.Width - this.RenderAreaPictureBox.Size.Width) / 2;
this.overlay.Size = overlay_size; this.overlay.Size = overlay_size;
this.overlay.Location = overlay_location; this.overlay.Location = overlay_location;
} }
} }
new public void Show() new public void Show()
{ {
if (!hide) if (!hide)
{ {
base.Show(); base.Show();
if (show_overlay) if (show_overlay)
this.overlay.Show(); this.overlay.Show();
else else
this.overlay.Hide(); this.overlay.Hide();
} }
else else
{ {
this.Hide(); this.Hide();
this.overlay.Hide(); this.overlay.Hide();
} }
} }
new public void Hide() new public void Hide()
{ {
base.Hide(); base.Hide();
this.overlay.Hide(); this.overlay.Hide();
} }
private void SetUpThumbnail() private void SetUpThumbnail()
{ {
if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up) if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up)
{ {
m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow); m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow);
m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES(); m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES();
m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY; + DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY;
m_ThumbnailProperties.opacity = 255; m_ThumbnailProperties.opacity = 255;
m_ThumbnailProperties.fVisible = true; m_ThumbnailProperties.fVisible = true;
m_ThumbnailProperties.fSourceClientAreaOnly = true; m_ThumbnailProperties.fSourceClientAreaOnly = true;
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom); m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties); DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
thumbnail_has_been_set_up = true; thumbnail_has_been_set_up = true;
} }
} }
private void Preview_Load(object sender, EventArgs e) private void Preview_Load(object sender, EventArgs e)
{ {
} }
public void bring_client_to_foreground() public void bring_client_to_foreground()
{ {
DwmApiNativeMethods.SetForegroundWindow(sourceWindow); DwmApiNativeMethods.SetForegroundWindow(sourceWindow);
int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE); int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE);
if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE) if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE)
{ {
//It's maximized //It's maximized
} }
else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE) else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE)
{ {
DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL); DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL);
} }
} }
public void render_area_Click(object sender, MouseEventArgs e) public void render_area_Click(object sender, MouseEventArgs e)
{ {
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
bring_client_to_foreground(); bring_client_to_foreground();
spawner.preview_did_switch(); spawner.preview_did_switch();
} }
if (e.Button == MouseButtons.Right) if (e.Button == MouseButtons.Right)
{ {
// do smth cool? // do smth cool?
} }
if (e.Button == MouseButtons.Middle) if (e.Button == MouseButtons.Middle)
{ {
// do smth cool? // do smth cool?
} }
} }
public void set_render_area_size(Size size) public void set_render_area_size(Size size)
{ {
this.Size = size; this.Size = size;
} }
}
}
} }

View File

@@ -28,66 +28,63 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.overlay_area = new System.Windows.Forms.PictureBox(); System.Windows.Forms.PictureBox OverlayAreaPictureBox;
this.client_label = new System.Windows.Forms.Label(); this.OverlayLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.overlay_area)).BeginInit(); OverlayAreaPictureBox = new System.Windows.Forms.PictureBox();
this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).BeginInit();
// this.SuspendLayout();
// overlay_area //
// // OverlayAreaPictureBox
this.overlay_area.BackColor = System.Drawing.Color.Transparent; //
this.overlay_area.Cursor = System.Windows.Forms.Cursors.Hand; OverlayAreaPictureBox.BackColor = System.Drawing.Color.Transparent;
this.overlay_area.Dock = System.Windows.Forms.DockStyle.Fill; OverlayAreaPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.overlay_area.Location = new System.Drawing.Point(0, 0); OverlayAreaPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.overlay_area.Name = "overlay_area"; OverlayAreaPictureBox.Location = new System.Drawing.Point(0, 0);
this.overlay_area.Size = new System.Drawing.Size(284, 262); OverlayAreaPictureBox.Name = "OverlayAreaPictureBox";
this.overlay_area.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; OverlayAreaPictureBox.Size = new System.Drawing.Size(284, 262);
this.overlay_area.TabIndex = 0; OverlayAreaPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.overlay_area.TabStop = false; OverlayAreaPictureBox.TabIndex = 0;
this.overlay_area.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_Click); OverlayAreaPictureBox.TabStop = false;
// OverlayAreaPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OverlayArea_Click);
// client_label //
// // OverlayLabel
this.client_label.AutoSize = true; //
this.client_label.Dock = System.Windows.Forms.DockStyle.Top; this.OverlayLabel.AutoSize = true;
this.client_label.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.OverlayLabel.Dock = System.Windows.Forms.DockStyle.Top;
this.client_label.ForeColor = System.Drawing.Color.DarkGray; this.OverlayLabel.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.client_label.Location = new System.Drawing.Point(0, 0); this.OverlayLabel.ForeColor = System.Drawing.Color.DarkGray;
this.client_label.Name = "client_label"; this.OverlayLabel.Location = new System.Drawing.Point(0, 0);
this.client_label.Size = new System.Drawing.Size(25, 13); this.OverlayLabel.Name = "OverlayLabel";
this.client_label.TabIndex = 1; this.OverlayLabel.Size = new System.Drawing.Size(25, 13);
this.client_label.Text = "..."; this.OverlayLabel.TabIndex = 1;
this.client_label.Click += new System.EventHandler(this.client_label_Click); this.OverlayLabel.Text = "...";
// //
// PreviewOverlay // PreviewOverlay
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Black; this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(284, 262); this.ClientSize = new System.Drawing.Size(284, 262);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.client_label); this.Controls.Add(this.OverlayLabel);
this.Controls.Add(this.overlay_area); this.Controls.Add(OverlayAreaPictureBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "PreviewOverlay"; this.Name = "PreviewOverlay";
this.ShowIcon = false; this.ShowIcon = false;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "PreviewOverlay"; this.Text = "PreviewOverlay";
this.TransparencyKey = System.Drawing.Color.Black; this.TransparencyKey = System.Drawing.Color.Black;
this.Load += new System.EventHandler(this.PreviewOverlay_Load); ((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.overlay_area)).EndInit(); this.ResumeLayout(false);
this.ResumeLayout(false); this.PerformLayout();
this.PerformLayout();
} }
#endregion #endregion
public System.Windows.Forms.PictureBox overlay_area; private System.Windows.Forms.Label OverlayLabel;
public System.Windows.Forms.Label client_label; }
}
} }

View File

@@ -1,55 +1,40 @@
using System; using System.Windows.Forms;
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 EveOPreview namespace EveOPreview
{ {
public partial class PreviewOverlay : Form public partial class PreviewOverlay : Form
{ {
private Preview parent; private readonly 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) public PreviewOverlay(Preview parent)
{ {
this._parent = parent;
InitializeComponent();
}
} private void OverlayArea_Click(object sender, MouseEventArgs e)
{
this._parent.render_area_Click(sender, e);
}
private void pictureBox1_Click(object sender, MouseEventArgs e) public void MakeTopMost()
{ {
this.parent.render_area_Click(sender, e); this.TopMost = true;
} }
public void makeTopMost() public void SetOverlayLabel(string label)
{ {
this.TopMost = true; this.OverlayLabel.Text = label;
} }
private void client_label_Click(object sender, EventArgs e) protected override CreateParams CreateParams
{ {
get
} {
var Params = base.CreateParams;
protected override CreateParams CreateParams Params.ExStyle |= 0x80;
{ return Params;
get }
{ }
var Params = base.CreateParams; }
Params.ExStyle |= 0x80;
return Params;
}
}
}
} }

View File

@@ -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>

View File

@@ -1,16 +1,18 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
[assembly: AssemblyTitle("PreviewToy")] [assembly: AssemblyTitle("EVE-O Preview")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("?")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PreviewToy")] [assembly: AssemblyProduct("EVE-O Preview")]
[assembly: AssemblyCopyright("")] [assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")] [assembly: Guid("04f08f8d-9e98-423b-acdb-4effb31c0d35")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.18.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.18.0.0")]
// Provide your own key name to build the app locally
[assembly: AssemblyKeyName("Phrynohyas")]