# HG changeset patch
# User sl
# Date 1407869750 -7200
# Node ID 7acec5059fa6529a83d09cb3b83406bb6492490f
# Parent 19c1aaf900dcc6c420cb49c93eaf0d8ab015ab49
Adding our client implementation. Moving server into its own folder.
diff -r 19c1aaf900dc -r 7acec5059fa6 App.config
--- a/App.config Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
- Microsoft Sans Serif, 9.75pt
-
-
- False
-
-
- False
-
-
- False
-
-
-
-
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 CbtHook.cs
--- a/CbtHook.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-//=============================================================================
-// COPYRIGHT: Prosoft-Lanz
-//=============================================================================
-//
-// $Workfile: CbtHook.cs $
-//
-// PROJECT : CodeProject Components
-// VERSION : 1.00
-// CREATION : 19.02.2003
-// AUTHOR : JCL
-//
-// DETAILS : This class implement the WH_CBT Windows hook mechanism.
-// From MSDN, Dino Esposito.
-// WindowCreate, WindowDestroy and WindowActivate user events.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace CodeProject.Win32API.Hook
-{
- ///////////////////////////////////////////////////////////////////////
- #region Enum CbtHookAction
-
- ///
- /// CBT hook actions.
- ///
- internal enum CbtHookAction : int
- {
- HCBT_MOVESIZE = 0,
- HCBT_MINMAX = 1,
- HCBT_QS = 2,
- HCBT_CREATEWND = 3,
- HCBT_DESTROYWND = 4,
- HCBT_ACTIVATE = 5,
- HCBT_CLICKSKIPPED = 6,
- HCBT_KEYSKIPPED = 7,
- HCBT_SYSCOMMAND = 8,
- HCBT_SETFOCUS = 9
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Class CbtEventArgs
-
- ///
- /// Class used for WH_CBT hook event arguments.
- ///
- public class CbtEventArgs : EventArgs
- {
- /// wParam parameter.
- public IntPtr wParam;
- /// lParam parameter.
- public IntPtr lParam;
- /// Window class name.
- public string className;
- /// True if it is a dialog window.
- public bool IsDialog;
-
- internal CbtEventArgs(IntPtr wParam, IntPtr lParam)
- {
- // cache the parameters
- this.wParam = wParam;
- this.lParam = lParam;
-
- // cache the window's class name
- StringBuilder sb = new StringBuilder();
- sb.Capacity = 256;
- USER32.GetClassName(wParam, sb, 256);
- className = sb.ToString();
- IsDialog = (className == "#32770");
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Class CbtHook
-
- ///
- /// Class to expose the windows WH_CBT hook mechanism.
- ///
- public class CbtHook : WindowsHook
- {
- ///
- /// WH_CBT hook delegate method.
- ///
- public delegate void CbtEventHandler(object sender, CbtEventArgs e);
-
- ///
- /// WH_CBT create event.
- ///
- public event CbtEventHandler WindowCreate;
- ///
- /// WH_CBT destroy event.
- ///
- public event CbtEventHandler WindowDestroye;
- ///
- /// WH_CBT activate event.
- ///
- public event CbtEventHandler WindowActivate;
-
- ///
- /// Construct a WH_CBT hook.
- ///
- public CbtHook() : base(HookType.WH_CBT)
- {
- this.HookInvoke += new HookEventHandler(CbtHookInvoked);
- }
- ///
- /// Construct a WH_CBT hook giving a hook filter delegate method.
- ///
- /// Hook filter event.
- public CbtHook(HookProc func) : base(HookType.WH_CBT, func)
- {
- this.HookInvoke += new HookEventHandler(CbtHookInvoked);
- }
-
- // handles the hook event
- private void CbtHookInvoked(object sender, HookEventArgs e)
- {
- // handle hook events (only a few of available actions)
- switch ((CbtHookAction)e.code)
- {
- case CbtHookAction.HCBT_CREATEWND:
- HandleCreateWndEvent(e.wParam, e.lParam);
- break;
- case CbtHookAction.HCBT_DESTROYWND:
- HandleDestroyWndEvent(e.wParam, e.lParam);
- break;
- case CbtHookAction.HCBT_ACTIVATE:
- HandleActivateEvent(e.wParam, e.lParam);
- break;
- }
- return;
- }
-
- // handle the CREATEWND hook event
- private void HandleCreateWndEvent(IntPtr wParam, IntPtr lParam)
- {
- if (WindowCreate != null)
- {
- CbtEventArgs e = new CbtEventArgs(wParam, lParam);
- WindowCreate(this, e);
- }
- }
-
- // handle the DESTROYWND hook event
- private void HandleDestroyWndEvent(IntPtr wParam, IntPtr lParam)
- {
- if (WindowDestroye != null)
- {
- CbtEventArgs e = new CbtEventArgs(wParam, lParam);
- WindowDestroye(this, e);
- }
- }
-
- // handle the ACTIVATE hook event
- private void HandleActivateEvent(IntPtr wParam, IntPtr lParam)
- {
- if (WindowActivate != null)
- {
- CbtEventArgs e = new CbtEventArgs(wParam, lParam);
- WindowActivate(this, e);
- }
- }
- }
- #endregion
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/App.config
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/App.config Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/MainForm.Designer.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/MainForm.Designer.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,62 @@
+namespace SharpDisplayClient
+{
+ partial class MainForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonSetText = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // buttonSetText
+ //
+ this.buttonSetText.Location = new System.Drawing.Point(170, 104);
+ this.buttonSetText.Name = "buttonSetText";
+ this.buttonSetText.Size = new System.Drawing.Size(75, 23);
+ this.buttonSetText.TabIndex = 0;
+ this.buttonSetText.Text = "Set Text";
+ this.buttonSetText.UseVisualStyleBackColor = true;
+ this.buttonSetText.Click += new System.EventHandler(this.buttonSetText_Click);
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(443, 252);
+ this.Controls.Add(this.buttonSetText);
+ this.Name = "MainForm";
+ this.Text = "Sharp Display Client";
+ this.Load += new System.EventHandler(this.MainForm_Load);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button buttonSetText;
+ }
+}
+
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/MainForm.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/MainForm.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,43 @@
+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.ServiceModel;
+using System.ServiceModel.Channels;
+using SharpDisplayManager;
+
+namespace SharpDisplayClient
+{
+ public partial class MainForm : Form
+ {
+ ChannelFactory iChannelFactory;
+ SharpDisplayManager.IDisplayService iClient;
+
+ public MainForm()
+ {
+ InitializeComponent();
+ }
+
+ private void buttonSetText_Click(object sender, EventArgs e)
+ {
+ iClient.SetText(0,"Top");
+ iClient.SetText(1, "Bottom");
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+
+ iChannelFactory = new ChannelFactory(
+ new NetNamedPipeBinding(),
+ new EndpointAddress(
+ "net.pipe://localhost/DisplayService"));
+
+ iClient = iChannelFactory.CreateChannel();
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/MainForm.resx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/MainForm.resx Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/Program.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/Program.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SharpDisplayClient
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new MainForm());
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/Properties/AssemblyInfo.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/Properties/AssemblyInfo.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SharpDisplayClient")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SharpDisplayClient")]
+[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("36255ddc-eb97-4253-8696-3e360b5bc824")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/Properties/Resources.Designer.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/Properties/Resources.Designer.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18444
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SharpDisplayClient.Properties
+{
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDisplayClient.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/Properties/Resources.resx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/Properties/Resources.resx Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/Properties/Settings.Designer.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/Properties/Settings.Designer.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18444
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SharpDisplayClient.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/Properties/Settings.settings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/Properties/Settings.settings Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff -r 19c1aaf900dc -r 7acec5059fa6 Client/SharpDisplayClient.csproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Client/SharpDisplayClient.csproj Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,95 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7EE64074-8CDB-4448-B40C-81B75D6B31CD}
+ WinExe
+ Properties
+ SharpDisplayClient
+ SharpDisplayClient
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ MainForm.cs
+
+
+
+
+ MainForm.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+ {1da8c1b3-18c5-4e74-be4e-0b0e15fbaf49}
+ SharpDisplayManager
+
+
+
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 DialogBox.cs
--- a/DialogBox.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,630 +0,0 @@
-//=============================================================================
-// COPYRIGHT: Prosoft-Lanz
-//=============================================================================
-//
-// $Workfile: DialogBox.cs $
-//
-// PROJECT : CodeProject Components
-// VERSION : 1.00
-// CREATION : 19.02.2003
-// AUTHOR : JCL
-//
-// DETAILS : DialogBoxes centered into the parent owner.
-// This class implement the following objects:
-//
-// DlgBox.ShowDialog(...) for CommonDialog and Form
-// MsgBox.Show(...) for standard MessageBox
-// AppBox.Show(...) for standard MessageBox with ProductName as caption
-// ErrBox.Show(...) for standard error MessageBox
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using System.Runtime.InteropServices;
-using System.Diagnostics;
-
-using CodeProject.Win32API;
-using CodeProject.Win32API.Hook;
-
-namespace CodeProject.Dialog
-{
- ///////////////////////////////////////////////////////////////////////
- #region DlgBox
-
- ///
- /// Class to display a CommonDialog or modal Form centered on the owner.
- ///
- ///
- /// This example display the default print dialog box in the center of the parent.
- ///
- /// PrintDialog printDlg = new PrintDialog();
- /// if (DlgBox.ShowDialog(printDlg, parent) == DialogResult.OK)
- /// printDocument.Print();
- ///
- ///
- public sealed class DlgBox
- {
- private DlgBox() {} // To remove the constructor from the documentation!
-
- ///////////////////////////////////////////////////////////////////////
- // CommonDialog
-
- ///
- /// Show a command dialog box at the center of the active window.
- ///
- public static DialogResult ShowDialog(CommonDialog dlg)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = dlg.ShowDialog();
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// Show a command dialog box at the center of the owner window.
- ///
- public static DialogResult ShowDialog(CommonDialog dlg, IWin32Window owner)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = dlg.ShowDialog();
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // Form
-
- ///
- /// Show a form dialog box at the center of the active window.
- ///
- public static DialogResult ShowDialog(Form form)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = form.ShowDialog();
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// Show a form dialog box at the center of the owner window.
- ///
- public static DialogResult ShowDialog(Form form, IWin32Window owner)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = form.ShowDialog();
- centerWindow.Dispose();
- return dlgResult;
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region MsgBox
-
- ///
- /// Class to display a MessageBox centered on the owner.
- ///
- ///
- /// Same methods as the standard MessageBox.
- ///
- ///
- /// This example display a "Hello" message box centered on the owner.
- ///
- /// MsgBox.Show("Hello");
- ///
- ///
- public sealed class MsgBox
- {
- private MsgBox() {} // To remove the constructor from the documentation!
-
- ///////////////////////////////////////////////////////////////////////
- // text
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(string text)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(text, caption);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(IWin32Window owner, string text)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(owner, text, caption);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, caption
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(string text, string caption)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = MessageBox.Show(text, caption);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(IWin32Window owner, string text, string caption)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = MessageBox.Show(owner, text, caption);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, caption, buttons
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, caption, buttons, defaultButton
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, caption, buttons, defaultButton, icon
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, caption, buttons, defaultButton, icon, options
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method.
- ///
- public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
- centerWindow.Dispose();
- return dlgResult;
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region AppBox
-
- ///
- /// Class to display a MessageBox centered on the owner.
- /// The MessageBox caption is always Application.ProductName.
- ///
- ///
- /// Same methods as the standard MessageBox without caption.
- ///
- ///
- /// This example display an application message box centered on the owner.
- ///
- /// AppBox.Show("Hello");
- ///
- ///
- public sealed class AppBox
- {
- private AppBox() {} // To remove the constructor from the documentation!
-
- ///////////////////////////////////////////////////////////////////////
- // text
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(string text)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(text, caption);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(IWin32Window owner, string text)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(owner, text, caption);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, buttons
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(string text, MessageBoxButtons buttons)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, buttons, defaultButton
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, buttons, defaultButton, icon
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///////////////////////////////////////////////////////////////////////
- // text, buttons, defaultButton, icon, options
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
- {
- CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
- centerWindow.Dispose();
- return dlgResult;
- }
-
- ///
- /// See MSDN MessageBox() method. Caption is Application.ProductName.
- ///
- public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
- {
- IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
- CenterWindow centerWindow = new CenterWindow(handle);
- string caption = Application.ProductName;
- DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
- centerWindow.Dispose();
- return dlgResult;
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region ErrBox
-
- ///
- /// Class to display application error MessageBox centered on the owner.
- /// The caption of the MessageBox is Application.ProductName.
- ///
- ///
- /// This example display an error message box centered on the owner.
- ///
- /// ErrBox.Show(ex);
- ///
- ///
- public sealed class ErrBox
- {
- private ErrBox() {} // To remove the constructor from the documentation!
-
- ///
- /// Show an error MessageBox with an icon error and an OK button.
- ///
- /// The error message.
- /// The owner of the error MessageBox.
- /// Dialog result of the MessageBox.
- public static DialogResult Show(IWin32Window owner, string err)
- {
- string caption = Application.ProductName;
- return MsgBox.Show(owner, err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- ///
- /// Show an error MessageBox with an icon error and an OK button.
- ///
- /// The error message.
- /// Dialog result of the MessageBox.
- public static DialogResult Show(string err)
- {
- string caption = Application.ProductName;
- return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- ///
- /// Show an error MessageBox with exception message, an icon error and an OK button.
- ///
- /// Exception to be displayed.
- /// Dialog result of the MessageBox.
- public static DialogResult Show(Exception ex)
- {
- string err = ex.Message;
- while (ex.InnerException != null)
- {
- ex = ex.InnerException;
- err += Environment.NewLine;
- err += ex.Message;
- }
- string caption = Application.ProductName;
- return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
-
- ///
- /// Show a specialized error MessageBox centered into the parent owner.
- ///
- /// Exception to be displayed.
- /// true to display the full informations else false.
- /// Dialog result of the MessageBox.
- public static DialogResult Show(Exception ex, bool debugMode)
- {
- if (debugMode)
- return Show(ex);
- else
- return Show(ex.Message);
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region CenterWindow class
-
- internal sealed class CenterWindow
- {
- public IntPtr hOwner = IntPtr.Zero;
- private Rectangle rect;
-
- public CbtHook cbtHook = null;
- public WndProcRetHook wndProcRetHook = null;
-
- public CenterWindow(IntPtr hOwner)
- {
- this.hOwner = hOwner;
- this.cbtHook = new CbtHook();
- cbtHook.WindowActivate += new CbtHook.CbtEventHandler(WndActivate);
- cbtHook.Install();
- }
-
- public void Dispose()
- {
- if (wndProcRetHook != null)
- {
- wndProcRetHook.Uninstall();
- wndProcRetHook = null;
- }
- if (cbtHook != null)
- {
- cbtHook.Uninstall();
- cbtHook = null;
- }
- }
-
- public void WndActivate(object sender, CbtEventArgs e)
- {
- IntPtr hMsgBox = e.wParam;
-
- // try to find a howner for this message box
- if (hOwner == IntPtr.Zero)
- hOwner = USER32.GetActiveWindow();
-
- // get the MessageBox window rect
- RECT rectDlg = new RECT();
- USER32.GetWindowRect(hMsgBox, ref rectDlg);
-
- // get the owner window rect
- RECT rectForm = new RECT();
- USER32.GetWindowRect(hOwner, ref rectForm);
-
- // get the biggest screen area
- Rectangle rectScreen = API.TrueScreenRect;
-
- // if no parent window, center on the primary screen
- if (rectForm.right == rectForm.left)
- rectForm.right = rectForm.left = Screen.PrimaryScreen.WorkingArea.Width / 2;
- if (rectForm.bottom == rectForm.top)
- rectForm.bottom = rectForm.top = Screen.PrimaryScreen.WorkingArea.Height / 2;
-
- // center on parent
- int dx = ((rectDlg.left + rectDlg.right) - (rectForm.left + rectForm.right)) / 2;
- int dy = ((rectDlg.top + rectDlg.bottom) - (rectForm.top + rectForm.bottom)) / 2;
-
- rect = new Rectangle(
- rectDlg.left - dx,
- rectDlg.top - dy,
- rectDlg.right - rectDlg.left,
- rectDlg.bottom - rectDlg.top);
-
- // place in the screen
- if (rect.Right > rectScreen.Right) rect.Offset(rectScreen.Right - rect.Right, 0);
- if (rect.Bottom > rectScreen.Bottom) rect.Offset(0, rectScreen.Bottom - rect.Bottom);
- if (rect.Left < rectScreen.Left) rect.Offset(rectScreen.Left - rect.Left, 0);
- if (rect.Top < rectScreen.Top) rect.Offset(0, rectScreen.Top - rect.Top);
-
- if (e.IsDialog)
- {
- // do the job when the WM_INITDIALOG message returns
- wndProcRetHook = new WndProcRetHook(hMsgBox);
- wndProcRetHook.WndProcRet += new WndProcRetHook.WndProcEventHandler(WndProcRet);
- wndProcRetHook.Install();
- }
- else
- USER32.MoveWindow(hMsgBox, rect.Left, rect.Top, rect.Width, rect.Height, 1);
-
- // uninstall this hook
- WindowsHook wndHook = (WindowsHook)sender;
- Debug.Assert(cbtHook == wndHook);
- cbtHook.Uninstall();
- cbtHook = null;
- }
-
- public void WndProcRet(object sender, WndProcRetEventArgs e)
- {
- if (e.cw.message == WndMessage.WM_INITDIALOG ||
- e.cw.message == WndMessage.WM_UNKNOWINIT)
- {
- USER32.MoveWindow(e.cw.hwnd, rect.Left, rect.Top, rect.Width, rect.Height, 1);
-
- // uninstall this hook
- WindowsHook wndHook = (WindowsHook)sender;
- Debug.Assert(wndProcRetHook == wndHook);
- wndProcRetHook.Uninstall();
- wndProcRetHook = null;
- }
- }
- }
- #endregion
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Display.cs
--- a/Display.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,243 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-//
-using System.Runtime.InteropServices;
-
-namespace SharpDisplayManager
-{
- class Display
- {
-
- //Constructor
- public Display()
- {
- iDevice = IntPtr.Zero;
- }
-
- //
- public bool Open()
- {
- if (iDevice == IntPtr.Zero)
- {
- iDevice = MiniDisplayOpen();
- }
- return iDevice != IntPtr.Zero;
- }
-
- public void Close()
- {
- MiniDisplayClose(iDevice);
- iDevice = IntPtr.Zero;
- }
-
- public bool IsOpen()
- {
- return iDevice != IntPtr.Zero;
- }
-
- public void Clear()
- {
- MiniDisplayClear(iDevice);
- }
-
- public void Fill()
- {
- MiniDisplayFill(iDevice);
- }
-
- public void SwapBuffers()
- {
- MiniDisplaySwapBuffers(iDevice);
- }
-
- public int MaxBrightness()
- {
- return MiniDisplayMaxBrightness(iDevice);
- }
-
- public int MinBrightness()
- {
- return MiniDisplayMinBrightness(iDevice);
- }
-
- public void SetBrightness(int aBrightness)
- {
- if (!IsOpen()) return;
-
- MiniDisplaySetBrightness(iDevice, aBrightness);
- }
-
- public int WidthInPixels()
- {
- return MiniDisplayWidthInPixels(iDevice);
- }
-
- public int HeightInPixels()
- {
- return MiniDisplayHeightInPixels(iDevice);
- }
-
- public void SetPixel(int aX, int aY, int aValue)
- {
- MiniDisplaySetPixel(iDevice,aX,aY,aValue);
- }
-
- public void RequestPowerSupplyStatus()
- {
- MiniDisplayRequestPowerSupplyStatus(iDevice);
- }
-
- public void RequestDeviceId()
- {
- MiniDisplayRequestDeviceId(iDevice);
- }
-
- public void RequestFirmwareRevision()
- {
- MiniDisplayRequestFirmwareRevision(iDevice);
- }
-
- public bool PowerSupplyStatus()
- {
- bool res = MiniDisplayPowerSupplyStatus(iDevice);
- return res;
- }
-
- public TMiniDisplayRequest AttemptRequestCompletion()
- {
- return MiniDisplayAttemptRequestCompletion(iDevice);
- }
-
- public TMiniDisplayRequest CurrentRequest()
- {
- return MiniDisplayCurrentRequest(iDevice);
- }
-
- public bool IsRequestPending()
- {
- return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
- }
-
-
- public string Vendor()
- {
- IntPtr ptr = MiniDisplayVendor(iDevice);
- string str = Marshal.PtrToStringUni(ptr);
- return str;
- }
-
- public string Product()
- {
- IntPtr ptr = MiniDisplayProduct(iDevice);
- string str = Marshal.PtrToStringUni(ptr);
- return str;
- }
-
- public string SerialNumber()
- {
- IntPtr ptr = MiniDisplaySerialNumber(iDevice);
- string str = Marshal.PtrToStringUni(ptr);
- return str;
- }
-
- public string DeviceId()
- {
- IntPtr ptr = MiniDisplayDeviceId(iDevice);
- string str = Marshal.PtrToStringAnsi(ptr);
- return str;
- }
-
- public string FirmwareRevision()
- {
- IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
- string str = Marshal.PtrToStringAnsi(ptr);
- return str;
- }
-
- //Our display device handle
- IntPtr iDevice;
-
- public enum TMiniDisplayRequest
- {
- EMiniDisplayRequestNone,
- EMiniDisplayRequestDeviceId,
- EMiniDisplayRequestFirmwareRevision,
- EMiniDisplayRequestPowerSupplyStatus
- }
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr MiniDisplayOpen();
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayClose(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayClear(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayFill(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- [return: MarshalAs(UnmanagedType.I1)]
- public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
-
- [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
- public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
-
-
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 MainForm.Designer.cs
--- a/MainForm.Designer.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,432 +0,0 @@
-namespace SharpDisplayManager
-{
- partial class MainForm
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.tabControl = new System.Windows.Forms.TabControl();
- this.tabPageDisplay = new System.Windows.Forms.TabPage();
- this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox();
- this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox();
- this.panelDisplay = new System.Windows.Forms.Panel();
- this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
- this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
- this.trackBarBrightness = new System.Windows.Forms.TrackBar();
- this.buttonFill = new System.Windows.Forms.Button();
- this.buttonClear = new System.Windows.Forms.Button();
- this.buttonClose = new System.Windows.Forms.Button();
- this.buttonOpen = new System.Windows.Forms.Button();
- this.buttonCapture = new System.Windows.Forms.Button();
- this.buttonFont = new System.Windows.Forms.Button();
- this.tabPageTests = new System.Windows.Forms.TabPage();
- this.fontDialog = new System.Windows.Forms.FontDialog();
- this.timer = new System.Windows.Forms.Timer(this.components);
- this.statusStrip = new System.Windows.Forms.StatusStrip();
- this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
- this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
- this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
- this.tabControl.SuspendLayout();
- this.tabPageDisplay.SuspendLayout();
- this.panelDisplay.SuspendLayout();
- this.tableLayoutPanel.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
- this.statusStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // tabControl
- //
- this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.tabControl.Controls.Add(this.tabPageDisplay);
- this.tabControl.Controls.Add(this.tabPageTests);
- this.tabControl.Location = new System.Drawing.Point(12, 12);
- this.tabControl.Name = "tabControl";
- this.tabControl.SelectedIndex = 0;
- this.tabControl.Size = new System.Drawing.Size(600, 395);
- this.tabControl.TabIndex = 0;
- //
- // tabPageDisplay
- //
- this.tabPageDisplay.Controls.Add(this.checkBoxReverseScreen);
- this.tabPageDisplay.Controls.Add(this.checkBoxConnectOnStartup);
- this.tabPageDisplay.Controls.Add(this.panelDisplay);
- this.tabPageDisplay.Controls.Add(this.checkBoxShowBorders);
- this.tabPageDisplay.Controls.Add(this.trackBarBrightness);
- this.tabPageDisplay.Controls.Add(this.buttonFill);
- this.tabPageDisplay.Controls.Add(this.buttonClear);
- this.tabPageDisplay.Controls.Add(this.buttonClose);
- this.tabPageDisplay.Controls.Add(this.buttonOpen);
- this.tabPageDisplay.Controls.Add(this.buttonCapture);
- this.tabPageDisplay.Controls.Add(this.buttonFont);
- this.tabPageDisplay.Location = new System.Drawing.Point(4, 22);
- this.tabPageDisplay.Name = "tabPageDisplay";
- this.tabPageDisplay.Padding = new System.Windows.Forms.Padding(3);
- this.tabPageDisplay.Size = new System.Drawing.Size(592, 369);
- this.tabPageDisplay.TabIndex = 0;
- this.tabPageDisplay.Text = "Display";
- this.tabPageDisplay.UseVisualStyleBackColor = true;
- //
- // checkBoxReverseScreen
- //
- this.checkBoxReverseScreen.AutoSize = true;
- this.checkBoxReverseScreen.Location = new System.Drawing.Point(113, 298);
- this.checkBoxReverseScreen.Name = "checkBoxReverseScreen";
- this.checkBoxReverseScreen.Size = new System.Drawing.Size(101, 17);
- this.checkBoxReverseScreen.TabIndex = 14;
- this.checkBoxReverseScreen.Text = "Reverse screen";
- this.checkBoxReverseScreen.UseVisualStyleBackColor = true;
- this.checkBoxReverseScreen.CheckedChanged += new System.EventHandler(this.checkBoxReverseScreen_CheckedChanged);
- //
- // checkBoxConnectOnStartup
- //
- this.checkBoxConnectOnStartup.AutoSize = true;
- this.checkBoxConnectOnStartup.Location = new System.Drawing.Point(113, 321);
- this.checkBoxConnectOnStartup.Name = "checkBoxConnectOnStartup";
- this.checkBoxConnectOnStartup.Size = new System.Drawing.Size(119, 17);
- this.checkBoxConnectOnStartup.TabIndex = 13;
- this.checkBoxConnectOnStartup.Text = "Connect on stratup ";
- this.checkBoxConnectOnStartup.UseVisualStyleBackColor = true;
- this.checkBoxConnectOnStartup.CheckedChanged += new System.EventHandler(this.checkBoxConnectOnStartup_CheckedChanged);
- //
- // panelDisplay
- //
- this.panelDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panelDisplay.Controls.Add(this.tableLayoutPanel);
- this.panelDisplay.Location = new System.Drawing.Point(181, 151);
- this.panelDisplay.Margin = new System.Windows.Forms.Padding(0);
- this.panelDisplay.Name = "panelDisplay";
- this.panelDisplay.Size = new System.Drawing.Size(258, 66);
- this.panelDisplay.TabIndex = 12;
- //
- // tableLayoutPanel
- //
- this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.tableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
- this.tableLayoutPanel.ColumnCount = 1;
- this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
- this.tableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0);
- this.tableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1);
- this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
- this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
- this.tableLayoutPanel.Name = "tableLayoutPanel";
- this.tableLayoutPanel.RowCount = 2;
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
- this.tableLayoutPanel.TabIndex = 5;
- //
- // checkBoxShowBorders
- //
- this.checkBoxShowBorders.AutoSize = true;
- this.checkBoxShowBorders.Location = new System.Drawing.Point(113, 344);
- this.checkBoxShowBorders.Name = "checkBoxShowBorders";
- this.checkBoxShowBorders.Size = new System.Drawing.Size(91, 17);
- this.checkBoxShowBorders.TabIndex = 11;
- this.checkBoxShowBorders.Text = "Show borders";
- this.checkBoxShowBorders.UseVisualStyleBackColor = true;
- this.checkBoxShowBorders.CheckedChanged += new System.EventHandler(this.checkBoxShowBorders_CheckedChanged);
- //
- // trackBarBrightness
- //
- this.trackBarBrightness.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
- this.trackBarBrightness.Location = new System.Drawing.Point(544, 9);
- this.trackBarBrightness.Name = "trackBarBrightness";
- this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
- this.trackBarBrightness.Size = new System.Drawing.Size(45, 357);
- this.trackBarBrightness.TabIndex = 10;
- this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
- this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
- //
- // buttonFill
- //
- this.buttonFill.Location = new System.Drawing.Point(6, 93);
- this.buttonFill.Name = "buttonFill";
- this.buttonFill.Size = new System.Drawing.Size(75, 23);
- this.buttonFill.TabIndex = 9;
- this.buttonFill.Text = "Fill";
- this.buttonFill.UseVisualStyleBackColor = true;
- this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click);
- //
- // buttonClear
- //
- this.buttonClear.Location = new System.Drawing.Point(6, 64);
- this.buttonClear.Name = "buttonClear";
- this.buttonClear.Size = new System.Drawing.Size(75, 23);
- this.buttonClear.TabIndex = 8;
- this.buttonClear.Text = "Clear";
- this.buttonClear.UseVisualStyleBackColor = true;
- this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
- //
- // buttonClose
- //
- this.buttonClose.Location = new System.Drawing.Point(6, 35);
- this.buttonClose.Name = "buttonClose";
- this.buttonClose.Size = new System.Drawing.Size(75, 23);
- this.buttonClose.TabIndex = 7;
- this.buttonClose.Text = "Close";
- this.buttonClose.UseVisualStyleBackColor = true;
- this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
- //
- // buttonOpen
- //
- this.buttonOpen.Location = new System.Drawing.Point(6, 6);
- this.buttonOpen.Name = "buttonOpen";
- this.buttonOpen.Size = new System.Drawing.Size(75, 23);
- this.buttonOpen.TabIndex = 6;
- this.buttonOpen.Text = "Open";
- this.buttonOpen.UseVisualStyleBackColor = true;
- this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
- //
- // buttonCapture
- //
- this.buttonCapture.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonCapture.Location = new System.Drawing.Point(6, 311);
- this.buttonCapture.Name = "buttonCapture";
- this.buttonCapture.Size = new System.Drawing.Size(75, 23);
- this.buttonCapture.TabIndex = 5;
- this.buttonCapture.Text = "Capture";
- this.buttonCapture.UseVisualStyleBackColor = true;
- this.buttonCapture.Click += new System.EventHandler(this.buttonCapture_Click);
- //
- // buttonFont
- //
- this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonFont.Location = new System.Drawing.Point(6, 340);
- this.buttonFont.Name = "buttonFont";
- this.buttonFont.Size = new System.Drawing.Size(75, 23);
- this.buttonFont.TabIndex = 0;
- this.buttonFont.Text = "Select Font";
- this.buttonFont.UseVisualStyleBackColor = true;
- this.buttonFont.Click += new System.EventHandler(this.buttonFont_Click);
- //
- // tabPageTests
- //
- this.tabPageTests.Location = new System.Drawing.Point(4, 22);
- this.tabPageTests.Name = "tabPageTests";
- this.tabPageTests.Padding = new System.Windows.Forms.Padding(3);
- this.tabPageTests.Size = new System.Drawing.Size(592, 369);
- this.tabPageTests.TabIndex = 1;
- this.tabPageTests.Text = "Test";
- this.tabPageTests.UseVisualStyleBackColor = true;
- //
- // timer
- //
- this.timer.Enabled = true;
- this.timer.Interval = 50;
- this.timer.Tick += new System.EventHandler(this.timer_Tick);
- //
- // statusStrip
- //
- this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelConnect,
- this.toolStripStatusLabelSpring,
- this.toolStripStatusLabelPower,
- this.toolStripStatusLabelFps});
- this.statusStrip.Location = new System.Drawing.Point(0, 420);
- this.statusStrip.Name = "statusStrip";
- this.statusStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
- this.statusStrip.Size = new System.Drawing.Size(624, 22);
- this.statusStrip.TabIndex = 1;
- this.statusStrip.Text = "statusStrip";
- //
- // toolStripStatusLabelConnect
- //
- this.toolStripStatusLabelConnect.Name = "toolStripStatusLabelConnect";
- this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17);
- this.toolStripStatusLabelConnect.Text = "Not connected";
- //
- // toolStripStatusLabelSpring
- //
- this.toolStripStatusLabelSpring.Name = "toolStripStatusLabelSpring";
- this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(473, 17);
- this.toolStripStatusLabelSpring.Spring = true;
- //
- // toolStripStatusLabelPower
- //
- this.toolStripStatusLabelPower.Name = "toolStripStatusLabelPower";
- this.toolStripStatusLabelPower.Size = new System.Drawing.Size(24, 17);
- this.toolStripStatusLabelPower.Text = "NA";
- //
- // toolStripStatusLabelFps
- //
- this.toolStripStatusLabelFps.Name = "toolStripStatusLabelFps";
- this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
- this.toolStripStatusLabelFps.Text = "FPS";
- //
- // marqueeLabelTop
- //
- this.marqueeLabelTop.AutoEllipsis = true;
- this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
- this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
- this.marqueeLabelTop.Location = new System.Drawing.Point(1, -124);
- this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
- this.marqueeLabelTop.Name = "marqueeLabelTop";
- this.marqueeLabelTop.OwnTimer = false;
- this.marqueeLabelTop.PixelsPerSecond = 64;
- this.marqueeLabelTop.Separator = "|";
- this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20);
- this.marqueeLabelTop.TabIndex = 2;
- this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
- this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.marqueeLabelTop.UseCompatibleTextRendering = true;
- //
- // marqueeLabelBottom
- //
- this.marqueeLabelBottom.AutoEllipsis = true;
- this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
- this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -40);
- this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
- this.marqueeLabelBottom.Name = "marqueeLabelBottom";
- this.marqueeLabelBottom.OwnTimer = false;
- this.marqueeLabelBottom.PixelsPerSecond = 64;
- this.marqueeLabelBottom.Separator = null;
- this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
- this.marqueeLabelBottom.TabIndex = 3;
- this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
- this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
- this.marqueeLabelBottom.UseCompatibleTextRendering = true;
- //
- // MainForm
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(624, 442);
- this.Controls.Add(this.statusStrip);
- this.Controls.Add(this.tabControl);
- this.MinimumSize = new System.Drawing.Size(640, 480);
- this.Name = "MainForm";
- this.Text = "Sharp Display Manager";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
- this.Load += new System.EventHandler(this.MainForm_Load);
- this.Resize += new System.EventHandler(this.MainForm_Resize);
- this.tabControl.ResumeLayout(false);
- this.tabPageDisplay.ResumeLayout(false);
- this.tabPageDisplay.PerformLayout();
- this.panelDisplay.ResumeLayout(false);
- this.tableLayoutPanel.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
- this.statusStrip.ResumeLayout(false);
- this.statusStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.TabControl tabControl;
- private System.Windows.Forms.TabPage tabPageDisplay;
- private System.Windows.Forms.TabPage tabPageTests;
- private System.Windows.Forms.Button buttonFont;
- private System.Windows.Forms.FontDialog fontDialog;
- private System.Windows.Forms.Button buttonCapture;
- private System.Windows.Forms.Timer timer;
- private System.Windows.Forms.Button buttonFill;
- private System.Windows.Forms.Button buttonClear;
- private System.Windows.Forms.Button buttonClose;
- private System.Windows.Forms.Button buttonOpen;
- private System.Windows.Forms.TrackBar trackBarBrightness;
- private System.Windows.Forms.StatusStrip statusStrip;
- private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect;
- private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps;
- private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring;
- private System.Windows.Forms.CheckBox checkBoxShowBorders;
- private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower;
- private System.Windows.Forms.Panel panelDisplay;
- private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
- public MarqueeLabel marqueeLabelTop;
- public MarqueeLabel marqueeLabelBottom;
- private System.Windows.Forms.CheckBox checkBoxConnectOnStartup;
- private System.Windows.Forms.CheckBox checkBoxReverseScreen;
- }
-}
-
diff -r 19c1aaf900dc -r 7acec5059fa6 MainForm.cs
--- a/MainForm.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,368 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using System.IO;
-using CodeProject.Dialog;
-using System.Drawing.Imaging;
-using System.ServiceModel;
-
-
-namespace SharpDisplayManager
-{
- public partial class MainForm : Form
- {
- DateTime LastTickTime;
- Display iDisplay;
- System.Drawing.Bitmap iBmp;
- bool iCreateBitmap; //Workaround render to bitmap issues when minimized
- ServiceHost iServiceHost;
-
- public MainForm()
- {
- LastTickTime = DateTime.Now;
- iDisplay = new Display();
-
- InitializeComponent();
- UpdateStatus();
-
- //Load settings
- marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont;
- marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont;
- checkBoxShowBorders.Checked = Properties.Settings.Default.DisplayShowBorders;
- checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
- checkBoxReverseScreen.Checked = Properties.Settings.Default.DisplayReverseScreen;
- //
- tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
- //We have a bug when drawing minimized and reusing our bitmap
- iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
- iCreateBitmap = false;
- }
-
- private void MainForm_Load(object sender, EventArgs e)
- {
- StartServer();
-
- if (Properties.Settings.Default.DisplayConnectOnStartup)
- {
- iDisplay.Open();
- UpdateStatus();
- }
- }
-
-
- private void buttonFont_Click(object sender, EventArgs e)
- {
- //fontDialog.ShowColor = true;
- //fontDialog.ShowApply = true;
- fontDialog.ShowEffects = true;
- fontDialog.Font = marqueeLabelTop.Font;
- //fontDialog.ShowHelp = true;
-
- //fontDlg.MaxSize = 40;
- //fontDlg.MinSize = 22;
-
- //fontDialog.Parent = this;
- //fontDialog.StartPosition = FormStartPosition.CenterParent;
-
- //DlgBox.ShowDialog(fontDialog);
-
- //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
- if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
- {
-
- //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
-
- //MessageBox.Show("Ok");
- marqueeLabelTop.Font = fontDialog.Font;
- marqueeLabelBottom.Font = fontDialog.Font;
- Properties.Settings.Default.DisplayFont = fontDialog.Font;
- Properties.Settings.Default.Save();
- //label1.Font = fontDlg.Font;
- //textBox1.BackColor = fontDlg.Color;
- //label1.ForeColor = fontDlg.Color;
- }
- }
-
- private void buttonCapture_Click(object sender, EventArgs e)
- {
- System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
- tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
- //Bitmap bmpToSave = new Bitmap(bmp);
- bmp.Save("D:\\capture.png");
-
- marqueeLabelTop.Text = "Sweet";
-
- /*
- string outputFileName = "d:\\capture.png";
- using (MemoryStream memory = new MemoryStream())
- {
- using (FileStream fs = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
- {
- bmp.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
- byte[] bytes = memory.ToArray();
- fs.Write(bytes, 0, bytes.Length);
- }
- }
- */
-
- }
-
- private void CheckForRequestResults()
- {
- if (iDisplay.IsRequestPending())
- {
- switch (iDisplay.AttemptRequestCompletion())
- {
- case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus:
- if (iDisplay.PowerSupplyStatus())
- {
- toolStripStatusLabelPower.Text = "ON";
- }
- else
- {
- toolStripStatusLabelPower.Text = "OFF";
- }
- //Issue next request then
- iDisplay.RequestDeviceId();
- break;
-
- case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId:
- toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId();
- //Issue next request then
- iDisplay.RequestFirmwareRevision();
- break;
-
- case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision:
- toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision();
- //No more request to issue
- break;
- }
- }
- }
-
-
- public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
-
-
- public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
- {
- return aBmp.Width - aX - 1;
- }
-
- public int ScreenReversedY(System.Drawing.Bitmap aBmp, int aY)
- {
- return iBmp.Height - aY - 1;
- }
-
- public int ScreenX(System.Drawing.Bitmap aBmp, int aX)
- {
- return aX;
- }
-
- public int ScreenY(System.Drawing.Bitmap aBmp, int aY)
- {
- return aY;
- }
-
-
- //This is our timer tick responsible to perform our render
- private void timer_Tick(object sender, EventArgs e)
- {
- //Update our animations
- DateTime NewTickTime = DateTime.Now;
-
- marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
- marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
-
- //Update our display
- if (iDisplay.IsOpen())
- {
- CheckForRequestResults();
-
- //Draw to bitmap
- if (iCreateBitmap)
- {
- iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
- }
- tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
- //iBmp.Save("D:\\capture.png");
-
- //Select proper coordinate translation functions
- //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
- CoordinateTranslationDelegate screenX;
- CoordinateTranslationDelegate screenY;
-
- if (Properties.Settings.Default.DisplayReverseScreen)
- {
- screenX = ScreenReversedX;
- screenY = ScreenReversedY;
- }
- else
- {
- screenX = ScreenX;
- screenY = ScreenY;
- }
-
- //Send it to our display
- for (int i = 0; i < iBmp.Width; i++)
- {
- for (int j = 0; j < iBmp.Height; j++)
- {
- unchecked
- {
- uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
- //For some reason when the app is minimized in the task bar only the alpha of our color is set.
- //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
- iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
- }
- }
- }
-
- iDisplay.SwapBuffers();
-
- }
-
- //Compute instant FPS
- toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " FPS";
-
- LastTickTime = NewTickTime;
-
- }
-
- private void buttonOpen_Click(object sender, EventArgs e)
- {
- if (iDisplay.Open())
- {
- UpdateStatus();
- iDisplay.RequestPowerSupplyStatus();
- }
- else
- {
- UpdateStatus();
- toolStripStatusLabelConnect.Text = "Connection error";
- }
-
- }
-
- private void buttonClose_Click(object sender, EventArgs e)
- {
- iDisplay.Close();
- UpdateStatus();
- }
-
- private void buttonClear_Click(object sender, EventArgs e)
- {
- iDisplay.Clear();
- iDisplay.SwapBuffers();
- }
-
- private void buttonFill_Click(object sender, EventArgs e)
- {
- iDisplay.Fill();
- iDisplay.SwapBuffers();
- }
-
- private void trackBarBrightness_Scroll(object sender, EventArgs e)
- {
- Properties.Settings.Default.DisplayBrightness = trackBarBrightness.Value;
- Properties.Settings.Default.Save();
- iDisplay.SetBrightness(trackBarBrightness.Value);
-
- }
-
- private void UpdateStatus()
- {
- if (iDisplay.IsOpen())
- {
- buttonFill.Enabled = true;
- buttonClear.Enabled = true;
- buttonOpen.Enabled = false;
- buttonClose.Enabled = true;
- trackBarBrightness.Enabled = true;
- trackBarBrightness.Minimum = iDisplay.MinBrightness();
- trackBarBrightness.Maximum = iDisplay.MaxBrightness();
- trackBarBrightness.Value = Properties.Settings.Default.DisplayBrightness;
- trackBarBrightness.LargeChange = Math.Max(1,(iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
- trackBarBrightness.SmallChange = 1;
- iDisplay.SetBrightness(Properties.Settings.Default.DisplayBrightness);
-
- toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
- //+ " - " + iDisplay.SerialNumber();
- }
- else
- {
- buttonFill.Enabled = false;
- buttonClear.Enabled = false;
- buttonOpen.Enabled = true;
- buttonClose.Enabled = false;
- trackBarBrightness.Enabled = false;
- toolStripStatusLabelConnect.Text = "Disconnected";
- }
- }
-
-
-
- private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
- {
- //Save our show borders setting
- tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
- Properties.Settings.Default.DisplayShowBorders = checkBoxShowBorders.Checked;
- Properties.Settings.Default.Save();
- }
-
- private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
- {
- //Save our connect on startup setting
- Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
- Properties.Settings.Default.Save();
- }
-
- private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
- {
- //Save our reverse screen setting
- Properties.Settings.Default.DisplayReverseScreen = checkBoxReverseScreen.Checked;
- Properties.Settings.Default.Save();
- }
-
- private void MainForm_Resize(object sender, EventArgs e)
- {
- if (WindowState == FormWindowState.Minimized)
- {
- // Do some stuff
- //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
- iCreateBitmap = true;
- }
- }
-
- private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- StopServer();
- }
-
- public void StartServer()
- {
- iServiceHost = new ServiceHost
- (
- typeof(DisplayServer),
- new Uri[] { new Uri("net.pipe://localhost") }
- );
-
- iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetNamedPipeBinding(), "DisplayService");
- iServiceHost.Open();
- }
-
- public void StopServer()
- {
- //Tell connected client first? Is that possible?
- iServiceHost.Close();
- }
-
-
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 MainForm.resx
--- a/MainForm.resx Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
- 126, 17
-
-
- 206, 17
-
-
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 MarqueeLabel.cs
--- a/MarqueeLabel.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,293 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-//using System.Timers;
-using System.Windows.Forms;
-using System.Drawing;
-
-namespace SharpDisplayManager
-{
- [System.ComponentModel.DesignerCategory("Code")]
- public class MarqueeLabel : Label
- {
- private bool iOwnTimer;
- private StringFormat iStringFormat;
- private SolidBrush iBrush;
- private SizeF iTextSize;
- private SizeF iSeparatorSize;
-
- [Category("Appearance")]
- [Description("Separator in our scrolling loop.")]
- [DefaultValue(" | ")]
- [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
- public string Separator { get; set; }
-
- [Category("Behavior")]
- [Description("How fast is our text scrolling, in pixels per second.")]
- [DefaultValue(32)]
- [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
- public int PixelsPerSecond { get; set; }
-
- [Category("Behavior")]
- [Description("Use an internal or an external timer.")]
- [DefaultValue(true)]
- [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
- public bool OwnTimer
- {
- get
- {
- return iOwnTimer;
- }
- set
- {
- iOwnTimer = value;
-
- if (iOwnTimer)
- {
- Timer = new Timer();
- Timer.Interval = 10;
- Timer.Tick += new EventHandler(Timer_Tick);
- Timer.Start();
- }
- else
- {
- if (Timer != null)
- Timer.Dispose();
- Timer = null;
- }
-
- }
- }
-
- private int CurrentPosition { get; set; }
- private Timer Timer { get; set; }
- private DateTime LastTickTime { get; set; }
- private double PixelsLeft { get; set; }
- //DateTime a = new DateTime(2010, 05, 12, 13, 15, 00);
- //DateTime b = new DateTime(2010, 05, 12, 13, 45, 00);
- //Console.WriteLine(b.Subtract(a).TotalMinutes);
-
- public MarqueeLabel()
- {
- UseCompatibleTextRendering = true;
- //PixelsPerSecond = 32;
- LastTickTime = DateTime.Now;
- PixelsLeft = 0;
- iBrush = new SolidBrush(ForeColor);
- }
-
- public void UpdateAnimation(DateTime aLastTickTime, DateTime aNewTickTime)
- {
- if (!NeedToScroll())
- {
- CurrentPosition = 0;
- return;
- }
-
- while (CurrentPosition > (iTextSize.Width + iSeparatorSize.Width))
- {
- CurrentPosition -= ((int)(iTextSize.Width + iSeparatorSize.Width));
- }
-
- PixelsLeft += aNewTickTime.Subtract(aLastTickTime).TotalSeconds * PixelsPerSecond;
-
- //Keep track of our pixels left over
- //PixelsLeft = offset - Math.Truncate(offset);
- double offset = Math.Truncate(PixelsLeft);
- PixelsLeft -= offset;
-
- CurrentPosition += Convert.ToInt32(offset);
-
- /*
- if (offset > 1.0)
- {
- BackColor = Color.Red;
- }
- else if (offset==1.0)
- {
- if (BackColor != Color.White)
- {
- BackColor = Color.White;
- }
-
- }
- else
- {
- //Too slow
- //BackColor = Color.Green;
- }*/
-
- //Only redraw if something has changed
- if (offset != 0)
- {
- Invalidate();
- }
- }
-
- void Timer_Tick(object sender, EventArgs e)
- {
- DateTime NewTickTime = DateTime.Now;
- //
- UpdateAnimation(LastTickTime, NewTickTime);
- //
- LastTickTime = NewTickTime;
- }
-
- private StringFormat GetStringFormatFromContentAllignment(ContentAlignment ca)
- {
- StringFormat format = new StringFormat();
- format = StringFormat.GenericTypographic;
- switch (ca)
- {
- case ContentAlignment.TopCenter:
- format.Alignment = StringAlignment.Near;
- format.LineAlignment = StringAlignment.Center;
- break;
- case ContentAlignment.TopLeft:
- format.Alignment = StringAlignment.Near;
- format.LineAlignment = StringAlignment.Near;
- break;
- case ContentAlignment.TopRight:
- format.Alignment = StringAlignment.Near;
- format.LineAlignment = StringAlignment.Far;
- break;
- case ContentAlignment.MiddleCenter:
- format.Alignment = StringAlignment.Center;
- format.LineAlignment = StringAlignment.Center;
- break;
- case ContentAlignment.MiddleLeft:
- format.Alignment = StringAlignment.Center;
- format.LineAlignment = StringAlignment.Near;
- break;
- case ContentAlignment.MiddleRight:
- format.Alignment = StringAlignment.Center;
- format.LineAlignment = StringAlignment.Far;
- break;
- case ContentAlignment.BottomCenter:
- format.Alignment = StringAlignment.Far;
- format.LineAlignment = StringAlignment.Center;
- break;
- case ContentAlignment.BottomLeft:
- format.Alignment = StringAlignment.Far;
- format.LineAlignment = StringAlignment.Near;
- break;
- case ContentAlignment.BottomRight:
- format.Alignment = StringAlignment.Far;
- format.LineAlignment = StringAlignment.Far;
- break;
- }
-
- format.FormatFlags |= StringFormatFlags.NoWrap;
- format.FormatFlags |= StringFormatFlags.NoClip;
- format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
- format.Trimming = StringTrimming.None;
-
- return format;
- }
-
- protected override void OnForeColorChanged(EventArgs e)
- {
- //Color has changed recreate our brush
- iBrush = new SolidBrush(ForeColor);
-
- base.OnForeColorChanged(e);
- }
-
-
- private void HandleTextSizeChange()
- {
- //For all string measurements and drawing issues refer to the following article:
- // http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number
- //Update text size according to text and font
- Graphics g = this.CreateGraphics();
- g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
- iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
- iTextSize = g.MeasureString(Text, Font, Int32.MaxValue, iStringFormat);
- iSeparatorSize = g.MeasureString(Separator, Font, Int32.MaxValue, iStringFormat);
-
- if (NeedToScroll())
- {
- //Always align left when scrolling
- iStringFormat.Alignment = StringAlignment.Near;
- }
- }
-
- protected override void OnTextChanged(EventArgs e)
- {
- HandleTextSizeChange();
-
- base.OnTextChanged(e);
- }
-
- protected override void OnFontChanged(EventArgs e)
- {
- HandleTextSizeChange();
-
- base.OnFontChanged(e);
- }
-
- protected override void OnTextAlignChanged(EventArgs e)
- {
- iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
-
- base.OnTextAlignChanged(e);
-
- }
-
- protected override void OnPaint(PaintEventArgs e)
- {
- //Disable anti-aliasing
- e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
- if (NeedToScroll())
- {
- //Draw the first one
- e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
- e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
- //Draw separator
- e.Graphics.TranslateTransform(iTextSize.Width, 0);
- e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
- //Draw the last one
- e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
- e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
- }
- else
- {
- e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
- }
-
-
-
- //DrawText is not working without anti-aliasing. See: stackoverflow.com/questions/8283631/graphics-drawstring-vs-textrenderer-drawtextwhich-can-deliver-better-quality
- //TextRenderer.DrawText(e.Graphics, Text, Font, ClientRectangle, ForeColor, BackColor, iTextFormatFlags);
-
- //base.OnPaint(e);
- }
-
- public bool NeedToScroll()
- {
- //if (Width < e.Graphics.MeasureString(Text, Font).Width)
- if (Width < iTextSize.Width)
- {
- return true;
- }
- return false;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Timer != null)
- Timer.Dispose();
- }
- Timer = null;
- }
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Program.cs
--- a/Program.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace SharpDisplayManager
-{
- static class Program
- {
- public static MainForm iMainForm;
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- iMainForm = new MainForm();
- Application.Run(iMainForm);
- }
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Properties/AssemblyInfo.cs
--- a/Properties/AssemblyInfo.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("SharpDisplayManager")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("SharpDisplayManager")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("5da0f26b-76a6-41e8-832c-5b593b3a75b0")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff -r 19c1aaf900dc -r 7acec5059fa6 Properties/Resources.Designer.cs
--- a/Properties/Resources.Designer.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.18063
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace SharpDisplayManager.Properties
-{
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDisplayManager.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Properties/Resources.resx
--- a/Properties/Resources.resx Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Properties/Settings.Designer.cs
--- a/Properties/Settings.Designer.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace SharpDisplayManager.Properties {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default {
- get {
- return defaultInstance;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("1")]
- public int DisplayBrightness {
- get {
- return ((int)(this["DisplayBrightness"]));
- }
- set {
- this["DisplayBrightness"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("Microsoft Sans Serif, 9.75pt")]
- public global::System.Drawing.Font DisplayFont {
- get {
- return ((global::System.Drawing.Font)(this["DisplayFont"]));
- }
- set {
- this["DisplayFont"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("False")]
- public bool DisplayShowBorders {
- get {
- return ((bool)(this["DisplayShowBorders"]));
- }
- set {
- this["DisplayShowBorders"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("False")]
- public bool DisplayConnectOnStartup {
- get {
- return ((bool)(this["DisplayConnectOnStartup"]));
- }
- set {
- this["DisplayConnectOnStartup"] = value;
- }
- }
-
- [global::System.Configuration.UserScopedSettingAttribute()]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("False")]
- public bool DisplayReverseScreen {
- get {
- return ((bool)(this["DisplayReverseScreen"]));
- }
- set {
- this["DisplayReverseScreen"] = value;
- }
- }
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Properties/Settings.settings
--- a/Properties/Settings.settings Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-
-
-
-
- 1
-
-
- Microsoft Sans Serif, 9.75pt
-
-
- False
-
-
- False
-
-
- False
-
-
-
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/App.config
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/App.config Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+ Microsoft Sans Serif, 9.75pt
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/CbtHook.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/CbtHook.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,171 @@
+//=============================================================================
+// COPYRIGHT: Prosoft-Lanz
+//=============================================================================
+//
+// $Workfile: CbtHook.cs $
+//
+// PROJECT : CodeProject Components
+// VERSION : 1.00
+// CREATION : 19.02.2003
+// AUTHOR : JCL
+//
+// DETAILS : This class implement the WH_CBT Windows hook mechanism.
+// From MSDN, Dino Esposito.
+// WindowCreate, WindowDestroy and WindowActivate user events.
+//
+//-----------------------------------------------------------------------------
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace CodeProject.Win32API.Hook
+{
+ ///////////////////////////////////////////////////////////////////////
+ #region Enum CbtHookAction
+
+ ///
+ /// CBT hook actions.
+ ///
+ internal enum CbtHookAction : int
+ {
+ HCBT_MOVESIZE = 0,
+ HCBT_MINMAX = 1,
+ HCBT_QS = 2,
+ HCBT_CREATEWND = 3,
+ HCBT_DESTROYWND = 4,
+ HCBT_ACTIVATE = 5,
+ HCBT_CLICKSKIPPED = 6,
+ HCBT_KEYSKIPPED = 7,
+ HCBT_SYSCOMMAND = 8,
+ HCBT_SETFOCUS = 9
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Class CbtEventArgs
+
+ ///
+ /// Class used for WH_CBT hook event arguments.
+ ///
+ public class CbtEventArgs : EventArgs
+ {
+ /// wParam parameter.
+ public IntPtr wParam;
+ /// lParam parameter.
+ public IntPtr lParam;
+ /// Window class name.
+ public string className;
+ /// True if it is a dialog window.
+ public bool IsDialog;
+
+ internal CbtEventArgs(IntPtr wParam, IntPtr lParam)
+ {
+ // cache the parameters
+ this.wParam = wParam;
+ this.lParam = lParam;
+
+ // cache the window's class name
+ StringBuilder sb = new StringBuilder();
+ sb.Capacity = 256;
+ USER32.GetClassName(wParam, sb, 256);
+ className = sb.ToString();
+ IsDialog = (className == "#32770");
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Class CbtHook
+
+ ///
+ /// Class to expose the windows WH_CBT hook mechanism.
+ ///
+ public class CbtHook : WindowsHook
+ {
+ ///
+ /// WH_CBT hook delegate method.
+ ///
+ public delegate void CbtEventHandler(object sender, CbtEventArgs e);
+
+ ///
+ /// WH_CBT create event.
+ ///
+ public event CbtEventHandler WindowCreate;
+ ///
+ /// WH_CBT destroy event.
+ ///
+ public event CbtEventHandler WindowDestroye;
+ ///
+ /// WH_CBT activate event.
+ ///
+ public event CbtEventHandler WindowActivate;
+
+ ///
+ /// Construct a WH_CBT hook.
+ ///
+ public CbtHook() : base(HookType.WH_CBT)
+ {
+ this.HookInvoke += new HookEventHandler(CbtHookInvoked);
+ }
+ ///
+ /// Construct a WH_CBT hook giving a hook filter delegate method.
+ ///
+ /// Hook filter event.
+ public CbtHook(HookProc func) : base(HookType.WH_CBT, func)
+ {
+ this.HookInvoke += new HookEventHandler(CbtHookInvoked);
+ }
+
+ // handles the hook event
+ private void CbtHookInvoked(object sender, HookEventArgs e)
+ {
+ // handle hook events (only a few of available actions)
+ switch ((CbtHookAction)e.code)
+ {
+ case CbtHookAction.HCBT_CREATEWND:
+ HandleCreateWndEvent(e.wParam, e.lParam);
+ break;
+ case CbtHookAction.HCBT_DESTROYWND:
+ HandleDestroyWndEvent(e.wParam, e.lParam);
+ break;
+ case CbtHookAction.HCBT_ACTIVATE:
+ HandleActivateEvent(e.wParam, e.lParam);
+ break;
+ }
+ return;
+ }
+
+ // handle the CREATEWND hook event
+ private void HandleCreateWndEvent(IntPtr wParam, IntPtr lParam)
+ {
+ if (WindowCreate != null)
+ {
+ CbtEventArgs e = new CbtEventArgs(wParam, lParam);
+ WindowCreate(this, e);
+ }
+ }
+
+ // handle the DESTROYWND hook event
+ private void HandleDestroyWndEvent(IntPtr wParam, IntPtr lParam)
+ {
+ if (WindowDestroye != null)
+ {
+ CbtEventArgs e = new CbtEventArgs(wParam, lParam);
+ WindowDestroye(this, e);
+ }
+ }
+
+ // handle the ACTIVATE hook event
+ private void HandleActivateEvent(IntPtr wParam, IntPtr lParam)
+ {
+ if (WindowActivate != null)
+ {
+ CbtEventArgs e = new CbtEventArgs(wParam, lParam);
+ WindowActivate(this, e);
+ }
+ }
+ }
+ #endregion
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/DialogBox.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/DialogBox.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,630 @@
+//=============================================================================
+// COPYRIGHT: Prosoft-Lanz
+//=============================================================================
+//
+// $Workfile: DialogBox.cs $
+//
+// PROJECT : CodeProject Components
+// VERSION : 1.00
+// CREATION : 19.02.2003
+// AUTHOR : JCL
+//
+// DETAILS : DialogBoxes centered into the parent owner.
+// This class implement the following objects:
+//
+// DlgBox.ShowDialog(...) for CommonDialog and Form
+// MsgBox.Show(...) for standard MessageBox
+// AppBox.Show(...) for standard MessageBox with ProductName as caption
+// ErrBox.Show(...) for standard error MessageBox
+//
+//-----------------------------------------------------------------------------
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+using CodeProject.Win32API;
+using CodeProject.Win32API.Hook;
+
+namespace CodeProject.Dialog
+{
+ ///////////////////////////////////////////////////////////////////////
+ #region DlgBox
+
+ ///
+ /// Class to display a CommonDialog or modal Form centered on the owner.
+ ///
+ ///
+ /// This example display the default print dialog box in the center of the parent.
+ ///
+ /// PrintDialog printDlg = new PrintDialog();
+ /// if (DlgBox.ShowDialog(printDlg, parent) == DialogResult.OK)
+ /// printDocument.Print();
+ ///
+ ///
+ public sealed class DlgBox
+ {
+ private DlgBox() {} // To remove the constructor from the documentation!
+
+ ///////////////////////////////////////////////////////////////////////
+ // CommonDialog
+
+ ///
+ /// Show a command dialog box at the center of the active window.
+ ///
+ public static DialogResult ShowDialog(CommonDialog dlg)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = dlg.ShowDialog();
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// Show a command dialog box at the center of the owner window.
+ ///
+ public static DialogResult ShowDialog(CommonDialog dlg, IWin32Window owner)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = dlg.ShowDialog();
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Form
+
+ ///
+ /// Show a form dialog box at the center of the active window.
+ ///
+ public static DialogResult ShowDialog(Form form)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = form.ShowDialog();
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// Show a form dialog box at the center of the owner window.
+ ///
+ public static DialogResult ShowDialog(Form form, IWin32Window owner)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = form.ShowDialog();
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region MsgBox
+
+ ///
+ /// Class to display a MessageBox centered on the owner.
+ ///
+ ///
+ /// Same methods as the standard MessageBox.
+ ///
+ ///
+ /// This example display a "Hello" message box centered on the owner.
+ ///
+ /// MsgBox.Show("Hello");
+ ///
+ ///
+ public sealed class MsgBox
+ {
+ private MsgBox() {} // To remove the constructor from the documentation!
+
+ ///////////////////////////////////////////////////////////////////////
+ // text
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(string text)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(text, caption);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, caption
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(string text, string caption)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = MessageBox.Show(text, caption);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, string caption)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, caption, buttons
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, caption, buttons, defaultButton
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, caption, buttons, defaultButton, icon
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, caption, buttons, defaultButton, icon, options
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region AppBox
+
+ ///
+ /// Class to display a MessageBox centered on the owner.
+ /// The MessageBox caption is always Application.ProductName.
+ ///
+ ///
+ /// Same methods as the standard MessageBox without caption.
+ ///
+ ///
+ /// This example display an application message box centered on the owner.
+ ///
+ /// AppBox.Show("Hello");
+ ///
+ ///
+ public sealed class AppBox
+ {
+ private AppBox() {} // To remove the constructor from the documentation!
+
+ ///////////////////////////////////////////////////////////////////////
+ // text
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(string text)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(text, caption);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, buttons
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(string text, MessageBoxButtons buttons)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, buttons, defaultButton
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, buttons, defaultButton, icon
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // text, buttons, defaultButton, icon, options
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
+ {
+ CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+
+ ///
+ /// See MSDN MessageBox() method. Caption is Application.ProductName.
+ ///
+ public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
+ {
+ IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
+ CenterWindow centerWindow = new CenterWindow(handle);
+ string caption = Application.ProductName;
+ DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
+ centerWindow.Dispose();
+ return dlgResult;
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region ErrBox
+
+ ///
+ /// Class to display application error MessageBox centered on the owner.
+ /// The caption of the MessageBox is Application.ProductName.
+ ///
+ ///
+ /// This example display an error message box centered on the owner.
+ ///
+ /// ErrBox.Show(ex);
+ ///
+ ///
+ public sealed class ErrBox
+ {
+ private ErrBox() {} // To remove the constructor from the documentation!
+
+ ///
+ /// Show an error MessageBox with an icon error and an OK button.
+ ///
+ /// The error message.
+ /// The owner of the error MessageBox.
+ /// Dialog result of the MessageBox.
+ public static DialogResult Show(IWin32Window owner, string err)
+ {
+ string caption = Application.ProductName;
+ return MsgBox.Show(owner, err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ ///
+ /// Show an error MessageBox with an icon error and an OK button.
+ ///
+ /// The error message.
+ /// Dialog result of the MessageBox.
+ public static DialogResult Show(string err)
+ {
+ string caption = Application.ProductName;
+ return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ ///
+ /// Show an error MessageBox with exception message, an icon error and an OK button.
+ ///
+ /// Exception to be displayed.
+ /// Dialog result of the MessageBox.
+ public static DialogResult Show(Exception ex)
+ {
+ string err = ex.Message;
+ while (ex.InnerException != null)
+ {
+ ex = ex.InnerException;
+ err += Environment.NewLine;
+ err += ex.Message;
+ }
+ string caption = Application.ProductName;
+ return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+
+ ///
+ /// Show a specialized error MessageBox centered into the parent owner.
+ ///
+ /// Exception to be displayed.
+ /// true to display the full informations else false.
+ /// Dialog result of the MessageBox.
+ public static DialogResult Show(Exception ex, bool debugMode)
+ {
+ if (debugMode)
+ return Show(ex);
+ else
+ return Show(ex.Message);
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region CenterWindow class
+
+ internal sealed class CenterWindow
+ {
+ public IntPtr hOwner = IntPtr.Zero;
+ private Rectangle rect;
+
+ public CbtHook cbtHook = null;
+ public WndProcRetHook wndProcRetHook = null;
+
+ public CenterWindow(IntPtr hOwner)
+ {
+ this.hOwner = hOwner;
+ this.cbtHook = new CbtHook();
+ cbtHook.WindowActivate += new CbtHook.CbtEventHandler(WndActivate);
+ cbtHook.Install();
+ }
+
+ public void Dispose()
+ {
+ if (wndProcRetHook != null)
+ {
+ wndProcRetHook.Uninstall();
+ wndProcRetHook = null;
+ }
+ if (cbtHook != null)
+ {
+ cbtHook.Uninstall();
+ cbtHook = null;
+ }
+ }
+
+ public void WndActivate(object sender, CbtEventArgs e)
+ {
+ IntPtr hMsgBox = e.wParam;
+
+ // try to find a howner for this message box
+ if (hOwner == IntPtr.Zero)
+ hOwner = USER32.GetActiveWindow();
+
+ // get the MessageBox window rect
+ RECT rectDlg = new RECT();
+ USER32.GetWindowRect(hMsgBox, ref rectDlg);
+
+ // get the owner window rect
+ RECT rectForm = new RECT();
+ USER32.GetWindowRect(hOwner, ref rectForm);
+
+ // get the biggest screen area
+ Rectangle rectScreen = API.TrueScreenRect;
+
+ // if no parent window, center on the primary screen
+ if (rectForm.right == rectForm.left)
+ rectForm.right = rectForm.left = Screen.PrimaryScreen.WorkingArea.Width / 2;
+ if (rectForm.bottom == rectForm.top)
+ rectForm.bottom = rectForm.top = Screen.PrimaryScreen.WorkingArea.Height / 2;
+
+ // center on parent
+ int dx = ((rectDlg.left + rectDlg.right) - (rectForm.left + rectForm.right)) / 2;
+ int dy = ((rectDlg.top + rectDlg.bottom) - (rectForm.top + rectForm.bottom)) / 2;
+
+ rect = new Rectangle(
+ rectDlg.left - dx,
+ rectDlg.top - dy,
+ rectDlg.right - rectDlg.left,
+ rectDlg.bottom - rectDlg.top);
+
+ // place in the screen
+ if (rect.Right > rectScreen.Right) rect.Offset(rectScreen.Right - rect.Right, 0);
+ if (rect.Bottom > rectScreen.Bottom) rect.Offset(0, rectScreen.Bottom - rect.Bottom);
+ if (rect.Left < rectScreen.Left) rect.Offset(rectScreen.Left - rect.Left, 0);
+ if (rect.Top < rectScreen.Top) rect.Offset(0, rectScreen.Top - rect.Top);
+
+ if (e.IsDialog)
+ {
+ // do the job when the WM_INITDIALOG message returns
+ wndProcRetHook = new WndProcRetHook(hMsgBox);
+ wndProcRetHook.WndProcRet += new WndProcRetHook.WndProcEventHandler(WndProcRet);
+ wndProcRetHook.Install();
+ }
+ else
+ USER32.MoveWindow(hMsgBox, rect.Left, rect.Top, rect.Width, rect.Height, 1);
+
+ // uninstall this hook
+ WindowsHook wndHook = (WindowsHook)sender;
+ Debug.Assert(cbtHook == wndHook);
+ cbtHook.Uninstall();
+ cbtHook = null;
+ }
+
+ public void WndProcRet(object sender, WndProcRetEventArgs e)
+ {
+ if (e.cw.message == WndMessage.WM_INITDIALOG ||
+ e.cw.message == WndMessage.WM_UNKNOWINIT)
+ {
+ USER32.MoveWindow(e.cw.hwnd, rect.Left, rect.Top, rect.Width, rect.Height, 1);
+
+ // uninstall this hook
+ WindowsHook wndHook = (WindowsHook)sender;
+ Debug.Assert(wndProcRetHook == wndHook);
+ wndProcRetHook.Uninstall();
+ wndProcRetHook = null;
+ }
+ }
+ }
+ #endregion
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Display.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Display.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,243 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+//
+using System.Runtime.InteropServices;
+
+namespace SharpDisplayManager
+{
+ class Display
+ {
+
+ //Constructor
+ public Display()
+ {
+ iDevice = IntPtr.Zero;
+ }
+
+ //
+ public bool Open()
+ {
+ if (iDevice == IntPtr.Zero)
+ {
+ iDevice = MiniDisplayOpen();
+ }
+ return iDevice != IntPtr.Zero;
+ }
+
+ public void Close()
+ {
+ MiniDisplayClose(iDevice);
+ iDevice = IntPtr.Zero;
+ }
+
+ public bool IsOpen()
+ {
+ return iDevice != IntPtr.Zero;
+ }
+
+ public void Clear()
+ {
+ MiniDisplayClear(iDevice);
+ }
+
+ public void Fill()
+ {
+ MiniDisplayFill(iDevice);
+ }
+
+ public void SwapBuffers()
+ {
+ MiniDisplaySwapBuffers(iDevice);
+ }
+
+ public int MaxBrightness()
+ {
+ return MiniDisplayMaxBrightness(iDevice);
+ }
+
+ public int MinBrightness()
+ {
+ return MiniDisplayMinBrightness(iDevice);
+ }
+
+ public void SetBrightness(int aBrightness)
+ {
+ if (!IsOpen()) return;
+
+ MiniDisplaySetBrightness(iDevice, aBrightness);
+ }
+
+ public int WidthInPixels()
+ {
+ return MiniDisplayWidthInPixels(iDevice);
+ }
+
+ public int HeightInPixels()
+ {
+ return MiniDisplayHeightInPixels(iDevice);
+ }
+
+ public void SetPixel(int aX, int aY, int aValue)
+ {
+ MiniDisplaySetPixel(iDevice,aX,aY,aValue);
+ }
+
+ public void RequestPowerSupplyStatus()
+ {
+ MiniDisplayRequestPowerSupplyStatus(iDevice);
+ }
+
+ public void RequestDeviceId()
+ {
+ MiniDisplayRequestDeviceId(iDevice);
+ }
+
+ public void RequestFirmwareRevision()
+ {
+ MiniDisplayRequestFirmwareRevision(iDevice);
+ }
+
+ public bool PowerSupplyStatus()
+ {
+ bool res = MiniDisplayPowerSupplyStatus(iDevice);
+ return res;
+ }
+
+ public TMiniDisplayRequest AttemptRequestCompletion()
+ {
+ return MiniDisplayAttemptRequestCompletion(iDevice);
+ }
+
+ public TMiniDisplayRequest CurrentRequest()
+ {
+ return MiniDisplayCurrentRequest(iDevice);
+ }
+
+ public bool IsRequestPending()
+ {
+ return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
+ }
+
+
+ public string Vendor()
+ {
+ IntPtr ptr = MiniDisplayVendor(iDevice);
+ string str = Marshal.PtrToStringUni(ptr);
+ return str;
+ }
+
+ public string Product()
+ {
+ IntPtr ptr = MiniDisplayProduct(iDevice);
+ string str = Marshal.PtrToStringUni(ptr);
+ return str;
+ }
+
+ public string SerialNumber()
+ {
+ IntPtr ptr = MiniDisplaySerialNumber(iDevice);
+ string str = Marshal.PtrToStringUni(ptr);
+ return str;
+ }
+
+ public string DeviceId()
+ {
+ IntPtr ptr = MiniDisplayDeviceId(iDevice);
+ string str = Marshal.PtrToStringAnsi(ptr);
+ return str;
+ }
+
+ public string FirmwareRevision()
+ {
+ IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
+ string str = Marshal.PtrToStringAnsi(ptr);
+ return str;
+ }
+
+ //Our display device handle
+ IntPtr iDevice;
+
+ public enum TMiniDisplayRequest
+ {
+ EMiniDisplayRequestNone,
+ EMiniDisplayRequestDeviceId,
+ EMiniDisplayRequestFirmwareRevision,
+ EMiniDisplayRequestPowerSupplyStatus
+ }
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr MiniDisplayOpen();
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayClose(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayClear(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayFill(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ [return: MarshalAs(UnmanagedType.I1)]
+ public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
+
+ [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
+
+
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/MainForm.Designer.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/MainForm.Designer.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,432 @@
+namespace SharpDisplayManager
+{
+ partial class MainForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.tabControl = new System.Windows.Forms.TabControl();
+ this.tabPageDisplay = new System.Windows.Forms.TabPage();
+ this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox();
+ this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox();
+ this.panelDisplay = new System.Windows.Forms.Panel();
+ this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
+ this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
+ this.trackBarBrightness = new System.Windows.Forms.TrackBar();
+ this.buttonFill = new System.Windows.Forms.Button();
+ this.buttonClear = new System.Windows.Forms.Button();
+ this.buttonClose = new System.Windows.Forms.Button();
+ this.buttonOpen = new System.Windows.Forms.Button();
+ this.buttonCapture = new System.Windows.Forms.Button();
+ this.buttonFont = new System.Windows.Forms.Button();
+ this.tabPageTests = new System.Windows.Forms.TabPage();
+ this.fontDialog = new System.Windows.Forms.FontDialog();
+ this.timer = new System.Windows.Forms.Timer(this.components);
+ this.statusStrip = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
+ this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
+ this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
+ this.tabControl.SuspendLayout();
+ this.tabPageDisplay.SuspendLayout();
+ this.panelDisplay.SuspendLayout();
+ this.tableLayoutPanel.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
+ this.statusStrip.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // tabControl
+ //
+ this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tabControl.Controls.Add(this.tabPageDisplay);
+ this.tabControl.Controls.Add(this.tabPageTests);
+ this.tabControl.Location = new System.Drawing.Point(12, 12);
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.Size = new System.Drawing.Size(600, 395);
+ this.tabControl.TabIndex = 0;
+ //
+ // tabPageDisplay
+ //
+ this.tabPageDisplay.Controls.Add(this.checkBoxReverseScreen);
+ this.tabPageDisplay.Controls.Add(this.checkBoxConnectOnStartup);
+ this.tabPageDisplay.Controls.Add(this.panelDisplay);
+ this.tabPageDisplay.Controls.Add(this.checkBoxShowBorders);
+ this.tabPageDisplay.Controls.Add(this.trackBarBrightness);
+ this.tabPageDisplay.Controls.Add(this.buttonFill);
+ this.tabPageDisplay.Controls.Add(this.buttonClear);
+ this.tabPageDisplay.Controls.Add(this.buttonClose);
+ this.tabPageDisplay.Controls.Add(this.buttonOpen);
+ this.tabPageDisplay.Controls.Add(this.buttonCapture);
+ this.tabPageDisplay.Controls.Add(this.buttonFont);
+ this.tabPageDisplay.Location = new System.Drawing.Point(4, 22);
+ this.tabPageDisplay.Name = "tabPageDisplay";
+ this.tabPageDisplay.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPageDisplay.Size = new System.Drawing.Size(592, 369);
+ this.tabPageDisplay.TabIndex = 0;
+ this.tabPageDisplay.Text = "Display";
+ this.tabPageDisplay.UseVisualStyleBackColor = true;
+ //
+ // checkBoxReverseScreen
+ //
+ this.checkBoxReverseScreen.AutoSize = true;
+ this.checkBoxReverseScreen.Location = new System.Drawing.Point(113, 298);
+ this.checkBoxReverseScreen.Name = "checkBoxReverseScreen";
+ this.checkBoxReverseScreen.Size = new System.Drawing.Size(101, 17);
+ this.checkBoxReverseScreen.TabIndex = 14;
+ this.checkBoxReverseScreen.Text = "Reverse screen";
+ this.checkBoxReverseScreen.UseVisualStyleBackColor = true;
+ this.checkBoxReverseScreen.CheckedChanged += new System.EventHandler(this.checkBoxReverseScreen_CheckedChanged);
+ //
+ // checkBoxConnectOnStartup
+ //
+ this.checkBoxConnectOnStartup.AutoSize = true;
+ this.checkBoxConnectOnStartup.Location = new System.Drawing.Point(113, 321);
+ this.checkBoxConnectOnStartup.Name = "checkBoxConnectOnStartup";
+ this.checkBoxConnectOnStartup.Size = new System.Drawing.Size(119, 17);
+ this.checkBoxConnectOnStartup.TabIndex = 13;
+ this.checkBoxConnectOnStartup.Text = "Connect on stratup ";
+ this.checkBoxConnectOnStartup.UseVisualStyleBackColor = true;
+ this.checkBoxConnectOnStartup.CheckedChanged += new System.EventHandler(this.checkBoxConnectOnStartup_CheckedChanged);
+ //
+ // panelDisplay
+ //
+ this.panelDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.panelDisplay.Controls.Add(this.tableLayoutPanel);
+ this.panelDisplay.Location = new System.Drawing.Point(181, 151);
+ this.panelDisplay.Margin = new System.Windows.Forms.Padding(0);
+ this.panelDisplay.Name = "panelDisplay";
+ this.panelDisplay.Size = new System.Drawing.Size(258, 66);
+ this.panelDisplay.TabIndex = 12;
+ //
+ // tableLayoutPanel
+ //
+ this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
+ this.tableLayoutPanel.ColumnCount = 1;
+ this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+ this.tableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0);
+ this.tableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1);
+ this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
+ this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
+ this.tableLayoutPanel.Name = "tableLayoutPanel";
+ this.tableLayoutPanel.RowCount = 2;
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
+ this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
+ this.tableLayoutPanel.TabIndex = 5;
+ //
+ // checkBoxShowBorders
+ //
+ this.checkBoxShowBorders.AutoSize = true;
+ this.checkBoxShowBorders.Location = new System.Drawing.Point(113, 344);
+ this.checkBoxShowBorders.Name = "checkBoxShowBorders";
+ this.checkBoxShowBorders.Size = new System.Drawing.Size(91, 17);
+ this.checkBoxShowBorders.TabIndex = 11;
+ this.checkBoxShowBorders.Text = "Show borders";
+ this.checkBoxShowBorders.UseVisualStyleBackColor = true;
+ this.checkBoxShowBorders.CheckedChanged += new System.EventHandler(this.checkBoxShowBorders_CheckedChanged);
+ //
+ // trackBarBrightness
+ //
+ this.trackBarBrightness.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
+ this.trackBarBrightness.Location = new System.Drawing.Point(544, 9);
+ this.trackBarBrightness.Name = "trackBarBrightness";
+ this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
+ this.trackBarBrightness.Size = new System.Drawing.Size(45, 357);
+ this.trackBarBrightness.TabIndex = 10;
+ this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
+ this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
+ //
+ // buttonFill
+ //
+ this.buttonFill.Location = new System.Drawing.Point(6, 93);
+ this.buttonFill.Name = "buttonFill";
+ this.buttonFill.Size = new System.Drawing.Size(75, 23);
+ this.buttonFill.TabIndex = 9;
+ this.buttonFill.Text = "Fill";
+ this.buttonFill.UseVisualStyleBackColor = true;
+ this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click);
+ //
+ // buttonClear
+ //
+ this.buttonClear.Location = new System.Drawing.Point(6, 64);
+ this.buttonClear.Name = "buttonClear";
+ this.buttonClear.Size = new System.Drawing.Size(75, 23);
+ this.buttonClear.TabIndex = 8;
+ this.buttonClear.Text = "Clear";
+ this.buttonClear.UseVisualStyleBackColor = true;
+ this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
+ //
+ // buttonClose
+ //
+ this.buttonClose.Location = new System.Drawing.Point(6, 35);
+ this.buttonClose.Name = "buttonClose";
+ this.buttonClose.Size = new System.Drawing.Size(75, 23);
+ this.buttonClose.TabIndex = 7;
+ this.buttonClose.Text = "Close";
+ this.buttonClose.UseVisualStyleBackColor = true;
+ this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
+ //
+ // buttonOpen
+ //
+ this.buttonOpen.Location = new System.Drawing.Point(6, 6);
+ this.buttonOpen.Name = "buttonOpen";
+ this.buttonOpen.Size = new System.Drawing.Size(75, 23);
+ this.buttonOpen.TabIndex = 6;
+ this.buttonOpen.Text = "Open";
+ this.buttonOpen.UseVisualStyleBackColor = true;
+ this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
+ //
+ // buttonCapture
+ //
+ this.buttonCapture.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCapture.Location = new System.Drawing.Point(6, 311);
+ this.buttonCapture.Name = "buttonCapture";
+ this.buttonCapture.Size = new System.Drawing.Size(75, 23);
+ this.buttonCapture.TabIndex = 5;
+ this.buttonCapture.Text = "Capture";
+ this.buttonCapture.UseVisualStyleBackColor = true;
+ this.buttonCapture.Click += new System.EventHandler(this.buttonCapture_Click);
+ //
+ // buttonFont
+ //
+ this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonFont.Location = new System.Drawing.Point(6, 340);
+ this.buttonFont.Name = "buttonFont";
+ this.buttonFont.Size = new System.Drawing.Size(75, 23);
+ this.buttonFont.TabIndex = 0;
+ this.buttonFont.Text = "Select Font";
+ this.buttonFont.UseVisualStyleBackColor = true;
+ this.buttonFont.Click += new System.EventHandler(this.buttonFont_Click);
+ //
+ // tabPageTests
+ //
+ this.tabPageTests.Location = new System.Drawing.Point(4, 22);
+ this.tabPageTests.Name = "tabPageTests";
+ this.tabPageTests.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPageTests.Size = new System.Drawing.Size(592, 369);
+ this.tabPageTests.TabIndex = 1;
+ this.tabPageTests.Text = "Test";
+ this.tabPageTests.UseVisualStyleBackColor = true;
+ //
+ // timer
+ //
+ this.timer.Enabled = true;
+ this.timer.Interval = 50;
+ this.timer.Tick += new System.EventHandler(this.timer_Tick);
+ //
+ // statusStrip
+ //
+ this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabelConnect,
+ this.toolStripStatusLabelSpring,
+ this.toolStripStatusLabelPower,
+ this.toolStripStatusLabelFps});
+ this.statusStrip.Location = new System.Drawing.Point(0, 420);
+ this.statusStrip.Name = "statusStrip";
+ this.statusStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
+ this.statusStrip.Size = new System.Drawing.Size(624, 22);
+ this.statusStrip.TabIndex = 1;
+ this.statusStrip.Text = "statusStrip";
+ //
+ // toolStripStatusLabelConnect
+ //
+ this.toolStripStatusLabelConnect.Name = "toolStripStatusLabelConnect";
+ this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17);
+ this.toolStripStatusLabelConnect.Text = "Not connected";
+ //
+ // toolStripStatusLabelSpring
+ //
+ this.toolStripStatusLabelSpring.Name = "toolStripStatusLabelSpring";
+ this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(473, 17);
+ this.toolStripStatusLabelSpring.Spring = true;
+ //
+ // toolStripStatusLabelPower
+ //
+ this.toolStripStatusLabelPower.Name = "toolStripStatusLabelPower";
+ this.toolStripStatusLabelPower.Size = new System.Drawing.Size(24, 17);
+ this.toolStripStatusLabelPower.Text = "NA";
+ //
+ // toolStripStatusLabelFps
+ //
+ this.toolStripStatusLabelFps.Name = "toolStripStatusLabelFps";
+ this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
+ this.toolStripStatusLabelFps.Text = "FPS";
+ //
+ // marqueeLabelTop
+ //
+ this.marqueeLabelTop.AutoEllipsis = true;
+ this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
+ this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.marqueeLabelTop.Location = new System.Drawing.Point(1, -124);
+ this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
+ this.marqueeLabelTop.Name = "marqueeLabelTop";
+ this.marqueeLabelTop.OwnTimer = false;
+ this.marqueeLabelTop.PixelsPerSecond = 64;
+ this.marqueeLabelTop.Separator = "|";
+ this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20);
+ this.marqueeLabelTop.TabIndex = 2;
+ this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
+ this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.marqueeLabelTop.UseCompatibleTextRendering = true;
+ //
+ // marqueeLabelBottom
+ //
+ this.marqueeLabelBottom.AutoEllipsis = true;
+ this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -40);
+ this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
+ this.marqueeLabelBottom.Name = "marqueeLabelBottom";
+ this.marqueeLabelBottom.OwnTimer = false;
+ this.marqueeLabelBottom.PixelsPerSecond = 64;
+ this.marqueeLabelBottom.Separator = null;
+ this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
+ this.marqueeLabelBottom.TabIndex = 3;
+ this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
+ this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ this.marqueeLabelBottom.UseCompatibleTextRendering = true;
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(624, 442);
+ this.Controls.Add(this.statusStrip);
+ this.Controls.Add(this.tabControl);
+ this.MinimumSize = new System.Drawing.Size(640, 480);
+ this.Name = "MainForm";
+ this.Text = "Sharp Display Manager";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
+ this.Load += new System.EventHandler(this.MainForm_Load);
+ this.Resize += new System.EventHandler(this.MainForm_Resize);
+ this.tabControl.ResumeLayout(false);
+ this.tabPageDisplay.ResumeLayout(false);
+ this.tabPageDisplay.PerformLayout();
+ this.panelDisplay.ResumeLayout(false);
+ this.tableLayoutPanel.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
+ this.statusStrip.ResumeLayout(false);
+ this.statusStrip.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TabControl tabControl;
+ private System.Windows.Forms.TabPage tabPageDisplay;
+ private System.Windows.Forms.TabPage tabPageTests;
+ private System.Windows.Forms.Button buttonFont;
+ private System.Windows.Forms.FontDialog fontDialog;
+ private System.Windows.Forms.Button buttonCapture;
+ private System.Windows.Forms.Timer timer;
+ private System.Windows.Forms.Button buttonFill;
+ private System.Windows.Forms.Button buttonClear;
+ private System.Windows.Forms.Button buttonClose;
+ private System.Windows.Forms.Button buttonOpen;
+ private System.Windows.Forms.TrackBar trackBarBrightness;
+ private System.Windows.Forms.StatusStrip statusStrip;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring;
+ private System.Windows.Forms.CheckBox checkBoxShowBorders;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower;
+ private System.Windows.Forms.Panel panelDisplay;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
+ public MarqueeLabel marqueeLabelTop;
+ public MarqueeLabel marqueeLabelBottom;
+ private System.Windows.Forms.CheckBox checkBoxConnectOnStartup;
+ private System.Windows.Forms.CheckBox checkBoxReverseScreen;
+ }
+}
+
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/MainForm.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/MainForm.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,368 @@
+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.IO;
+using CodeProject.Dialog;
+using System.Drawing.Imaging;
+using System.ServiceModel;
+
+
+namespace SharpDisplayManager
+{
+ public partial class MainForm : Form
+ {
+ DateTime LastTickTime;
+ Display iDisplay;
+ System.Drawing.Bitmap iBmp;
+ bool iCreateBitmap; //Workaround render to bitmap issues when minimized
+ ServiceHost iServiceHost;
+
+ public MainForm()
+ {
+ LastTickTime = DateTime.Now;
+ iDisplay = new Display();
+
+ InitializeComponent();
+ UpdateStatus();
+
+ //Load settings
+ marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont;
+ marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont;
+ checkBoxShowBorders.Checked = Properties.Settings.Default.DisplayShowBorders;
+ checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
+ checkBoxReverseScreen.Checked = Properties.Settings.Default.DisplayReverseScreen;
+ //
+ tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
+ //We have a bug when drawing minimized and reusing our bitmap
+ iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
+ iCreateBitmap = false;
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ StartServer();
+
+ if (Properties.Settings.Default.DisplayConnectOnStartup)
+ {
+ iDisplay.Open();
+ UpdateStatus();
+ }
+ }
+
+
+ private void buttonFont_Click(object sender, EventArgs e)
+ {
+ //fontDialog.ShowColor = true;
+ //fontDialog.ShowApply = true;
+ fontDialog.ShowEffects = true;
+ fontDialog.Font = marqueeLabelTop.Font;
+ //fontDialog.ShowHelp = true;
+
+ //fontDlg.MaxSize = 40;
+ //fontDlg.MinSize = 22;
+
+ //fontDialog.Parent = this;
+ //fontDialog.StartPosition = FormStartPosition.CenterParent;
+
+ //DlgBox.ShowDialog(fontDialog);
+
+ //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
+ if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
+ {
+
+ //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
+
+ //MessageBox.Show("Ok");
+ marqueeLabelTop.Font = fontDialog.Font;
+ marqueeLabelBottom.Font = fontDialog.Font;
+ Properties.Settings.Default.DisplayFont = fontDialog.Font;
+ Properties.Settings.Default.Save();
+ //label1.Font = fontDlg.Font;
+ //textBox1.BackColor = fontDlg.Color;
+ //label1.ForeColor = fontDlg.Color;
+ }
+ }
+
+ private void buttonCapture_Click(object sender, EventArgs e)
+ {
+ System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
+ tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
+ //Bitmap bmpToSave = new Bitmap(bmp);
+ bmp.Save("D:\\capture.png");
+
+ marqueeLabelTop.Text = "Sweet";
+
+ /*
+ string outputFileName = "d:\\capture.png";
+ using (MemoryStream memory = new MemoryStream())
+ {
+ using (FileStream fs = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+ {
+ bmp.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
+ byte[] bytes = memory.ToArray();
+ fs.Write(bytes, 0, bytes.Length);
+ }
+ }
+ */
+
+ }
+
+ private void CheckForRequestResults()
+ {
+ if (iDisplay.IsRequestPending())
+ {
+ switch (iDisplay.AttemptRequestCompletion())
+ {
+ case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus:
+ if (iDisplay.PowerSupplyStatus())
+ {
+ toolStripStatusLabelPower.Text = "ON";
+ }
+ else
+ {
+ toolStripStatusLabelPower.Text = "OFF";
+ }
+ //Issue next request then
+ iDisplay.RequestDeviceId();
+ break;
+
+ case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId:
+ toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId();
+ //Issue next request then
+ iDisplay.RequestFirmwareRevision();
+ break;
+
+ case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision:
+ toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision();
+ //No more request to issue
+ break;
+ }
+ }
+ }
+
+
+ public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
+
+
+ public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
+ {
+ return aBmp.Width - aX - 1;
+ }
+
+ public int ScreenReversedY(System.Drawing.Bitmap aBmp, int aY)
+ {
+ return iBmp.Height - aY - 1;
+ }
+
+ public int ScreenX(System.Drawing.Bitmap aBmp, int aX)
+ {
+ return aX;
+ }
+
+ public int ScreenY(System.Drawing.Bitmap aBmp, int aY)
+ {
+ return aY;
+ }
+
+
+ //This is our timer tick responsible to perform our render
+ private void timer_Tick(object sender, EventArgs e)
+ {
+ //Update our animations
+ DateTime NewTickTime = DateTime.Now;
+
+ marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
+ marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
+
+ //Update our display
+ if (iDisplay.IsOpen())
+ {
+ CheckForRequestResults();
+
+ //Draw to bitmap
+ if (iCreateBitmap)
+ {
+ iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
+ }
+ tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
+ //iBmp.Save("D:\\capture.png");
+
+ //Select proper coordinate translation functions
+ //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
+ CoordinateTranslationDelegate screenX;
+ CoordinateTranslationDelegate screenY;
+
+ if (Properties.Settings.Default.DisplayReverseScreen)
+ {
+ screenX = ScreenReversedX;
+ screenY = ScreenReversedY;
+ }
+ else
+ {
+ screenX = ScreenX;
+ screenY = ScreenY;
+ }
+
+ //Send it to our display
+ for (int i = 0; i < iBmp.Width; i++)
+ {
+ for (int j = 0; j < iBmp.Height; j++)
+ {
+ unchecked
+ {
+ uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
+ //For some reason when the app is minimized in the task bar only the alpha of our color is set.
+ //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
+ iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
+ }
+ }
+ }
+
+ iDisplay.SwapBuffers();
+
+ }
+
+ //Compute instant FPS
+ toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " FPS";
+
+ LastTickTime = NewTickTime;
+
+ }
+
+ private void buttonOpen_Click(object sender, EventArgs e)
+ {
+ if (iDisplay.Open())
+ {
+ UpdateStatus();
+ iDisplay.RequestPowerSupplyStatus();
+ }
+ else
+ {
+ UpdateStatus();
+ toolStripStatusLabelConnect.Text = "Connection error";
+ }
+
+ }
+
+ private void buttonClose_Click(object sender, EventArgs e)
+ {
+ iDisplay.Close();
+ UpdateStatus();
+ }
+
+ private void buttonClear_Click(object sender, EventArgs e)
+ {
+ iDisplay.Clear();
+ iDisplay.SwapBuffers();
+ }
+
+ private void buttonFill_Click(object sender, EventArgs e)
+ {
+ iDisplay.Fill();
+ iDisplay.SwapBuffers();
+ }
+
+ private void trackBarBrightness_Scroll(object sender, EventArgs e)
+ {
+ Properties.Settings.Default.DisplayBrightness = trackBarBrightness.Value;
+ Properties.Settings.Default.Save();
+ iDisplay.SetBrightness(trackBarBrightness.Value);
+
+ }
+
+ private void UpdateStatus()
+ {
+ if (iDisplay.IsOpen())
+ {
+ buttonFill.Enabled = true;
+ buttonClear.Enabled = true;
+ buttonOpen.Enabled = false;
+ buttonClose.Enabled = true;
+ trackBarBrightness.Enabled = true;
+ trackBarBrightness.Minimum = iDisplay.MinBrightness();
+ trackBarBrightness.Maximum = iDisplay.MaxBrightness();
+ trackBarBrightness.Value = Properties.Settings.Default.DisplayBrightness;
+ trackBarBrightness.LargeChange = Math.Max(1,(iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
+ trackBarBrightness.SmallChange = 1;
+ iDisplay.SetBrightness(Properties.Settings.Default.DisplayBrightness);
+
+ toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
+ //+ " - " + iDisplay.SerialNumber();
+ }
+ else
+ {
+ buttonFill.Enabled = false;
+ buttonClear.Enabled = false;
+ buttonOpen.Enabled = true;
+ buttonClose.Enabled = false;
+ trackBarBrightness.Enabled = false;
+ toolStripStatusLabelConnect.Text = "Disconnected";
+ }
+ }
+
+
+
+ private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
+ {
+ //Save our show borders setting
+ tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
+ Properties.Settings.Default.DisplayShowBorders = checkBoxShowBorders.Checked;
+ Properties.Settings.Default.Save();
+ }
+
+ private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
+ {
+ //Save our connect on startup setting
+ Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
+ Properties.Settings.Default.Save();
+ }
+
+ private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
+ {
+ //Save our reverse screen setting
+ Properties.Settings.Default.DisplayReverseScreen = checkBoxReverseScreen.Checked;
+ Properties.Settings.Default.Save();
+ }
+
+ private void MainForm_Resize(object sender, EventArgs e)
+ {
+ if (WindowState == FormWindowState.Minimized)
+ {
+ // Do some stuff
+ //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
+ iCreateBitmap = true;
+ }
+ }
+
+ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ StopServer();
+ }
+
+ public void StartServer()
+ {
+ iServiceHost = new ServiceHost
+ (
+ typeof(DisplayServer),
+ new Uri[] { new Uri("net.pipe://localhost") }
+ );
+
+ iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetNamedPipeBinding(), "DisplayService");
+ iServiceHost.Open();
+ }
+
+ public void StopServer()
+ {
+ //Tell connected client first? Is that possible?
+ iServiceHost.Close();
+ }
+
+
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/MainForm.resx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/MainForm.resx Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 126, 17
+
+
+ 206, 17
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/MarqueeLabel.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/MarqueeLabel.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,293 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+//using System.Timers;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace SharpDisplayManager
+{
+ [System.ComponentModel.DesignerCategory("Code")]
+ public class MarqueeLabel : Label
+ {
+ private bool iOwnTimer;
+ private StringFormat iStringFormat;
+ private SolidBrush iBrush;
+ private SizeF iTextSize;
+ private SizeF iSeparatorSize;
+
+ [Category("Appearance")]
+ [Description("Separator in our scrolling loop.")]
+ [DefaultValue(" | ")]
+ [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public string Separator { get; set; }
+
+ [Category("Behavior")]
+ [Description("How fast is our text scrolling, in pixels per second.")]
+ [DefaultValue(32)]
+ [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public int PixelsPerSecond { get; set; }
+
+ [Category("Behavior")]
+ [Description("Use an internal or an external timer.")]
+ [DefaultValue(true)]
+ [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
+ public bool OwnTimer
+ {
+ get
+ {
+ return iOwnTimer;
+ }
+ set
+ {
+ iOwnTimer = value;
+
+ if (iOwnTimer)
+ {
+ Timer = new Timer();
+ Timer.Interval = 10;
+ Timer.Tick += new EventHandler(Timer_Tick);
+ Timer.Start();
+ }
+ else
+ {
+ if (Timer != null)
+ Timer.Dispose();
+ Timer = null;
+ }
+
+ }
+ }
+
+ private int CurrentPosition { get; set; }
+ private Timer Timer { get; set; }
+ private DateTime LastTickTime { get; set; }
+ private double PixelsLeft { get; set; }
+ //DateTime a = new DateTime(2010, 05, 12, 13, 15, 00);
+ //DateTime b = new DateTime(2010, 05, 12, 13, 45, 00);
+ //Console.WriteLine(b.Subtract(a).TotalMinutes);
+
+ public MarqueeLabel()
+ {
+ UseCompatibleTextRendering = true;
+ //PixelsPerSecond = 32;
+ LastTickTime = DateTime.Now;
+ PixelsLeft = 0;
+ iBrush = new SolidBrush(ForeColor);
+ }
+
+ public void UpdateAnimation(DateTime aLastTickTime, DateTime aNewTickTime)
+ {
+ if (!NeedToScroll())
+ {
+ CurrentPosition = 0;
+ return;
+ }
+
+ while (CurrentPosition > (iTextSize.Width + iSeparatorSize.Width))
+ {
+ CurrentPosition -= ((int)(iTextSize.Width + iSeparatorSize.Width));
+ }
+
+ PixelsLeft += aNewTickTime.Subtract(aLastTickTime).TotalSeconds * PixelsPerSecond;
+
+ //Keep track of our pixels left over
+ //PixelsLeft = offset - Math.Truncate(offset);
+ double offset = Math.Truncate(PixelsLeft);
+ PixelsLeft -= offset;
+
+ CurrentPosition += Convert.ToInt32(offset);
+
+ /*
+ if (offset > 1.0)
+ {
+ BackColor = Color.Red;
+ }
+ else if (offset==1.0)
+ {
+ if (BackColor != Color.White)
+ {
+ BackColor = Color.White;
+ }
+
+ }
+ else
+ {
+ //Too slow
+ //BackColor = Color.Green;
+ }*/
+
+ //Only redraw if something has changed
+ if (offset != 0)
+ {
+ Invalidate();
+ }
+ }
+
+ void Timer_Tick(object sender, EventArgs e)
+ {
+ DateTime NewTickTime = DateTime.Now;
+ //
+ UpdateAnimation(LastTickTime, NewTickTime);
+ //
+ LastTickTime = NewTickTime;
+ }
+
+ private StringFormat GetStringFormatFromContentAllignment(ContentAlignment ca)
+ {
+ StringFormat format = new StringFormat();
+ format = StringFormat.GenericTypographic;
+ switch (ca)
+ {
+ case ContentAlignment.TopCenter:
+ format.Alignment = StringAlignment.Near;
+ format.LineAlignment = StringAlignment.Center;
+ break;
+ case ContentAlignment.TopLeft:
+ format.Alignment = StringAlignment.Near;
+ format.LineAlignment = StringAlignment.Near;
+ break;
+ case ContentAlignment.TopRight:
+ format.Alignment = StringAlignment.Near;
+ format.LineAlignment = StringAlignment.Far;
+ break;
+ case ContentAlignment.MiddleCenter:
+ format.Alignment = StringAlignment.Center;
+ format.LineAlignment = StringAlignment.Center;
+ break;
+ case ContentAlignment.MiddleLeft:
+ format.Alignment = StringAlignment.Center;
+ format.LineAlignment = StringAlignment.Near;
+ break;
+ case ContentAlignment.MiddleRight:
+ format.Alignment = StringAlignment.Center;
+ format.LineAlignment = StringAlignment.Far;
+ break;
+ case ContentAlignment.BottomCenter:
+ format.Alignment = StringAlignment.Far;
+ format.LineAlignment = StringAlignment.Center;
+ break;
+ case ContentAlignment.BottomLeft:
+ format.Alignment = StringAlignment.Far;
+ format.LineAlignment = StringAlignment.Near;
+ break;
+ case ContentAlignment.BottomRight:
+ format.Alignment = StringAlignment.Far;
+ format.LineAlignment = StringAlignment.Far;
+ break;
+ }
+
+ format.FormatFlags |= StringFormatFlags.NoWrap;
+ format.FormatFlags |= StringFormatFlags.NoClip;
+ format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
+ format.Trimming = StringTrimming.None;
+
+ return format;
+ }
+
+ protected override void OnForeColorChanged(EventArgs e)
+ {
+ //Color has changed recreate our brush
+ iBrush = new SolidBrush(ForeColor);
+
+ base.OnForeColorChanged(e);
+ }
+
+
+ private void HandleTextSizeChange()
+ {
+ //For all string measurements and drawing issues refer to the following article:
+ // http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number
+ //Update text size according to text and font
+ Graphics g = this.CreateGraphics();
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
+ iTextSize = g.MeasureString(Text, Font, Int32.MaxValue, iStringFormat);
+ iSeparatorSize = g.MeasureString(Separator, Font, Int32.MaxValue, iStringFormat);
+
+ if (NeedToScroll())
+ {
+ //Always align left when scrolling
+ iStringFormat.Alignment = StringAlignment.Near;
+ }
+ }
+
+ protected override void OnTextChanged(EventArgs e)
+ {
+ HandleTextSizeChange();
+
+ base.OnTextChanged(e);
+ }
+
+ protected override void OnFontChanged(EventArgs e)
+ {
+ HandleTextSizeChange();
+
+ base.OnFontChanged(e);
+ }
+
+ protected override void OnTextAlignChanged(EventArgs e)
+ {
+ iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
+
+ base.OnTextAlignChanged(e);
+
+ }
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ //Disable anti-aliasing
+ e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
+ if (NeedToScroll())
+ {
+ //Draw the first one
+ e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
+ e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
+ //Draw separator
+ e.Graphics.TranslateTransform(iTextSize.Width, 0);
+ e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
+ //Draw the last one
+ e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
+ e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
+ }
+ else
+ {
+ e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
+ }
+
+
+
+ //DrawText is not working without anti-aliasing. See: stackoverflow.com/questions/8283631/graphics-drawstring-vs-textrenderer-drawtextwhich-can-deliver-better-quality
+ //TextRenderer.DrawText(e.Graphics, Text, Font, ClientRectangle, ForeColor, BackColor, iTextFormatFlags);
+
+ //base.OnPaint(e);
+ }
+
+ public bool NeedToScroll()
+ {
+ //if (Width < e.Graphics.MeasureString(Text, Font).Width)
+ if (Width < iTextSize.Width)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (Timer != null)
+ Timer.Dispose();
+ }
+ Timer = null;
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Program.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Program.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SharpDisplayManager
+{
+ static class Program
+ {
+ public static MainForm iMainForm;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ iMainForm = new MainForm();
+ Application.Run(iMainForm);
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Properties/AssemblyInfo.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Properties/AssemblyInfo.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SharpDisplayManager")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SharpDisplayManager")]
+[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("5da0f26b-76a6-41e8-832c-5b593b3a75b0")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Properties/Resources.Designer.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Properties/Resources.Designer.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18063
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SharpDisplayManager.Properties
+{
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDisplayManager.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Properties/Resources.resx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Properties/Resources.resx Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Properties/Settings.Designer.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Properties/Settings.Designer.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,86 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.18444
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace SharpDisplayManager.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1")]
+ public int DisplayBrightness {
+ get {
+ return ((int)(this["DisplayBrightness"]));
+ }
+ set {
+ this["DisplayBrightness"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("Microsoft Sans Serif, 9.75pt")]
+ public global::System.Drawing.Font DisplayFont {
+ get {
+ return ((global::System.Drawing.Font)(this["DisplayFont"]));
+ }
+ set {
+ this["DisplayFont"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool DisplayShowBorders {
+ get {
+ return ((bool)(this["DisplayShowBorders"]));
+ }
+ set {
+ this["DisplayShowBorders"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool DisplayConnectOnStartup {
+ get {
+ return ((bool)(this["DisplayConnectOnStartup"]));
+ }
+ set {
+ this["DisplayConnectOnStartup"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool DisplayReverseScreen {
+ get {
+ return ((bool)(this["DisplayReverseScreen"]));
+ }
+ set {
+ this["DisplayReverseScreen"] = value;
+ }
+ }
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Properties/Settings.settings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Properties/Settings.settings Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,21 @@
+
+
+
+
+
+ 1
+
+
+ Microsoft Sans Serif, 9.75pt
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Servers.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Servers.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,27 @@
+using System;
+using System.Windows.Forms;
+
+namespace SharpDisplayManager
+{
+ ///
+ /// Implement our display service.
+ /// This class is instantiated anew whenever a client send a request.
+ ///
+ class DisplayServer : IDisplayService
+ {
+ //From IDisplayService
+ public void SetText(int aLineIndex, string aText)
+ {
+ if (aLineIndex == 0)
+ {
+ Program.iMainForm.marqueeLabelTop.Text = aText;
+ }
+ else if (aLineIndex == 1)
+ {
+ Program.iMainForm.marqueeLabelBottom.Text = aText;
+ }
+ }
+
+ }
+
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Services.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Services.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,12 @@
+using System;
+using System.ServiceModel;
+
+namespace SharpDisplayManager
+{
+ [ServiceContract]
+ public interface IDisplayService
+ {
+ [OperationContract]
+ void SetText(int aLineIndex, string aText);
+ }
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/SharpDisplayManager.csproj
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/SharpDisplayManager.csproj Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,100 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}
+ WinExe
+ Properties
+ SharpDisplayManager
+ SharpDisplayManager
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ ..\..\bin\MiniDisplay\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ ..\..\bin\MiniDisplay\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ MainForm.cs
+
+
+
+
+
+
+
+
+
+
+ MainForm.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/SharpDisplayManager.sln
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/SharpDisplayManager.sln Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDisplayManager", "SharpDisplayManager.csproj", "{1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDisplayClient", "..\Client\SharpDisplayClient.csproj", "{7EE64074-8CDB-4448-B40C-81B75D6B31CD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Win32API.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/Win32API.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,100 @@
+//=============================================================================
+// COPYRIGHT: Prosoft-Lanz
+//=============================================================================
+//
+// $Workfile: Win32API.cs $
+//
+// PROJECT : CodeProject Components
+// VERSION : 1.00
+// CREATION : 19.02.2003
+// AUTHOR : JCL
+//
+// DETAILS : This class implement Win32 API calls
+// and the contants used for these calls.
+//
+//-----------------------------------------------------------------------------
+using System;
+using System.Text;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Runtime.InteropServices;
+
+namespace CodeProject.Win32API
+{
+ ///////////////////////////////////////////////////////////////////////
+ #region Generic declarations
+
+ ///
+ /// Rectangle parameters exposed as a structure.
+ ///
+ public struct RECT
+ {
+ ///
+ /// Rectangle members.
+ ///
+ public int left, top, right, bottom;
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Util class
+
+ ///
+ /// Utility functions.
+ ///
+ public sealed class API
+ {
+ private API() {} // To remove the constructor from the documentation!
+
+ ///
+ /// Get true multiscreen size.
+ ///
+ public static Rectangle TrueScreenRect
+ {
+ get
+ {
+ // get the biggest screen area
+ Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea;
+ int left = rectScreen.Left;
+ int top = rectScreen.Top;
+ int right = rectScreen.Right;
+ int bottom = rectScreen.Bottom;
+ foreach (Screen screen in Screen.AllScreens)
+ {
+ left = Math.Min(left, screen.WorkingArea.Left);
+ right = Math.Max(right, screen.WorkingArea.Right);
+ top = Math.Min(top, screen.WorkingArea.Top);
+ bottom = Math.Max(bottom, screen.WorkingArea.Bottom);
+ }
+ return new Rectangle(left, top, right-left, bottom-top);
+ }
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region USER32 class
+
+ ///
+ /// Class to expose USER32 API functions.
+ ///
+ public sealed class USER32
+ {
+ private USER32() {} // To remove the constructor from the documentation!
+
+ [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
+ internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect);
+
+ [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
+ internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int w, int h, int repaint);
+
+ [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
+ internal static extern IntPtr GetActiveWindow();
+
+ [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
+ internal static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
+ }
+ #endregion
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/WindowsHook.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/WindowsHook.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,186 @@
+//=============================================================================
+// COPYRIGHT: Prosoft-Lanz
+//=============================================================================
+//
+// $Workfile: WindowsHook.cs $
+//
+// PROJECT : CodeProject Components
+// VERSION : 1.00
+// CREATION : 19.02.2003
+// AUTHOR : JCL
+//
+// DETAILS : This class implement the Windows hook mechanism.
+// From MSDN, Dino Esposito.
+//
+//-----------------------------------------------------------------------------
+using System;
+using System.Runtime.InteropServices;
+
+namespace CodeProject.Win32API.Hook
+{
+ ///////////////////////////////////////////////////////////////////////
+ #region Class HookEventArgs
+
+ /// Class used for hook event arguments.
+ public class HookEventArgs : EventArgs
+ {
+ /// Event code parameter.
+ public int code;
+ /// wParam parameter.
+ public IntPtr wParam;
+ /// lParam parameter.
+ public IntPtr lParam;
+
+ internal HookEventArgs(int code, IntPtr wParam, IntPtr lParam)
+ {
+ this.code = code;
+ this.wParam = wParam;
+ this.lParam = lParam;
+ }
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Enum HookType
+
+ /// Hook Types.
+ public enum HookType : int
+ {
+ /// 0
+ WH_JOURNALRECORD = 0,
+ /// 1
+ WH_JOURNALPLAYBACK = 1,
+ /// 2
+ WH_KEYBOARD = 2,
+ /// 3
+ WH_GETMESSAGE = 3,
+ /// 4
+ WH_CALLWNDPROC = 4,
+ /// 5
+ WH_CBT = 5,
+ /// 6
+ WH_SYSMSGFILTER = 6,
+ /// 7
+ WH_MOUSE = 7,
+ /// 8
+ WH_HARDWARE = 8,
+ /// 9
+ WH_DEBUG = 9,
+ /// 10
+ WH_SHELL = 10,
+ /// 11
+ WH_FOREGROUNDIDLE = 11,
+ /// 12
+ WH_CALLWNDPROCRET = 12,
+ /// 13
+ WH_KEYBOARD_LL = 13,
+ /// 14
+ WH_MOUSE_LL = 14
+ }
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Class WindowsHook
+
+ ///
+ /// Class to expose the windows hook mechanism.
+ ///
+ public class WindowsHook
+ {
+ ///
+ /// Hook delegate method.
+ ///
+ public delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
+
+ // internal properties
+ internal IntPtr hHook = IntPtr.Zero;
+ internal HookProc filterFunc = null;
+ internal HookType hookType;
+
+ ///
+ /// Hook delegate method.
+ ///
+ public delegate void HookEventHandler(object sender, HookEventArgs e);
+
+ ///
+ /// Hook invoke event.
+ ///
+ public event HookEventHandler HookInvoke;
+
+ internal void OnHookInvoke(HookEventArgs e)
+ {
+ if (HookInvoke != null)
+ HookInvoke(this, e);
+ }
+
+ ///
+ /// Construct a HookType hook.
+ ///
+ /// Hook type.
+ public WindowsHook(HookType hook)
+ {
+ hookType = hook;
+ filterFunc = new HookProc(this.CoreHookProc);
+ }
+ ///
+ /// Construct a HookType hook giving a hook filter delegate method.
+ ///
+ /// Hook type
+ /// Hook filter event.
+ public WindowsHook(HookType hook, HookProc func)
+ {
+ hookType = hook;
+ filterFunc = func;
+ }
+
+ // default hook filter function
+ internal int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
+ {
+ if (code < 0)
+ return CallNextHookEx(hHook, code, wParam, lParam);
+
+ // let clients determine what to do
+ HookEventArgs e = new HookEventArgs(code, wParam, lParam);
+ OnHookInvoke(e);
+
+ // yield to the next hook in the chain
+ return CallNextHookEx(hHook, code, wParam, lParam);
+ }
+
+ ///
+ /// Install the hook.
+ ///
+ public void Install()
+ {
+ hHook = SetWindowsHookEx(hookType, filterFunc, IntPtr.Zero, (int)AppDomain.GetCurrentThreadId());
+ }
+
+
+ ///
+ /// Uninstall the hook.
+ ///
+ public void Uninstall()
+ {
+ if (hHook != IntPtr.Zero)
+ {
+ UnhookWindowsHookEx(hHook);
+ hHook = IntPtr.Zero;
+ }
+ }
+
+ #region Win32 Imports
+
+ [DllImport("user32.dll")]
+ internal static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
+
+ [DllImport("user32.dll")]
+ internal static extern int UnhookWindowsHookEx(IntPtr hhook);
+
+ [DllImport("user32.dll")]
+ internal static extern int CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam);
+
+ #endregion
+ }
+ #endregion
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Server/WndProcRetHook.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Server/WndProcRetHook.cs Tue Aug 12 20:55:50 2014 +0200
@@ -0,0 +1,135 @@
+//=============================================================================
+// COPYRIGHT: Prosoft-Lanz
+//=============================================================================
+//
+// $Workfile: WndProcRetHook.cs $
+//
+// PROJECT : CodeProject Components
+// VERSION : 1.00
+// CREATION : 19.02.2003
+// AUTHOR : JCL
+//
+// DETAILS : This class implement the WH_CALLWNDPROCRET Windows hook mechanism.
+// From MSDN, Dino Esposito.
+//
+// WindowCreate, WindowDestroye and WindowActivate user events.
+//
+//-----------------------------------------------------------------------------
+using System;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+
+namespace CodeProject.Win32API.Hook
+{
+ ///////////////////////////////////////////////////////////////////////
+ #region Enum WndMessage
+
+ ///
+ /// windows message.
+ ///
+ public enum WndMessage : int
+ {
+ /// Sent to the dialog procedure immediately before the dialog is displayed.
+ WM_INITDIALOG = 0x0110,
+ /// Sent to the dialog procedure immediately before the dialog is displayed.
+ WM_UNKNOWINIT = 0x0127
+ }
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Class WndProcRetEventArgs
+
+ /// Class used for WH_CALLWNDPROCRET hook event arguments.
+ public class WndProcRetEventArgs : EventArgs
+ {
+ /// wParam parameter.
+ public IntPtr wParam;
+ /// lParam parameter.
+ public IntPtr lParam;
+ /// CWPRETSTRUCT structure.
+ public CwPRetStruct cw;
+
+ internal WndProcRetEventArgs(IntPtr wParam, IntPtr lParam)
+ {
+ this.wParam = wParam;
+ this.lParam = lParam;
+ cw = new CwPRetStruct();
+ Marshal.PtrToStructure(lParam, cw);
+ }
+ }
+
+ ///
+ /// CWPRETSTRUCT structure.
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public class CwPRetStruct
+ {
+ /// Return value.
+ public int lResult;
+ /// lParam parameter.
+ public int lParam;
+ /// wParam parameter.
+ public int wParam;
+ /// Specifies the message.
+ public WndMessage message;
+ /// Handle to the window that processed the message.
+ public IntPtr hwnd;
+ }
+
+ #endregion
+
+ ///////////////////////////////////////////////////////////////////////
+ #region Class WndProcRetHook
+
+ ///
+ /// Class to expose the windows WH_CALLWNDPROCRET hook mechanism.
+ ///
+ public class WndProcRetHook : WindowsHook
+ {
+ ///
+ /// WH_CALLWNDPROCRET hook delegate method.
+ ///
+ public delegate void WndProcEventHandler(object sender, WndProcRetEventArgs e);
+
+ private IntPtr hWndHooked;
+
+ ///
+ /// Window procedure event.
+ ///
+ public event WndProcEventHandler WndProcRet;
+
+ ///
+ /// Construct a WH_CALLWNDPROCRET hook.
+ ///
+ ///
+ /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
+ ///
+ public WndProcRetHook(IntPtr hWndHooked) : base(HookType.WH_CALLWNDPROCRET)
+ {
+ this.hWndHooked = hWndHooked;
+ this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
+ }
+ ///
+ /// Construct a WH_CALLWNDPROCRET hook giving a hook filter delegate method.
+ ///
+ ///
+ /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
+ ///
+ /// Hook filter event.
+ public WndProcRetHook(IntPtr hWndHooked, HookProc func) : base(HookType.WH_CALLWNDPROCRET, func)
+ {
+ this.hWndHooked = hWndHooked;
+ this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
+ }
+
+ // handles the hook event
+ private void WndProcRetHookInvoked(object sender, HookEventArgs e)
+ {
+ WndProcRetEventArgs wpe = new WndProcRetEventArgs(e.wParam, e.lParam);
+ if ((hWndHooked == IntPtr.Zero || wpe.cw.hwnd == hWndHooked) && WndProcRet != null)
+ WndProcRet(this, wpe);
+ return;
+ }
+ }
+ #endregion
+}
diff -r 19c1aaf900dc -r 7acec5059fa6 Servers.cs
--- a/Servers.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-using System;
-using System.Windows.Forms;
-
-namespace SharpDisplayManager
-{
- ///
- /// Implement our display service.
- /// This class is instantiated anew whenever a client send a request.
- ///
- class DisplayServer : IDisplayService
- {
- //From IDisplayService
- public void SetText(int aLineIndex, string aText)
- {
- if (aLineIndex == 0)
- {
- Program.iMainForm.marqueeLabelTop.Text = aText;
- }
- else if (aLineIndex == 1)
- {
- Program.iMainForm.marqueeLabelBottom.Text = aText;
- }
- }
-
- }
-
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 Services.cs
--- a/Services.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-using System;
-using System.ServiceModel;
-
-namespace SharpDisplayManager
-{
- [ServiceContract]
- public interface IDisplayService
- {
- [OperationContract]
- void SetText(int aLineIndex, string aText);
- }
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 SharpDisplayManager.csproj
--- a/SharpDisplayManager.csproj Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}
- WinExe
- Properties
- SharpDisplayManager
- SharpDisplayManager
- v4.5
- 512
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- MainForm.cs
-
-
-
-
-
-
-
-
-
-
- MainForm.cs
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -r 19c1aaf900dc -r 7acec5059fa6 SharpDisplayManager.sln
--- a/SharpDisplayManager.sln Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDisplayManager", "SharpDisplayManager.csproj", "{1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff -r 19c1aaf900dc -r 7acec5059fa6 Win32API.cs
--- a/Win32API.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-//=============================================================================
-// COPYRIGHT: Prosoft-Lanz
-//=============================================================================
-//
-// $Workfile: Win32API.cs $
-//
-// PROJECT : CodeProject Components
-// VERSION : 1.00
-// CREATION : 19.02.2003
-// AUTHOR : JCL
-//
-// DETAILS : This class implement Win32 API calls
-// and the contants used for these calls.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Text;
-using System.Drawing;
-using System.Windows.Forms;
-using System.Runtime.InteropServices;
-
-namespace CodeProject.Win32API
-{
- ///////////////////////////////////////////////////////////////////////
- #region Generic declarations
-
- ///
- /// Rectangle parameters exposed as a structure.
- ///
- public struct RECT
- {
- ///
- /// Rectangle members.
- ///
- public int left, top, right, bottom;
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Util class
-
- ///
- /// Utility functions.
- ///
- public sealed class API
- {
- private API() {} // To remove the constructor from the documentation!
-
- ///
- /// Get true multiscreen size.
- ///
- public static Rectangle TrueScreenRect
- {
- get
- {
- // get the biggest screen area
- Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea;
- int left = rectScreen.Left;
- int top = rectScreen.Top;
- int right = rectScreen.Right;
- int bottom = rectScreen.Bottom;
- foreach (Screen screen in Screen.AllScreens)
- {
- left = Math.Min(left, screen.WorkingArea.Left);
- right = Math.Max(right, screen.WorkingArea.Right);
- top = Math.Min(top, screen.WorkingArea.Top);
- bottom = Math.Max(bottom, screen.WorkingArea.Bottom);
- }
- return new Rectangle(left, top, right-left, bottom-top);
- }
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region USER32 class
-
- ///
- /// Class to expose USER32 API functions.
- ///
- public sealed class USER32
- {
- private USER32() {} // To remove the constructor from the documentation!
-
- [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect);
-
- [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int w, int h, int repaint);
-
- [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- internal static extern IntPtr GetActiveWindow();
-
- [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- internal static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
- }
- #endregion
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 WindowsHook.cs
--- a/WindowsHook.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-//=============================================================================
-// COPYRIGHT: Prosoft-Lanz
-//=============================================================================
-//
-// $Workfile: WindowsHook.cs $
-//
-// PROJECT : CodeProject Components
-// VERSION : 1.00
-// CREATION : 19.02.2003
-// AUTHOR : JCL
-//
-// DETAILS : This class implement the Windows hook mechanism.
-// From MSDN, Dino Esposito.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Runtime.InteropServices;
-
-namespace CodeProject.Win32API.Hook
-{
- ///////////////////////////////////////////////////////////////////////
- #region Class HookEventArgs
-
- /// Class used for hook event arguments.
- public class HookEventArgs : EventArgs
- {
- /// Event code parameter.
- public int code;
- /// wParam parameter.
- public IntPtr wParam;
- /// lParam parameter.
- public IntPtr lParam;
-
- internal HookEventArgs(int code, IntPtr wParam, IntPtr lParam)
- {
- this.code = code;
- this.wParam = wParam;
- this.lParam = lParam;
- }
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Enum HookType
-
- /// Hook Types.
- public enum HookType : int
- {
- /// 0
- WH_JOURNALRECORD = 0,
- /// 1
- WH_JOURNALPLAYBACK = 1,
- /// 2
- WH_KEYBOARD = 2,
- /// 3
- WH_GETMESSAGE = 3,
- /// 4
- WH_CALLWNDPROC = 4,
- /// 5
- WH_CBT = 5,
- /// 6
- WH_SYSMSGFILTER = 6,
- /// 7
- WH_MOUSE = 7,
- /// 8
- WH_HARDWARE = 8,
- /// 9
- WH_DEBUG = 9,
- /// 10
- WH_SHELL = 10,
- /// 11
- WH_FOREGROUNDIDLE = 11,
- /// 12
- WH_CALLWNDPROCRET = 12,
- /// 13
- WH_KEYBOARD_LL = 13,
- /// 14
- WH_MOUSE_LL = 14
- }
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Class WindowsHook
-
- ///
- /// Class to expose the windows hook mechanism.
- ///
- public class WindowsHook
- {
- ///
- /// Hook delegate method.
- ///
- public delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
-
- // internal properties
- internal IntPtr hHook = IntPtr.Zero;
- internal HookProc filterFunc = null;
- internal HookType hookType;
-
- ///
- /// Hook delegate method.
- ///
- public delegate void HookEventHandler(object sender, HookEventArgs e);
-
- ///
- /// Hook invoke event.
- ///
- public event HookEventHandler HookInvoke;
-
- internal void OnHookInvoke(HookEventArgs e)
- {
- if (HookInvoke != null)
- HookInvoke(this, e);
- }
-
- ///
- /// Construct a HookType hook.
- ///
- /// Hook type.
- public WindowsHook(HookType hook)
- {
- hookType = hook;
- filterFunc = new HookProc(this.CoreHookProc);
- }
- ///
- /// Construct a HookType hook giving a hook filter delegate method.
- ///
- /// Hook type
- /// Hook filter event.
- public WindowsHook(HookType hook, HookProc func)
- {
- hookType = hook;
- filterFunc = func;
- }
-
- // default hook filter function
- internal int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
- {
- if (code < 0)
- return CallNextHookEx(hHook, code, wParam, lParam);
-
- // let clients determine what to do
- HookEventArgs e = new HookEventArgs(code, wParam, lParam);
- OnHookInvoke(e);
-
- // yield to the next hook in the chain
- return CallNextHookEx(hHook, code, wParam, lParam);
- }
-
- ///
- /// Install the hook.
- ///
- public void Install()
- {
- hHook = SetWindowsHookEx(hookType, filterFunc, IntPtr.Zero, (int)AppDomain.GetCurrentThreadId());
- }
-
-
- ///
- /// Uninstall the hook.
- ///
- public void Uninstall()
- {
- if (hHook != IntPtr.Zero)
- {
- UnhookWindowsHookEx(hHook);
- hHook = IntPtr.Zero;
- }
- }
-
- #region Win32 Imports
-
- [DllImport("user32.dll")]
- internal static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
-
- [DllImport("user32.dll")]
- internal static extern int UnhookWindowsHookEx(IntPtr hhook);
-
- [DllImport("user32.dll")]
- internal static extern int CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam);
-
- #endregion
- }
- #endregion
-}
diff -r 19c1aaf900dc -r 7acec5059fa6 WndProcRetHook.cs
--- a/WndProcRetHook.cs Tue Aug 12 20:37:57 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-//=============================================================================
-// COPYRIGHT: Prosoft-Lanz
-//=============================================================================
-//
-// $Workfile: WndProcRetHook.cs $
-//
-// PROJECT : CodeProject Components
-// VERSION : 1.00
-// CREATION : 19.02.2003
-// AUTHOR : JCL
-//
-// DETAILS : This class implement the WH_CALLWNDPROCRET Windows hook mechanism.
-// From MSDN, Dino Esposito.
-//
-// WindowCreate, WindowDestroye and WindowActivate user events.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Runtime.InteropServices;
-using System.Diagnostics;
-
-namespace CodeProject.Win32API.Hook
-{
- ///////////////////////////////////////////////////////////////////////
- #region Enum WndMessage
-
- ///
- /// windows message.
- ///
- public enum WndMessage : int
- {
- /// Sent to the dialog procedure immediately before the dialog is displayed.
- WM_INITDIALOG = 0x0110,
- /// Sent to the dialog procedure immediately before the dialog is displayed.
- WM_UNKNOWINIT = 0x0127
- }
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Class WndProcRetEventArgs
-
- /// Class used for WH_CALLWNDPROCRET hook event arguments.
- public class WndProcRetEventArgs : EventArgs
- {
- /// wParam parameter.
- public IntPtr wParam;
- /// lParam parameter.
- public IntPtr lParam;
- /// CWPRETSTRUCT structure.
- public CwPRetStruct cw;
-
- internal WndProcRetEventArgs(IntPtr wParam, IntPtr lParam)
- {
- this.wParam = wParam;
- this.lParam = lParam;
- cw = new CwPRetStruct();
- Marshal.PtrToStructure(lParam, cw);
- }
- }
-
- ///
- /// CWPRETSTRUCT structure.
- ///
- [StructLayout(LayoutKind.Sequential)]
- public class CwPRetStruct
- {
- /// Return value.
- public int lResult;
- /// lParam parameter.
- public int lParam;
- /// wParam parameter.
- public int wParam;
- /// Specifies the message.
- public WndMessage message;
- /// Handle to the window that processed the message.
- public IntPtr hwnd;
- }
-
- #endregion
-
- ///////////////////////////////////////////////////////////////////////
- #region Class WndProcRetHook
-
- ///
- /// Class to expose the windows WH_CALLWNDPROCRET hook mechanism.
- ///
- public class WndProcRetHook : WindowsHook
- {
- ///
- /// WH_CALLWNDPROCRET hook delegate method.
- ///
- public delegate void WndProcEventHandler(object sender, WndProcRetEventArgs e);
-
- private IntPtr hWndHooked;
-
- ///
- /// Window procedure event.
- ///
- public event WndProcEventHandler WndProcRet;
-
- ///
- /// Construct a WH_CALLWNDPROCRET hook.
- ///
- ///
- /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
- ///
- public WndProcRetHook(IntPtr hWndHooked) : base(HookType.WH_CALLWNDPROCRET)
- {
- this.hWndHooked = hWndHooked;
- this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
- }
- ///
- /// Construct a WH_CALLWNDPROCRET hook giving a hook filter delegate method.
- ///
- ///
- /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
- ///
- /// Hook filter event.
- public WndProcRetHook(IntPtr hWndHooked, HookProc func) : base(HookType.WH_CALLWNDPROCRET, func)
- {
- this.hWndHooked = hWndHooked;
- this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
- }
-
- // handles the hook event
- private void WndProcRetHookInvoked(object sender, HookEventArgs e)
- {
- WndProcRetEventArgs wpe = new WndProcRetEventArgs(e.wParam, e.lParam);
- if ((hWndHooked == IntPtr.Zero || wpe.cw.hwnd == hWndHooked) && WndProcRet != null)
- WndProcRet(this, wpe);
- return;
- }
- }
- #endregion
-}