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>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EveOMock</RootNamespace>
<AssemblyName>exefile</AssemblyName>
<AssemblyName>ExeFile</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>

View File

@@ -51,8 +51,10 @@ namespace EveOPreview
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

View File

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

View File

@@ -82,6 +82,13 @@
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
@@ -100,6 +107,9 @@
<Compile Include="DwmAPI\DWM_THUMBNAIL_PROPERTIES.cs" />
<Compile Include="DwmAPI\MARGINS.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\HotkeyNativeMethods.cs" />
<Compile Include="GUI\MainForm.cs">
@@ -140,7 +150,6 @@
<None Include="app.config">
<SubType>Designer</SubType>
</None>
<None Include="preview toy_TemporaryKey.pfx" />
<None Include="Properties\DataSources\PreviewToyMain.datasource" />
<None Include="Properties\Settings.settings">
<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>
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();
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.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.RenderAreaPictureBox);
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.RenderAreaPictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#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
{
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;
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 bool mouse_over_lock = false;
private Size old_size;
private Point old_position;
private IntPtr m_hThumbnail;
public IntPtr sourceWindow;
private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties;
private bool has_been_set_up = false;
private bool thumbnail_has_been_set_up = false;
private MainForm spawner;
private Hotkey hotkey;
private IntPtr m_hThumbnail;
public IntPtr sourceWindow;
private DWM_THUMBNAIL_PROPERTIES m_ThumbnailProperties;
private bool has_been_set_up = false;
private bool thumbnail_has_been_set_up = false;
private MainForm spawner;
private Hotkey hotkey;
private bool hide = false;
private bool hide = false;
public PreviewOverlay overlay;
public void MakeHidden(bool wha)
{
hide = wha;
}
public override string ToString()
{
return this.Text;
}
public PreviewOverlay overlay;
public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size)
{
has_been_set_up = false;
public void MakeTopMost(bool topmost)
{
this.TopMost = topmost && !(this.hide);
}
this.sourceWindow = sourceWindow;
this.spawner = spawner;
public Preview(IntPtr sourceWindow, String title, MainForm spawner, Size size)
{
has_been_set_up = false;
InitializeComponent();
this.sourceWindow = sourceWindow;
this.spawner = spawner;
this.Text = title;
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);
this.render_area.MouseLeave += new System.EventHandler(this.preview_MouseLeave);
has_been_set_up = true;
}
this.old_size = this.Size;
this.old_position = this.Location;
public void MakeHidden(bool wha)
{
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)
{
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();
}
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;
}
}
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);
public void registerShortcut(string shortcut)
{
if (shortcut == "")
return;
var cvt = new KeysConverter();
var key = (Keys)cvt.ConvertFrom(shortcut);
Hotkey hotkey = new Hotkey();
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)
{
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(); };
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;
}
this.hotkey = hotkey;
}
public void doZoom()
{
if (is_zoomed)
return;
public void doZoom()
{
if (is_zoomed)
return;
is_zoomed = true;
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_position = Location;
old_size = Size;
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)
{
case (MainForm.zoom_anchor_t.NW):
break;
case (MainForm.zoom_anchor_t.N):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y);
break;
case (MainForm.zoom_anchor_t.NE):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y);
break;
switch ((ZoomAnchor)Properties.Settings.Default.zoom_anchor)
{
case (ZoomAnchor.NW):
break;
case (ZoomAnchor.N):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y);
break;
case (ZoomAnchor.NE):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y);
break;
case (MainForm.zoom_anchor_t.W):
Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2);
break;
case (MainForm.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 (MainForm.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 (ZoomAnchor.W):
Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2);
break;
case (ZoomAnchor.C):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height / 2 + old_size.Height / 2);
break;
case (ZoomAnchor.E):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height / 2 + old_size.Height / 2);
break;
case (MainForm.zoom_anchor_t.SW):
Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height);
break;
case (MainForm.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 (MainForm.zoom_anchor_t.SE):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y - Size.Height + old_size.Height);
break;
}
}
case (ZoomAnchor.SW):
Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height);
break;
case (ZoomAnchor.S):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y - Size.Height + old_size.Height);
break;
case (ZoomAnchor.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;
public void restoreZoom()
{
if (!is_zoomed)
return;
Size = old_size;
Location = old_position;
is_zoomed = false;
}
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();
}
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 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);
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();
}
RefreshPreview();
}
public void doMove(Point position)
{
if (has_been_set_up && !mouse_over_lock)
Location = position;
public void doMove(Point position)
{
if (has_been_set_up && !mouse_over_lock)
Location = position;
RefreshPreview();
}
RefreshPreview();
}
public void SetLabel(String label)
{
this.Text = label;
this.overlay.client_label.Text = label;
}
public void SetLabel(String label)
{
this.Text = label;
this.overlay.SetOverlayLabel(label);
}
public void RefreshPreview()
{
if (has_been_set_up)
{
if (DwmApiNativeMethods.DwmIsCompositionEnabled())
{
if (thumbnail_has_been_set_up == false)
{
this.SetUpThumbnail();
}
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
DwmApiNativeMethods.DwmUpdateThumbnailProperties(m_hThumbnail, m_ThumbnailProperties);
}
else
{
thumbnail_has_been_set_up = false;
}
public void RefreshPreview()
{
if (has_been_set_up)
{
if (DwmApiNativeMethods.DwmIsCompositionEnabled())
{
if (thumbnail_has_been_set_up == false)
{
this.SetUpThumbnail();
}
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
DwmApiNativeMethods.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;
Size overlay_size = this.RenderAreaPictureBox.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;
Point overlay_location = this.Location;
overlay_location.X += 5 + (this.Size.Width - this.RenderAreaPictureBox.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.Location = overlay_location;
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 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();
}
new public void Hide()
{
base.Hide();
this.overlay.Hide();
}
private void SetUpThumbnail()
{
if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up)
{
m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow);
private void SetUpThumbnail()
{
if (DwmApiNativeMethods.DwmIsCompositionEnabled() && !thumbnail_has_been_set_up)
{
m_hThumbnail = DwmApiNativeMethods.DwmRegisterThumbnail(this.Handle, sourceWindow);
m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES();
m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY;
m_ThumbnailProperties.opacity = 255;
m_ThumbnailProperties.fVisible = true;
m_ThumbnailProperties.fSourceClientAreaOnly = true;
m_ThumbnailProperties.rcDestination = new RECT(0, 0, ClientRectangle.Right, ClientRectangle.Bottom);
m_ThumbnailProperties = new DWM_THUMBNAIL_PROPERTIES();
m_ThumbnailProperties.dwFlags = DWM_THUMBNAIL_PROPERTIES.DWM_TNP_VISIBLE
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_OPACITY
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_RECTDESTINATION
+ DWM_THUMBNAIL_PROPERTIES.DWM_TNP_SOURCECLIENTAREAONLY;
m_ThumbnailProperties.opacity = 255;
m_ThumbnailProperties.fVisible = true;
m_ThumbnailProperties.fSourceClientAreaOnly = true;
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()
{
DwmApiNativeMethods.SetForegroundWindow(sourceWindow);
int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE);
if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE)
{
//It's maximized
}
else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE)
{
DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.SW_SHOWNORMAL);
}
}
public void bring_client_to_foreground()
{
DwmApiNativeMethods.SetForegroundWindow(sourceWindow);
int style = DwmApiNativeMethods.GetWindowLong(sourceWindow, DwmApiNativeMethods.GWL_STYLE);
if ((style & DwmApiNativeMethods.WS_MAXIMIZE) == DwmApiNativeMethods.WS_MAXIMIZE)
{
//It's maximized
}
else if ((style & DwmApiNativeMethods.WS_MINIMIZE) == DwmApiNativeMethods.WS_MINIMIZE)
{
DwmApiNativeMethods.ShowWindowAsync(sourceWindow, DwmApiNativeMethods.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 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;
}
}
public void set_render_area_size(Size size)
{
this.Size = size;
}
}
}

View File

@@ -28,66 +28,63 @@
/// </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();
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 = "PreviewOverlay";
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
#endregion
public System.Windows.Forms.PictureBox overlay_area;
public System.Windows.Forms.Label client_label;
}
private System.Windows.Forms.Label OverlayLabel;
}
}

View File

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

View File

@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="OverlayAreaPictureBox.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@@ -1,16 +1,18 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("PreviewToy")]
[assembly: AssemblyTitle("EVE-O Preview")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("?")]
[assembly: AssemblyProduct("PreviewToy")]
[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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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")]