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);
}
}

View File

@@ -2,8 +2,8 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Threading;
using System.Xml.Linq;
using System.IO;
@@ -12,13 +12,6 @@ namespace EveOPreview
{
public partial class MainForm : 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;
@@ -28,92 +21,57 @@ namespace EveOPreview
private DispatcherTimer _dispatcherTimer;
private IntPtr _activeClientHandle;
private String _activeClientTitle;
private string _activeClientTitle;
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 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 bool is_initialized;
private readonly bool _isInitialized;
private Stopwatch ignoring_size_sync;
private readonly Stopwatch _ignoringSizeSync;
Dictionary<string, string> xml_bad_to_ok_chars;
private readonly Dictionary<string, string> _xmlBadToOkChars;
[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;
private Dictionary<ZoomAnchor, RadioButton> _zoomAnchorButtonMap;
public MainForm()
{
is_initialized = false;
_isInitialized = false;
this._activeClientHandle = (IntPtr)0;
this._activeClientTitle = "";
_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---";
_xmlBadToOkChars = new Dictionary<string, string>();
_xmlBadToOkChars["<"] = "---lt---";
_xmlBadToOkChars["&"] = "---amp---";
_xmlBadToOkChars[">"] = "---gt---";
_xmlBadToOkChars["\""] = "---quot---";
_xmlBadToOkChars["\'"] = "---apos---";
_xmlBadToOkChars[","] = "---comma---";
_xmlBadToOkChars["."] = "---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>();
_uniqueLayouts = new Dictionary<string, Dictionary<string, Point>>();
_flatLayout = new Dictionary<string, Point>();
_flatLayoutShortcuts = new Dictionary<string, string>();
_clientLayout = new Dictionary<string, ClientLocation>();
ignoring_size_sync = new Stopwatch();
ignoring_size_sync.Start();
_ignoringSizeSync = new Stopwatch();
_ignoringSizeSync.Start();
InitializeComponent();
init_options();
// DispatcherTimer setup
_dispatcherTimer = new DispatcherTimer();
_dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
_dispatcherTimer.Tick += dispatcherTimer_Tick;
_dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
_dispatcherTimer.Start();
is_initialized = true;
_isInitialized = true;
previews_check_listbox.DisplayMember = "Text";
@@ -127,21 +85,21 @@ namespace EveOPreview
private void init_options()
{
this.Minimized += new EventHandler(MainForm_Minimized);
this.Minimized += 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();
_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;
@@ -163,7 +121,7 @@ namespace EveOPreview
// disable/enable zoom suboptions
option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover;
foreach (var kv in zoom_anchor_button_map)
foreach (var kv in _zoomAnchorButtonMap)
{
kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover;
}
@@ -176,7 +134,7 @@ namespace EveOPreview
private void spawn_and_kill_previews()
{
if (!is_initialized) { return; }
if (!_isInitialized) { return; }
Process[] processes = Process.GetProcessesByName("ExeFile");
List<IntPtr> processHandles = new List<IntPtr>();
@@ -194,7 +152,7 @@ namespace EveOPreview
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);
_previews[process.MainWindowHandle].set_render_area_size(sync_size);// TODO Remove
// apply more thumbnail specific options
_previews[process.MainWindowHandle].MakeTopMost(Properties.Settings.Default.always_on_top);
@@ -213,7 +171,7 @@ namespace EveOPreview
_previews[process.MainWindowHandle].SetLabel(process.MainWindowTitle);
string key = _previews[process.MainWindowHandle].Text;
string value;
if (flat_layout_shortcuts.TryGetValue(key, out value))
if (_flatLayoutShortcuts.TryGetValue(key, out value))
{
_previews[process.MainWindowHandle].registerShortcut(value);
}
@@ -255,22 +213,18 @@ namespace EveOPreview
private void refresh_client_window_locations(Process process)
{
if (Properties.Settings.Default.track_client_windows && client_layout.ContainsKey(process.MainWindowTitle))
if (Properties.Settings.Default.track_client_windows && _clientLayout.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);
GuiNativeMethods.MoveWindow(process.MainWindowHandle, _clientLayout[process.MainWindowTitle].X,
_clientLayout[process.MainWindowTitle].Y, _clientLayout[process.MainWindowTitle].Width,
_clientLayout[process.MainWindowTitle].Height, true);
}
}
private string remove_nonconform_xml_characters(string entry)
{
foreach (var kv in xml_bad_to_ok_chars)
foreach (var kv in _xmlBadToOkChars)
{
entry = entry.Replace(kv.Key, kv.Value);
}
@@ -279,7 +233,7 @@ namespace EveOPreview
private string restore_nonconform_xml_characters(string entry)
{
foreach (var kv in xml_bad_to_ok_chars)
foreach (var kv in _xmlBadToOkChars)
{
entry = entry.Replace(kv.Value, kv.Key);
}
@@ -304,12 +258,12 @@ namespace EveOPreview
XElement rootElement = XElement.Load("layout.xml");
foreach (var el in rootElement.Elements())
{
Dictionary<String, Point> inner = new Dictionary<String, Point>();
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));
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;
_uniqueLayouts[ParseXElement(el)] = inner;
}
}
@@ -318,12 +272,12 @@ namespace EveOPreview
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)] = "";
_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)
{
flat_layout_shortcuts[ParseXElement(el)] = el.Element("shortcut").Value;
_flatLayoutShortcuts[ParseXElement(el)] = el.Element("shortcut").Value;
}
}
}
@@ -339,7 +293,7 @@ namespace EveOPreview
clientLocation.Width = Convert.ToInt32(el.Element("width").Value);
clientLocation.Height = Convert.ToInt32(el.Element("height").Value);
client_layout[ParseXElement(el)] = clientLocation;
_clientLayout[ParseXElement(el)] = clientLocation;
}
}
}
@@ -347,16 +301,16 @@ namespace EveOPreview
private void store_layout()
{
XElement el = new XElement("layouts");
foreach (var client in unique_layouts.Keys)
foreach (var client in _uniqueLayouts.Keys)
{
if (client == "")
{
continue;
}
XElement layout = MakeXElement(client);
foreach (var thumbnail_ in unique_layouts[client])
foreach (var thumbnail_ in _uniqueLayouts[client])
{
String thumbnail = thumbnail_.Key;
string thumbnail = thumbnail_.Key;
if (thumbnail == "" || thumbnail == "...")
{
continue;
@@ -372,7 +326,7 @@ namespace EveOPreview
el.Save("layout.xml");
XElement el2 = new XElement("flat_layout");
foreach (var clientKV in flat_layout)
foreach (var clientKV in _flatLayout)
{
if (clientKV.Key == "" || clientKV.Key == "...")
{
@@ -383,7 +337,7 @@ namespace EveOPreview
layout.Add(new XElement("y", clientKV.Value.Y));
string shortcut;
if (flat_layout_shortcuts.TryGetValue(clientKV.Key, out shortcut))
if (_flatLayoutShortcuts.TryGetValue(clientKV.Key, out shortcut))
{
layout.Add(new XElement("shortcut", shortcut));
}
@@ -393,7 +347,7 @@ namespace EveOPreview
el2.Save("flat_layout.xml");
XElement el3 = new XElement("client_layout");
foreach (var clientKV in client_layout)
foreach (var clientKV in _clientLayout)
{
if (clientKV.Key == "" || clientKV.Key == "...")
{
@@ -410,10 +364,10 @@ namespace EveOPreview
el3.Save("client_layout.xml");
}
private void handle_unique_layout(Preview preview, String last_known_active_window)
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))
Dictionary<string, Point> layout;
if (_uniqueLayouts.TryGetValue(last_known_active_window, out layout))
{
Point new_loc;
if (Properties.Settings.Default.unique_layout && layout.TryGetValue(preview.Text, out new_loc))
@@ -429,8 +383,8 @@ namespace EveOPreview
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;
_uniqueLayouts[last_known_active_window] = new Dictionary<string, Point>();
_uniqueLayouts[last_known_active_window][preview.Text] = preview.Location;
}
}
@@ -442,8 +396,8 @@ namespace EveOPreview
foreach (Process process in processes)
{
Rect rect = new Rect();
GetWindowRect(process.MainWindowHandle, out rect);
RECT rect = new RECT();
GuiNativeMethods.GetWindowRect(process.MainWindowHandle, out rect);
int left = Math.Abs(rect.Left);
int right = Math.Abs(rect.Right);
@@ -460,7 +414,7 @@ namespace EveOPreview
clientLocation.Height = client_height;
client_layout[process.MainWindowTitle] = clientLocation;
_clientLayout[process.MainWindowTitle] = clientLocation;
}
}
@@ -473,7 +427,7 @@ namespace EveOPreview
{
entry.Value.MakeTopMost(Properties.Settings.Default.always_on_top);
//makes the PreviewOverlay topmost
entry.Value.overlay.makeTopMost();
entry.Value.overlay.MakeTopMost();
}
}
@@ -481,13 +435,13 @@ namespace EveOPreview
private void handle_flat_layout(Preview preview)
{
Point layout;
if (flat_layout.TryGetValue(preview.Text, out layout))
if (_flatLayout.TryGetValue(preview.Text, out layout))
{
preview.doMove(layout);
}
else if (preview.Text != "")
{
flat_layout[preview.Text] = preview.Location;
_flatLayout[preview.Text] = preview.Location;
}
}
@@ -536,7 +490,7 @@ namespace EveOPreview
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();
entry.Value.overlay.MakeTopMost();
if (!entry.Value.is_hovered_over)
{
entry.Value.Opacity = Properties.Settings.Default.opacity;
@@ -549,13 +503,13 @@ namespace EveOPreview
public void syncronize_preview_size(Size sync_size)
{
if (!is_initialized) { return; }
if (!_isInitialized) { return; }
if (Properties.Settings.Default.sync_resize &&
Properties.Settings.Default.show_thumb_frames &&
ignoring_size_sync.ElapsedMilliseconds > 500)
_ignoringSizeSync.ElapsedMilliseconds > 500)
{
ignoring_size_sync.Stop();
_ignoringSizeSync.Stop();
option_sync_size_x.Text = sync_size.Width.ToString();
option_sync_size_y.Text = sync_size.Height.ToString();
@@ -573,25 +527,25 @@ namespace EveOPreview
}
public void register_preview_position(String preview_title, Point position)
public void register_preview_position(string preview_title, Point position)
{
if (Properties.Settings.Default.unique_layout)
{
Dictionary<String, Point> layout;
if (unique_layouts.TryGetValue(_activeClientTitle, out layout))
Dictionary<string, Point> layout;
if (_uniqueLayouts.TryGetValue(_activeClientTitle, out layout))
{
layout[preview_title] = position;
}
else if (_activeClientTitle == "")
{
unique_layouts[_activeClientTitle] = new Dictionary<String, Point>();
unique_layouts[_activeClientTitle][preview_title] = position;
_uniqueLayouts[_activeClientTitle] = new Dictionary<string, Point>();
_uniqueLayouts[_activeClientTitle][preview_title] = position;
}
}
else
{
flat_layout[preview_title] = position;
_flatLayout[preview_title] = position;
}
}
@@ -601,7 +555,7 @@ namespace EveOPreview
{
spawn_and_kill_previews();
refresh_thumbnails();
if (ignoring_size_sync.ElapsedMilliseconds > 500) { ignoring_size_sync.Stop(); };
if (_ignoringSizeSync.ElapsedMilliseconds > 500) { _ignoringSizeSync.Stop(); };
if (DwmApiNativeMethods.DwmIsCompositionEnabled())
{
@@ -717,9 +671,9 @@ namespace EveOPreview
if (Properties.Settings.Default.show_thumb_frames)
{
ignoring_size_sync.Stop();
ignoring_size_sync.Reset();
ignoring_size_sync.Start();
_ignoringSizeSync.Stop();
_ignoringSizeSync.Reset();
_ignoringSizeSync.Start();
}
foreach (var thumbnail in _previews)
@@ -752,9 +706,9 @@ namespace EveOPreview
Properties.Settings.Default.Save();
refresh_thumbnails();
option_zoom_factor.Enabled = Properties.Settings.Default.zoom_on_hover;
if (is_initialized)
if (_isInitialized)
{
foreach (var kv in zoom_anchor_button_map)
foreach (var kv in _zoomAnchorButtonMap)
{
kv.Value.Enabled = Properties.Settings.Default.zoom_on_hover;
}
@@ -771,7 +725,7 @@ namespace EveOPreview
private void handle_zoom_anchor_setting()
{
foreach (var kv in zoom_anchor_button_map)
foreach (var kv in _zoomAnchorButtonMap)
{
if (kv.Value.Checked == true)
Properties.Settings.Default.zoom_anchor = (byte)kv.Key;
@@ -863,33 +817,29 @@ namespace EveOPreview
private void OnRestored(EventArgs e)
{
if (Restored != null)
{
Restored(this, e);
}
Restored?.Invoke(this, e);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_SIZE:
case GuiNativeMethods.WM_SIZE:
switch (m.WParam.ToInt32())
{
case SIZE_RESTORED:
case GuiNativeMethods.SIZE_RESTORED:
OnRestored(EventArgs.Empty);
break;
case SIZE_MINIMIZED:
case GuiNativeMethods.SIZE_MINIMIZED:
OnMinimized(EventArgs.Empty);
break;
case SIZE_MAXIMIZED:
case GuiNativeMethods.SIZE_MAXIMIZED:
OnMaximized(EventArgs.Empty);
break;
}
break;
default:
break;
}
base.WndProc(ref m);
}

View File

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

View File

@@ -14,24 +14,24 @@ namespace EveOPreview
/// </summary>
private void InitializeComponent()
{
this.render_area = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.render_area)).BeginInit();
this.RenderAreaPictureBox = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.RenderAreaPictureBox)).BeginInit();
this.SuspendLayout();
//
// render_area
// RenderAreaPictureBox
//
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);
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
//
@@ -40,7 +40,7 @@ namespace EveOPreview
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.Controls.Add(this.RenderAreaPictureBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
@@ -52,7 +52,7 @@ namespace EveOPreview
this.Text = "Preview";
this.TopMost = true;
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.PerformLayout();
@@ -60,7 +60,7 @@ namespace EveOPreview
#endregion
private System.Windows.Forms.PictureBox render_area;
private System.Windows.Forms.PictureBox RenderAreaPictureBox;
}

View File

@@ -27,22 +27,6 @@ namespace EveOPreview
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, MainForm spawner, Size size)
{
@@ -57,15 +41,28 @@ namespace EveOPreview
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.RenderAreaPictureBox.MouseHover += new System.EventHandler(this.preview_MouseHover);
this.RenderAreaPictureBox.MouseLeave += new System.EventHandler(this.preview_MouseLeave);
this.old_size = this.Size;
this.old_position = this.Location;
has_been_set_up = true;
}
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 void preview_MouseHover(object sender, System.EventArgs e)
@@ -138,34 +135,34 @@ namespace EveOPreview
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;
case (MainForm.zoom_anchor_t.N):
case (ZoomAnchor.N):
Location = new Point(Location.X - Size.Width / 2 + old_size.Width / 2, Location.Y);
break;
case (MainForm.zoom_anchor_t.NE):
case (ZoomAnchor.NE):
Location = new Point(Location.X - Size.Width + old_size.Width, Location.Y);
break;
case (MainForm.zoom_anchor_t.W):
case (ZoomAnchor.W):
Location = new Point(Location.X, Location.Y - Size.Height / 2 + old_size.Height / 2);
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);
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);
break;
case (MainForm.zoom_anchor_t.SW):
case (ZoomAnchor.SW):
Location = new Point(Location.X, Location.Y - Size.Height + old_size.Height);
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);
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);
break;
}
@@ -224,7 +221,7 @@ namespace EveOPreview
public void SetLabel(String label)
{
this.Text = label;
this.overlay.client_label.Text = label;
this.overlay.SetOverlayLabel(label);
}
public void RefreshPreview()
@@ -245,13 +242,13 @@ namespace EveOPreview
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.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;
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;
@@ -344,6 +341,5 @@ namespace EveOPreview
{
this.Size = size;
}
}
}

View File

@@ -28,36 +28,36 @@
/// </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();
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();
//
// overlay_area
// OverlayAreaPictureBox
//
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);
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);
//
// client_label
// OverlayLabel
//
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);
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
//
@@ -66,8 +66,8 @@
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.Controls.Add(this.OverlayLabel);
this.Controls.Add(OverlayAreaPictureBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
@@ -77,8 +77,7 @@
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();
((System.ComponentModel.ISupportInitialize)(OverlayAreaPictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -86,8 +85,6 @@
#endregion
public System.Windows.Forms.PictureBox overlay_area;
public System.Windows.Forms.Label client_label;
private System.Windows.Forms.Label OverlayLabel;
}
}

View File

@@ -1,44 +1,30 @@
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;
private readonly Preview _parent;
public PreviewOverlay(Preview parent)
{
this.parent = parent;
this._parent = parent;
InitializeComponent();
original_color = overlay_area.BackColor;
}
private void PreviewOverlay_Load(object sender, EventArgs e)
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()
public void MakeTopMost()
{
this.TopMost = true;
}
private void client_label_Click(object sender, EventArgs e)
public void SetOverlayLabel(string label)
{
this.OverlayLabel.Text = label;
}
protected override CreateParams CreateParams
@@ -50,6 +36,5 @@ namespace EveOPreview
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")]