Adding our client implementation. Moving server into its own folder.
1.1 --- a/App.config Tue Aug 12 20:37:57 2014 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,30 +0,0 @@
1.4 -<?xml version="1.0" encoding="utf-8" ?>
1.5 -<configuration>
1.6 - <configSections>
1.7 - <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
1.8 - <section name="SharpDisplayManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
1.9 - </sectionGroup>
1.10 - </configSections>
1.11 - <startup>
1.12 - <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
1.13 - </startup>
1.14 - <userSettings>
1.15 - <SharpDisplayManager.Properties.Settings>
1.16 - <setting name="DisplayBrightness" serializeAs="String">
1.17 - <value>1</value>
1.18 - </setting>
1.19 - <setting name="DisplayFont" serializeAs="String">
1.20 - <value>Microsoft Sans Serif, 9.75pt</value>
1.21 - </setting>
1.22 - <setting name="DisplayShowBorders" serializeAs="String">
1.23 - <value>False</value>
1.24 - </setting>
1.25 - <setting name="DisplayConnectOnStartup" serializeAs="String">
1.26 - <value>False</value>
1.27 - </setting>
1.28 - <setting name="DisplayReverseScreen" serializeAs="String">
1.29 - <value>False</value>
1.30 - </setting>
1.31 - </SharpDisplayManager.Properties.Settings>
1.32 - </userSettings>
1.33 -</configuration>
1.34 \ No newline at end of file
2.1 --- a/CbtHook.cs Tue Aug 12 20:37:57 2014 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,171 +0,0 @@
2.4 -//=============================================================================
2.5 -// COPYRIGHT: Prosoft-Lanz
2.6 -//=============================================================================
2.7 -//
2.8 -// $Workfile: CbtHook.cs $
2.9 -//
2.10 -// PROJECT : CodeProject Components
2.11 -// VERSION : 1.00
2.12 -// CREATION : 19.02.2003
2.13 -// AUTHOR : JCL
2.14 -//
2.15 -// DETAILS : This class implement the WH_CBT Windows hook mechanism.
2.16 -// From MSDN, Dino Esposito.
2.17 -// WindowCreate, WindowDestroy and WindowActivate user events.
2.18 -//
2.19 -//-----------------------------------------------------------------------------
2.20 -using System;
2.21 -using System.Text;
2.22 -using System.Runtime.InteropServices;
2.23 -
2.24 -namespace CodeProject.Win32API.Hook
2.25 -{
2.26 - ///////////////////////////////////////////////////////////////////////
2.27 - #region Enum CbtHookAction
2.28 -
2.29 - /// <summary>
2.30 - /// CBT hook actions.
2.31 - /// </summary>
2.32 - internal enum CbtHookAction : int
2.33 - {
2.34 - HCBT_MOVESIZE = 0,
2.35 - HCBT_MINMAX = 1,
2.36 - HCBT_QS = 2,
2.37 - HCBT_CREATEWND = 3,
2.38 - HCBT_DESTROYWND = 4,
2.39 - HCBT_ACTIVATE = 5,
2.40 - HCBT_CLICKSKIPPED = 6,
2.41 - HCBT_KEYSKIPPED = 7,
2.42 - HCBT_SYSCOMMAND = 8,
2.43 - HCBT_SETFOCUS = 9
2.44 - }
2.45 -
2.46 - #endregion
2.47 -
2.48 - ///////////////////////////////////////////////////////////////////////
2.49 - #region Class CbtEventArgs
2.50 -
2.51 - /// <summary>
2.52 - /// Class used for WH_CBT hook event arguments.
2.53 - /// </summary>
2.54 - public class CbtEventArgs : EventArgs
2.55 - {
2.56 - /// wParam parameter.
2.57 - public IntPtr wParam;
2.58 - /// lParam parameter.
2.59 - public IntPtr lParam;
2.60 - /// Window class name.
2.61 - public string className;
2.62 - /// True if it is a dialog window.
2.63 - public bool IsDialog;
2.64 -
2.65 - internal CbtEventArgs(IntPtr wParam, IntPtr lParam)
2.66 - {
2.67 - // cache the parameters
2.68 - this.wParam = wParam;
2.69 - this.lParam = lParam;
2.70 -
2.71 - // cache the window's class name
2.72 - StringBuilder sb = new StringBuilder();
2.73 - sb.Capacity = 256;
2.74 - USER32.GetClassName(wParam, sb, 256);
2.75 - className = sb.ToString();
2.76 - IsDialog = (className == "#32770");
2.77 - }
2.78 - }
2.79 -
2.80 - #endregion
2.81 -
2.82 - ///////////////////////////////////////////////////////////////////////
2.83 - #region Class CbtHook
2.84 -
2.85 - /// <summary>
2.86 - /// Class to expose the windows WH_CBT hook mechanism.
2.87 - /// </summary>
2.88 - public class CbtHook : WindowsHook
2.89 - {
2.90 - /// <summary>
2.91 - /// WH_CBT hook delegate method.
2.92 - /// </summary>
2.93 - public delegate void CbtEventHandler(object sender, CbtEventArgs e);
2.94 -
2.95 - /// <summary>
2.96 - /// WH_CBT create event.
2.97 - /// </summary>
2.98 - public event CbtEventHandler WindowCreate;
2.99 - /// <summary>
2.100 - /// WH_CBT destroy event.
2.101 - /// </summary>
2.102 - public event CbtEventHandler WindowDestroye;
2.103 - /// <summary>
2.104 - /// WH_CBT activate event.
2.105 - /// </summary>
2.106 - public event CbtEventHandler WindowActivate;
2.107 -
2.108 - /// <summary>
2.109 - /// Construct a WH_CBT hook.
2.110 - /// </summary>
2.111 - public CbtHook() : base(HookType.WH_CBT)
2.112 - {
2.113 - this.HookInvoke += new HookEventHandler(CbtHookInvoked);
2.114 - }
2.115 - /// <summary>
2.116 - /// Construct a WH_CBT hook giving a hook filter delegate method.
2.117 - /// </summary>
2.118 - /// <param name="func">Hook filter event.</param>
2.119 - public CbtHook(HookProc func) : base(HookType.WH_CBT, func)
2.120 - {
2.121 - this.HookInvoke += new HookEventHandler(CbtHookInvoked);
2.122 - }
2.123 -
2.124 - // handles the hook event
2.125 - private void CbtHookInvoked(object sender, HookEventArgs e)
2.126 - {
2.127 - // handle hook events (only a few of available actions)
2.128 - switch ((CbtHookAction)e.code)
2.129 - {
2.130 - case CbtHookAction.HCBT_CREATEWND:
2.131 - HandleCreateWndEvent(e.wParam, e.lParam);
2.132 - break;
2.133 - case CbtHookAction.HCBT_DESTROYWND:
2.134 - HandleDestroyWndEvent(e.wParam, e.lParam);
2.135 - break;
2.136 - case CbtHookAction.HCBT_ACTIVATE:
2.137 - HandleActivateEvent(e.wParam, e.lParam);
2.138 - break;
2.139 - }
2.140 - return;
2.141 - }
2.142 -
2.143 - // handle the CREATEWND hook event
2.144 - private void HandleCreateWndEvent(IntPtr wParam, IntPtr lParam)
2.145 - {
2.146 - if (WindowCreate != null)
2.147 - {
2.148 - CbtEventArgs e = new CbtEventArgs(wParam, lParam);
2.149 - WindowCreate(this, e);
2.150 - }
2.151 - }
2.152 -
2.153 - // handle the DESTROYWND hook event
2.154 - private void HandleDestroyWndEvent(IntPtr wParam, IntPtr lParam)
2.155 - {
2.156 - if (WindowDestroye != null)
2.157 - {
2.158 - CbtEventArgs e = new CbtEventArgs(wParam, lParam);
2.159 - WindowDestroye(this, e);
2.160 - }
2.161 - }
2.162 -
2.163 - // handle the ACTIVATE hook event
2.164 - private void HandleActivateEvent(IntPtr wParam, IntPtr lParam)
2.165 - {
2.166 - if (WindowActivate != null)
2.167 - {
2.168 - CbtEventArgs e = new CbtEventArgs(wParam, lParam);
2.169 - WindowActivate(this, e);
2.170 - }
2.171 - }
2.172 - }
2.173 - #endregion
2.174 -}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/Client/App.config Tue Aug 12 20:55:50 2014 +0200
3.3 @@ -0,0 +1,6 @@
3.4 +<?xml version="1.0" encoding="utf-8" ?>
3.5 +<configuration>
3.6 + <startup>
3.7 + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
3.8 + </startup>
3.9 +</configuration>
3.10 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/Client/MainForm.Designer.cs Tue Aug 12 20:55:50 2014 +0200
4.3 @@ -0,0 +1,62 @@
4.4 +namespace SharpDisplayClient
4.5 +{
4.6 + partial class MainForm
4.7 + {
4.8 + /// <summary>
4.9 + /// Required designer variable.
4.10 + /// </summary>
4.11 + private System.ComponentModel.IContainer components = null;
4.12 +
4.13 + /// <summary>
4.14 + /// Clean up any resources being used.
4.15 + /// </summary>
4.16 + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
4.17 + protected override void Dispose(bool disposing)
4.18 + {
4.19 + if (disposing && (components != null))
4.20 + {
4.21 + components.Dispose();
4.22 + }
4.23 + base.Dispose(disposing);
4.24 + }
4.25 +
4.26 + #region Windows Form Designer generated code
4.27 +
4.28 + /// <summary>
4.29 + /// Required method for Designer support - do not modify
4.30 + /// the contents of this method with the code editor.
4.31 + /// </summary>
4.32 + private void InitializeComponent()
4.33 + {
4.34 + this.buttonSetText = new System.Windows.Forms.Button();
4.35 + this.SuspendLayout();
4.36 + //
4.37 + // buttonSetText
4.38 + //
4.39 + this.buttonSetText.Location = new System.Drawing.Point(170, 104);
4.40 + this.buttonSetText.Name = "buttonSetText";
4.41 + this.buttonSetText.Size = new System.Drawing.Size(75, 23);
4.42 + this.buttonSetText.TabIndex = 0;
4.43 + this.buttonSetText.Text = "Set Text";
4.44 + this.buttonSetText.UseVisualStyleBackColor = true;
4.45 + this.buttonSetText.Click += new System.EventHandler(this.buttonSetText_Click);
4.46 + //
4.47 + // MainForm
4.48 + //
4.49 + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
4.50 + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
4.51 + this.ClientSize = new System.Drawing.Size(443, 252);
4.52 + this.Controls.Add(this.buttonSetText);
4.53 + this.Name = "MainForm";
4.54 + this.Text = "Sharp Display Client";
4.55 + this.Load += new System.EventHandler(this.MainForm_Load);
4.56 + this.ResumeLayout(false);
4.57 +
4.58 + }
4.59 +
4.60 + #endregion
4.61 +
4.62 + private System.Windows.Forms.Button buttonSetText;
4.63 + }
4.64 +}
4.65 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/Client/MainForm.cs Tue Aug 12 20:55:50 2014 +0200
5.3 @@ -0,0 +1,43 @@
5.4 +using System;
5.5 +using System.Collections.Generic;
5.6 +using System.ComponentModel;
5.7 +using System.Data;
5.8 +using System.Drawing;
5.9 +using System.Linq;
5.10 +using System.Text;
5.11 +using System.Threading.Tasks;
5.12 +using System.Windows.Forms;
5.13 +using System.ServiceModel;
5.14 +using System.ServiceModel.Channels;
5.15 +using SharpDisplayManager;
5.16 +
5.17 +namespace SharpDisplayClient
5.18 +{
5.19 + public partial class MainForm : Form
5.20 + {
5.21 + ChannelFactory<SharpDisplayManager.IDisplayService> iChannelFactory;
5.22 + SharpDisplayManager.IDisplayService iClient;
5.23 +
5.24 + public MainForm()
5.25 + {
5.26 + InitializeComponent();
5.27 + }
5.28 +
5.29 + private void buttonSetText_Click(object sender, EventArgs e)
5.30 + {
5.31 + iClient.SetText(0,"Top");
5.32 + iClient.SetText(1, "Bottom");
5.33 + }
5.34 +
5.35 + private void MainForm_Load(object sender, EventArgs e)
5.36 + {
5.37 +
5.38 + iChannelFactory = new ChannelFactory<SharpDisplayManager.IDisplayService>(
5.39 + new NetNamedPipeBinding(),
5.40 + new EndpointAddress(
5.41 + "net.pipe://localhost/DisplayService"));
5.42 +
5.43 + iClient = iChannelFactory.CreateChannel();
5.44 + }
5.45 + }
5.46 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/Client/MainForm.resx Tue Aug 12 20:55:50 2014 +0200
6.3 @@ -0,0 +1,120 @@
6.4 +<?xml version="1.0" encoding="utf-8"?>
6.5 +<root>
6.6 + <!--
6.7 + Microsoft ResX Schema
6.8 +
6.9 + Version 2.0
6.10 +
6.11 + The primary goals of this format is to allow a simple XML format
6.12 + that is mostly human readable. The generation and parsing of the
6.13 + various data types are done through the TypeConverter classes
6.14 + associated with the data types.
6.15 +
6.16 + Example:
6.17 +
6.18 + ... ado.net/XML headers & schema ...
6.19 + <resheader name="resmimetype">text/microsoft-resx</resheader>
6.20 + <resheader name="version">2.0</resheader>
6.21 + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
6.22 + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
6.23 + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
6.24 + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
6.25 + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
6.26 + <value>[base64 mime encoded serialized .NET Framework object]</value>
6.27 + </data>
6.28 + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
6.29 + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
6.30 + <comment>This is a comment</comment>
6.31 + </data>
6.32 +
6.33 + There are any number of "resheader" rows that contain simple
6.34 + name/value pairs.
6.35 +
6.36 + Each data row contains a name, and value. The row also contains a
6.37 + type or mimetype. Type corresponds to a .NET class that support
6.38 + text/value conversion through the TypeConverter architecture.
6.39 + Classes that don't support this are serialized and stored with the
6.40 + mimetype set.
6.41 +
6.42 + The mimetype is used for serialized objects, and tells the
6.43 + ResXResourceReader how to depersist the object. This is currently not
6.44 + extensible. For a given mimetype the value must be set accordingly:
6.45 +
6.46 + Note - application/x-microsoft.net.object.binary.base64 is the format
6.47 + that the ResXResourceWriter will generate, however the reader can
6.48 + read any of the formats listed below.
6.49 +
6.50 + mimetype: application/x-microsoft.net.object.binary.base64
6.51 + value : The object must be serialized with
6.52 + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
6.53 + : and then encoded with base64 encoding.
6.54 +
6.55 + mimetype: application/x-microsoft.net.object.soap.base64
6.56 + value : The object must be serialized with
6.57 + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
6.58 + : and then encoded with base64 encoding.
6.59 +
6.60 + mimetype: application/x-microsoft.net.object.bytearray.base64
6.61 + value : The object must be serialized into a byte array
6.62 + : using a System.ComponentModel.TypeConverter
6.63 + : and then encoded with base64 encoding.
6.64 + -->
6.65 + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
6.66 + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6.67 + <xsd:element name="root" msdata:IsDataSet="true">
6.68 + <xsd:complexType>
6.69 + <xsd:choice maxOccurs="unbounded">
6.70 + <xsd:element name="metadata">
6.71 + <xsd:complexType>
6.72 + <xsd:sequence>
6.73 + <xsd:element name="value" type="xsd:string" minOccurs="0" />
6.74 + </xsd:sequence>
6.75 + <xsd:attribute name="name" use="required" type="xsd:string" />
6.76 + <xsd:attribute name="type" type="xsd:string" />
6.77 + <xsd:attribute name="mimetype" type="xsd:string" />
6.78 + <xsd:attribute ref="xml:space" />
6.79 + </xsd:complexType>
6.80 + </xsd:element>
6.81 + <xsd:element name="assembly">
6.82 + <xsd:complexType>
6.83 + <xsd:attribute name="alias" type="xsd:string" />
6.84 + <xsd:attribute name="name" type="xsd:string" />
6.85 + </xsd:complexType>
6.86 + </xsd:element>
6.87 + <xsd:element name="data">
6.88 + <xsd:complexType>
6.89 + <xsd:sequence>
6.90 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
6.91 + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
6.92 + </xsd:sequence>
6.93 + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
6.94 + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
6.95 + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
6.96 + <xsd:attribute ref="xml:space" />
6.97 + </xsd:complexType>
6.98 + </xsd:element>
6.99 + <xsd:element name="resheader">
6.100 + <xsd:complexType>
6.101 + <xsd:sequence>
6.102 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
6.103 + </xsd:sequence>
6.104 + <xsd:attribute name="name" type="xsd:string" use="required" />
6.105 + </xsd:complexType>
6.106 + </xsd:element>
6.107 + </xsd:choice>
6.108 + </xsd:complexType>
6.109 + </xsd:element>
6.110 + </xsd:schema>
6.111 + <resheader name="resmimetype">
6.112 + <value>text/microsoft-resx</value>
6.113 + </resheader>
6.114 + <resheader name="version">
6.115 + <value>2.0</value>
6.116 + </resheader>
6.117 + <resheader name="reader">
6.118 + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
6.119 + </resheader>
6.120 + <resheader name="writer">
6.121 + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
6.122 + </resheader>
6.123 +</root>
6.124 \ No newline at end of file
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/Client/Program.cs Tue Aug 12 20:55:50 2014 +0200
7.3 @@ -0,0 +1,22 @@
7.4 +using System;
7.5 +using System.Collections.Generic;
7.6 +using System.Linq;
7.7 +using System.Threading.Tasks;
7.8 +using System.Windows.Forms;
7.9 +
7.10 +namespace SharpDisplayClient
7.11 +{
7.12 + static class Program
7.13 + {
7.14 + /// <summary>
7.15 + /// The main entry point for the application.
7.16 + /// </summary>
7.17 + [STAThread]
7.18 + static void Main()
7.19 + {
7.20 + Application.EnableVisualStyles();
7.21 + Application.SetCompatibleTextRenderingDefault(false);
7.22 + Application.Run(new MainForm());
7.23 + }
7.24 + }
7.25 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/Client/Properties/AssemblyInfo.cs Tue Aug 12 20:55:50 2014 +0200
8.3 @@ -0,0 +1,36 @@
8.4 +using System.Reflection;
8.5 +using System.Runtime.CompilerServices;
8.6 +using System.Runtime.InteropServices;
8.7 +
8.8 +// General Information about an assembly is controlled through the following
8.9 +// set of attributes. Change these attribute values to modify the information
8.10 +// associated with an assembly.
8.11 +[assembly: AssemblyTitle("SharpDisplayClient")]
8.12 +[assembly: AssemblyDescription("")]
8.13 +[assembly: AssemblyConfiguration("")]
8.14 +[assembly: AssemblyCompany("")]
8.15 +[assembly: AssemblyProduct("SharpDisplayClient")]
8.16 +[assembly: AssemblyCopyright("Copyright © 2014")]
8.17 +[assembly: AssemblyTrademark("")]
8.18 +[assembly: AssemblyCulture("")]
8.19 +
8.20 +// Setting ComVisible to false makes the types in this assembly not visible
8.21 +// to COM components. If you need to access a type in this assembly from
8.22 +// COM, set the ComVisible attribute to true on that type.
8.23 +[assembly: ComVisible(false)]
8.24 +
8.25 +// The following GUID is for the ID of the typelib if this project is exposed to COM
8.26 +[assembly: Guid("36255ddc-eb97-4253-8696-3e360b5bc824")]
8.27 +
8.28 +// Version information for an assembly consists of the following four values:
8.29 +//
8.30 +// Major Version
8.31 +// Minor Version
8.32 +// Build Number
8.33 +// Revision
8.34 +//
8.35 +// You can specify all the values or you can default the Build and Revision Numbers
8.36 +// by using the '*' as shown below:
8.37 +// [assembly: AssemblyVersion("1.0.*")]
8.38 +[assembly: AssemblyVersion("1.0.0.0")]
8.39 +[assembly: AssemblyFileVersion("1.0.0.0")]
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/Client/Properties/Resources.Designer.cs Tue Aug 12 20:55:50 2014 +0200
9.3 @@ -0,0 +1,71 @@
9.4 +//------------------------------------------------------------------------------
9.5 +// <auto-generated>
9.6 +// This code was generated by a tool.
9.7 +// Runtime Version:4.0.30319.18444
9.8 +//
9.9 +// Changes to this file may cause incorrect behavior and will be lost if
9.10 +// the code is regenerated.
9.11 +// </auto-generated>
9.12 +//------------------------------------------------------------------------------
9.13 +
9.14 +namespace SharpDisplayClient.Properties
9.15 +{
9.16 +
9.17 +
9.18 + /// <summary>
9.19 + /// A strongly-typed resource class, for looking up localized strings, etc.
9.20 + /// </summary>
9.21 + // This class was auto-generated by the StronglyTypedResourceBuilder
9.22 + // class via a tool like ResGen or Visual Studio.
9.23 + // To add or remove a member, edit your .ResX file then rerun ResGen
9.24 + // with the /str option, or rebuild your VS project.
9.25 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
9.26 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
9.27 + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
9.28 + internal class Resources
9.29 + {
9.30 +
9.31 + private static global::System.Resources.ResourceManager resourceMan;
9.32 +
9.33 + private static global::System.Globalization.CultureInfo resourceCulture;
9.34 +
9.35 + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
9.36 + internal Resources()
9.37 + {
9.38 + }
9.39 +
9.40 + /// <summary>
9.41 + /// Returns the cached ResourceManager instance used by this class.
9.42 + /// </summary>
9.43 + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
9.44 + internal static global::System.Resources.ResourceManager ResourceManager
9.45 + {
9.46 + get
9.47 + {
9.48 + if ((resourceMan == null))
9.49 + {
9.50 + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDisplayClient.Properties.Resources", typeof(Resources).Assembly);
9.51 + resourceMan = temp;
9.52 + }
9.53 + return resourceMan;
9.54 + }
9.55 + }
9.56 +
9.57 + /// <summary>
9.58 + /// Overrides the current thread's CurrentUICulture property for all
9.59 + /// resource lookups using this strongly typed resource class.
9.60 + /// </summary>
9.61 + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
9.62 + internal static global::System.Globalization.CultureInfo Culture
9.63 + {
9.64 + get
9.65 + {
9.66 + return resourceCulture;
9.67 + }
9.68 + set
9.69 + {
9.70 + resourceCulture = value;
9.71 + }
9.72 + }
9.73 + }
9.74 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/Client/Properties/Resources.resx Tue Aug 12 20:55:50 2014 +0200
10.3 @@ -0,0 +1,117 @@
10.4 +<?xml version="1.0" encoding="utf-8"?>
10.5 +<root>
10.6 + <!--
10.7 + Microsoft ResX Schema
10.8 +
10.9 + Version 2.0
10.10 +
10.11 + The primary goals of this format is to allow a simple XML format
10.12 + that is mostly human readable. The generation and parsing of the
10.13 + various data types are done through the TypeConverter classes
10.14 + associated with the data types.
10.15 +
10.16 + Example:
10.17 +
10.18 + ... ado.net/XML headers & schema ...
10.19 + <resheader name="resmimetype">text/microsoft-resx</resheader>
10.20 + <resheader name="version">2.0</resheader>
10.21 + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
10.22 + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
10.23 + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
10.24 + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
10.25 + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
10.26 + <value>[base64 mime encoded serialized .NET Framework object]</value>
10.27 + </data>
10.28 + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
10.29 + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
10.30 + <comment>This is a comment</comment>
10.31 + </data>
10.32 +
10.33 + There are any number of "resheader" rows that contain simple
10.34 + name/value pairs.
10.35 +
10.36 + Each data row contains a name, and value. The row also contains a
10.37 + type or mimetype. Type corresponds to a .NET class that support
10.38 + text/value conversion through the TypeConverter architecture.
10.39 + Classes that don't support this are serialized and stored with the
10.40 + mimetype set.
10.41 +
10.42 + The mimetype is used for serialized objects, and tells the
10.43 + ResXResourceReader how to depersist the object. This is currently not
10.44 + extensible. For a given mimetype the value must be set accordingly:
10.45 +
10.46 + Note - application/x-microsoft.net.object.binary.base64 is the format
10.47 + that the ResXResourceWriter will generate, however the reader can
10.48 + read any of the formats listed below.
10.49 +
10.50 + mimetype: application/x-microsoft.net.object.binary.base64
10.51 + value : The object must be serialized with
10.52 + : System.Serialization.Formatters.Binary.BinaryFormatter
10.53 + : and then encoded with base64 encoding.
10.54 +
10.55 + mimetype: application/x-microsoft.net.object.soap.base64
10.56 + value : The object must be serialized with
10.57 + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
10.58 + : and then encoded with base64 encoding.
10.59 +
10.60 + mimetype: application/x-microsoft.net.object.bytearray.base64
10.61 + value : The object must be serialized into a byte array
10.62 + : using a System.ComponentModel.TypeConverter
10.63 + : and then encoded with base64 encoding.
10.64 + -->
10.65 + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
10.66 + <xsd:element name="root" msdata:IsDataSet="true">
10.67 + <xsd:complexType>
10.68 + <xsd:choice maxOccurs="unbounded">
10.69 + <xsd:element name="metadata">
10.70 + <xsd:complexType>
10.71 + <xsd:sequence>
10.72 + <xsd:element name="value" type="xsd:string" minOccurs="0" />
10.73 + </xsd:sequence>
10.74 + <xsd:attribute name="name" type="xsd:string" />
10.75 + <xsd:attribute name="type" type="xsd:string" />
10.76 + <xsd:attribute name="mimetype" type="xsd:string" />
10.77 + </xsd:complexType>
10.78 + </xsd:element>
10.79 + <xsd:element name="assembly">
10.80 + <xsd:complexType>
10.81 + <xsd:attribute name="alias" type="xsd:string" />
10.82 + <xsd:attribute name="name" type="xsd:string" />
10.83 + </xsd:complexType>
10.84 + </xsd:element>
10.85 + <xsd:element name="data">
10.86 + <xsd:complexType>
10.87 + <xsd:sequence>
10.88 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
10.89 + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
10.90 + </xsd:sequence>
10.91 + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
10.92 + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
10.93 + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
10.94 + </xsd:complexType>
10.95 + </xsd:element>
10.96 + <xsd:element name="resheader">
10.97 + <xsd:complexType>
10.98 + <xsd:sequence>
10.99 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
10.100 + </xsd:sequence>
10.101 + <xsd:attribute name="name" type="xsd:string" use="required" />
10.102 + </xsd:complexType>
10.103 + </xsd:element>
10.104 + </xsd:choice>
10.105 + </xsd:complexType>
10.106 + </xsd:element>
10.107 + </xsd:schema>
10.108 + <resheader name="resmimetype">
10.109 + <value>text/microsoft-resx</value>
10.110 + </resheader>
10.111 + <resheader name="version">
10.112 + <value>2.0</value>
10.113 + </resheader>
10.114 + <resheader name="reader">
10.115 + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
10.116 + </resheader>
10.117 + <resheader name="writer">
10.118 + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
10.119 + </resheader>
10.120 +</root>
10.121 \ No newline at end of file
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/Client/Properties/Settings.Designer.cs Tue Aug 12 20:55:50 2014 +0200
11.3 @@ -0,0 +1,30 @@
11.4 +//------------------------------------------------------------------------------
11.5 +// <auto-generated>
11.6 +// This code was generated by a tool.
11.7 +// Runtime Version:4.0.30319.18444
11.8 +//
11.9 +// Changes to this file may cause incorrect behavior and will be lost if
11.10 +// the code is regenerated.
11.11 +// </auto-generated>
11.12 +//------------------------------------------------------------------------------
11.13 +
11.14 +namespace SharpDisplayClient.Properties
11.15 +{
11.16 +
11.17 +
11.18 + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
11.19 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
11.20 + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
11.21 + {
11.22 +
11.23 + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
11.24 +
11.25 + public static Settings Default
11.26 + {
11.27 + get
11.28 + {
11.29 + return defaultInstance;
11.30 + }
11.31 + }
11.32 + }
11.33 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/Client/Properties/Settings.settings Tue Aug 12 20:55:50 2014 +0200
12.3 @@ -0,0 +1,7 @@
12.4 +<?xml version='1.0' encoding='utf-8'?>
12.5 +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
12.6 + <Profiles>
12.7 + <Profile Name="(Default)" />
12.8 + </Profiles>
12.9 + <Settings />
12.10 +</SettingsFile>
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/Client/SharpDisplayClient.csproj Tue Aug 12 20:55:50 2014 +0200
13.3 @@ -0,0 +1,95 @@
13.4 +<?xml version="1.0" encoding="utf-8"?>
13.5 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
13.6 + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
13.7 + <PropertyGroup>
13.8 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
13.9 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
13.10 + <ProjectGuid>{7EE64074-8CDB-4448-B40C-81B75D6B31CD}</ProjectGuid>
13.11 + <OutputType>WinExe</OutputType>
13.12 + <AppDesignerFolder>Properties</AppDesignerFolder>
13.13 + <RootNamespace>SharpDisplayClient</RootNamespace>
13.14 + <AssemblyName>SharpDisplayClient</AssemblyName>
13.15 + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13.16 + <FileAlignment>512</FileAlignment>
13.17 + </PropertyGroup>
13.18 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13.19 + <PlatformTarget>AnyCPU</PlatformTarget>
13.20 + <DebugSymbols>true</DebugSymbols>
13.21 + <DebugType>full</DebugType>
13.22 + <Optimize>false</Optimize>
13.23 + <OutputPath>bin\Debug\</OutputPath>
13.24 + <DefineConstants>DEBUG;TRACE</DefineConstants>
13.25 + <ErrorReport>prompt</ErrorReport>
13.26 + <WarningLevel>4</WarningLevel>
13.27 + </PropertyGroup>
13.28 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
13.29 + <PlatformTarget>AnyCPU</PlatformTarget>
13.30 + <DebugType>pdbonly</DebugType>
13.31 + <Optimize>true</Optimize>
13.32 + <OutputPath>bin\Release\</OutputPath>
13.33 + <DefineConstants>TRACE</DefineConstants>
13.34 + <ErrorReport>prompt</ErrorReport>
13.35 + <WarningLevel>4</WarningLevel>
13.36 + </PropertyGroup>
13.37 + <ItemGroup>
13.38 + <Reference Include="System" />
13.39 + <Reference Include="System.Core" />
13.40 + <Reference Include="System.ServiceModel" />
13.41 + <Reference Include="System.Xml.Linq" />
13.42 + <Reference Include="System.Data.DataSetExtensions" />
13.43 + <Reference Include="Microsoft.CSharp" />
13.44 + <Reference Include="System.Data" />
13.45 + <Reference Include="System.Deployment" />
13.46 + <Reference Include="System.Drawing" />
13.47 + <Reference Include="System.Windows.Forms" />
13.48 + <Reference Include="System.Xml" />
13.49 + </ItemGroup>
13.50 + <ItemGroup>
13.51 + <Compile Include="MainForm.cs">
13.52 + <SubType>Form</SubType>
13.53 + </Compile>
13.54 + <Compile Include="MainForm.Designer.cs">
13.55 + <DependentUpon>MainForm.cs</DependentUpon>
13.56 + </Compile>
13.57 + <Compile Include="Program.cs" />
13.58 + <Compile Include="Properties\AssemblyInfo.cs" />
13.59 + <EmbeddedResource Include="MainForm.resx">
13.60 + <DependentUpon>MainForm.cs</DependentUpon>
13.61 + </EmbeddedResource>
13.62 + <EmbeddedResource Include="Properties\Resources.resx">
13.63 + <Generator>ResXFileCodeGenerator</Generator>
13.64 + <LastGenOutput>Resources.Designer.cs</LastGenOutput>
13.65 + <SubType>Designer</SubType>
13.66 + </EmbeddedResource>
13.67 + <Compile Include="Properties\Resources.Designer.cs">
13.68 + <AutoGen>True</AutoGen>
13.69 + <DependentUpon>Resources.resx</DependentUpon>
13.70 + </Compile>
13.71 + <None Include="Properties\Settings.settings">
13.72 + <Generator>SettingsSingleFileGenerator</Generator>
13.73 + <LastGenOutput>Settings.Designer.cs</LastGenOutput>
13.74 + </None>
13.75 + <Compile Include="Properties\Settings.Designer.cs">
13.76 + <AutoGen>True</AutoGen>
13.77 + <DependentUpon>Settings.settings</DependentUpon>
13.78 + <DesignTimeSharedInput>True</DesignTimeSharedInput>
13.79 + </Compile>
13.80 + </ItemGroup>
13.81 + <ItemGroup>
13.82 + <None Include="App.config" />
13.83 + </ItemGroup>
13.84 + <ItemGroup>
13.85 + <ProjectReference Include="..\Server\SharpDisplayManager.csproj">
13.86 + <Project>{1da8c1b3-18c5-4e74-be4e-0b0e15fbaf49}</Project>
13.87 + <Name>SharpDisplayManager</Name>
13.88 + </ProjectReference>
13.89 + </ItemGroup>
13.90 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
13.91 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
13.92 + Other similar extension points exist, see Microsoft.Common.targets.
13.93 + <Target Name="BeforeBuild">
13.94 + </Target>
13.95 + <Target Name="AfterBuild">
13.96 + </Target>
13.97 + -->
13.98 +</Project>
13.99 \ No newline at end of file
14.1 --- a/DialogBox.cs Tue Aug 12 20:37:57 2014 +0200
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,630 +0,0 @@
14.4 -//=============================================================================
14.5 -// COPYRIGHT: Prosoft-Lanz
14.6 -//=============================================================================
14.7 -//
14.8 -// $Workfile: DialogBox.cs $
14.9 -//
14.10 -// PROJECT : CodeProject Components
14.11 -// VERSION : 1.00
14.12 -// CREATION : 19.02.2003
14.13 -// AUTHOR : JCL
14.14 -//
14.15 -// DETAILS : DialogBoxes centered into the parent owner.
14.16 -// This class implement the following objects:
14.17 -//
14.18 -// DlgBox.ShowDialog(...) for CommonDialog and Form
14.19 -// MsgBox.Show(...) for standard MessageBox
14.20 -// AppBox.Show(...) for standard MessageBox with ProductName as caption
14.21 -// ErrBox.Show(...) for standard error MessageBox
14.22 -//
14.23 -//-----------------------------------------------------------------------------
14.24 -using System;
14.25 -using System.Drawing;
14.26 -using System.Windows.Forms;
14.27 -using System.Runtime.InteropServices;
14.28 -using System.Diagnostics;
14.29 -
14.30 -using CodeProject.Win32API;
14.31 -using CodeProject.Win32API.Hook;
14.32 -
14.33 -namespace CodeProject.Dialog
14.34 -{
14.35 - ///////////////////////////////////////////////////////////////////////
14.36 - #region DlgBox
14.37 -
14.38 - /// <summary>
14.39 - /// Class to display a CommonDialog or modal Form centered on the owner.
14.40 - /// </summary>
14.41 - /// <example>
14.42 - /// This example display the default print dialog box in the center of the parent.
14.43 - /// <code>
14.44 - /// PrintDialog printDlg = new PrintDialog();
14.45 - /// if (DlgBox.ShowDialog(printDlg, parent) == DialogResult.OK)
14.46 - /// printDocument.Print();
14.47 - /// </code>
14.48 - /// </example>
14.49 - public sealed class DlgBox
14.50 - {
14.51 - private DlgBox() {} // To remove the constructor from the documentation!
14.52 -
14.53 - ///////////////////////////////////////////////////////////////////////
14.54 - // CommonDialog
14.55 -
14.56 - /// <summary>
14.57 - /// Show a command dialog box at the center of the active window.
14.58 - /// </summary>
14.59 - public static DialogResult ShowDialog(CommonDialog dlg)
14.60 - {
14.61 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.62 - DialogResult dlgResult = dlg.ShowDialog();
14.63 - centerWindow.Dispose();
14.64 - return dlgResult;
14.65 - }
14.66 -
14.67 - /// <summary>
14.68 - /// Show a command dialog box at the center of the owner window.
14.69 - /// </summary>
14.70 - public static DialogResult ShowDialog(CommonDialog dlg, IWin32Window owner)
14.71 - {
14.72 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.73 - CenterWindow centerWindow = new CenterWindow(handle);
14.74 - DialogResult dlgResult = dlg.ShowDialog();
14.75 - centerWindow.Dispose();
14.76 - return dlgResult;
14.77 - }
14.78 -
14.79 - ///////////////////////////////////////////////////////////////////////
14.80 - // Form
14.81 -
14.82 - /// <summary>
14.83 - /// Show a form dialog box at the center of the active window.
14.84 - /// </summary>
14.85 - public static DialogResult ShowDialog(Form form)
14.86 - {
14.87 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.88 - DialogResult dlgResult = form.ShowDialog();
14.89 - centerWindow.Dispose();
14.90 - return dlgResult;
14.91 - }
14.92 -
14.93 - /// <summary>
14.94 - /// Show a form dialog box at the center of the owner window.
14.95 - /// </summary>
14.96 - public static DialogResult ShowDialog(Form form, IWin32Window owner)
14.97 - {
14.98 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.99 - CenterWindow centerWindow = new CenterWindow(handle);
14.100 - DialogResult dlgResult = form.ShowDialog();
14.101 - centerWindow.Dispose();
14.102 - return dlgResult;
14.103 - }
14.104 - }
14.105 -
14.106 - #endregion
14.107 -
14.108 - ///////////////////////////////////////////////////////////////////////
14.109 - #region MsgBox
14.110 -
14.111 - /// <summary>
14.112 - /// Class to display a MessageBox centered on the owner.
14.113 - /// </summary>
14.114 - /// <remarks>
14.115 - /// Same methods as the standard MessageBox.
14.116 - /// </remarks>
14.117 - /// <example>
14.118 - /// This example display a "Hello" message box centered on the owner.
14.119 - /// <code>
14.120 - /// MsgBox.Show("Hello");
14.121 - /// </code>
14.122 - /// </example>
14.123 - public sealed class MsgBox
14.124 - {
14.125 - private MsgBox() {} // To remove the constructor from the documentation!
14.126 -
14.127 - ///////////////////////////////////////////////////////////////////////
14.128 - // text
14.129 -
14.130 - /// <summary>
14.131 - /// See MSDN MessageBox() method.
14.132 - /// </summary>
14.133 - public static DialogResult Show(string text)
14.134 - {
14.135 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.136 - string caption = Application.ProductName;
14.137 - DialogResult dlgResult = MessageBox.Show(text, caption);
14.138 - centerWindow.Dispose();
14.139 - return dlgResult;
14.140 - }
14.141 -
14.142 - /// <summary>
14.143 - /// See MSDN MessageBox() method.
14.144 - /// </summary>
14.145 - public static DialogResult Show(IWin32Window owner, string text)
14.146 - {
14.147 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.148 - CenterWindow centerWindow = new CenterWindow(handle);
14.149 - string caption = Application.ProductName;
14.150 - DialogResult dlgResult = MessageBox.Show(owner, text, caption);
14.151 - centerWindow.Dispose();
14.152 - return dlgResult;
14.153 - }
14.154 -
14.155 - ///////////////////////////////////////////////////////////////////////
14.156 - // text, caption
14.157 -
14.158 - /// <summary>
14.159 - /// See MSDN MessageBox() method.
14.160 - /// </summary>
14.161 - public static DialogResult Show(string text, string caption)
14.162 - {
14.163 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.164 - DialogResult dlgResult = MessageBox.Show(text, caption);
14.165 - centerWindow.Dispose();
14.166 - return dlgResult;
14.167 - }
14.168 -
14.169 - /// <summary>
14.170 - /// See MSDN MessageBox() method.
14.171 - /// </summary>
14.172 - public static DialogResult Show(IWin32Window owner, string text, string caption)
14.173 - {
14.174 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.175 - CenterWindow centerWindow = new CenterWindow(handle);
14.176 - DialogResult dlgResult = MessageBox.Show(owner, text, caption);
14.177 - centerWindow.Dispose();
14.178 - return dlgResult;
14.179 - }
14.180 -
14.181 - ///////////////////////////////////////////////////////////////////////
14.182 - // text, caption, buttons
14.183 -
14.184 - /// <summary>
14.185 - /// See MSDN MessageBox() method.
14.186 - /// </summary>
14.187 - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
14.188 - {
14.189 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.190 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
14.191 - centerWindow.Dispose();
14.192 - return dlgResult;
14.193 - }
14.194 -
14.195 - /// <summary>
14.196 - /// See MSDN MessageBox() method.
14.197 - /// </summary>
14.198 - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
14.199 - {
14.200 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.201 - CenterWindow centerWindow = new CenterWindow(handle);
14.202 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
14.203 - centerWindow.Dispose();
14.204 - return dlgResult;
14.205 - }
14.206 -
14.207 - ///////////////////////////////////////////////////////////////////////
14.208 - // text, caption, buttons, defaultButton
14.209 -
14.210 - /// <summary>
14.211 - /// See MSDN MessageBox() method.
14.212 - /// </summary>
14.213 - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
14.214 - {
14.215 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.216 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
14.217 - centerWindow.Dispose();
14.218 - return dlgResult;
14.219 - }
14.220 -
14.221 - /// <summary>
14.222 - /// See MSDN MessageBox() method.
14.223 - /// </summary>
14.224 - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
14.225 - {
14.226 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.227 - CenterWindow centerWindow = new CenterWindow(handle);
14.228 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
14.229 - centerWindow.Dispose();
14.230 - return dlgResult;
14.231 - }
14.232 -
14.233 - ///////////////////////////////////////////////////////////////////////
14.234 - // text, caption, buttons, defaultButton, icon
14.235 -
14.236 - /// <summary>
14.237 - /// See MSDN MessageBox() method.
14.238 - /// </summary>
14.239 - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
14.240 - {
14.241 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.242 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
14.243 - centerWindow.Dispose();
14.244 - return dlgResult;
14.245 - }
14.246 -
14.247 - /// <summary>
14.248 - /// See MSDN MessageBox() method.
14.249 - /// </summary>
14.250 - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
14.251 - {
14.252 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.253 - CenterWindow centerWindow = new CenterWindow(handle);
14.254 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
14.255 - centerWindow.Dispose();
14.256 - return dlgResult;
14.257 - }
14.258 -
14.259 - ///////////////////////////////////////////////////////////////////////
14.260 - // text, caption, buttons, defaultButton, icon, options
14.261 -
14.262 - /// <summary>
14.263 - /// See MSDN MessageBox() method.
14.264 - /// </summary>
14.265 - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
14.266 - {
14.267 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.268 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
14.269 - centerWindow.Dispose();
14.270 - return dlgResult;
14.271 - }
14.272 -
14.273 - /// <summary>
14.274 - /// See MSDN MessageBox() method.
14.275 - /// </summary>
14.276 - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
14.277 - {
14.278 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.279 - CenterWindow centerWindow = new CenterWindow(handle);
14.280 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
14.281 - centerWindow.Dispose();
14.282 - return dlgResult;
14.283 - }
14.284 - }
14.285 -
14.286 - #endregion
14.287 -
14.288 - ///////////////////////////////////////////////////////////////////////
14.289 - #region AppBox
14.290 -
14.291 - /// <summary>
14.292 - /// Class to display a MessageBox centered on the owner.
14.293 - /// The MessageBox caption is always Application.ProductName.
14.294 - /// </summary>
14.295 - /// <remarks>
14.296 - /// Same methods as the standard MessageBox without caption.
14.297 - /// </remarks>
14.298 - /// <example>
14.299 - /// This example display an application message box centered on the owner.
14.300 - /// <code>
14.301 - /// AppBox.Show("Hello");
14.302 - /// </code>
14.303 - /// </example>
14.304 - public sealed class AppBox
14.305 - {
14.306 - private AppBox() {} // To remove the constructor from the documentation!
14.307 -
14.308 - ///////////////////////////////////////////////////////////////////////
14.309 - // text
14.310 -
14.311 - /// <summary>
14.312 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.313 - /// </summary>
14.314 - public static DialogResult Show(string text)
14.315 - {
14.316 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.317 - string caption = Application.ProductName;
14.318 - DialogResult dlgResult = MessageBox.Show(text, caption);
14.319 - centerWindow.Dispose();
14.320 - return dlgResult;
14.321 - }
14.322 -
14.323 - /// <summary>
14.324 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.325 - /// </summary>
14.326 - public static DialogResult Show(IWin32Window owner, string text)
14.327 - {
14.328 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.329 - CenterWindow centerWindow = new CenterWindow(handle);
14.330 - string caption = Application.ProductName;
14.331 - DialogResult dlgResult = MessageBox.Show(owner, text, caption);
14.332 - centerWindow.Dispose();
14.333 - return dlgResult;
14.334 - }
14.335 -
14.336 - ///////////////////////////////////////////////////////////////////////
14.337 - // text, buttons
14.338 -
14.339 - /// <summary>
14.340 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.341 - /// </summary>
14.342 - public static DialogResult Show(string text, MessageBoxButtons buttons)
14.343 - {
14.344 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.345 - string caption = Application.ProductName;
14.346 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
14.347 - centerWindow.Dispose();
14.348 - return dlgResult;
14.349 - }
14.350 -
14.351 - /// <summary>
14.352 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.353 - /// </summary>
14.354 - public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons)
14.355 - {
14.356 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.357 - CenterWindow centerWindow = new CenterWindow(handle);
14.358 - string caption = Application.ProductName;
14.359 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
14.360 - centerWindow.Dispose();
14.361 - return dlgResult;
14.362 - }
14.363 -
14.364 - ///////////////////////////////////////////////////////////////////////
14.365 - // text, buttons, defaultButton
14.366 -
14.367 - /// <summary>
14.368 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.369 - /// </summary>
14.370 - public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
14.371 - {
14.372 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.373 - string caption = Application.ProductName;
14.374 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
14.375 - centerWindow.Dispose();
14.376 - return dlgResult;
14.377 - }
14.378 -
14.379 - /// <summary>
14.380 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.381 - /// </summary>
14.382 - public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon)
14.383 - {
14.384 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.385 - CenterWindow centerWindow = new CenterWindow(handle);
14.386 - string caption = Application.ProductName;
14.387 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
14.388 - centerWindow.Dispose();
14.389 - return dlgResult;
14.390 - }
14.391 -
14.392 - ///////////////////////////////////////////////////////////////////////
14.393 - // text, buttons, defaultButton, icon
14.394 -
14.395 - /// <summary>
14.396 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.397 - /// </summary>
14.398 - public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
14.399 - {
14.400 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.401 - string caption = Application.ProductName;
14.402 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
14.403 - centerWindow.Dispose();
14.404 - return dlgResult;
14.405 - }
14.406 -
14.407 - /// <summary>
14.408 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.409 - /// </summary>
14.410 - public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
14.411 - {
14.412 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.413 - CenterWindow centerWindow = new CenterWindow(handle);
14.414 - string caption = Application.ProductName;
14.415 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
14.416 - centerWindow.Dispose();
14.417 - return dlgResult;
14.418 - }
14.419 -
14.420 - ///////////////////////////////////////////////////////////////////////
14.421 - // text, buttons, defaultButton, icon, options
14.422 -
14.423 - /// <summary>
14.424 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.425 - /// </summary>
14.426 - public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
14.427 - {
14.428 - CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
14.429 - string caption = Application.ProductName;
14.430 - DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
14.431 - centerWindow.Dispose();
14.432 - return dlgResult;
14.433 - }
14.434 -
14.435 - /// <summary>
14.436 - /// See MSDN MessageBox() method. Caption is Application.ProductName.
14.437 - /// </summary>
14.438 - public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
14.439 - {
14.440 - IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
14.441 - CenterWindow centerWindow = new CenterWindow(handle);
14.442 - string caption = Application.ProductName;
14.443 - DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
14.444 - centerWindow.Dispose();
14.445 - return dlgResult;
14.446 - }
14.447 - }
14.448 -
14.449 - #endregion
14.450 -
14.451 - ///////////////////////////////////////////////////////////////////////
14.452 - #region ErrBox
14.453 -
14.454 - /// <summary>
14.455 - /// Class to display application error MessageBox centered on the owner.
14.456 - /// The caption of the MessageBox is Application.ProductName.
14.457 - /// </summary>
14.458 - /// <example>
14.459 - /// This example display an error message box centered on the owner.
14.460 - /// <code>
14.461 - /// ErrBox.Show(ex);
14.462 - /// </code>
14.463 - /// </example>
14.464 - public sealed class ErrBox
14.465 - {
14.466 - private ErrBox() {} // To remove the constructor from the documentation!
14.467 -
14.468 - /// <summary>
14.469 - /// Show an error MessageBox with an icon error and an OK button.
14.470 - /// </summary>
14.471 - /// <param name="err">The error message.</param>
14.472 - /// <param name="owner">The owner of the error MessageBox.</param>
14.473 - /// <returns>Dialog result of the MessageBox.</returns>
14.474 - public static DialogResult Show(IWin32Window owner, string err)
14.475 - {
14.476 - string caption = Application.ProductName;
14.477 - return MsgBox.Show(owner, err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
14.478 - }
14.479 -
14.480 - /// <summary>
14.481 - /// Show an error MessageBox with an icon error and an OK button.
14.482 - /// </summary>
14.483 - /// <param name="err">The error message.</param>
14.484 - /// <returns>Dialog result of the MessageBox.</returns>
14.485 - public static DialogResult Show(string err)
14.486 - {
14.487 - string caption = Application.ProductName;
14.488 - return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
14.489 - }
14.490 -
14.491 - /// <summary>
14.492 - /// Show an error MessageBox with exception message, an icon error and an OK button.
14.493 - /// </summary>
14.494 - /// <param name="ex">Exception to be displayed.</param>
14.495 - /// <returns>Dialog result of the MessageBox.</returns>
14.496 - public static DialogResult Show(Exception ex)
14.497 - {
14.498 - string err = ex.Message;
14.499 - while (ex.InnerException != null)
14.500 - {
14.501 - ex = ex.InnerException;
14.502 - err += Environment.NewLine;
14.503 - err += ex.Message;
14.504 - }
14.505 - string caption = Application.ProductName;
14.506 - return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
14.507 - }
14.508 -
14.509 - /// <summary>
14.510 - /// Show a specialized error MessageBox centered into the parent owner.
14.511 - /// </summary>
14.512 - /// <param name="ex">Exception to be displayed.</param>
14.513 - /// <param name="debugMode">true to display the full informations else false.</param>
14.514 - /// <returns>Dialog result of the MessageBox.</returns>
14.515 - public static DialogResult Show(Exception ex, bool debugMode)
14.516 - {
14.517 - if (debugMode)
14.518 - return Show(ex);
14.519 - else
14.520 - return Show(ex.Message);
14.521 - }
14.522 - }
14.523 -
14.524 - #endregion
14.525 -
14.526 - ///////////////////////////////////////////////////////////////////////
14.527 - #region CenterWindow class
14.528 -
14.529 - internal sealed class CenterWindow
14.530 - {
14.531 - public IntPtr hOwner = IntPtr.Zero;
14.532 - private Rectangle rect;
14.533 -
14.534 - public CbtHook cbtHook = null;
14.535 - public WndProcRetHook wndProcRetHook = null;
14.536 -
14.537 - public CenterWindow(IntPtr hOwner)
14.538 - {
14.539 - this.hOwner = hOwner;
14.540 - this.cbtHook = new CbtHook();
14.541 - cbtHook.WindowActivate += new CbtHook.CbtEventHandler(WndActivate);
14.542 - cbtHook.Install();
14.543 - }
14.544 -
14.545 - public void Dispose()
14.546 - {
14.547 - if (wndProcRetHook != null)
14.548 - {
14.549 - wndProcRetHook.Uninstall();
14.550 - wndProcRetHook = null;
14.551 - }
14.552 - if (cbtHook != null)
14.553 - {
14.554 - cbtHook.Uninstall();
14.555 - cbtHook = null;
14.556 - }
14.557 - }
14.558 -
14.559 - public void WndActivate(object sender, CbtEventArgs e)
14.560 - {
14.561 - IntPtr hMsgBox = e.wParam;
14.562 -
14.563 - // try to find a howner for this message box
14.564 - if (hOwner == IntPtr.Zero)
14.565 - hOwner = USER32.GetActiveWindow();
14.566 -
14.567 - // get the MessageBox window rect
14.568 - RECT rectDlg = new RECT();
14.569 - USER32.GetWindowRect(hMsgBox, ref rectDlg);
14.570 -
14.571 - // get the owner window rect
14.572 - RECT rectForm = new RECT();
14.573 - USER32.GetWindowRect(hOwner, ref rectForm);
14.574 -
14.575 - // get the biggest screen area
14.576 - Rectangle rectScreen = API.TrueScreenRect;
14.577 -
14.578 - // if no parent window, center on the primary screen
14.579 - if (rectForm.right == rectForm.left)
14.580 - rectForm.right = rectForm.left = Screen.PrimaryScreen.WorkingArea.Width / 2;
14.581 - if (rectForm.bottom == rectForm.top)
14.582 - rectForm.bottom = rectForm.top = Screen.PrimaryScreen.WorkingArea.Height / 2;
14.583 -
14.584 - // center on parent
14.585 - int dx = ((rectDlg.left + rectDlg.right) - (rectForm.left + rectForm.right)) / 2;
14.586 - int dy = ((rectDlg.top + rectDlg.bottom) - (rectForm.top + rectForm.bottom)) / 2;
14.587 -
14.588 - rect = new Rectangle(
14.589 - rectDlg.left - dx,
14.590 - rectDlg.top - dy,
14.591 - rectDlg.right - rectDlg.left,
14.592 - rectDlg.bottom - rectDlg.top);
14.593 -
14.594 - // place in the screen
14.595 - if (rect.Right > rectScreen.Right) rect.Offset(rectScreen.Right - rect.Right, 0);
14.596 - if (rect.Bottom > rectScreen.Bottom) rect.Offset(0, rectScreen.Bottom - rect.Bottom);
14.597 - if (rect.Left < rectScreen.Left) rect.Offset(rectScreen.Left - rect.Left, 0);
14.598 - if (rect.Top < rectScreen.Top) rect.Offset(0, rectScreen.Top - rect.Top);
14.599 -
14.600 - if (e.IsDialog)
14.601 - {
14.602 - // do the job when the WM_INITDIALOG message returns
14.603 - wndProcRetHook = new WndProcRetHook(hMsgBox);
14.604 - wndProcRetHook.WndProcRet += new WndProcRetHook.WndProcEventHandler(WndProcRet);
14.605 - wndProcRetHook.Install();
14.606 - }
14.607 - else
14.608 - USER32.MoveWindow(hMsgBox, rect.Left, rect.Top, rect.Width, rect.Height, 1);
14.609 -
14.610 - // uninstall this hook
14.611 - WindowsHook wndHook = (WindowsHook)sender;
14.612 - Debug.Assert(cbtHook == wndHook);
14.613 - cbtHook.Uninstall();
14.614 - cbtHook = null;
14.615 - }
14.616 -
14.617 - public void WndProcRet(object sender, WndProcRetEventArgs e)
14.618 - {
14.619 - if (e.cw.message == WndMessage.WM_INITDIALOG ||
14.620 - e.cw.message == WndMessage.WM_UNKNOWINIT)
14.621 - {
14.622 - USER32.MoveWindow(e.cw.hwnd, rect.Left, rect.Top, rect.Width, rect.Height, 1);
14.623 -
14.624 - // uninstall this hook
14.625 - WindowsHook wndHook = (WindowsHook)sender;
14.626 - Debug.Assert(wndProcRetHook == wndHook);
14.627 - wndProcRetHook.Uninstall();
14.628 - wndProcRetHook = null;
14.629 - }
14.630 - }
14.631 - }
14.632 - #endregion
14.633 -}
15.1 --- a/Display.cs Tue Aug 12 20:37:57 2014 +0200
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,243 +0,0 @@
15.4 -using System;
15.5 -using System.Collections.Generic;
15.6 -using System.Linq;
15.7 -using System.Text;
15.8 -using System.Threading.Tasks;
15.9 -//
15.10 -using System.Runtime.InteropServices;
15.11 -
15.12 -namespace SharpDisplayManager
15.13 -{
15.14 - class Display
15.15 - {
15.16 -
15.17 - //Constructor
15.18 - public Display()
15.19 - {
15.20 - iDevice = IntPtr.Zero;
15.21 - }
15.22 -
15.23 - //
15.24 - public bool Open()
15.25 - {
15.26 - if (iDevice == IntPtr.Zero)
15.27 - {
15.28 - iDevice = MiniDisplayOpen();
15.29 - }
15.30 - return iDevice != IntPtr.Zero;
15.31 - }
15.32 -
15.33 - public void Close()
15.34 - {
15.35 - MiniDisplayClose(iDevice);
15.36 - iDevice = IntPtr.Zero;
15.37 - }
15.38 -
15.39 - public bool IsOpen()
15.40 - {
15.41 - return iDevice != IntPtr.Zero;
15.42 - }
15.43 -
15.44 - public void Clear()
15.45 - {
15.46 - MiniDisplayClear(iDevice);
15.47 - }
15.48 -
15.49 - public void Fill()
15.50 - {
15.51 - MiniDisplayFill(iDevice);
15.52 - }
15.53 -
15.54 - public void SwapBuffers()
15.55 - {
15.56 - MiniDisplaySwapBuffers(iDevice);
15.57 - }
15.58 -
15.59 - public int MaxBrightness()
15.60 - {
15.61 - return MiniDisplayMaxBrightness(iDevice);
15.62 - }
15.63 -
15.64 - public int MinBrightness()
15.65 - {
15.66 - return MiniDisplayMinBrightness(iDevice);
15.67 - }
15.68 -
15.69 - public void SetBrightness(int aBrightness)
15.70 - {
15.71 - if (!IsOpen()) return;
15.72 -
15.73 - MiniDisplaySetBrightness(iDevice, aBrightness);
15.74 - }
15.75 -
15.76 - public int WidthInPixels()
15.77 - {
15.78 - return MiniDisplayWidthInPixels(iDevice);
15.79 - }
15.80 -
15.81 - public int HeightInPixels()
15.82 - {
15.83 - return MiniDisplayHeightInPixels(iDevice);
15.84 - }
15.85 -
15.86 - public void SetPixel(int aX, int aY, int aValue)
15.87 - {
15.88 - MiniDisplaySetPixel(iDevice,aX,aY,aValue);
15.89 - }
15.90 -
15.91 - public void RequestPowerSupplyStatus()
15.92 - {
15.93 - MiniDisplayRequestPowerSupplyStatus(iDevice);
15.94 - }
15.95 -
15.96 - public void RequestDeviceId()
15.97 - {
15.98 - MiniDisplayRequestDeviceId(iDevice);
15.99 - }
15.100 -
15.101 - public void RequestFirmwareRevision()
15.102 - {
15.103 - MiniDisplayRequestFirmwareRevision(iDevice);
15.104 - }
15.105 -
15.106 - public bool PowerSupplyStatus()
15.107 - {
15.108 - bool res = MiniDisplayPowerSupplyStatus(iDevice);
15.109 - return res;
15.110 - }
15.111 -
15.112 - public TMiniDisplayRequest AttemptRequestCompletion()
15.113 - {
15.114 - return MiniDisplayAttemptRequestCompletion(iDevice);
15.115 - }
15.116 -
15.117 - public TMiniDisplayRequest CurrentRequest()
15.118 - {
15.119 - return MiniDisplayCurrentRequest(iDevice);
15.120 - }
15.121 -
15.122 - public bool IsRequestPending()
15.123 - {
15.124 - return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
15.125 - }
15.126 -
15.127 -
15.128 - public string Vendor()
15.129 - {
15.130 - IntPtr ptr = MiniDisplayVendor(iDevice);
15.131 - string str = Marshal.PtrToStringUni(ptr);
15.132 - return str;
15.133 - }
15.134 -
15.135 - public string Product()
15.136 - {
15.137 - IntPtr ptr = MiniDisplayProduct(iDevice);
15.138 - string str = Marshal.PtrToStringUni(ptr);
15.139 - return str;
15.140 - }
15.141 -
15.142 - public string SerialNumber()
15.143 - {
15.144 - IntPtr ptr = MiniDisplaySerialNumber(iDevice);
15.145 - string str = Marshal.PtrToStringUni(ptr);
15.146 - return str;
15.147 - }
15.148 -
15.149 - public string DeviceId()
15.150 - {
15.151 - IntPtr ptr = MiniDisplayDeviceId(iDevice);
15.152 - string str = Marshal.PtrToStringAnsi(ptr);
15.153 - return str;
15.154 - }
15.155 -
15.156 - public string FirmwareRevision()
15.157 - {
15.158 - IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
15.159 - string str = Marshal.PtrToStringAnsi(ptr);
15.160 - return str;
15.161 - }
15.162 -
15.163 - //Our display device handle
15.164 - IntPtr iDevice;
15.165 -
15.166 - public enum TMiniDisplayRequest
15.167 - {
15.168 - EMiniDisplayRequestNone,
15.169 - EMiniDisplayRequestDeviceId,
15.170 - EMiniDisplayRequestFirmwareRevision,
15.171 - EMiniDisplayRequestPowerSupplyStatus
15.172 - }
15.173 -
15.174 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.175 - public static extern IntPtr MiniDisplayOpen();
15.176 -
15.177 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.178 - public static extern void MiniDisplayClose(IntPtr aDevice);
15.179 -
15.180 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.181 - public static extern void MiniDisplayClear(IntPtr aDevice);
15.182 -
15.183 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.184 - public static extern void MiniDisplayFill(IntPtr aDevice);
15.185 -
15.186 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.187 - public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
15.188 -
15.189 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.190 - public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
15.191 -
15.192 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.193 - public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
15.194 -
15.195 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.196 - public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
15.197 -
15.198 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.199 - public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
15.200 -
15.201 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.202 - public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
15.203 -
15.204 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.205 - public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
15.206 -
15.207 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.208 - public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
15.209 -
15.210 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.211 - public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
15.212 -
15.213 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.214 - public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
15.215 -
15.216 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.217 - public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
15.218 -
15.219 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.220 - public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
15.221 -
15.222 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.223 - [return: MarshalAs(UnmanagedType.I1)]
15.224 - public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
15.225 -
15.226 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.227 - public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
15.228 -
15.229 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.230 - public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
15.231 -
15.232 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.233 - public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
15.234 -
15.235 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.236 - public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
15.237 -
15.238 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.239 - public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
15.240 -
15.241 - [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
15.242 - public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
15.243 -
15.244 -
15.245 - }
15.246 -}
16.1 --- a/MainForm.Designer.cs Tue Aug 12 20:37:57 2014 +0200
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,432 +0,0 @@
16.4 -namespace SharpDisplayManager
16.5 -{
16.6 - partial class MainForm
16.7 - {
16.8 - /// <summary>
16.9 - /// Required designer variable.
16.10 - /// </summary>
16.11 - private System.ComponentModel.IContainer components = null;
16.12 -
16.13 - /// <summary>
16.14 - /// Clean up any resources being used.
16.15 - /// </summary>
16.16 - /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
16.17 - protected override void Dispose(bool disposing)
16.18 - {
16.19 - if (disposing && (components != null))
16.20 - {
16.21 - components.Dispose();
16.22 - }
16.23 - base.Dispose(disposing);
16.24 - }
16.25 -
16.26 - #region Windows Form Designer generated code
16.27 -
16.28 - /// <summary>
16.29 - /// Required method for Designer support - do not modify
16.30 - /// the contents of this method with the code editor.
16.31 - /// </summary>
16.32 - private void InitializeComponent()
16.33 - {
16.34 - this.components = new System.ComponentModel.Container();
16.35 - this.tabControl = new System.Windows.Forms.TabControl();
16.36 - this.tabPageDisplay = new System.Windows.Forms.TabPage();
16.37 - this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox();
16.38 - this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox();
16.39 - this.panelDisplay = new System.Windows.Forms.Panel();
16.40 - this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
16.41 - this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
16.42 - this.trackBarBrightness = new System.Windows.Forms.TrackBar();
16.43 - this.buttonFill = new System.Windows.Forms.Button();
16.44 - this.buttonClear = new System.Windows.Forms.Button();
16.45 - this.buttonClose = new System.Windows.Forms.Button();
16.46 - this.buttonOpen = new System.Windows.Forms.Button();
16.47 - this.buttonCapture = new System.Windows.Forms.Button();
16.48 - this.buttonFont = new System.Windows.Forms.Button();
16.49 - this.tabPageTests = new System.Windows.Forms.TabPage();
16.50 - this.fontDialog = new System.Windows.Forms.FontDialog();
16.51 - this.timer = new System.Windows.Forms.Timer(this.components);
16.52 - this.statusStrip = new System.Windows.Forms.StatusStrip();
16.53 - this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel();
16.54 - this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
16.55 - this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel();
16.56 - this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
16.57 - this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
16.58 - this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
16.59 - this.tabControl.SuspendLayout();
16.60 - this.tabPageDisplay.SuspendLayout();
16.61 - this.panelDisplay.SuspendLayout();
16.62 - this.tableLayoutPanel.SuspendLayout();
16.63 - ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
16.64 - this.statusStrip.SuspendLayout();
16.65 - this.SuspendLayout();
16.66 - //
16.67 - // tabControl
16.68 - //
16.69 - this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
16.70 - | System.Windows.Forms.AnchorStyles.Left)
16.71 - | System.Windows.Forms.AnchorStyles.Right)));
16.72 - this.tabControl.Controls.Add(this.tabPageDisplay);
16.73 - this.tabControl.Controls.Add(this.tabPageTests);
16.74 - this.tabControl.Location = new System.Drawing.Point(12, 12);
16.75 - this.tabControl.Name = "tabControl";
16.76 - this.tabControl.SelectedIndex = 0;
16.77 - this.tabControl.Size = new System.Drawing.Size(600, 395);
16.78 - this.tabControl.TabIndex = 0;
16.79 - //
16.80 - // tabPageDisplay
16.81 - //
16.82 - this.tabPageDisplay.Controls.Add(this.checkBoxReverseScreen);
16.83 - this.tabPageDisplay.Controls.Add(this.checkBoxConnectOnStartup);
16.84 - this.tabPageDisplay.Controls.Add(this.panelDisplay);
16.85 - this.tabPageDisplay.Controls.Add(this.checkBoxShowBorders);
16.86 - this.tabPageDisplay.Controls.Add(this.trackBarBrightness);
16.87 - this.tabPageDisplay.Controls.Add(this.buttonFill);
16.88 - this.tabPageDisplay.Controls.Add(this.buttonClear);
16.89 - this.tabPageDisplay.Controls.Add(this.buttonClose);
16.90 - this.tabPageDisplay.Controls.Add(this.buttonOpen);
16.91 - this.tabPageDisplay.Controls.Add(this.buttonCapture);
16.92 - this.tabPageDisplay.Controls.Add(this.buttonFont);
16.93 - this.tabPageDisplay.Location = new System.Drawing.Point(4, 22);
16.94 - this.tabPageDisplay.Name = "tabPageDisplay";
16.95 - this.tabPageDisplay.Padding = new System.Windows.Forms.Padding(3);
16.96 - this.tabPageDisplay.Size = new System.Drawing.Size(592, 369);
16.97 - this.tabPageDisplay.TabIndex = 0;
16.98 - this.tabPageDisplay.Text = "Display";
16.99 - this.tabPageDisplay.UseVisualStyleBackColor = true;
16.100 - //
16.101 - // checkBoxReverseScreen
16.102 - //
16.103 - this.checkBoxReverseScreen.AutoSize = true;
16.104 - this.checkBoxReverseScreen.Location = new System.Drawing.Point(113, 298);
16.105 - this.checkBoxReverseScreen.Name = "checkBoxReverseScreen";
16.106 - this.checkBoxReverseScreen.Size = new System.Drawing.Size(101, 17);
16.107 - this.checkBoxReverseScreen.TabIndex = 14;
16.108 - this.checkBoxReverseScreen.Text = "Reverse screen";
16.109 - this.checkBoxReverseScreen.UseVisualStyleBackColor = true;
16.110 - this.checkBoxReverseScreen.CheckedChanged += new System.EventHandler(this.checkBoxReverseScreen_CheckedChanged);
16.111 - //
16.112 - // checkBoxConnectOnStartup
16.113 - //
16.114 - this.checkBoxConnectOnStartup.AutoSize = true;
16.115 - this.checkBoxConnectOnStartup.Location = new System.Drawing.Point(113, 321);
16.116 - this.checkBoxConnectOnStartup.Name = "checkBoxConnectOnStartup";
16.117 - this.checkBoxConnectOnStartup.Size = new System.Drawing.Size(119, 17);
16.118 - this.checkBoxConnectOnStartup.TabIndex = 13;
16.119 - this.checkBoxConnectOnStartup.Text = "Connect on stratup ";
16.120 - this.checkBoxConnectOnStartup.UseVisualStyleBackColor = true;
16.121 - this.checkBoxConnectOnStartup.CheckedChanged += new System.EventHandler(this.checkBoxConnectOnStartup_CheckedChanged);
16.122 - //
16.123 - // panelDisplay
16.124 - //
16.125 - this.panelDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
16.126 - this.panelDisplay.Controls.Add(this.tableLayoutPanel);
16.127 - this.panelDisplay.Location = new System.Drawing.Point(181, 151);
16.128 - this.panelDisplay.Margin = new System.Windows.Forms.Padding(0);
16.129 - this.panelDisplay.Name = "panelDisplay";
16.130 - this.panelDisplay.Size = new System.Drawing.Size(258, 66);
16.131 - this.panelDisplay.TabIndex = 12;
16.132 - //
16.133 - // tableLayoutPanel
16.134 - //
16.135 - this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
16.136 - | System.Windows.Forms.AnchorStyles.Left)
16.137 - | System.Windows.Forms.AnchorStyles.Right)));
16.138 - this.tableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
16.139 - this.tableLayoutPanel.ColumnCount = 1;
16.140 - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
16.141 - this.tableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0);
16.142 - this.tableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1);
16.143 - this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
16.144 - this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
16.145 - this.tableLayoutPanel.Name = "tableLayoutPanel";
16.146 - this.tableLayoutPanel.RowCount = 2;
16.147 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
16.148 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
16.149 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.150 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.151 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.152 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.153 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.154 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.155 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.156 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.157 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.158 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.159 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.160 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.161 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.162 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.163 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.164 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.165 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.166 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.167 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.168 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.169 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.170 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.171 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.172 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.173 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.174 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.175 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.176 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.177 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.178 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.179 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.180 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.181 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.182 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.183 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.184 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.185 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.186 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.187 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.188 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.189 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.190 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.191 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.192 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.193 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.194 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.195 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.196 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.197 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.198 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.199 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.200 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.201 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.202 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.203 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.204 - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
16.205 - this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
16.206 - this.tableLayoutPanel.TabIndex = 5;
16.207 - //
16.208 - // checkBoxShowBorders
16.209 - //
16.210 - this.checkBoxShowBorders.AutoSize = true;
16.211 - this.checkBoxShowBorders.Location = new System.Drawing.Point(113, 344);
16.212 - this.checkBoxShowBorders.Name = "checkBoxShowBorders";
16.213 - this.checkBoxShowBorders.Size = new System.Drawing.Size(91, 17);
16.214 - this.checkBoxShowBorders.TabIndex = 11;
16.215 - this.checkBoxShowBorders.Text = "Show borders";
16.216 - this.checkBoxShowBorders.UseVisualStyleBackColor = true;
16.217 - this.checkBoxShowBorders.CheckedChanged += new System.EventHandler(this.checkBoxShowBorders_CheckedChanged);
16.218 - //
16.219 - // trackBarBrightness
16.220 - //
16.221 - this.trackBarBrightness.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
16.222 - | System.Windows.Forms.AnchorStyles.Right)));
16.223 - this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
16.224 - this.trackBarBrightness.Location = new System.Drawing.Point(544, 9);
16.225 - this.trackBarBrightness.Name = "trackBarBrightness";
16.226 - this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
16.227 - this.trackBarBrightness.Size = new System.Drawing.Size(45, 357);
16.228 - this.trackBarBrightness.TabIndex = 10;
16.229 - this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
16.230 - this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
16.231 - //
16.232 - // buttonFill
16.233 - //
16.234 - this.buttonFill.Location = new System.Drawing.Point(6, 93);
16.235 - this.buttonFill.Name = "buttonFill";
16.236 - this.buttonFill.Size = new System.Drawing.Size(75, 23);
16.237 - this.buttonFill.TabIndex = 9;
16.238 - this.buttonFill.Text = "Fill";
16.239 - this.buttonFill.UseVisualStyleBackColor = true;
16.240 - this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click);
16.241 - //
16.242 - // buttonClear
16.243 - //
16.244 - this.buttonClear.Location = new System.Drawing.Point(6, 64);
16.245 - this.buttonClear.Name = "buttonClear";
16.246 - this.buttonClear.Size = new System.Drawing.Size(75, 23);
16.247 - this.buttonClear.TabIndex = 8;
16.248 - this.buttonClear.Text = "Clear";
16.249 - this.buttonClear.UseVisualStyleBackColor = true;
16.250 - this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
16.251 - //
16.252 - // buttonClose
16.253 - //
16.254 - this.buttonClose.Location = new System.Drawing.Point(6, 35);
16.255 - this.buttonClose.Name = "buttonClose";
16.256 - this.buttonClose.Size = new System.Drawing.Size(75, 23);
16.257 - this.buttonClose.TabIndex = 7;
16.258 - this.buttonClose.Text = "Close";
16.259 - this.buttonClose.UseVisualStyleBackColor = true;
16.260 - this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
16.261 - //
16.262 - // buttonOpen
16.263 - //
16.264 - this.buttonOpen.Location = new System.Drawing.Point(6, 6);
16.265 - this.buttonOpen.Name = "buttonOpen";
16.266 - this.buttonOpen.Size = new System.Drawing.Size(75, 23);
16.267 - this.buttonOpen.TabIndex = 6;
16.268 - this.buttonOpen.Text = "Open";
16.269 - this.buttonOpen.UseVisualStyleBackColor = true;
16.270 - this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
16.271 - //
16.272 - // buttonCapture
16.273 - //
16.274 - this.buttonCapture.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
16.275 - this.buttonCapture.Location = new System.Drawing.Point(6, 311);
16.276 - this.buttonCapture.Name = "buttonCapture";
16.277 - this.buttonCapture.Size = new System.Drawing.Size(75, 23);
16.278 - this.buttonCapture.TabIndex = 5;
16.279 - this.buttonCapture.Text = "Capture";
16.280 - this.buttonCapture.UseVisualStyleBackColor = true;
16.281 - this.buttonCapture.Click += new System.EventHandler(this.buttonCapture_Click);
16.282 - //
16.283 - // buttonFont
16.284 - //
16.285 - this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
16.286 - this.buttonFont.Location = new System.Drawing.Point(6, 340);
16.287 - this.buttonFont.Name = "buttonFont";
16.288 - this.buttonFont.Size = new System.Drawing.Size(75, 23);
16.289 - this.buttonFont.TabIndex = 0;
16.290 - this.buttonFont.Text = "Select Font";
16.291 - this.buttonFont.UseVisualStyleBackColor = true;
16.292 - this.buttonFont.Click += new System.EventHandler(this.buttonFont_Click);
16.293 - //
16.294 - // tabPageTests
16.295 - //
16.296 - this.tabPageTests.Location = new System.Drawing.Point(4, 22);
16.297 - this.tabPageTests.Name = "tabPageTests";
16.298 - this.tabPageTests.Padding = new System.Windows.Forms.Padding(3);
16.299 - this.tabPageTests.Size = new System.Drawing.Size(592, 369);
16.300 - this.tabPageTests.TabIndex = 1;
16.301 - this.tabPageTests.Text = "Test";
16.302 - this.tabPageTests.UseVisualStyleBackColor = true;
16.303 - //
16.304 - // timer
16.305 - //
16.306 - this.timer.Enabled = true;
16.307 - this.timer.Interval = 50;
16.308 - this.timer.Tick += new System.EventHandler(this.timer_Tick);
16.309 - //
16.310 - // statusStrip
16.311 - //
16.312 - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
16.313 - this.toolStripStatusLabelConnect,
16.314 - this.toolStripStatusLabelSpring,
16.315 - this.toolStripStatusLabelPower,
16.316 - this.toolStripStatusLabelFps});
16.317 - this.statusStrip.Location = new System.Drawing.Point(0, 420);
16.318 - this.statusStrip.Name = "statusStrip";
16.319 - this.statusStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
16.320 - this.statusStrip.Size = new System.Drawing.Size(624, 22);
16.321 - this.statusStrip.TabIndex = 1;
16.322 - this.statusStrip.Text = "statusStrip";
16.323 - //
16.324 - // toolStripStatusLabelConnect
16.325 - //
16.326 - this.toolStripStatusLabelConnect.Name = "toolStripStatusLabelConnect";
16.327 - this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17);
16.328 - this.toolStripStatusLabelConnect.Text = "Not connected";
16.329 - //
16.330 - // toolStripStatusLabelSpring
16.331 - //
16.332 - this.toolStripStatusLabelSpring.Name = "toolStripStatusLabelSpring";
16.333 - this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(473, 17);
16.334 - this.toolStripStatusLabelSpring.Spring = true;
16.335 - //
16.336 - // toolStripStatusLabelPower
16.337 - //
16.338 - this.toolStripStatusLabelPower.Name = "toolStripStatusLabelPower";
16.339 - this.toolStripStatusLabelPower.Size = new System.Drawing.Size(24, 17);
16.340 - this.toolStripStatusLabelPower.Text = "NA";
16.341 - //
16.342 - // toolStripStatusLabelFps
16.343 - //
16.344 - this.toolStripStatusLabelFps.Name = "toolStripStatusLabelFps";
16.345 - this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
16.346 - this.toolStripStatusLabelFps.Text = "FPS";
16.347 - //
16.348 - // marqueeLabelTop
16.349 - //
16.350 - this.marqueeLabelTop.AutoEllipsis = true;
16.351 - this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
16.352 - this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
16.353 - this.marqueeLabelTop.Location = new System.Drawing.Point(1, -124);
16.354 - this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
16.355 - this.marqueeLabelTop.Name = "marqueeLabelTop";
16.356 - this.marqueeLabelTop.OwnTimer = false;
16.357 - this.marqueeLabelTop.PixelsPerSecond = 64;
16.358 - this.marqueeLabelTop.Separator = "|";
16.359 - this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20);
16.360 - this.marqueeLabelTop.TabIndex = 2;
16.361 - this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
16.362 - this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
16.363 - this.marqueeLabelTop.UseCompatibleTextRendering = true;
16.364 - //
16.365 - // marqueeLabelBottom
16.366 - //
16.367 - this.marqueeLabelBottom.AutoEllipsis = true;
16.368 - this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
16.369 - this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -40);
16.370 - this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
16.371 - this.marqueeLabelBottom.Name = "marqueeLabelBottom";
16.372 - this.marqueeLabelBottom.OwnTimer = false;
16.373 - this.marqueeLabelBottom.PixelsPerSecond = 64;
16.374 - this.marqueeLabelBottom.Separator = null;
16.375 - this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
16.376 - this.marqueeLabelBottom.TabIndex = 3;
16.377 - this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
16.378 - this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
16.379 - this.marqueeLabelBottom.UseCompatibleTextRendering = true;
16.380 - //
16.381 - // MainForm
16.382 - //
16.383 - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
16.384 - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
16.385 - this.ClientSize = new System.Drawing.Size(624, 442);
16.386 - this.Controls.Add(this.statusStrip);
16.387 - this.Controls.Add(this.tabControl);
16.388 - this.MinimumSize = new System.Drawing.Size(640, 480);
16.389 - this.Name = "MainForm";
16.390 - this.Text = "Sharp Display Manager";
16.391 - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
16.392 - this.Load += new System.EventHandler(this.MainForm_Load);
16.393 - this.Resize += new System.EventHandler(this.MainForm_Resize);
16.394 - this.tabControl.ResumeLayout(false);
16.395 - this.tabPageDisplay.ResumeLayout(false);
16.396 - this.tabPageDisplay.PerformLayout();
16.397 - this.panelDisplay.ResumeLayout(false);
16.398 - this.tableLayoutPanel.ResumeLayout(false);
16.399 - ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
16.400 - this.statusStrip.ResumeLayout(false);
16.401 - this.statusStrip.PerformLayout();
16.402 - this.ResumeLayout(false);
16.403 - this.PerformLayout();
16.404 -
16.405 - }
16.406 -
16.407 - #endregion
16.408 -
16.409 - private System.Windows.Forms.TabControl tabControl;
16.410 - private System.Windows.Forms.TabPage tabPageDisplay;
16.411 - private System.Windows.Forms.TabPage tabPageTests;
16.412 - private System.Windows.Forms.Button buttonFont;
16.413 - private System.Windows.Forms.FontDialog fontDialog;
16.414 - private System.Windows.Forms.Button buttonCapture;
16.415 - private System.Windows.Forms.Timer timer;
16.416 - private System.Windows.Forms.Button buttonFill;
16.417 - private System.Windows.Forms.Button buttonClear;
16.418 - private System.Windows.Forms.Button buttonClose;
16.419 - private System.Windows.Forms.Button buttonOpen;
16.420 - private System.Windows.Forms.TrackBar trackBarBrightness;
16.421 - private System.Windows.Forms.StatusStrip statusStrip;
16.422 - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect;
16.423 - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps;
16.424 - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring;
16.425 - private System.Windows.Forms.CheckBox checkBoxShowBorders;
16.426 - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower;
16.427 - private System.Windows.Forms.Panel panelDisplay;
16.428 - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
16.429 - public MarqueeLabel marqueeLabelTop;
16.430 - public MarqueeLabel marqueeLabelBottom;
16.431 - private System.Windows.Forms.CheckBox checkBoxConnectOnStartup;
16.432 - private System.Windows.Forms.CheckBox checkBoxReverseScreen;
16.433 - }
16.434 -}
16.435 -
17.1 --- a/MainForm.cs Tue Aug 12 20:37:57 2014 +0200
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,368 +0,0 @@
17.4 -using System;
17.5 -using System.Collections.Generic;
17.6 -using System.ComponentModel;
17.7 -using System.Data;
17.8 -using System.Drawing;
17.9 -using System.Linq;
17.10 -using System.Text;
17.11 -using System.Threading.Tasks;
17.12 -using System.Windows.Forms;
17.13 -using System.IO;
17.14 -using CodeProject.Dialog;
17.15 -using System.Drawing.Imaging;
17.16 -using System.ServiceModel;
17.17 -
17.18 -
17.19 -namespace SharpDisplayManager
17.20 -{
17.21 - public partial class MainForm : Form
17.22 - {
17.23 - DateTime LastTickTime;
17.24 - Display iDisplay;
17.25 - System.Drawing.Bitmap iBmp;
17.26 - bool iCreateBitmap; //Workaround render to bitmap issues when minimized
17.27 - ServiceHost iServiceHost;
17.28 -
17.29 - public MainForm()
17.30 - {
17.31 - LastTickTime = DateTime.Now;
17.32 - iDisplay = new Display();
17.33 -
17.34 - InitializeComponent();
17.35 - UpdateStatus();
17.36 -
17.37 - //Load settings
17.38 - marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont;
17.39 - marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont;
17.40 - checkBoxShowBorders.Checked = Properties.Settings.Default.DisplayShowBorders;
17.41 - checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
17.42 - checkBoxReverseScreen.Checked = Properties.Settings.Default.DisplayReverseScreen;
17.43 - //
17.44 - tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
17.45 - //We have a bug when drawing minimized and reusing our bitmap
17.46 - iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
17.47 - iCreateBitmap = false;
17.48 - }
17.49 -
17.50 - private void MainForm_Load(object sender, EventArgs e)
17.51 - {
17.52 - StartServer();
17.53 -
17.54 - if (Properties.Settings.Default.DisplayConnectOnStartup)
17.55 - {
17.56 - iDisplay.Open();
17.57 - UpdateStatus();
17.58 - }
17.59 - }
17.60 -
17.61 -
17.62 - private void buttonFont_Click(object sender, EventArgs e)
17.63 - {
17.64 - //fontDialog.ShowColor = true;
17.65 - //fontDialog.ShowApply = true;
17.66 - fontDialog.ShowEffects = true;
17.67 - fontDialog.Font = marqueeLabelTop.Font;
17.68 - //fontDialog.ShowHelp = true;
17.69 -
17.70 - //fontDlg.MaxSize = 40;
17.71 - //fontDlg.MinSize = 22;
17.72 -
17.73 - //fontDialog.Parent = this;
17.74 - //fontDialog.StartPosition = FormStartPosition.CenterParent;
17.75 -
17.76 - //DlgBox.ShowDialog(fontDialog);
17.77 -
17.78 - //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
17.79 - if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
17.80 - {
17.81 -
17.82 - //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
17.83 -
17.84 - //MessageBox.Show("Ok");
17.85 - marqueeLabelTop.Font = fontDialog.Font;
17.86 - marqueeLabelBottom.Font = fontDialog.Font;
17.87 - Properties.Settings.Default.DisplayFont = fontDialog.Font;
17.88 - Properties.Settings.Default.Save();
17.89 - //label1.Font = fontDlg.Font;
17.90 - //textBox1.BackColor = fontDlg.Color;
17.91 - //label1.ForeColor = fontDlg.Color;
17.92 - }
17.93 - }
17.94 -
17.95 - private void buttonCapture_Click(object sender, EventArgs e)
17.96 - {
17.97 - System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
17.98 - tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
17.99 - //Bitmap bmpToSave = new Bitmap(bmp);
17.100 - bmp.Save("D:\\capture.png");
17.101 -
17.102 - marqueeLabelTop.Text = "Sweet";
17.103 -
17.104 - /*
17.105 - string outputFileName = "d:\\capture.png";
17.106 - using (MemoryStream memory = new MemoryStream())
17.107 - {
17.108 - using (FileStream fs = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
17.109 - {
17.110 - bmp.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
17.111 - byte[] bytes = memory.ToArray();
17.112 - fs.Write(bytes, 0, bytes.Length);
17.113 - }
17.114 - }
17.115 - */
17.116 -
17.117 - }
17.118 -
17.119 - private void CheckForRequestResults()
17.120 - {
17.121 - if (iDisplay.IsRequestPending())
17.122 - {
17.123 - switch (iDisplay.AttemptRequestCompletion())
17.124 - {
17.125 - case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus:
17.126 - if (iDisplay.PowerSupplyStatus())
17.127 - {
17.128 - toolStripStatusLabelPower.Text = "ON";
17.129 - }
17.130 - else
17.131 - {
17.132 - toolStripStatusLabelPower.Text = "OFF";
17.133 - }
17.134 - //Issue next request then
17.135 - iDisplay.RequestDeviceId();
17.136 - break;
17.137 -
17.138 - case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId:
17.139 - toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId();
17.140 - //Issue next request then
17.141 - iDisplay.RequestFirmwareRevision();
17.142 - break;
17.143 -
17.144 - case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision:
17.145 - toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision();
17.146 - //No more request to issue
17.147 - break;
17.148 - }
17.149 - }
17.150 - }
17.151 -
17.152 -
17.153 - public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
17.154 -
17.155 -
17.156 - public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
17.157 - {
17.158 - return aBmp.Width - aX - 1;
17.159 - }
17.160 -
17.161 - public int ScreenReversedY(System.Drawing.Bitmap aBmp, int aY)
17.162 - {
17.163 - return iBmp.Height - aY - 1;
17.164 - }
17.165 -
17.166 - public int ScreenX(System.Drawing.Bitmap aBmp, int aX)
17.167 - {
17.168 - return aX;
17.169 - }
17.170 -
17.171 - public int ScreenY(System.Drawing.Bitmap aBmp, int aY)
17.172 - {
17.173 - return aY;
17.174 - }
17.175 -
17.176 -
17.177 - //This is our timer tick responsible to perform our render
17.178 - private void timer_Tick(object sender, EventArgs e)
17.179 - {
17.180 - //Update our animations
17.181 - DateTime NewTickTime = DateTime.Now;
17.182 -
17.183 - marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
17.184 - marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
17.185 -
17.186 - //Update our display
17.187 - if (iDisplay.IsOpen())
17.188 - {
17.189 - CheckForRequestResults();
17.190 -
17.191 - //Draw to bitmap
17.192 - if (iCreateBitmap)
17.193 - {
17.194 - iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
17.195 - }
17.196 - tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
17.197 - //iBmp.Save("D:\\capture.png");
17.198 -
17.199 - //Select proper coordinate translation functions
17.200 - //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
17.201 - CoordinateTranslationDelegate screenX;
17.202 - CoordinateTranslationDelegate screenY;
17.203 -
17.204 - if (Properties.Settings.Default.DisplayReverseScreen)
17.205 - {
17.206 - screenX = ScreenReversedX;
17.207 - screenY = ScreenReversedY;
17.208 - }
17.209 - else
17.210 - {
17.211 - screenX = ScreenX;
17.212 - screenY = ScreenY;
17.213 - }
17.214 -
17.215 - //Send it to our display
17.216 - for (int i = 0; i < iBmp.Width; i++)
17.217 - {
17.218 - for (int j = 0; j < iBmp.Height; j++)
17.219 - {
17.220 - unchecked
17.221 - {
17.222 - uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
17.223 - //For some reason when the app is minimized in the task bar only the alpha of our color is set.
17.224 - //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
17.225 - iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
17.226 - }
17.227 - }
17.228 - }
17.229 -
17.230 - iDisplay.SwapBuffers();
17.231 -
17.232 - }
17.233 -
17.234 - //Compute instant FPS
17.235 - toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " FPS";
17.236 -
17.237 - LastTickTime = NewTickTime;
17.238 -
17.239 - }
17.240 -
17.241 - private void buttonOpen_Click(object sender, EventArgs e)
17.242 - {
17.243 - if (iDisplay.Open())
17.244 - {
17.245 - UpdateStatus();
17.246 - iDisplay.RequestPowerSupplyStatus();
17.247 - }
17.248 - else
17.249 - {
17.250 - UpdateStatus();
17.251 - toolStripStatusLabelConnect.Text = "Connection error";
17.252 - }
17.253 -
17.254 - }
17.255 -
17.256 - private void buttonClose_Click(object sender, EventArgs e)
17.257 - {
17.258 - iDisplay.Close();
17.259 - UpdateStatus();
17.260 - }
17.261 -
17.262 - private void buttonClear_Click(object sender, EventArgs e)
17.263 - {
17.264 - iDisplay.Clear();
17.265 - iDisplay.SwapBuffers();
17.266 - }
17.267 -
17.268 - private void buttonFill_Click(object sender, EventArgs e)
17.269 - {
17.270 - iDisplay.Fill();
17.271 - iDisplay.SwapBuffers();
17.272 - }
17.273 -
17.274 - private void trackBarBrightness_Scroll(object sender, EventArgs e)
17.275 - {
17.276 - Properties.Settings.Default.DisplayBrightness = trackBarBrightness.Value;
17.277 - Properties.Settings.Default.Save();
17.278 - iDisplay.SetBrightness(trackBarBrightness.Value);
17.279 -
17.280 - }
17.281 -
17.282 - private void UpdateStatus()
17.283 - {
17.284 - if (iDisplay.IsOpen())
17.285 - {
17.286 - buttonFill.Enabled = true;
17.287 - buttonClear.Enabled = true;
17.288 - buttonOpen.Enabled = false;
17.289 - buttonClose.Enabled = true;
17.290 - trackBarBrightness.Enabled = true;
17.291 - trackBarBrightness.Minimum = iDisplay.MinBrightness();
17.292 - trackBarBrightness.Maximum = iDisplay.MaxBrightness();
17.293 - trackBarBrightness.Value = Properties.Settings.Default.DisplayBrightness;
17.294 - trackBarBrightness.LargeChange = Math.Max(1,(iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
17.295 - trackBarBrightness.SmallChange = 1;
17.296 - iDisplay.SetBrightness(Properties.Settings.Default.DisplayBrightness);
17.297 -
17.298 - toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
17.299 - //+ " - " + iDisplay.SerialNumber();
17.300 - }
17.301 - else
17.302 - {
17.303 - buttonFill.Enabled = false;
17.304 - buttonClear.Enabled = false;
17.305 - buttonOpen.Enabled = true;
17.306 - buttonClose.Enabled = false;
17.307 - trackBarBrightness.Enabled = false;
17.308 - toolStripStatusLabelConnect.Text = "Disconnected";
17.309 - }
17.310 - }
17.311 -
17.312 -
17.313 -
17.314 - private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
17.315 - {
17.316 - //Save our show borders setting
17.317 - tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
17.318 - Properties.Settings.Default.DisplayShowBorders = checkBoxShowBorders.Checked;
17.319 - Properties.Settings.Default.Save();
17.320 - }
17.321 -
17.322 - private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
17.323 - {
17.324 - //Save our connect on startup setting
17.325 - Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
17.326 - Properties.Settings.Default.Save();
17.327 - }
17.328 -
17.329 - private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
17.330 - {
17.331 - //Save our reverse screen setting
17.332 - Properties.Settings.Default.DisplayReverseScreen = checkBoxReverseScreen.Checked;
17.333 - Properties.Settings.Default.Save();
17.334 - }
17.335 -
17.336 - private void MainForm_Resize(object sender, EventArgs e)
17.337 - {
17.338 - if (WindowState == FormWindowState.Minimized)
17.339 - {
17.340 - // Do some stuff
17.341 - //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
17.342 - iCreateBitmap = true;
17.343 - }
17.344 - }
17.345 -
17.346 - private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
17.347 - {
17.348 - StopServer();
17.349 - }
17.350 -
17.351 - public void StartServer()
17.352 - {
17.353 - iServiceHost = new ServiceHost
17.354 - (
17.355 - typeof(DisplayServer),
17.356 - new Uri[] { new Uri("net.pipe://localhost") }
17.357 - );
17.358 -
17.359 - iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetNamedPipeBinding(), "DisplayService");
17.360 - iServiceHost.Open();
17.361 - }
17.362 -
17.363 - public void StopServer()
17.364 - {
17.365 - //Tell connected client first? Is that possible?
17.366 - iServiceHost.Close();
17.367 - }
17.368 -
17.369 -
17.370 - }
17.371 -}
18.1 --- a/MainForm.resx Tue Aug 12 20:37:57 2014 +0200
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,129 +0,0 @@
18.4 -<?xml version="1.0" encoding="utf-8"?>
18.5 -<root>
18.6 - <!--
18.7 - Microsoft ResX Schema
18.8 -
18.9 - Version 2.0
18.10 -
18.11 - The primary goals of this format is to allow a simple XML format
18.12 - that is mostly human readable. The generation and parsing of the
18.13 - various data types are done through the TypeConverter classes
18.14 - associated with the data types.
18.15 -
18.16 - Example:
18.17 -
18.18 - ... ado.net/XML headers & schema ...
18.19 - <resheader name="resmimetype">text/microsoft-resx</resheader>
18.20 - <resheader name="version">2.0</resheader>
18.21 - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
18.22 - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
18.23 - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
18.24 - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
18.25 - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
18.26 - <value>[base64 mime encoded serialized .NET Framework object]</value>
18.27 - </data>
18.28 - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
18.29 - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
18.30 - <comment>This is a comment</comment>
18.31 - </data>
18.32 -
18.33 - There are any number of "resheader" rows that contain simple
18.34 - name/value pairs.
18.35 -
18.36 - Each data row contains a name, and value. The row also contains a
18.37 - type or mimetype. Type corresponds to a .NET class that support
18.38 - text/value conversion through the TypeConverter architecture.
18.39 - Classes that don't support this are serialized and stored with the
18.40 - mimetype set.
18.41 -
18.42 - The mimetype is used for serialized objects, and tells the
18.43 - ResXResourceReader how to depersist the object. This is currently not
18.44 - extensible. For a given mimetype the value must be set accordingly:
18.45 -
18.46 - Note - application/x-microsoft.net.object.binary.base64 is the format
18.47 - that the ResXResourceWriter will generate, however the reader can
18.48 - read any of the formats listed below.
18.49 -
18.50 - mimetype: application/x-microsoft.net.object.binary.base64
18.51 - value : The object must be serialized with
18.52 - : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
18.53 - : and then encoded with base64 encoding.
18.54 -
18.55 - mimetype: application/x-microsoft.net.object.soap.base64
18.56 - value : The object must be serialized with
18.57 - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
18.58 - : and then encoded with base64 encoding.
18.59 -
18.60 - mimetype: application/x-microsoft.net.object.bytearray.base64
18.61 - value : The object must be serialized into a byte array
18.62 - : using a System.ComponentModel.TypeConverter
18.63 - : and then encoded with base64 encoding.
18.64 - -->
18.65 - <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
18.66 - <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
18.67 - <xsd:element name="root" msdata:IsDataSet="true">
18.68 - <xsd:complexType>
18.69 - <xsd:choice maxOccurs="unbounded">
18.70 - <xsd:element name="metadata">
18.71 - <xsd:complexType>
18.72 - <xsd:sequence>
18.73 - <xsd:element name="value" type="xsd:string" minOccurs="0" />
18.74 - </xsd:sequence>
18.75 - <xsd:attribute name="name" use="required" type="xsd:string" />
18.76 - <xsd:attribute name="type" type="xsd:string" />
18.77 - <xsd:attribute name="mimetype" type="xsd:string" />
18.78 - <xsd:attribute ref="xml:space" />
18.79 - </xsd:complexType>
18.80 - </xsd:element>
18.81 - <xsd:element name="assembly">
18.82 - <xsd:complexType>
18.83 - <xsd:attribute name="alias" type="xsd:string" />
18.84 - <xsd:attribute name="name" type="xsd:string" />
18.85 - </xsd:complexType>
18.86 - </xsd:element>
18.87 - <xsd:element name="data">
18.88 - <xsd:complexType>
18.89 - <xsd:sequence>
18.90 - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
18.91 - <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
18.92 - </xsd:sequence>
18.93 - <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
18.94 - <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
18.95 - <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
18.96 - <xsd:attribute ref="xml:space" />
18.97 - </xsd:complexType>
18.98 - </xsd:element>
18.99 - <xsd:element name="resheader">
18.100 - <xsd:complexType>
18.101 - <xsd:sequence>
18.102 - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
18.103 - </xsd:sequence>
18.104 - <xsd:attribute name="name" type="xsd:string" use="required" />
18.105 - </xsd:complexType>
18.106 - </xsd:element>
18.107 - </xsd:choice>
18.108 - </xsd:complexType>
18.109 - </xsd:element>
18.110 - </xsd:schema>
18.111 - <resheader name="resmimetype">
18.112 - <value>text/microsoft-resx</value>
18.113 - </resheader>
18.114 - <resheader name="version">
18.115 - <value>2.0</value>
18.116 - </resheader>
18.117 - <resheader name="reader">
18.118 - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
18.119 - </resheader>
18.120 - <resheader name="writer">
18.121 - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
18.122 - </resheader>
18.123 - <metadata name="fontDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
18.124 - <value>17, 17</value>
18.125 - </metadata>
18.126 - <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
18.127 - <value>126, 17</value>
18.128 - </metadata>
18.129 - <metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
18.130 - <value>206, 17</value>
18.131 - </metadata>
18.132 -</root>
18.133 \ No newline at end of file
19.1 --- a/MarqueeLabel.cs Tue Aug 12 20:37:57 2014 +0200
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,293 +0,0 @@
19.4 -using System;
19.5 -using System.Collections.Generic;
19.6 -using System.ComponentModel;
19.7 -using System.Diagnostics;
19.8 -using System.Linq;
19.9 -using System.Text;
19.10 -using System.Threading.Tasks;
19.11 -//using System.Timers;
19.12 -using System.Windows.Forms;
19.13 -using System.Drawing;
19.14 -
19.15 -namespace SharpDisplayManager
19.16 -{
19.17 - [System.ComponentModel.DesignerCategory("Code")]
19.18 - public class MarqueeLabel : Label
19.19 - {
19.20 - private bool iOwnTimer;
19.21 - private StringFormat iStringFormat;
19.22 - private SolidBrush iBrush;
19.23 - private SizeF iTextSize;
19.24 - private SizeF iSeparatorSize;
19.25 -
19.26 - [Category("Appearance")]
19.27 - [Description("Separator in our scrolling loop.")]
19.28 - [DefaultValue(" | ")]
19.29 - [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
19.30 - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
19.31 - public string Separator { get; set; }
19.32 -
19.33 - [Category("Behavior")]
19.34 - [Description("How fast is our text scrolling, in pixels per second.")]
19.35 - [DefaultValue(32)]
19.36 - [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
19.37 - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
19.38 - public int PixelsPerSecond { get; set; }
19.39 -
19.40 - [Category("Behavior")]
19.41 - [Description("Use an internal or an external timer.")]
19.42 - [DefaultValue(true)]
19.43 - [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
19.44 - [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
19.45 - public bool OwnTimer
19.46 - {
19.47 - get
19.48 - {
19.49 - return iOwnTimer;
19.50 - }
19.51 - set
19.52 - {
19.53 - iOwnTimer = value;
19.54 -
19.55 - if (iOwnTimer)
19.56 - {
19.57 - Timer = new Timer();
19.58 - Timer.Interval = 10;
19.59 - Timer.Tick += new EventHandler(Timer_Tick);
19.60 - Timer.Start();
19.61 - }
19.62 - else
19.63 - {
19.64 - if (Timer != null)
19.65 - Timer.Dispose();
19.66 - Timer = null;
19.67 - }
19.68 -
19.69 - }
19.70 - }
19.71 -
19.72 - private int CurrentPosition { get; set; }
19.73 - private Timer Timer { get; set; }
19.74 - private DateTime LastTickTime { get; set; }
19.75 - private double PixelsLeft { get; set; }
19.76 - //DateTime a = new DateTime(2010, 05, 12, 13, 15, 00);
19.77 - //DateTime b = new DateTime(2010, 05, 12, 13, 45, 00);
19.78 - //Console.WriteLine(b.Subtract(a).TotalMinutes);
19.79 -
19.80 - public MarqueeLabel()
19.81 - {
19.82 - UseCompatibleTextRendering = true;
19.83 - //PixelsPerSecond = 32;
19.84 - LastTickTime = DateTime.Now;
19.85 - PixelsLeft = 0;
19.86 - iBrush = new SolidBrush(ForeColor);
19.87 - }
19.88 -
19.89 - public void UpdateAnimation(DateTime aLastTickTime, DateTime aNewTickTime)
19.90 - {
19.91 - if (!NeedToScroll())
19.92 - {
19.93 - CurrentPosition = 0;
19.94 - return;
19.95 - }
19.96 -
19.97 - while (CurrentPosition > (iTextSize.Width + iSeparatorSize.Width))
19.98 - {
19.99 - CurrentPosition -= ((int)(iTextSize.Width + iSeparatorSize.Width));
19.100 - }
19.101 -
19.102 - PixelsLeft += aNewTickTime.Subtract(aLastTickTime).TotalSeconds * PixelsPerSecond;
19.103 -
19.104 - //Keep track of our pixels left over
19.105 - //PixelsLeft = offset - Math.Truncate(offset);
19.106 - double offset = Math.Truncate(PixelsLeft);
19.107 - PixelsLeft -= offset;
19.108 -
19.109 - CurrentPosition += Convert.ToInt32(offset);
19.110 -
19.111 - /*
19.112 - if (offset > 1.0)
19.113 - {
19.114 - BackColor = Color.Red;
19.115 - }
19.116 - else if (offset==1.0)
19.117 - {
19.118 - if (BackColor != Color.White)
19.119 - {
19.120 - BackColor = Color.White;
19.121 - }
19.122 -
19.123 - }
19.124 - else
19.125 - {
19.126 - //Too slow
19.127 - //BackColor = Color.Green;
19.128 - }*/
19.129 -
19.130 - //Only redraw if something has changed
19.131 - if (offset != 0)
19.132 - {
19.133 - Invalidate();
19.134 - }
19.135 - }
19.136 -
19.137 - void Timer_Tick(object sender, EventArgs e)
19.138 - {
19.139 - DateTime NewTickTime = DateTime.Now;
19.140 - //
19.141 - UpdateAnimation(LastTickTime, NewTickTime);
19.142 - //
19.143 - LastTickTime = NewTickTime;
19.144 - }
19.145 -
19.146 - private StringFormat GetStringFormatFromContentAllignment(ContentAlignment ca)
19.147 - {
19.148 - StringFormat format = new StringFormat();
19.149 - format = StringFormat.GenericTypographic;
19.150 - switch (ca)
19.151 - {
19.152 - case ContentAlignment.TopCenter:
19.153 - format.Alignment = StringAlignment.Near;
19.154 - format.LineAlignment = StringAlignment.Center;
19.155 - break;
19.156 - case ContentAlignment.TopLeft:
19.157 - format.Alignment = StringAlignment.Near;
19.158 - format.LineAlignment = StringAlignment.Near;
19.159 - break;
19.160 - case ContentAlignment.TopRight:
19.161 - format.Alignment = StringAlignment.Near;
19.162 - format.LineAlignment = StringAlignment.Far;
19.163 - break;
19.164 - case ContentAlignment.MiddleCenter:
19.165 - format.Alignment = StringAlignment.Center;
19.166 - format.LineAlignment = StringAlignment.Center;
19.167 - break;
19.168 - case ContentAlignment.MiddleLeft:
19.169 - format.Alignment = StringAlignment.Center;
19.170 - format.LineAlignment = StringAlignment.Near;
19.171 - break;
19.172 - case ContentAlignment.MiddleRight:
19.173 - format.Alignment = StringAlignment.Center;
19.174 - format.LineAlignment = StringAlignment.Far;
19.175 - break;
19.176 - case ContentAlignment.BottomCenter:
19.177 - format.Alignment = StringAlignment.Far;
19.178 - format.LineAlignment = StringAlignment.Center;
19.179 - break;
19.180 - case ContentAlignment.BottomLeft:
19.181 - format.Alignment = StringAlignment.Far;
19.182 - format.LineAlignment = StringAlignment.Near;
19.183 - break;
19.184 - case ContentAlignment.BottomRight:
19.185 - format.Alignment = StringAlignment.Far;
19.186 - format.LineAlignment = StringAlignment.Far;
19.187 - break;
19.188 - }
19.189 -
19.190 - format.FormatFlags |= StringFormatFlags.NoWrap;
19.191 - format.FormatFlags |= StringFormatFlags.NoClip;
19.192 - format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
19.193 - format.Trimming = StringTrimming.None;
19.194 -
19.195 - return format;
19.196 - }
19.197 -
19.198 - protected override void OnForeColorChanged(EventArgs e)
19.199 - {
19.200 - //Color has changed recreate our brush
19.201 - iBrush = new SolidBrush(ForeColor);
19.202 -
19.203 - base.OnForeColorChanged(e);
19.204 - }
19.205 -
19.206 -
19.207 - private void HandleTextSizeChange()
19.208 - {
19.209 - //For all string measurements and drawing issues refer to the following article:
19.210 - // http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number
19.211 - //Update text size according to text and font
19.212 - Graphics g = this.CreateGraphics();
19.213 - g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
19.214 - iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
19.215 - iTextSize = g.MeasureString(Text, Font, Int32.MaxValue, iStringFormat);
19.216 - iSeparatorSize = g.MeasureString(Separator, Font, Int32.MaxValue, iStringFormat);
19.217 -
19.218 - if (NeedToScroll())
19.219 - {
19.220 - //Always align left when scrolling
19.221 - iStringFormat.Alignment = StringAlignment.Near;
19.222 - }
19.223 - }
19.224 -
19.225 - protected override void OnTextChanged(EventArgs e)
19.226 - {
19.227 - HandleTextSizeChange();
19.228 -
19.229 - base.OnTextChanged(e);
19.230 - }
19.231 -
19.232 - protected override void OnFontChanged(EventArgs e)
19.233 - {
19.234 - HandleTextSizeChange();
19.235 -
19.236 - base.OnFontChanged(e);
19.237 - }
19.238 -
19.239 - protected override void OnTextAlignChanged(EventArgs e)
19.240 - {
19.241 - iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
19.242 -
19.243 - base.OnTextAlignChanged(e);
19.244 -
19.245 - }
19.246 -
19.247 - protected override void OnPaint(PaintEventArgs e)
19.248 - {
19.249 - //Disable anti-aliasing
19.250 - e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
19.251 - if (NeedToScroll())
19.252 - {
19.253 - //Draw the first one
19.254 - e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
19.255 - e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
19.256 - //Draw separator
19.257 - e.Graphics.TranslateTransform(iTextSize.Width, 0);
19.258 - e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
19.259 - //Draw the last one
19.260 - e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
19.261 - e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
19.262 - }
19.263 - else
19.264 - {
19.265 - e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
19.266 - }
19.267 -
19.268 -
19.269 -
19.270 - //DrawText is not working without anti-aliasing. See: stackoverflow.com/questions/8283631/graphics-drawstring-vs-textrenderer-drawtextwhich-can-deliver-better-quality
19.271 - //TextRenderer.DrawText(e.Graphics, Text, Font, ClientRectangle, ForeColor, BackColor, iTextFormatFlags);
19.272 -
19.273 - //base.OnPaint(e);
19.274 - }
19.275 -
19.276 - public bool NeedToScroll()
19.277 - {
19.278 - //if (Width < e.Graphics.MeasureString(Text, Font).Width)
19.279 - if (Width < iTextSize.Width)
19.280 - {
19.281 - return true;
19.282 - }
19.283 - return false;
19.284 - }
19.285 -
19.286 - protected override void Dispose(bool disposing)
19.287 - {
19.288 - if (disposing)
19.289 - {
19.290 - if (Timer != null)
19.291 - Timer.Dispose();
19.292 - }
19.293 - Timer = null;
19.294 - }
19.295 - }
19.296 -}
20.1 --- a/Program.cs Tue Aug 12 20:37:57 2014 +0200
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,24 +0,0 @@
20.4 -using System;
20.5 -using System.Collections.Generic;
20.6 -using System.Linq;
20.7 -using System.Threading.Tasks;
20.8 -using System.Windows.Forms;
20.9 -
20.10 -namespace SharpDisplayManager
20.11 -{
20.12 - static class Program
20.13 - {
20.14 - public static MainForm iMainForm;
20.15 - /// <summary>
20.16 - /// The main entry point for the application.
20.17 - /// </summary>
20.18 - [STAThread]
20.19 - static void Main()
20.20 - {
20.21 - Application.EnableVisualStyles();
20.22 - Application.SetCompatibleTextRenderingDefault(false);
20.23 - iMainForm = new MainForm();
20.24 - Application.Run(iMainForm);
20.25 - }
20.26 - }
20.27 -}
21.1 --- a/Properties/AssemblyInfo.cs Tue Aug 12 20:37:57 2014 +0200
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,36 +0,0 @@
21.4 -using System.Reflection;
21.5 -using System.Runtime.CompilerServices;
21.6 -using System.Runtime.InteropServices;
21.7 -
21.8 -// General Information about an assembly is controlled through the following
21.9 -// set of attributes. Change these attribute values to modify the information
21.10 -// associated with an assembly.
21.11 -[assembly: AssemblyTitle("SharpDisplayManager")]
21.12 -[assembly: AssemblyDescription("")]
21.13 -[assembly: AssemblyConfiguration("")]
21.14 -[assembly: AssemblyCompany("")]
21.15 -[assembly: AssemblyProduct("SharpDisplayManager")]
21.16 -[assembly: AssemblyCopyright("Copyright © 2014")]
21.17 -[assembly: AssemblyTrademark("")]
21.18 -[assembly: AssemblyCulture("")]
21.19 -
21.20 -// Setting ComVisible to false makes the types in this assembly not visible
21.21 -// to COM components. If you need to access a type in this assembly from
21.22 -// COM, set the ComVisible attribute to true on that type.
21.23 -[assembly: ComVisible(false)]
21.24 -
21.25 -// The following GUID is for the ID of the typelib if this project is exposed to COM
21.26 -[assembly: Guid("5da0f26b-76a6-41e8-832c-5b593b3a75b0")]
21.27 -
21.28 -// Version information for an assembly consists of the following four values:
21.29 -//
21.30 -// Major Version
21.31 -// Minor Version
21.32 -// Build Number
21.33 -// Revision
21.34 -//
21.35 -// You can specify all the values or you can default the Build and Revision Numbers
21.36 -// by using the '*' as shown below:
21.37 -// [assembly: AssemblyVersion("1.0.*")]
21.38 -[assembly: AssemblyVersion("1.0.0.0")]
21.39 -[assembly: AssemblyFileVersion("1.0.0.0")]
22.1 --- a/Properties/Resources.Designer.cs Tue Aug 12 20:37:57 2014 +0200
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,71 +0,0 @@
22.4 -//------------------------------------------------------------------------------
22.5 -// <auto-generated>
22.6 -// This code was generated by a tool.
22.7 -// Runtime Version:4.0.30319.18063
22.8 -//
22.9 -// Changes to this file may cause incorrect behavior and will be lost if
22.10 -// the code is regenerated.
22.11 -// </auto-generated>
22.12 -//------------------------------------------------------------------------------
22.13 -
22.14 -namespace SharpDisplayManager.Properties
22.15 -{
22.16 -
22.17 -
22.18 - /// <summary>
22.19 - /// A strongly-typed resource class, for looking up localized strings, etc.
22.20 - /// </summary>
22.21 - // This class was auto-generated by the StronglyTypedResourceBuilder
22.22 - // class via a tool like ResGen or Visual Studio.
22.23 - // To add or remove a member, edit your .ResX file then rerun ResGen
22.24 - // with the /str option, or rebuild your VS project.
22.25 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22.26 - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
22.27 - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
22.28 - internal class Resources
22.29 - {
22.30 -
22.31 - private static global::System.Resources.ResourceManager resourceMan;
22.32 -
22.33 - private static global::System.Globalization.CultureInfo resourceCulture;
22.34 -
22.35 - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
22.36 - internal Resources()
22.37 - {
22.38 - }
22.39 -
22.40 - /// <summary>
22.41 - /// Returns the cached ResourceManager instance used by this class.
22.42 - /// </summary>
22.43 - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
22.44 - internal static global::System.Resources.ResourceManager ResourceManager
22.45 - {
22.46 - get
22.47 - {
22.48 - if ((resourceMan == null))
22.49 - {
22.50 - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDisplayManager.Properties.Resources", typeof(Resources).Assembly);
22.51 - resourceMan = temp;
22.52 - }
22.53 - return resourceMan;
22.54 - }
22.55 - }
22.56 -
22.57 - /// <summary>
22.58 - /// Overrides the current thread's CurrentUICulture property for all
22.59 - /// resource lookups using this strongly typed resource class.
22.60 - /// </summary>
22.61 - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
22.62 - internal static global::System.Globalization.CultureInfo Culture
22.63 - {
22.64 - get
22.65 - {
22.66 - return resourceCulture;
22.67 - }
22.68 - set
22.69 - {
22.70 - resourceCulture = value;
22.71 - }
22.72 - }
22.73 - }
22.74 -}
23.1 --- a/Properties/Resources.resx Tue Aug 12 20:37:57 2014 +0200
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,117 +0,0 @@
23.4 -<?xml version="1.0" encoding="utf-8"?>
23.5 -<root>
23.6 - <!--
23.7 - Microsoft ResX Schema
23.8 -
23.9 - Version 2.0
23.10 -
23.11 - The primary goals of this format is to allow a simple XML format
23.12 - that is mostly human readable. The generation and parsing of the
23.13 - various data types are done through the TypeConverter classes
23.14 - associated with the data types.
23.15 -
23.16 - Example:
23.17 -
23.18 - ... ado.net/XML headers & schema ...
23.19 - <resheader name="resmimetype">text/microsoft-resx</resheader>
23.20 - <resheader name="version">2.0</resheader>
23.21 - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
23.22 - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
23.23 - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
23.24 - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
23.25 - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23.26 - <value>[base64 mime encoded serialized .NET Framework object]</value>
23.27 - </data>
23.28 - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
23.29 - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
23.30 - <comment>This is a comment</comment>
23.31 - </data>
23.32 -
23.33 - There are any number of "resheader" rows that contain simple
23.34 - name/value pairs.
23.35 -
23.36 - Each data row contains a name, and value. The row also contains a
23.37 - type or mimetype. Type corresponds to a .NET class that support
23.38 - text/value conversion through the TypeConverter architecture.
23.39 - Classes that don't support this are serialized and stored with the
23.40 - mimetype set.
23.41 -
23.42 - The mimetype is used for serialized objects, and tells the
23.43 - ResXResourceReader how to depersist the object. This is currently not
23.44 - extensible. For a given mimetype the value must be set accordingly:
23.45 -
23.46 - Note - application/x-microsoft.net.object.binary.base64 is the format
23.47 - that the ResXResourceWriter will generate, however the reader can
23.48 - read any of the formats listed below.
23.49 -
23.50 - mimetype: application/x-microsoft.net.object.binary.base64
23.51 - value : The object must be serialized with
23.52 - : System.Serialization.Formatters.Binary.BinaryFormatter
23.53 - : and then encoded with base64 encoding.
23.54 -
23.55 - mimetype: application/x-microsoft.net.object.soap.base64
23.56 - value : The object must be serialized with
23.57 - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
23.58 - : and then encoded with base64 encoding.
23.59 -
23.60 - mimetype: application/x-microsoft.net.object.bytearray.base64
23.61 - value : The object must be serialized into a byte array
23.62 - : using a System.ComponentModel.TypeConverter
23.63 - : and then encoded with base64 encoding.
23.64 - -->
23.65 - <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
23.66 - <xsd:element name="root" msdata:IsDataSet="true">
23.67 - <xsd:complexType>
23.68 - <xsd:choice maxOccurs="unbounded">
23.69 - <xsd:element name="metadata">
23.70 - <xsd:complexType>
23.71 - <xsd:sequence>
23.72 - <xsd:element name="value" type="xsd:string" minOccurs="0" />
23.73 - </xsd:sequence>
23.74 - <xsd:attribute name="name" type="xsd:string" />
23.75 - <xsd:attribute name="type" type="xsd:string" />
23.76 - <xsd:attribute name="mimetype" type="xsd:string" />
23.77 - </xsd:complexType>
23.78 - </xsd:element>
23.79 - <xsd:element name="assembly">
23.80 - <xsd:complexType>
23.81 - <xsd:attribute name="alias" type="xsd:string" />
23.82 - <xsd:attribute name="name" type="xsd:string" />
23.83 - </xsd:complexType>
23.84 - </xsd:element>
23.85 - <xsd:element name="data">
23.86 - <xsd:complexType>
23.87 - <xsd:sequence>
23.88 - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
23.89 - <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
23.90 - </xsd:sequence>
23.91 - <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
23.92 - <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
23.93 - <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
23.94 - </xsd:complexType>
23.95 - </xsd:element>
23.96 - <xsd:element name="resheader">
23.97 - <xsd:complexType>
23.98 - <xsd:sequence>
23.99 - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
23.100 - </xsd:sequence>
23.101 - <xsd:attribute name="name" type="xsd:string" use="required" />
23.102 - </xsd:complexType>
23.103 - </xsd:element>
23.104 - </xsd:choice>
23.105 - </xsd:complexType>
23.106 - </xsd:element>
23.107 - </xsd:schema>
23.108 - <resheader name="resmimetype">
23.109 - <value>text/microsoft-resx</value>
23.110 - </resheader>
23.111 - <resheader name="version">
23.112 - <value>2.0</value>
23.113 - </resheader>
23.114 - <resheader name="reader">
23.115 - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
23.116 - </resheader>
23.117 - <resheader name="writer">
23.118 - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
23.119 - </resheader>
23.120 -</root>
23.121 \ No newline at end of file
24.1 --- a/Properties/Settings.Designer.cs Tue Aug 12 20:37:57 2014 +0200
24.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
24.3 @@ -1,86 +0,0 @@
24.4 -//------------------------------------------------------------------------------
24.5 -// <auto-generated>
24.6 -// This code was generated by a tool.
24.7 -// Runtime Version:4.0.30319.18444
24.8 -//
24.9 -// Changes to this file may cause incorrect behavior and will be lost if
24.10 -// the code is regenerated.
24.11 -// </auto-generated>
24.12 -//------------------------------------------------------------------------------
24.13 -
24.14 -namespace SharpDisplayManager.Properties {
24.15 -
24.16 -
24.17 - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24.18 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
24.19 - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
24.20 -
24.21 - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
24.22 -
24.23 - public static Settings Default {
24.24 - get {
24.25 - return defaultInstance;
24.26 - }
24.27 - }
24.28 -
24.29 - [global::System.Configuration.UserScopedSettingAttribute()]
24.30 - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24.31 - [global::System.Configuration.DefaultSettingValueAttribute("1")]
24.32 - public int DisplayBrightness {
24.33 - get {
24.34 - return ((int)(this["DisplayBrightness"]));
24.35 - }
24.36 - set {
24.37 - this["DisplayBrightness"] = value;
24.38 - }
24.39 - }
24.40 -
24.41 - [global::System.Configuration.UserScopedSettingAttribute()]
24.42 - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24.43 - [global::System.Configuration.DefaultSettingValueAttribute("Microsoft Sans Serif, 9.75pt")]
24.44 - public global::System.Drawing.Font DisplayFont {
24.45 - get {
24.46 - return ((global::System.Drawing.Font)(this["DisplayFont"]));
24.47 - }
24.48 - set {
24.49 - this["DisplayFont"] = value;
24.50 - }
24.51 - }
24.52 -
24.53 - [global::System.Configuration.UserScopedSettingAttribute()]
24.54 - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24.55 - [global::System.Configuration.DefaultSettingValueAttribute("False")]
24.56 - public bool DisplayShowBorders {
24.57 - get {
24.58 - return ((bool)(this["DisplayShowBorders"]));
24.59 - }
24.60 - set {
24.61 - this["DisplayShowBorders"] = value;
24.62 - }
24.63 - }
24.64 -
24.65 - [global::System.Configuration.UserScopedSettingAttribute()]
24.66 - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24.67 - [global::System.Configuration.DefaultSettingValueAttribute("False")]
24.68 - public bool DisplayConnectOnStartup {
24.69 - get {
24.70 - return ((bool)(this["DisplayConnectOnStartup"]));
24.71 - }
24.72 - set {
24.73 - this["DisplayConnectOnStartup"] = value;
24.74 - }
24.75 - }
24.76 -
24.77 - [global::System.Configuration.UserScopedSettingAttribute()]
24.78 - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24.79 - [global::System.Configuration.DefaultSettingValueAttribute("False")]
24.80 - public bool DisplayReverseScreen {
24.81 - get {
24.82 - return ((bool)(this["DisplayReverseScreen"]));
24.83 - }
24.84 - set {
24.85 - this["DisplayReverseScreen"] = value;
24.86 - }
24.87 - }
24.88 - }
24.89 -}
25.1 --- a/Properties/Settings.settings Tue Aug 12 20:37:57 2014 +0200
25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
25.3 @@ -1,21 +0,0 @@
25.4 -<?xml version='1.0' encoding='utf-8'?>
25.5 -<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SharpDisplayManager.Properties" GeneratedClassName="Settings">
25.6 - <Profiles />
25.7 - <Settings>
25.8 - <Setting Name="DisplayBrightness" Type="System.Int32" Scope="User">
25.9 - <Value Profile="(Default)">1</Value>
25.10 - </Setting>
25.11 - <Setting Name="DisplayFont" Type="System.Drawing.Font" Scope="User">
25.12 - <Value Profile="(Default)">Microsoft Sans Serif, 9.75pt</Value>
25.13 - </Setting>
25.14 - <Setting Name="DisplayShowBorders" Type="System.Boolean" Scope="User">
25.15 - <Value Profile="(Default)">False</Value>
25.16 - </Setting>
25.17 - <Setting Name="DisplayConnectOnStartup" Type="System.Boolean" Scope="User">
25.18 - <Value Profile="(Default)">False</Value>
25.19 - </Setting>
25.20 - <Setting Name="DisplayReverseScreen" Type="System.Boolean" Scope="User">
25.21 - <Value Profile="(Default)">False</Value>
25.22 - </Setting>
25.23 - </Settings>
25.24 -</SettingsFile>
25.25 \ No newline at end of file
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/Server/App.config Tue Aug 12 20:55:50 2014 +0200
26.3 @@ -0,0 +1,30 @@
26.4 +<?xml version="1.0" encoding="utf-8" ?>
26.5 +<configuration>
26.6 + <configSections>
26.7 + <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
26.8 + <section name="SharpDisplayManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
26.9 + </sectionGroup>
26.10 + </configSections>
26.11 + <startup>
26.12 + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
26.13 + </startup>
26.14 + <userSettings>
26.15 + <SharpDisplayManager.Properties.Settings>
26.16 + <setting name="DisplayBrightness" serializeAs="String">
26.17 + <value>1</value>
26.18 + </setting>
26.19 + <setting name="DisplayFont" serializeAs="String">
26.20 + <value>Microsoft Sans Serif, 9.75pt</value>
26.21 + </setting>
26.22 + <setting name="DisplayShowBorders" serializeAs="String">
26.23 + <value>False</value>
26.24 + </setting>
26.25 + <setting name="DisplayConnectOnStartup" serializeAs="String">
26.26 + <value>False</value>
26.27 + </setting>
26.28 + <setting name="DisplayReverseScreen" serializeAs="String">
26.29 + <value>False</value>
26.30 + </setting>
26.31 + </SharpDisplayManager.Properties.Settings>
26.32 + </userSettings>
26.33 +</configuration>
26.34 \ No newline at end of file
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/Server/CbtHook.cs Tue Aug 12 20:55:50 2014 +0200
27.3 @@ -0,0 +1,171 @@
27.4 +//=============================================================================
27.5 +// COPYRIGHT: Prosoft-Lanz
27.6 +//=============================================================================
27.7 +//
27.8 +// $Workfile: CbtHook.cs $
27.9 +//
27.10 +// PROJECT : CodeProject Components
27.11 +// VERSION : 1.00
27.12 +// CREATION : 19.02.2003
27.13 +// AUTHOR : JCL
27.14 +//
27.15 +// DETAILS : This class implement the WH_CBT Windows hook mechanism.
27.16 +// From MSDN, Dino Esposito.
27.17 +// WindowCreate, WindowDestroy and WindowActivate user events.
27.18 +//
27.19 +//-----------------------------------------------------------------------------
27.20 +using System;
27.21 +using System.Text;
27.22 +using System.Runtime.InteropServices;
27.23 +
27.24 +namespace CodeProject.Win32API.Hook
27.25 +{
27.26 + ///////////////////////////////////////////////////////////////////////
27.27 + #region Enum CbtHookAction
27.28 +
27.29 + /// <summary>
27.30 + /// CBT hook actions.
27.31 + /// </summary>
27.32 + internal enum CbtHookAction : int
27.33 + {
27.34 + HCBT_MOVESIZE = 0,
27.35 + HCBT_MINMAX = 1,
27.36 + HCBT_QS = 2,
27.37 + HCBT_CREATEWND = 3,
27.38 + HCBT_DESTROYWND = 4,
27.39 + HCBT_ACTIVATE = 5,
27.40 + HCBT_CLICKSKIPPED = 6,
27.41 + HCBT_KEYSKIPPED = 7,
27.42 + HCBT_SYSCOMMAND = 8,
27.43 + HCBT_SETFOCUS = 9
27.44 + }
27.45 +
27.46 + #endregion
27.47 +
27.48 + ///////////////////////////////////////////////////////////////////////
27.49 + #region Class CbtEventArgs
27.50 +
27.51 + /// <summary>
27.52 + /// Class used for WH_CBT hook event arguments.
27.53 + /// </summary>
27.54 + public class CbtEventArgs : EventArgs
27.55 + {
27.56 + /// wParam parameter.
27.57 + public IntPtr wParam;
27.58 + /// lParam parameter.
27.59 + public IntPtr lParam;
27.60 + /// Window class name.
27.61 + public string className;
27.62 + /// True if it is a dialog window.
27.63 + public bool IsDialog;
27.64 +
27.65 + internal CbtEventArgs(IntPtr wParam, IntPtr lParam)
27.66 + {
27.67 + // cache the parameters
27.68 + this.wParam = wParam;
27.69 + this.lParam = lParam;
27.70 +
27.71 + // cache the window's class name
27.72 + StringBuilder sb = new StringBuilder();
27.73 + sb.Capacity = 256;
27.74 + USER32.GetClassName(wParam, sb, 256);
27.75 + className = sb.ToString();
27.76 + IsDialog = (className == "#32770");
27.77 + }
27.78 + }
27.79 +
27.80 + #endregion
27.81 +
27.82 + ///////////////////////////////////////////////////////////////////////
27.83 + #region Class CbtHook
27.84 +
27.85 + /// <summary>
27.86 + /// Class to expose the windows WH_CBT hook mechanism.
27.87 + /// </summary>
27.88 + public class CbtHook : WindowsHook
27.89 + {
27.90 + /// <summary>
27.91 + /// WH_CBT hook delegate method.
27.92 + /// </summary>
27.93 + public delegate void CbtEventHandler(object sender, CbtEventArgs e);
27.94 +
27.95 + /// <summary>
27.96 + /// WH_CBT create event.
27.97 + /// </summary>
27.98 + public event CbtEventHandler WindowCreate;
27.99 + /// <summary>
27.100 + /// WH_CBT destroy event.
27.101 + /// </summary>
27.102 + public event CbtEventHandler WindowDestroye;
27.103 + /// <summary>
27.104 + /// WH_CBT activate event.
27.105 + /// </summary>
27.106 + public event CbtEventHandler WindowActivate;
27.107 +
27.108 + /// <summary>
27.109 + /// Construct a WH_CBT hook.
27.110 + /// </summary>
27.111 + public CbtHook() : base(HookType.WH_CBT)
27.112 + {
27.113 + this.HookInvoke += new HookEventHandler(CbtHookInvoked);
27.114 + }
27.115 + /// <summary>
27.116 + /// Construct a WH_CBT hook giving a hook filter delegate method.
27.117 + /// </summary>
27.118 + /// <param name="func">Hook filter event.</param>
27.119 + public CbtHook(HookProc func) : base(HookType.WH_CBT, func)
27.120 + {
27.121 + this.HookInvoke += new HookEventHandler(CbtHookInvoked);
27.122 + }
27.123 +
27.124 + // handles the hook event
27.125 + private void CbtHookInvoked(object sender, HookEventArgs e)
27.126 + {
27.127 + // handle hook events (only a few of available actions)
27.128 + switch ((CbtHookAction)e.code)
27.129 + {
27.130 + case CbtHookAction.HCBT_CREATEWND:
27.131 + HandleCreateWndEvent(e.wParam, e.lParam);
27.132 + break;
27.133 + case CbtHookAction.HCBT_DESTROYWND:
27.134 + HandleDestroyWndEvent(e.wParam, e.lParam);
27.135 + break;
27.136 + case CbtHookAction.HCBT_ACTIVATE:
27.137 + HandleActivateEvent(e.wParam, e.lParam);
27.138 + break;
27.139 + }
27.140 + return;
27.141 + }
27.142 +
27.143 + // handle the CREATEWND hook event
27.144 + private void HandleCreateWndEvent(IntPtr wParam, IntPtr lParam)
27.145 + {
27.146 + if (WindowCreate != null)
27.147 + {
27.148 + CbtEventArgs e = new CbtEventArgs(wParam, lParam);
27.149 + WindowCreate(this, e);
27.150 + }
27.151 + }
27.152 +
27.153 + // handle the DESTROYWND hook event
27.154 + private void HandleDestroyWndEvent(IntPtr wParam, IntPtr lParam)
27.155 + {
27.156 + if (WindowDestroye != null)
27.157 + {
27.158 + CbtEventArgs e = new CbtEventArgs(wParam, lParam);
27.159 + WindowDestroye(this, e);
27.160 + }
27.161 + }
27.162 +
27.163 + // handle the ACTIVATE hook event
27.164 + private void HandleActivateEvent(IntPtr wParam, IntPtr lParam)
27.165 + {
27.166 + if (WindowActivate != null)
27.167 + {
27.168 + CbtEventArgs e = new CbtEventArgs(wParam, lParam);
27.169 + WindowActivate(this, e);
27.170 + }
27.171 + }
27.172 + }
27.173 + #endregion
27.174 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/Server/DialogBox.cs Tue Aug 12 20:55:50 2014 +0200
28.3 @@ -0,0 +1,630 @@
28.4 +//=============================================================================
28.5 +// COPYRIGHT: Prosoft-Lanz
28.6 +//=============================================================================
28.7 +//
28.8 +// $Workfile: DialogBox.cs $
28.9 +//
28.10 +// PROJECT : CodeProject Components
28.11 +// VERSION : 1.00
28.12 +// CREATION : 19.02.2003
28.13 +// AUTHOR : JCL
28.14 +//
28.15 +// DETAILS : DialogBoxes centered into the parent owner.
28.16 +// This class implement the following objects:
28.17 +//
28.18 +// DlgBox.ShowDialog(...) for CommonDialog and Form
28.19 +// MsgBox.Show(...) for standard MessageBox
28.20 +// AppBox.Show(...) for standard MessageBox with ProductName as caption
28.21 +// ErrBox.Show(...) for standard error MessageBox
28.22 +//
28.23 +//-----------------------------------------------------------------------------
28.24 +using System;
28.25 +using System.Drawing;
28.26 +using System.Windows.Forms;
28.27 +using System.Runtime.InteropServices;
28.28 +using System.Diagnostics;
28.29 +
28.30 +using CodeProject.Win32API;
28.31 +using CodeProject.Win32API.Hook;
28.32 +
28.33 +namespace CodeProject.Dialog
28.34 +{
28.35 + ///////////////////////////////////////////////////////////////////////
28.36 + #region DlgBox
28.37 +
28.38 + /// <summary>
28.39 + /// Class to display a CommonDialog or modal Form centered on the owner.
28.40 + /// </summary>
28.41 + /// <example>
28.42 + /// This example display the default print dialog box in the center of the parent.
28.43 + /// <code>
28.44 + /// PrintDialog printDlg = new PrintDialog();
28.45 + /// if (DlgBox.ShowDialog(printDlg, parent) == DialogResult.OK)
28.46 + /// printDocument.Print();
28.47 + /// </code>
28.48 + /// </example>
28.49 + public sealed class DlgBox
28.50 + {
28.51 + private DlgBox() {} // To remove the constructor from the documentation!
28.52 +
28.53 + ///////////////////////////////////////////////////////////////////////
28.54 + // CommonDialog
28.55 +
28.56 + /// <summary>
28.57 + /// Show a command dialog box at the center of the active window.
28.58 + /// </summary>
28.59 + public static DialogResult ShowDialog(CommonDialog dlg)
28.60 + {
28.61 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.62 + DialogResult dlgResult = dlg.ShowDialog();
28.63 + centerWindow.Dispose();
28.64 + return dlgResult;
28.65 + }
28.66 +
28.67 + /// <summary>
28.68 + /// Show a command dialog box at the center of the owner window.
28.69 + /// </summary>
28.70 + public static DialogResult ShowDialog(CommonDialog dlg, IWin32Window owner)
28.71 + {
28.72 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.73 + CenterWindow centerWindow = new CenterWindow(handle);
28.74 + DialogResult dlgResult = dlg.ShowDialog();
28.75 + centerWindow.Dispose();
28.76 + return dlgResult;
28.77 + }
28.78 +
28.79 + ///////////////////////////////////////////////////////////////////////
28.80 + // Form
28.81 +
28.82 + /// <summary>
28.83 + /// Show a form dialog box at the center of the active window.
28.84 + /// </summary>
28.85 + public static DialogResult ShowDialog(Form form)
28.86 + {
28.87 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.88 + DialogResult dlgResult = form.ShowDialog();
28.89 + centerWindow.Dispose();
28.90 + return dlgResult;
28.91 + }
28.92 +
28.93 + /// <summary>
28.94 + /// Show a form dialog box at the center of the owner window.
28.95 + /// </summary>
28.96 + public static DialogResult ShowDialog(Form form, IWin32Window owner)
28.97 + {
28.98 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.99 + CenterWindow centerWindow = new CenterWindow(handle);
28.100 + DialogResult dlgResult = form.ShowDialog();
28.101 + centerWindow.Dispose();
28.102 + return dlgResult;
28.103 + }
28.104 + }
28.105 +
28.106 + #endregion
28.107 +
28.108 + ///////////////////////////////////////////////////////////////////////
28.109 + #region MsgBox
28.110 +
28.111 + /// <summary>
28.112 + /// Class to display a MessageBox centered on the owner.
28.113 + /// </summary>
28.114 + /// <remarks>
28.115 + /// Same methods as the standard MessageBox.
28.116 + /// </remarks>
28.117 + /// <example>
28.118 + /// This example display a "Hello" message box centered on the owner.
28.119 + /// <code>
28.120 + /// MsgBox.Show("Hello");
28.121 + /// </code>
28.122 + /// </example>
28.123 + public sealed class MsgBox
28.124 + {
28.125 + private MsgBox() {} // To remove the constructor from the documentation!
28.126 +
28.127 + ///////////////////////////////////////////////////////////////////////
28.128 + // text
28.129 +
28.130 + /// <summary>
28.131 + /// See MSDN MessageBox() method.
28.132 + /// </summary>
28.133 + public static DialogResult Show(string text)
28.134 + {
28.135 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.136 + string caption = Application.ProductName;
28.137 + DialogResult dlgResult = MessageBox.Show(text, caption);
28.138 + centerWindow.Dispose();
28.139 + return dlgResult;
28.140 + }
28.141 +
28.142 + /// <summary>
28.143 + /// See MSDN MessageBox() method.
28.144 + /// </summary>
28.145 + public static DialogResult Show(IWin32Window owner, string text)
28.146 + {
28.147 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.148 + CenterWindow centerWindow = new CenterWindow(handle);
28.149 + string caption = Application.ProductName;
28.150 + DialogResult dlgResult = MessageBox.Show(owner, text, caption);
28.151 + centerWindow.Dispose();
28.152 + return dlgResult;
28.153 + }
28.154 +
28.155 + ///////////////////////////////////////////////////////////////////////
28.156 + // text, caption
28.157 +
28.158 + /// <summary>
28.159 + /// See MSDN MessageBox() method.
28.160 + /// </summary>
28.161 + public static DialogResult Show(string text, string caption)
28.162 + {
28.163 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.164 + DialogResult dlgResult = MessageBox.Show(text, caption);
28.165 + centerWindow.Dispose();
28.166 + return dlgResult;
28.167 + }
28.168 +
28.169 + /// <summary>
28.170 + /// See MSDN MessageBox() method.
28.171 + /// </summary>
28.172 + public static DialogResult Show(IWin32Window owner, string text, string caption)
28.173 + {
28.174 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.175 + CenterWindow centerWindow = new CenterWindow(handle);
28.176 + DialogResult dlgResult = MessageBox.Show(owner, text, caption);
28.177 + centerWindow.Dispose();
28.178 + return dlgResult;
28.179 + }
28.180 +
28.181 + ///////////////////////////////////////////////////////////////////////
28.182 + // text, caption, buttons
28.183 +
28.184 + /// <summary>
28.185 + /// See MSDN MessageBox() method.
28.186 + /// </summary>
28.187 + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
28.188 + {
28.189 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.190 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
28.191 + centerWindow.Dispose();
28.192 + return dlgResult;
28.193 + }
28.194 +
28.195 + /// <summary>
28.196 + /// See MSDN MessageBox() method.
28.197 + /// </summary>
28.198 + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
28.199 + {
28.200 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.201 + CenterWindow centerWindow = new CenterWindow(handle);
28.202 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
28.203 + centerWindow.Dispose();
28.204 + return dlgResult;
28.205 + }
28.206 +
28.207 + ///////////////////////////////////////////////////////////////////////
28.208 + // text, caption, buttons, defaultButton
28.209 +
28.210 + /// <summary>
28.211 + /// See MSDN MessageBox() method.
28.212 + /// </summary>
28.213 + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
28.214 + {
28.215 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.216 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
28.217 + centerWindow.Dispose();
28.218 + return dlgResult;
28.219 + }
28.220 +
28.221 + /// <summary>
28.222 + /// See MSDN MessageBox() method.
28.223 + /// </summary>
28.224 + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
28.225 + {
28.226 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.227 + CenterWindow centerWindow = new CenterWindow(handle);
28.228 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
28.229 + centerWindow.Dispose();
28.230 + return dlgResult;
28.231 + }
28.232 +
28.233 + ///////////////////////////////////////////////////////////////////////
28.234 + // text, caption, buttons, defaultButton, icon
28.235 +
28.236 + /// <summary>
28.237 + /// See MSDN MessageBox() method.
28.238 + /// </summary>
28.239 + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
28.240 + {
28.241 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.242 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
28.243 + centerWindow.Dispose();
28.244 + return dlgResult;
28.245 + }
28.246 +
28.247 + /// <summary>
28.248 + /// See MSDN MessageBox() method.
28.249 + /// </summary>
28.250 + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
28.251 + {
28.252 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.253 + CenterWindow centerWindow = new CenterWindow(handle);
28.254 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
28.255 + centerWindow.Dispose();
28.256 + return dlgResult;
28.257 + }
28.258 +
28.259 + ///////////////////////////////////////////////////////////////////////
28.260 + // text, caption, buttons, defaultButton, icon, options
28.261 +
28.262 + /// <summary>
28.263 + /// See MSDN MessageBox() method.
28.264 + /// </summary>
28.265 + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
28.266 + {
28.267 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.268 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
28.269 + centerWindow.Dispose();
28.270 + return dlgResult;
28.271 + }
28.272 +
28.273 + /// <summary>
28.274 + /// See MSDN MessageBox() method.
28.275 + /// </summary>
28.276 + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
28.277 + {
28.278 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.279 + CenterWindow centerWindow = new CenterWindow(handle);
28.280 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
28.281 + centerWindow.Dispose();
28.282 + return dlgResult;
28.283 + }
28.284 + }
28.285 +
28.286 + #endregion
28.287 +
28.288 + ///////////////////////////////////////////////////////////////////////
28.289 + #region AppBox
28.290 +
28.291 + /// <summary>
28.292 + /// Class to display a MessageBox centered on the owner.
28.293 + /// The MessageBox caption is always Application.ProductName.
28.294 + /// </summary>
28.295 + /// <remarks>
28.296 + /// Same methods as the standard MessageBox without caption.
28.297 + /// </remarks>
28.298 + /// <example>
28.299 + /// This example display an application message box centered on the owner.
28.300 + /// <code>
28.301 + /// AppBox.Show("Hello");
28.302 + /// </code>
28.303 + /// </example>
28.304 + public sealed class AppBox
28.305 + {
28.306 + private AppBox() {} // To remove the constructor from the documentation!
28.307 +
28.308 + ///////////////////////////////////////////////////////////////////////
28.309 + // text
28.310 +
28.311 + /// <summary>
28.312 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.313 + /// </summary>
28.314 + public static DialogResult Show(string text)
28.315 + {
28.316 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.317 + string caption = Application.ProductName;
28.318 + DialogResult dlgResult = MessageBox.Show(text, caption);
28.319 + centerWindow.Dispose();
28.320 + return dlgResult;
28.321 + }
28.322 +
28.323 + /// <summary>
28.324 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.325 + /// </summary>
28.326 + public static DialogResult Show(IWin32Window owner, string text)
28.327 + {
28.328 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.329 + CenterWindow centerWindow = new CenterWindow(handle);
28.330 + string caption = Application.ProductName;
28.331 + DialogResult dlgResult = MessageBox.Show(owner, text, caption);
28.332 + centerWindow.Dispose();
28.333 + return dlgResult;
28.334 + }
28.335 +
28.336 + ///////////////////////////////////////////////////////////////////////
28.337 + // text, buttons
28.338 +
28.339 + /// <summary>
28.340 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.341 + /// </summary>
28.342 + public static DialogResult Show(string text, MessageBoxButtons buttons)
28.343 + {
28.344 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.345 + string caption = Application.ProductName;
28.346 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons);
28.347 + centerWindow.Dispose();
28.348 + return dlgResult;
28.349 + }
28.350 +
28.351 + /// <summary>
28.352 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.353 + /// </summary>
28.354 + public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons)
28.355 + {
28.356 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.357 + CenterWindow centerWindow = new CenterWindow(handle);
28.358 + string caption = Application.ProductName;
28.359 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons);
28.360 + centerWindow.Dispose();
28.361 + return dlgResult;
28.362 + }
28.363 +
28.364 + ///////////////////////////////////////////////////////////////////////
28.365 + // text, buttons, defaultButton
28.366 +
28.367 + /// <summary>
28.368 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.369 + /// </summary>
28.370 + public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon)
28.371 + {
28.372 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.373 + string caption = Application.ProductName;
28.374 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon);
28.375 + centerWindow.Dispose();
28.376 + return dlgResult;
28.377 + }
28.378 +
28.379 + /// <summary>
28.380 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.381 + /// </summary>
28.382 + public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon)
28.383 + {
28.384 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.385 + CenterWindow centerWindow = new CenterWindow(handle);
28.386 + string caption = Application.ProductName;
28.387 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon);
28.388 + centerWindow.Dispose();
28.389 + return dlgResult;
28.390 + }
28.391 +
28.392 + ///////////////////////////////////////////////////////////////////////
28.393 + // text, buttons, defaultButton, icon
28.394 +
28.395 + /// <summary>
28.396 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.397 + /// </summary>
28.398 + public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
28.399 + {
28.400 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.401 + string caption = Application.ProductName;
28.402 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton);
28.403 + centerWindow.Dispose();
28.404 + return dlgResult;
28.405 + }
28.406 +
28.407 + /// <summary>
28.408 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.409 + /// </summary>
28.410 + public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
28.411 + {
28.412 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.413 + CenterWindow centerWindow = new CenterWindow(handle);
28.414 + string caption = Application.ProductName;
28.415 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton);
28.416 + centerWindow.Dispose();
28.417 + return dlgResult;
28.418 + }
28.419 +
28.420 + ///////////////////////////////////////////////////////////////////////
28.421 + // text, buttons, defaultButton, icon, options
28.422 +
28.423 + /// <summary>
28.424 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.425 + /// </summary>
28.426 + public static DialogResult Show(string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
28.427 + {
28.428 + CenterWindow centerWindow = new CenterWindow(IntPtr.Zero);
28.429 + string caption = Application.ProductName;
28.430 + DialogResult dlgResult = MessageBox.Show(text, caption, buttons, icon, defaultButton, options);
28.431 + centerWindow.Dispose();
28.432 + return dlgResult;
28.433 + }
28.434 +
28.435 + /// <summary>
28.436 + /// See MSDN MessageBox() method. Caption is Application.ProductName.
28.437 + /// </summary>
28.438 + public static DialogResult Show(IWin32Window owner, string text, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
28.439 + {
28.440 + IntPtr handle = (owner == null) ? IntPtr.Zero: owner.Handle;
28.441 + CenterWindow centerWindow = new CenterWindow(handle);
28.442 + string caption = Application.ProductName;
28.443 + DialogResult dlgResult = MessageBox.Show(owner, text, caption, buttons, icon, defaultButton, options);
28.444 + centerWindow.Dispose();
28.445 + return dlgResult;
28.446 + }
28.447 + }
28.448 +
28.449 + #endregion
28.450 +
28.451 + ///////////////////////////////////////////////////////////////////////
28.452 + #region ErrBox
28.453 +
28.454 + /// <summary>
28.455 + /// Class to display application error MessageBox centered on the owner.
28.456 + /// The caption of the MessageBox is Application.ProductName.
28.457 + /// </summary>
28.458 + /// <example>
28.459 + /// This example display an error message box centered on the owner.
28.460 + /// <code>
28.461 + /// ErrBox.Show(ex);
28.462 + /// </code>
28.463 + /// </example>
28.464 + public sealed class ErrBox
28.465 + {
28.466 + private ErrBox() {} // To remove the constructor from the documentation!
28.467 +
28.468 + /// <summary>
28.469 + /// Show an error MessageBox with an icon error and an OK button.
28.470 + /// </summary>
28.471 + /// <param name="err">The error message.</param>
28.472 + /// <param name="owner">The owner of the error MessageBox.</param>
28.473 + /// <returns>Dialog result of the MessageBox.</returns>
28.474 + public static DialogResult Show(IWin32Window owner, string err)
28.475 + {
28.476 + string caption = Application.ProductName;
28.477 + return MsgBox.Show(owner, err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
28.478 + }
28.479 +
28.480 + /// <summary>
28.481 + /// Show an error MessageBox with an icon error and an OK button.
28.482 + /// </summary>
28.483 + /// <param name="err">The error message.</param>
28.484 + /// <returns>Dialog result of the MessageBox.</returns>
28.485 + public static DialogResult Show(string err)
28.486 + {
28.487 + string caption = Application.ProductName;
28.488 + return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
28.489 + }
28.490 +
28.491 + /// <summary>
28.492 + /// Show an error MessageBox with exception message, an icon error and an OK button.
28.493 + /// </summary>
28.494 + /// <param name="ex">Exception to be displayed.</param>
28.495 + /// <returns>Dialog result of the MessageBox.</returns>
28.496 + public static DialogResult Show(Exception ex)
28.497 + {
28.498 + string err = ex.Message;
28.499 + while (ex.InnerException != null)
28.500 + {
28.501 + ex = ex.InnerException;
28.502 + err += Environment.NewLine;
28.503 + err += ex.Message;
28.504 + }
28.505 + string caption = Application.ProductName;
28.506 + return MsgBox.Show(err, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
28.507 + }
28.508 +
28.509 + /// <summary>
28.510 + /// Show a specialized error MessageBox centered into the parent owner.
28.511 + /// </summary>
28.512 + /// <param name="ex">Exception to be displayed.</param>
28.513 + /// <param name="debugMode">true to display the full informations else false.</param>
28.514 + /// <returns>Dialog result of the MessageBox.</returns>
28.515 + public static DialogResult Show(Exception ex, bool debugMode)
28.516 + {
28.517 + if (debugMode)
28.518 + return Show(ex);
28.519 + else
28.520 + return Show(ex.Message);
28.521 + }
28.522 + }
28.523 +
28.524 + #endregion
28.525 +
28.526 + ///////////////////////////////////////////////////////////////////////
28.527 + #region CenterWindow class
28.528 +
28.529 + internal sealed class CenterWindow
28.530 + {
28.531 + public IntPtr hOwner = IntPtr.Zero;
28.532 + private Rectangle rect;
28.533 +
28.534 + public CbtHook cbtHook = null;
28.535 + public WndProcRetHook wndProcRetHook = null;
28.536 +
28.537 + public CenterWindow(IntPtr hOwner)
28.538 + {
28.539 + this.hOwner = hOwner;
28.540 + this.cbtHook = new CbtHook();
28.541 + cbtHook.WindowActivate += new CbtHook.CbtEventHandler(WndActivate);
28.542 + cbtHook.Install();
28.543 + }
28.544 +
28.545 + public void Dispose()
28.546 + {
28.547 + if (wndProcRetHook != null)
28.548 + {
28.549 + wndProcRetHook.Uninstall();
28.550 + wndProcRetHook = null;
28.551 + }
28.552 + if (cbtHook != null)
28.553 + {
28.554 + cbtHook.Uninstall();
28.555 + cbtHook = null;
28.556 + }
28.557 + }
28.558 +
28.559 + public void WndActivate(object sender, CbtEventArgs e)
28.560 + {
28.561 + IntPtr hMsgBox = e.wParam;
28.562 +
28.563 + // try to find a howner for this message box
28.564 + if (hOwner == IntPtr.Zero)
28.565 + hOwner = USER32.GetActiveWindow();
28.566 +
28.567 + // get the MessageBox window rect
28.568 + RECT rectDlg = new RECT();
28.569 + USER32.GetWindowRect(hMsgBox, ref rectDlg);
28.570 +
28.571 + // get the owner window rect
28.572 + RECT rectForm = new RECT();
28.573 + USER32.GetWindowRect(hOwner, ref rectForm);
28.574 +
28.575 + // get the biggest screen area
28.576 + Rectangle rectScreen = API.TrueScreenRect;
28.577 +
28.578 + // if no parent window, center on the primary screen
28.579 + if (rectForm.right == rectForm.left)
28.580 + rectForm.right = rectForm.left = Screen.PrimaryScreen.WorkingArea.Width / 2;
28.581 + if (rectForm.bottom == rectForm.top)
28.582 + rectForm.bottom = rectForm.top = Screen.PrimaryScreen.WorkingArea.Height / 2;
28.583 +
28.584 + // center on parent
28.585 + int dx = ((rectDlg.left + rectDlg.right) - (rectForm.left + rectForm.right)) / 2;
28.586 + int dy = ((rectDlg.top + rectDlg.bottom) - (rectForm.top + rectForm.bottom)) / 2;
28.587 +
28.588 + rect = new Rectangle(
28.589 + rectDlg.left - dx,
28.590 + rectDlg.top - dy,
28.591 + rectDlg.right - rectDlg.left,
28.592 + rectDlg.bottom - rectDlg.top);
28.593 +
28.594 + // place in the screen
28.595 + if (rect.Right > rectScreen.Right) rect.Offset(rectScreen.Right - rect.Right, 0);
28.596 + if (rect.Bottom > rectScreen.Bottom) rect.Offset(0, rectScreen.Bottom - rect.Bottom);
28.597 + if (rect.Left < rectScreen.Left) rect.Offset(rectScreen.Left - rect.Left, 0);
28.598 + if (rect.Top < rectScreen.Top) rect.Offset(0, rectScreen.Top - rect.Top);
28.599 +
28.600 + if (e.IsDialog)
28.601 + {
28.602 + // do the job when the WM_INITDIALOG message returns
28.603 + wndProcRetHook = new WndProcRetHook(hMsgBox);
28.604 + wndProcRetHook.WndProcRet += new WndProcRetHook.WndProcEventHandler(WndProcRet);
28.605 + wndProcRetHook.Install();
28.606 + }
28.607 + else
28.608 + USER32.MoveWindow(hMsgBox, rect.Left, rect.Top, rect.Width, rect.Height, 1);
28.609 +
28.610 + // uninstall this hook
28.611 + WindowsHook wndHook = (WindowsHook)sender;
28.612 + Debug.Assert(cbtHook == wndHook);
28.613 + cbtHook.Uninstall();
28.614 + cbtHook = null;
28.615 + }
28.616 +
28.617 + public void WndProcRet(object sender, WndProcRetEventArgs e)
28.618 + {
28.619 + if (e.cw.message == WndMessage.WM_INITDIALOG ||
28.620 + e.cw.message == WndMessage.WM_UNKNOWINIT)
28.621 + {
28.622 + USER32.MoveWindow(e.cw.hwnd, rect.Left, rect.Top, rect.Width, rect.Height, 1);
28.623 +
28.624 + // uninstall this hook
28.625 + WindowsHook wndHook = (WindowsHook)sender;
28.626 + Debug.Assert(wndProcRetHook == wndHook);
28.627 + wndProcRetHook.Uninstall();
28.628 + wndProcRetHook = null;
28.629 + }
28.630 + }
28.631 + }
28.632 + #endregion
28.633 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/Server/Display.cs Tue Aug 12 20:55:50 2014 +0200
29.3 @@ -0,0 +1,243 @@
29.4 +using System;
29.5 +using System.Collections.Generic;
29.6 +using System.Linq;
29.7 +using System.Text;
29.8 +using System.Threading.Tasks;
29.9 +//
29.10 +using System.Runtime.InteropServices;
29.11 +
29.12 +namespace SharpDisplayManager
29.13 +{
29.14 + class Display
29.15 + {
29.16 +
29.17 + //Constructor
29.18 + public Display()
29.19 + {
29.20 + iDevice = IntPtr.Zero;
29.21 + }
29.22 +
29.23 + //
29.24 + public bool Open()
29.25 + {
29.26 + if (iDevice == IntPtr.Zero)
29.27 + {
29.28 + iDevice = MiniDisplayOpen();
29.29 + }
29.30 + return iDevice != IntPtr.Zero;
29.31 + }
29.32 +
29.33 + public void Close()
29.34 + {
29.35 + MiniDisplayClose(iDevice);
29.36 + iDevice = IntPtr.Zero;
29.37 + }
29.38 +
29.39 + public bool IsOpen()
29.40 + {
29.41 + return iDevice != IntPtr.Zero;
29.42 + }
29.43 +
29.44 + public void Clear()
29.45 + {
29.46 + MiniDisplayClear(iDevice);
29.47 + }
29.48 +
29.49 + public void Fill()
29.50 + {
29.51 + MiniDisplayFill(iDevice);
29.52 + }
29.53 +
29.54 + public void SwapBuffers()
29.55 + {
29.56 + MiniDisplaySwapBuffers(iDevice);
29.57 + }
29.58 +
29.59 + public int MaxBrightness()
29.60 + {
29.61 + return MiniDisplayMaxBrightness(iDevice);
29.62 + }
29.63 +
29.64 + public int MinBrightness()
29.65 + {
29.66 + return MiniDisplayMinBrightness(iDevice);
29.67 + }
29.68 +
29.69 + public void SetBrightness(int aBrightness)
29.70 + {
29.71 + if (!IsOpen()) return;
29.72 +
29.73 + MiniDisplaySetBrightness(iDevice, aBrightness);
29.74 + }
29.75 +
29.76 + public int WidthInPixels()
29.77 + {
29.78 + return MiniDisplayWidthInPixels(iDevice);
29.79 + }
29.80 +
29.81 + public int HeightInPixels()
29.82 + {
29.83 + return MiniDisplayHeightInPixels(iDevice);
29.84 + }
29.85 +
29.86 + public void SetPixel(int aX, int aY, int aValue)
29.87 + {
29.88 + MiniDisplaySetPixel(iDevice,aX,aY,aValue);
29.89 + }
29.90 +
29.91 + public void RequestPowerSupplyStatus()
29.92 + {
29.93 + MiniDisplayRequestPowerSupplyStatus(iDevice);
29.94 + }
29.95 +
29.96 + public void RequestDeviceId()
29.97 + {
29.98 + MiniDisplayRequestDeviceId(iDevice);
29.99 + }
29.100 +
29.101 + public void RequestFirmwareRevision()
29.102 + {
29.103 + MiniDisplayRequestFirmwareRevision(iDevice);
29.104 + }
29.105 +
29.106 + public bool PowerSupplyStatus()
29.107 + {
29.108 + bool res = MiniDisplayPowerSupplyStatus(iDevice);
29.109 + return res;
29.110 + }
29.111 +
29.112 + public TMiniDisplayRequest AttemptRequestCompletion()
29.113 + {
29.114 + return MiniDisplayAttemptRequestCompletion(iDevice);
29.115 + }
29.116 +
29.117 + public TMiniDisplayRequest CurrentRequest()
29.118 + {
29.119 + return MiniDisplayCurrentRequest(iDevice);
29.120 + }
29.121 +
29.122 + public bool IsRequestPending()
29.123 + {
29.124 + return CurrentRequest() != TMiniDisplayRequest.EMiniDisplayRequestNone;
29.125 + }
29.126 +
29.127 +
29.128 + public string Vendor()
29.129 + {
29.130 + IntPtr ptr = MiniDisplayVendor(iDevice);
29.131 + string str = Marshal.PtrToStringUni(ptr);
29.132 + return str;
29.133 + }
29.134 +
29.135 + public string Product()
29.136 + {
29.137 + IntPtr ptr = MiniDisplayProduct(iDevice);
29.138 + string str = Marshal.PtrToStringUni(ptr);
29.139 + return str;
29.140 + }
29.141 +
29.142 + public string SerialNumber()
29.143 + {
29.144 + IntPtr ptr = MiniDisplaySerialNumber(iDevice);
29.145 + string str = Marshal.PtrToStringUni(ptr);
29.146 + return str;
29.147 + }
29.148 +
29.149 + public string DeviceId()
29.150 + {
29.151 + IntPtr ptr = MiniDisplayDeviceId(iDevice);
29.152 + string str = Marshal.PtrToStringAnsi(ptr);
29.153 + return str;
29.154 + }
29.155 +
29.156 + public string FirmwareRevision()
29.157 + {
29.158 + IntPtr ptr = MiniDisplayFirmwareRevision(iDevice);
29.159 + string str = Marshal.PtrToStringAnsi(ptr);
29.160 + return str;
29.161 + }
29.162 +
29.163 + //Our display device handle
29.164 + IntPtr iDevice;
29.165 +
29.166 + public enum TMiniDisplayRequest
29.167 + {
29.168 + EMiniDisplayRequestNone,
29.169 + EMiniDisplayRequestDeviceId,
29.170 + EMiniDisplayRequestFirmwareRevision,
29.171 + EMiniDisplayRequestPowerSupplyStatus
29.172 + }
29.173 +
29.174 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.175 + public static extern IntPtr MiniDisplayOpen();
29.176 +
29.177 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.178 + public static extern void MiniDisplayClose(IntPtr aDevice);
29.179 +
29.180 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.181 + public static extern void MiniDisplayClear(IntPtr aDevice);
29.182 +
29.183 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.184 + public static extern void MiniDisplayFill(IntPtr aDevice);
29.185 +
29.186 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.187 + public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
29.188 +
29.189 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.190 + public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
29.191 +
29.192 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.193 + public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
29.194 +
29.195 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.196 + public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
29.197 +
29.198 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.199 + public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
29.200 +
29.201 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.202 + public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
29.203 +
29.204 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.205 + public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, int aValue);
29.206 +
29.207 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.208 + public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
29.209 +
29.210 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.211 + public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
29.212 +
29.213 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.214 + public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
29.215 +
29.216 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.217 + public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
29.218 +
29.219 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.220 + public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
29.221 +
29.222 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.223 + [return: MarshalAs(UnmanagedType.I1)]
29.224 + public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
29.225 +
29.226 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.227 + public static extern void MiniDisplayRequestDeviceId(IntPtr aDevice);
29.228 +
29.229 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.230 + public static extern void MiniDisplayRequestFirmwareRevision(IntPtr aDevice);
29.231 +
29.232 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.233 + public static extern void MiniDisplayRequestPowerSupplyStatus(IntPtr aDevice);
29.234 +
29.235 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.236 + public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
29.237 +
29.238 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.239 + public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
29.240 +
29.241 + [DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
29.242 + public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
29.243 +
29.244 +
29.245 + }
29.246 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/Server/MainForm.Designer.cs Tue Aug 12 20:55:50 2014 +0200
30.3 @@ -0,0 +1,432 @@
30.4 +namespace SharpDisplayManager
30.5 +{
30.6 + partial class MainForm
30.7 + {
30.8 + /// <summary>
30.9 + /// Required designer variable.
30.10 + /// </summary>
30.11 + private System.ComponentModel.IContainer components = null;
30.12 +
30.13 + /// <summary>
30.14 + /// Clean up any resources being used.
30.15 + /// </summary>
30.16 + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
30.17 + protected override void Dispose(bool disposing)
30.18 + {
30.19 + if (disposing && (components != null))
30.20 + {
30.21 + components.Dispose();
30.22 + }
30.23 + base.Dispose(disposing);
30.24 + }
30.25 +
30.26 + #region Windows Form Designer generated code
30.27 +
30.28 + /// <summary>
30.29 + /// Required method for Designer support - do not modify
30.30 + /// the contents of this method with the code editor.
30.31 + /// </summary>
30.32 + private void InitializeComponent()
30.33 + {
30.34 + this.components = new System.ComponentModel.Container();
30.35 + this.tabControl = new System.Windows.Forms.TabControl();
30.36 + this.tabPageDisplay = new System.Windows.Forms.TabPage();
30.37 + this.checkBoxReverseScreen = new System.Windows.Forms.CheckBox();
30.38 + this.checkBoxConnectOnStartup = new System.Windows.Forms.CheckBox();
30.39 + this.panelDisplay = new System.Windows.Forms.Panel();
30.40 + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
30.41 + this.checkBoxShowBorders = new System.Windows.Forms.CheckBox();
30.42 + this.trackBarBrightness = new System.Windows.Forms.TrackBar();
30.43 + this.buttonFill = new System.Windows.Forms.Button();
30.44 + this.buttonClear = new System.Windows.Forms.Button();
30.45 + this.buttonClose = new System.Windows.Forms.Button();
30.46 + this.buttonOpen = new System.Windows.Forms.Button();
30.47 + this.buttonCapture = new System.Windows.Forms.Button();
30.48 + this.buttonFont = new System.Windows.Forms.Button();
30.49 + this.tabPageTests = new System.Windows.Forms.TabPage();
30.50 + this.fontDialog = new System.Windows.Forms.FontDialog();
30.51 + this.timer = new System.Windows.Forms.Timer(this.components);
30.52 + this.statusStrip = new System.Windows.Forms.StatusStrip();
30.53 + this.toolStripStatusLabelConnect = new System.Windows.Forms.ToolStripStatusLabel();
30.54 + this.toolStripStatusLabelSpring = new System.Windows.Forms.ToolStripStatusLabel();
30.55 + this.toolStripStatusLabelPower = new System.Windows.Forms.ToolStripStatusLabel();
30.56 + this.toolStripStatusLabelFps = new System.Windows.Forms.ToolStripStatusLabel();
30.57 + this.marqueeLabelTop = new SharpDisplayManager.MarqueeLabel();
30.58 + this.marqueeLabelBottom = new SharpDisplayManager.MarqueeLabel();
30.59 + this.tabControl.SuspendLayout();
30.60 + this.tabPageDisplay.SuspendLayout();
30.61 + this.panelDisplay.SuspendLayout();
30.62 + this.tableLayoutPanel.SuspendLayout();
30.63 + ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).BeginInit();
30.64 + this.statusStrip.SuspendLayout();
30.65 + this.SuspendLayout();
30.66 + //
30.67 + // tabControl
30.68 + //
30.69 + this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
30.70 + | System.Windows.Forms.AnchorStyles.Left)
30.71 + | System.Windows.Forms.AnchorStyles.Right)));
30.72 + this.tabControl.Controls.Add(this.tabPageDisplay);
30.73 + this.tabControl.Controls.Add(this.tabPageTests);
30.74 + this.tabControl.Location = new System.Drawing.Point(12, 12);
30.75 + this.tabControl.Name = "tabControl";
30.76 + this.tabControl.SelectedIndex = 0;
30.77 + this.tabControl.Size = new System.Drawing.Size(600, 395);
30.78 + this.tabControl.TabIndex = 0;
30.79 + //
30.80 + // tabPageDisplay
30.81 + //
30.82 + this.tabPageDisplay.Controls.Add(this.checkBoxReverseScreen);
30.83 + this.tabPageDisplay.Controls.Add(this.checkBoxConnectOnStartup);
30.84 + this.tabPageDisplay.Controls.Add(this.panelDisplay);
30.85 + this.tabPageDisplay.Controls.Add(this.checkBoxShowBorders);
30.86 + this.tabPageDisplay.Controls.Add(this.trackBarBrightness);
30.87 + this.tabPageDisplay.Controls.Add(this.buttonFill);
30.88 + this.tabPageDisplay.Controls.Add(this.buttonClear);
30.89 + this.tabPageDisplay.Controls.Add(this.buttonClose);
30.90 + this.tabPageDisplay.Controls.Add(this.buttonOpen);
30.91 + this.tabPageDisplay.Controls.Add(this.buttonCapture);
30.92 + this.tabPageDisplay.Controls.Add(this.buttonFont);
30.93 + this.tabPageDisplay.Location = new System.Drawing.Point(4, 22);
30.94 + this.tabPageDisplay.Name = "tabPageDisplay";
30.95 + this.tabPageDisplay.Padding = new System.Windows.Forms.Padding(3);
30.96 + this.tabPageDisplay.Size = new System.Drawing.Size(592, 369);
30.97 + this.tabPageDisplay.TabIndex = 0;
30.98 + this.tabPageDisplay.Text = "Display";
30.99 + this.tabPageDisplay.UseVisualStyleBackColor = true;
30.100 + //
30.101 + // checkBoxReverseScreen
30.102 + //
30.103 + this.checkBoxReverseScreen.AutoSize = true;
30.104 + this.checkBoxReverseScreen.Location = new System.Drawing.Point(113, 298);
30.105 + this.checkBoxReverseScreen.Name = "checkBoxReverseScreen";
30.106 + this.checkBoxReverseScreen.Size = new System.Drawing.Size(101, 17);
30.107 + this.checkBoxReverseScreen.TabIndex = 14;
30.108 + this.checkBoxReverseScreen.Text = "Reverse screen";
30.109 + this.checkBoxReverseScreen.UseVisualStyleBackColor = true;
30.110 + this.checkBoxReverseScreen.CheckedChanged += new System.EventHandler(this.checkBoxReverseScreen_CheckedChanged);
30.111 + //
30.112 + // checkBoxConnectOnStartup
30.113 + //
30.114 + this.checkBoxConnectOnStartup.AutoSize = true;
30.115 + this.checkBoxConnectOnStartup.Location = new System.Drawing.Point(113, 321);
30.116 + this.checkBoxConnectOnStartup.Name = "checkBoxConnectOnStartup";
30.117 + this.checkBoxConnectOnStartup.Size = new System.Drawing.Size(119, 17);
30.118 + this.checkBoxConnectOnStartup.TabIndex = 13;
30.119 + this.checkBoxConnectOnStartup.Text = "Connect on stratup ";
30.120 + this.checkBoxConnectOnStartup.UseVisualStyleBackColor = true;
30.121 + this.checkBoxConnectOnStartup.CheckedChanged += new System.EventHandler(this.checkBoxConnectOnStartup_CheckedChanged);
30.122 + //
30.123 + // panelDisplay
30.124 + //
30.125 + this.panelDisplay.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
30.126 + this.panelDisplay.Controls.Add(this.tableLayoutPanel);
30.127 + this.panelDisplay.Location = new System.Drawing.Point(181, 151);
30.128 + this.panelDisplay.Margin = new System.Windows.Forms.Padding(0);
30.129 + this.panelDisplay.Name = "panelDisplay";
30.130 + this.panelDisplay.Size = new System.Drawing.Size(258, 66);
30.131 + this.panelDisplay.TabIndex = 12;
30.132 + //
30.133 + // tableLayoutPanel
30.134 + //
30.135 + this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
30.136 + | System.Windows.Forms.AnchorStyles.Left)
30.137 + | System.Windows.Forms.AnchorStyles.Right)));
30.138 + this.tableLayoutPanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
30.139 + this.tableLayoutPanel.ColumnCount = 1;
30.140 + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
30.141 + this.tableLayoutPanel.Controls.Add(this.marqueeLabelTop, 0, 0);
30.142 + this.tableLayoutPanel.Controls.Add(this.marqueeLabelBottom, 0, 1);
30.143 + this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
30.144 + this.tableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
30.145 + this.tableLayoutPanel.Name = "tableLayoutPanel";
30.146 + this.tableLayoutPanel.RowCount = 2;
30.147 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
30.148 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
30.149 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.150 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.151 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.152 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.153 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.154 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.155 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.156 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.157 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.158 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.159 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.160 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.161 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.162 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.163 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.164 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.165 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.166 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.167 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.168 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.169 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.170 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.171 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.172 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.173 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.174 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.175 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.176 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.177 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.178 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.179 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.180 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.181 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.182 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.183 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.184 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.185 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.186 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.187 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.188 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.189 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.190 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.191 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.192 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.193 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.194 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.195 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.196 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.197 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.198 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.199 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.200 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.201 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.202 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.203 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.204 + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
30.205 + this.tableLayoutPanel.Size = new System.Drawing.Size(256, 64);
30.206 + this.tableLayoutPanel.TabIndex = 5;
30.207 + //
30.208 + // checkBoxShowBorders
30.209 + //
30.210 + this.checkBoxShowBorders.AutoSize = true;
30.211 + this.checkBoxShowBorders.Location = new System.Drawing.Point(113, 344);
30.212 + this.checkBoxShowBorders.Name = "checkBoxShowBorders";
30.213 + this.checkBoxShowBorders.Size = new System.Drawing.Size(91, 17);
30.214 + this.checkBoxShowBorders.TabIndex = 11;
30.215 + this.checkBoxShowBorders.Text = "Show borders";
30.216 + this.checkBoxShowBorders.UseVisualStyleBackColor = true;
30.217 + this.checkBoxShowBorders.CheckedChanged += new System.EventHandler(this.checkBoxShowBorders_CheckedChanged);
30.218 + //
30.219 + // trackBarBrightness
30.220 + //
30.221 + this.trackBarBrightness.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
30.222 + | System.Windows.Forms.AnchorStyles.Right)));
30.223 + this.trackBarBrightness.BackColor = System.Drawing.SystemColors.Window;
30.224 + this.trackBarBrightness.Location = new System.Drawing.Point(544, 9);
30.225 + this.trackBarBrightness.Name = "trackBarBrightness";
30.226 + this.trackBarBrightness.Orientation = System.Windows.Forms.Orientation.Vertical;
30.227 + this.trackBarBrightness.Size = new System.Drawing.Size(45, 357);
30.228 + this.trackBarBrightness.TabIndex = 10;
30.229 + this.trackBarBrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
30.230 + this.trackBarBrightness.Scroll += new System.EventHandler(this.trackBarBrightness_Scroll);
30.231 + //
30.232 + // buttonFill
30.233 + //
30.234 + this.buttonFill.Location = new System.Drawing.Point(6, 93);
30.235 + this.buttonFill.Name = "buttonFill";
30.236 + this.buttonFill.Size = new System.Drawing.Size(75, 23);
30.237 + this.buttonFill.TabIndex = 9;
30.238 + this.buttonFill.Text = "Fill";
30.239 + this.buttonFill.UseVisualStyleBackColor = true;
30.240 + this.buttonFill.Click += new System.EventHandler(this.buttonFill_Click);
30.241 + //
30.242 + // buttonClear
30.243 + //
30.244 + this.buttonClear.Location = new System.Drawing.Point(6, 64);
30.245 + this.buttonClear.Name = "buttonClear";
30.246 + this.buttonClear.Size = new System.Drawing.Size(75, 23);
30.247 + this.buttonClear.TabIndex = 8;
30.248 + this.buttonClear.Text = "Clear";
30.249 + this.buttonClear.UseVisualStyleBackColor = true;
30.250 + this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
30.251 + //
30.252 + // buttonClose
30.253 + //
30.254 + this.buttonClose.Location = new System.Drawing.Point(6, 35);
30.255 + this.buttonClose.Name = "buttonClose";
30.256 + this.buttonClose.Size = new System.Drawing.Size(75, 23);
30.257 + this.buttonClose.TabIndex = 7;
30.258 + this.buttonClose.Text = "Close";
30.259 + this.buttonClose.UseVisualStyleBackColor = true;
30.260 + this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
30.261 + //
30.262 + // buttonOpen
30.263 + //
30.264 + this.buttonOpen.Location = new System.Drawing.Point(6, 6);
30.265 + this.buttonOpen.Name = "buttonOpen";
30.266 + this.buttonOpen.Size = new System.Drawing.Size(75, 23);
30.267 + this.buttonOpen.TabIndex = 6;
30.268 + this.buttonOpen.Text = "Open";
30.269 + this.buttonOpen.UseVisualStyleBackColor = true;
30.270 + this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
30.271 + //
30.272 + // buttonCapture
30.273 + //
30.274 + this.buttonCapture.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
30.275 + this.buttonCapture.Location = new System.Drawing.Point(6, 311);
30.276 + this.buttonCapture.Name = "buttonCapture";
30.277 + this.buttonCapture.Size = new System.Drawing.Size(75, 23);
30.278 + this.buttonCapture.TabIndex = 5;
30.279 + this.buttonCapture.Text = "Capture";
30.280 + this.buttonCapture.UseVisualStyleBackColor = true;
30.281 + this.buttonCapture.Click += new System.EventHandler(this.buttonCapture_Click);
30.282 + //
30.283 + // buttonFont
30.284 + //
30.285 + this.buttonFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
30.286 + this.buttonFont.Location = new System.Drawing.Point(6, 340);
30.287 + this.buttonFont.Name = "buttonFont";
30.288 + this.buttonFont.Size = new System.Drawing.Size(75, 23);
30.289 + this.buttonFont.TabIndex = 0;
30.290 + this.buttonFont.Text = "Select Font";
30.291 + this.buttonFont.UseVisualStyleBackColor = true;
30.292 + this.buttonFont.Click += new System.EventHandler(this.buttonFont_Click);
30.293 + //
30.294 + // tabPageTests
30.295 + //
30.296 + this.tabPageTests.Location = new System.Drawing.Point(4, 22);
30.297 + this.tabPageTests.Name = "tabPageTests";
30.298 + this.tabPageTests.Padding = new System.Windows.Forms.Padding(3);
30.299 + this.tabPageTests.Size = new System.Drawing.Size(592, 369);
30.300 + this.tabPageTests.TabIndex = 1;
30.301 + this.tabPageTests.Text = "Test";
30.302 + this.tabPageTests.UseVisualStyleBackColor = true;
30.303 + //
30.304 + // timer
30.305 + //
30.306 + this.timer.Enabled = true;
30.307 + this.timer.Interval = 50;
30.308 + this.timer.Tick += new System.EventHandler(this.timer_Tick);
30.309 + //
30.310 + // statusStrip
30.311 + //
30.312 + this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
30.313 + this.toolStripStatusLabelConnect,
30.314 + this.toolStripStatusLabelSpring,
30.315 + this.toolStripStatusLabelPower,
30.316 + this.toolStripStatusLabelFps});
30.317 + this.statusStrip.Location = new System.Drawing.Point(0, 420);
30.318 + this.statusStrip.Name = "statusStrip";
30.319 + this.statusStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
30.320 + this.statusStrip.Size = new System.Drawing.Size(624, 22);
30.321 + this.statusStrip.TabIndex = 1;
30.322 + this.statusStrip.Text = "statusStrip";
30.323 + //
30.324 + // toolStripStatusLabelConnect
30.325 + //
30.326 + this.toolStripStatusLabelConnect.Name = "toolStripStatusLabelConnect";
30.327 + this.toolStripStatusLabelConnect.Size = new System.Drawing.Size(86, 17);
30.328 + this.toolStripStatusLabelConnect.Text = "Not connected";
30.329 + //
30.330 + // toolStripStatusLabelSpring
30.331 + //
30.332 + this.toolStripStatusLabelSpring.Name = "toolStripStatusLabelSpring";
30.333 + this.toolStripStatusLabelSpring.Size = new System.Drawing.Size(473, 17);
30.334 + this.toolStripStatusLabelSpring.Spring = true;
30.335 + //
30.336 + // toolStripStatusLabelPower
30.337 + //
30.338 + this.toolStripStatusLabelPower.Name = "toolStripStatusLabelPower";
30.339 + this.toolStripStatusLabelPower.Size = new System.Drawing.Size(24, 17);
30.340 + this.toolStripStatusLabelPower.Text = "NA";
30.341 + //
30.342 + // toolStripStatusLabelFps
30.343 + //
30.344 + this.toolStripStatusLabelFps.Name = "toolStripStatusLabelFps";
30.345 + this.toolStripStatusLabelFps.Size = new System.Drawing.Size(26, 17);
30.346 + this.toolStripStatusLabelFps.Text = "FPS";
30.347 + //
30.348 + // marqueeLabelTop
30.349 + //
30.350 + this.marqueeLabelTop.AutoEllipsis = true;
30.351 + this.marqueeLabelTop.BackColor = System.Drawing.Color.Transparent;
30.352 + this.marqueeLabelTop.Dock = System.Windows.Forms.DockStyle.Fill;
30.353 + this.marqueeLabelTop.Location = new System.Drawing.Point(1, -124);
30.354 + this.marqueeLabelTop.Margin = new System.Windows.Forms.Padding(0);
30.355 + this.marqueeLabelTop.Name = "marqueeLabelTop";
30.356 + this.marqueeLabelTop.OwnTimer = false;
30.357 + this.marqueeLabelTop.PixelsPerSecond = 64;
30.358 + this.marqueeLabelTop.Separator = "|";
30.359 + this.marqueeLabelTop.Size = new System.Drawing.Size(254, 20);
30.360 + this.marqueeLabelTop.TabIndex = 2;
30.361 + this.marqueeLabelTop.Text = "ABCDEFGHIJKLMNOPQRST-0123456789";
30.362 + this.marqueeLabelTop.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
30.363 + this.marqueeLabelTop.UseCompatibleTextRendering = true;
30.364 + //
30.365 + // marqueeLabelBottom
30.366 + //
30.367 + this.marqueeLabelBottom.AutoEllipsis = true;
30.368 + this.marqueeLabelBottom.Dock = System.Windows.Forms.DockStyle.Fill;
30.369 + this.marqueeLabelBottom.Location = new System.Drawing.Point(1, -40);
30.370 + this.marqueeLabelBottom.Margin = new System.Windows.Forms.Padding(0);
30.371 + this.marqueeLabelBottom.Name = "marqueeLabelBottom";
30.372 + this.marqueeLabelBottom.OwnTimer = false;
30.373 + this.marqueeLabelBottom.PixelsPerSecond = 64;
30.374 + this.marqueeLabelBottom.Separator = null;
30.375 + this.marqueeLabelBottom.Size = new System.Drawing.Size(254, 20);
30.376 + this.marqueeLabelBottom.TabIndex = 3;
30.377 + this.marqueeLabelBottom.Text = "abcdefghijklmnopqrst-0123456789";
30.378 + this.marqueeLabelBottom.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
30.379 + this.marqueeLabelBottom.UseCompatibleTextRendering = true;
30.380 + //
30.381 + // MainForm
30.382 + //
30.383 + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
30.384 + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
30.385 + this.ClientSize = new System.Drawing.Size(624, 442);
30.386 + this.Controls.Add(this.statusStrip);
30.387 + this.Controls.Add(this.tabControl);
30.388 + this.MinimumSize = new System.Drawing.Size(640, 480);
30.389 + this.Name = "MainForm";
30.390 + this.Text = "Sharp Display Manager";
30.391 + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
30.392 + this.Load += new System.EventHandler(this.MainForm_Load);
30.393 + this.Resize += new System.EventHandler(this.MainForm_Resize);
30.394 + this.tabControl.ResumeLayout(false);
30.395 + this.tabPageDisplay.ResumeLayout(false);
30.396 + this.tabPageDisplay.PerformLayout();
30.397 + this.panelDisplay.ResumeLayout(false);
30.398 + this.tableLayoutPanel.ResumeLayout(false);
30.399 + ((System.ComponentModel.ISupportInitialize)(this.trackBarBrightness)).EndInit();
30.400 + this.statusStrip.ResumeLayout(false);
30.401 + this.statusStrip.PerformLayout();
30.402 + this.ResumeLayout(false);
30.403 + this.PerformLayout();
30.404 +
30.405 + }
30.406 +
30.407 + #endregion
30.408 +
30.409 + private System.Windows.Forms.TabControl tabControl;
30.410 + private System.Windows.Forms.TabPage tabPageDisplay;
30.411 + private System.Windows.Forms.TabPage tabPageTests;
30.412 + private System.Windows.Forms.Button buttonFont;
30.413 + private System.Windows.Forms.FontDialog fontDialog;
30.414 + private System.Windows.Forms.Button buttonCapture;
30.415 + private System.Windows.Forms.Timer timer;
30.416 + private System.Windows.Forms.Button buttonFill;
30.417 + private System.Windows.Forms.Button buttonClear;
30.418 + private System.Windows.Forms.Button buttonClose;
30.419 + private System.Windows.Forms.Button buttonOpen;
30.420 + private System.Windows.Forms.TrackBar trackBarBrightness;
30.421 + private System.Windows.Forms.StatusStrip statusStrip;
30.422 + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelConnect;
30.423 + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelFps;
30.424 + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpring;
30.425 + private System.Windows.Forms.CheckBox checkBoxShowBorders;
30.426 + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelPower;
30.427 + private System.Windows.Forms.Panel panelDisplay;
30.428 + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
30.429 + public MarqueeLabel marqueeLabelTop;
30.430 + public MarqueeLabel marqueeLabelBottom;
30.431 + private System.Windows.Forms.CheckBox checkBoxConnectOnStartup;
30.432 + private System.Windows.Forms.CheckBox checkBoxReverseScreen;
30.433 + }
30.434 +}
30.435 +
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/Server/MainForm.cs Tue Aug 12 20:55:50 2014 +0200
31.3 @@ -0,0 +1,368 @@
31.4 +using System;
31.5 +using System.Collections.Generic;
31.6 +using System.ComponentModel;
31.7 +using System.Data;
31.8 +using System.Drawing;
31.9 +using System.Linq;
31.10 +using System.Text;
31.11 +using System.Threading.Tasks;
31.12 +using System.Windows.Forms;
31.13 +using System.IO;
31.14 +using CodeProject.Dialog;
31.15 +using System.Drawing.Imaging;
31.16 +using System.ServiceModel;
31.17 +
31.18 +
31.19 +namespace SharpDisplayManager
31.20 +{
31.21 + public partial class MainForm : Form
31.22 + {
31.23 + DateTime LastTickTime;
31.24 + Display iDisplay;
31.25 + System.Drawing.Bitmap iBmp;
31.26 + bool iCreateBitmap; //Workaround render to bitmap issues when minimized
31.27 + ServiceHost iServiceHost;
31.28 +
31.29 + public MainForm()
31.30 + {
31.31 + LastTickTime = DateTime.Now;
31.32 + iDisplay = new Display();
31.33 +
31.34 + InitializeComponent();
31.35 + UpdateStatus();
31.36 +
31.37 + //Load settings
31.38 + marqueeLabelTop.Font = Properties.Settings.Default.DisplayFont;
31.39 + marqueeLabelBottom.Font = Properties.Settings.Default.DisplayFont;
31.40 + checkBoxShowBorders.Checked = Properties.Settings.Default.DisplayShowBorders;
31.41 + checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
31.42 + checkBoxReverseScreen.Checked = Properties.Settings.Default.DisplayReverseScreen;
31.43 + //
31.44 + tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
31.45 + //We have a bug when drawing minimized and reusing our bitmap
31.46 + iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
31.47 + iCreateBitmap = false;
31.48 + }
31.49 +
31.50 + private void MainForm_Load(object sender, EventArgs e)
31.51 + {
31.52 + StartServer();
31.53 +
31.54 + if (Properties.Settings.Default.DisplayConnectOnStartup)
31.55 + {
31.56 + iDisplay.Open();
31.57 + UpdateStatus();
31.58 + }
31.59 + }
31.60 +
31.61 +
31.62 + private void buttonFont_Click(object sender, EventArgs e)
31.63 + {
31.64 + //fontDialog.ShowColor = true;
31.65 + //fontDialog.ShowApply = true;
31.66 + fontDialog.ShowEffects = true;
31.67 + fontDialog.Font = marqueeLabelTop.Font;
31.68 + //fontDialog.ShowHelp = true;
31.69 +
31.70 + //fontDlg.MaxSize = 40;
31.71 + //fontDlg.MinSize = 22;
31.72 +
31.73 + //fontDialog.Parent = this;
31.74 + //fontDialog.StartPosition = FormStartPosition.CenterParent;
31.75 +
31.76 + //DlgBox.ShowDialog(fontDialog);
31.77 +
31.78 + //if (fontDialog.ShowDialog(this) != DialogResult.Cancel)
31.79 + if (DlgBox.ShowDialog(fontDialog) != DialogResult.Cancel)
31.80 + {
31.81 +
31.82 + //MsgBox.Show("MessageBox MsgBox", "MsgBox caption");
31.83 +
31.84 + //MessageBox.Show("Ok");
31.85 + marqueeLabelTop.Font = fontDialog.Font;
31.86 + marqueeLabelBottom.Font = fontDialog.Font;
31.87 + Properties.Settings.Default.DisplayFont = fontDialog.Font;
31.88 + Properties.Settings.Default.Save();
31.89 + //label1.Font = fontDlg.Font;
31.90 + //textBox1.BackColor = fontDlg.Color;
31.91 + //label1.ForeColor = fontDlg.Color;
31.92 + }
31.93 + }
31.94 +
31.95 + private void buttonCapture_Click(object sender, EventArgs e)
31.96 + {
31.97 + System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height);
31.98 + tableLayoutPanel.DrawToBitmap(bmp, tableLayoutPanel.ClientRectangle);
31.99 + //Bitmap bmpToSave = new Bitmap(bmp);
31.100 + bmp.Save("D:\\capture.png");
31.101 +
31.102 + marqueeLabelTop.Text = "Sweet";
31.103 +
31.104 + /*
31.105 + string outputFileName = "d:\\capture.png";
31.106 + using (MemoryStream memory = new MemoryStream())
31.107 + {
31.108 + using (FileStream fs = new FileStream(outputFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite))
31.109 + {
31.110 + bmp.Save(memory, System.Drawing.Imaging.ImageFormat.Png);
31.111 + byte[] bytes = memory.ToArray();
31.112 + fs.Write(bytes, 0, bytes.Length);
31.113 + }
31.114 + }
31.115 + */
31.116 +
31.117 + }
31.118 +
31.119 + private void CheckForRequestResults()
31.120 + {
31.121 + if (iDisplay.IsRequestPending())
31.122 + {
31.123 + switch (iDisplay.AttemptRequestCompletion())
31.124 + {
31.125 + case Display.TMiniDisplayRequest.EMiniDisplayRequestPowerSupplyStatus:
31.126 + if (iDisplay.PowerSupplyStatus())
31.127 + {
31.128 + toolStripStatusLabelPower.Text = "ON";
31.129 + }
31.130 + else
31.131 + {
31.132 + toolStripStatusLabelPower.Text = "OFF";
31.133 + }
31.134 + //Issue next request then
31.135 + iDisplay.RequestDeviceId();
31.136 + break;
31.137 +
31.138 + case Display.TMiniDisplayRequest.EMiniDisplayRequestDeviceId:
31.139 + toolStripStatusLabelConnect.Text += " - " + iDisplay.DeviceId();
31.140 + //Issue next request then
31.141 + iDisplay.RequestFirmwareRevision();
31.142 + break;
31.143 +
31.144 + case Display.TMiniDisplayRequest.EMiniDisplayRequestFirmwareRevision:
31.145 + toolStripStatusLabelConnect.Text += " v" + iDisplay.FirmwareRevision();
31.146 + //No more request to issue
31.147 + break;
31.148 + }
31.149 + }
31.150 + }
31.151 +
31.152 +
31.153 + public delegate int CoordinateTranslationDelegate(System.Drawing.Bitmap aBmp, int aInt);
31.154 +
31.155 +
31.156 + public static int ScreenReversedX(System.Drawing.Bitmap aBmp, int aX)
31.157 + {
31.158 + return aBmp.Width - aX - 1;
31.159 + }
31.160 +
31.161 + public int ScreenReversedY(System.Drawing.Bitmap aBmp, int aY)
31.162 + {
31.163 + return iBmp.Height - aY - 1;
31.164 + }
31.165 +
31.166 + public int ScreenX(System.Drawing.Bitmap aBmp, int aX)
31.167 + {
31.168 + return aX;
31.169 + }
31.170 +
31.171 + public int ScreenY(System.Drawing.Bitmap aBmp, int aY)
31.172 + {
31.173 + return aY;
31.174 + }
31.175 +
31.176 +
31.177 + //This is our timer tick responsible to perform our render
31.178 + private void timer_Tick(object sender, EventArgs e)
31.179 + {
31.180 + //Update our animations
31.181 + DateTime NewTickTime = DateTime.Now;
31.182 +
31.183 + marqueeLabelTop.UpdateAnimation(LastTickTime, NewTickTime);
31.184 + marqueeLabelBottom.UpdateAnimation(LastTickTime, NewTickTime);
31.185 +
31.186 + //Update our display
31.187 + if (iDisplay.IsOpen())
31.188 + {
31.189 + CheckForRequestResults();
31.190 +
31.191 + //Draw to bitmap
31.192 + if (iCreateBitmap)
31.193 + {
31.194 + iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
31.195 + }
31.196 + tableLayoutPanel.DrawToBitmap(iBmp, tableLayoutPanel.ClientRectangle);
31.197 + //iBmp.Save("D:\\capture.png");
31.198 +
31.199 + //Select proper coordinate translation functions
31.200 + //We used delegate/function pointer to support reverse screen without doing an extra test on each pixels
31.201 + CoordinateTranslationDelegate screenX;
31.202 + CoordinateTranslationDelegate screenY;
31.203 +
31.204 + if (Properties.Settings.Default.DisplayReverseScreen)
31.205 + {
31.206 + screenX = ScreenReversedX;
31.207 + screenY = ScreenReversedY;
31.208 + }
31.209 + else
31.210 + {
31.211 + screenX = ScreenX;
31.212 + screenY = ScreenY;
31.213 + }
31.214 +
31.215 + //Send it to our display
31.216 + for (int i = 0; i < iBmp.Width; i++)
31.217 + {
31.218 + for (int j = 0; j < iBmp.Height; j++)
31.219 + {
31.220 + unchecked
31.221 + {
31.222 + uint color = (uint)iBmp.GetPixel(i, j).ToArgb();
31.223 + //For some reason when the app is minimized in the task bar only the alpha of our color is set.
31.224 + //Thus that strange test for rendering to work both when the app is in the task bar and when it isn't.
31.225 + iDisplay.SetPixel(screenX(iBmp, i), screenY(iBmp, j), Convert.ToInt32(!(color != 0xFF000000)));
31.226 + }
31.227 + }
31.228 + }
31.229 +
31.230 + iDisplay.SwapBuffers();
31.231 +
31.232 + }
31.233 +
31.234 + //Compute instant FPS
31.235 + toolStripStatusLabelFps.Text = (1.0/NewTickTime.Subtract(LastTickTime).TotalSeconds).ToString("F0") + " FPS";
31.236 +
31.237 + LastTickTime = NewTickTime;
31.238 +
31.239 + }
31.240 +
31.241 + private void buttonOpen_Click(object sender, EventArgs e)
31.242 + {
31.243 + if (iDisplay.Open())
31.244 + {
31.245 + UpdateStatus();
31.246 + iDisplay.RequestPowerSupplyStatus();
31.247 + }
31.248 + else
31.249 + {
31.250 + UpdateStatus();
31.251 + toolStripStatusLabelConnect.Text = "Connection error";
31.252 + }
31.253 +
31.254 + }
31.255 +
31.256 + private void buttonClose_Click(object sender, EventArgs e)
31.257 + {
31.258 + iDisplay.Close();
31.259 + UpdateStatus();
31.260 + }
31.261 +
31.262 + private void buttonClear_Click(object sender, EventArgs e)
31.263 + {
31.264 + iDisplay.Clear();
31.265 + iDisplay.SwapBuffers();
31.266 + }
31.267 +
31.268 + private void buttonFill_Click(object sender, EventArgs e)
31.269 + {
31.270 + iDisplay.Fill();
31.271 + iDisplay.SwapBuffers();
31.272 + }
31.273 +
31.274 + private void trackBarBrightness_Scroll(object sender, EventArgs e)
31.275 + {
31.276 + Properties.Settings.Default.DisplayBrightness = trackBarBrightness.Value;
31.277 + Properties.Settings.Default.Save();
31.278 + iDisplay.SetBrightness(trackBarBrightness.Value);
31.279 +
31.280 + }
31.281 +
31.282 + private void UpdateStatus()
31.283 + {
31.284 + if (iDisplay.IsOpen())
31.285 + {
31.286 + buttonFill.Enabled = true;
31.287 + buttonClear.Enabled = true;
31.288 + buttonOpen.Enabled = false;
31.289 + buttonClose.Enabled = true;
31.290 + trackBarBrightness.Enabled = true;
31.291 + trackBarBrightness.Minimum = iDisplay.MinBrightness();
31.292 + trackBarBrightness.Maximum = iDisplay.MaxBrightness();
31.293 + trackBarBrightness.Value = Properties.Settings.Default.DisplayBrightness;
31.294 + trackBarBrightness.LargeChange = Math.Max(1,(iDisplay.MaxBrightness() - iDisplay.MinBrightness())/5);
31.295 + trackBarBrightness.SmallChange = 1;
31.296 + iDisplay.SetBrightness(Properties.Settings.Default.DisplayBrightness);
31.297 +
31.298 + toolStripStatusLabelConnect.Text = "Connected - " + iDisplay.Vendor() + " - " + iDisplay.Product();
31.299 + //+ " - " + iDisplay.SerialNumber();
31.300 + }
31.301 + else
31.302 + {
31.303 + buttonFill.Enabled = false;
31.304 + buttonClear.Enabled = false;
31.305 + buttonOpen.Enabled = true;
31.306 + buttonClose.Enabled = false;
31.307 + trackBarBrightness.Enabled = false;
31.308 + toolStripStatusLabelConnect.Text = "Disconnected";
31.309 + }
31.310 + }
31.311 +
31.312 +
31.313 +
31.314 + private void checkBoxShowBorders_CheckedChanged(object sender, EventArgs e)
31.315 + {
31.316 + //Save our show borders setting
31.317 + tableLayoutPanel.CellBorderStyle = (checkBoxShowBorders.Checked ? TableLayoutPanelCellBorderStyle.Single : TableLayoutPanelCellBorderStyle.None);
31.318 + Properties.Settings.Default.DisplayShowBorders = checkBoxShowBorders.Checked;
31.319 + Properties.Settings.Default.Save();
31.320 + }
31.321 +
31.322 + private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
31.323 + {
31.324 + //Save our connect on startup setting
31.325 + Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
31.326 + Properties.Settings.Default.Save();
31.327 + }
31.328 +
31.329 + private void checkBoxReverseScreen_CheckedChanged(object sender, EventArgs e)
31.330 + {
31.331 + //Save our reverse screen setting
31.332 + Properties.Settings.Default.DisplayReverseScreen = checkBoxReverseScreen.Checked;
31.333 + Properties.Settings.Default.Save();
31.334 + }
31.335 +
31.336 + private void MainForm_Resize(object sender, EventArgs e)
31.337 + {
31.338 + if (WindowState == FormWindowState.Minimized)
31.339 + {
31.340 + // Do some stuff
31.341 + //iBmp = new System.Drawing.Bitmap(tableLayoutPanel.Width, tableLayoutPanel.Height, PixelFormat.Format32bppArgb);
31.342 + iCreateBitmap = true;
31.343 + }
31.344 + }
31.345 +
31.346 + private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
31.347 + {
31.348 + StopServer();
31.349 + }
31.350 +
31.351 + public void StartServer()
31.352 + {
31.353 + iServiceHost = new ServiceHost
31.354 + (
31.355 + typeof(DisplayServer),
31.356 + new Uri[] { new Uri("net.pipe://localhost") }
31.357 + );
31.358 +
31.359 + iServiceHost.AddServiceEndpoint(typeof(IDisplayService), new NetNamedPipeBinding(), "DisplayService");
31.360 + iServiceHost.Open();
31.361 + }
31.362 +
31.363 + public void StopServer()
31.364 + {
31.365 + //Tell connected client first? Is that possible?
31.366 + iServiceHost.Close();
31.367 + }
31.368 +
31.369 +
31.370 + }
31.371 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/Server/MainForm.resx Tue Aug 12 20:55:50 2014 +0200
32.3 @@ -0,0 +1,129 @@
32.4 +<?xml version="1.0" encoding="utf-8"?>
32.5 +<root>
32.6 + <!--
32.7 + Microsoft ResX Schema
32.8 +
32.9 + Version 2.0
32.10 +
32.11 + The primary goals of this format is to allow a simple XML format
32.12 + that is mostly human readable. The generation and parsing of the
32.13 + various data types are done through the TypeConverter classes
32.14 + associated with the data types.
32.15 +
32.16 + Example:
32.17 +
32.18 + ... ado.net/XML headers & schema ...
32.19 + <resheader name="resmimetype">text/microsoft-resx</resheader>
32.20 + <resheader name="version">2.0</resheader>
32.21 + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
32.22 + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
32.23 + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
32.24 + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
32.25 + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
32.26 + <value>[base64 mime encoded serialized .NET Framework object]</value>
32.27 + </data>
32.28 + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
32.29 + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
32.30 + <comment>This is a comment</comment>
32.31 + </data>
32.32 +
32.33 + There are any number of "resheader" rows that contain simple
32.34 + name/value pairs.
32.35 +
32.36 + Each data row contains a name, and value. The row also contains a
32.37 + type or mimetype. Type corresponds to a .NET class that support
32.38 + text/value conversion through the TypeConverter architecture.
32.39 + Classes that don't support this are serialized and stored with the
32.40 + mimetype set.
32.41 +
32.42 + The mimetype is used for serialized objects, and tells the
32.43 + ResXResourceReader how to depersist the object. This is currently not
32.44 + extensible. For a given mimetype the value must be set accordingly:
32.45 +
32.46 + Note - application/x-microsoft.net.object.binary.base64 is the format
32.47 + that the ResXResourceWriter will generate, however the reader can
32.48 + read any of the formats listed below.
32.49 +
32.50 + mimetype: application/x-microsoft.net.object.binary.base64
32.51 + value : The object must be serialized with
32.52 + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
32.53 + : and then encoded with base64 encoding.
32.54 +
32.55 + mimetype: application/x-microsoft.net.object.soap.base64
32.56 + value : The object must be serialized with
32.57 + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
32.58 + : and then encoded with base64 encoding.
32.59 +
32.60 + mimetype: application/x-microsoft.net.object.bytearray.base64
32.61 + value : The object must be serialized into a byte array
32.62 + : using a System.ComponentModel.TypeConverter
32.63 + : and then encoded with base64 encoding.
32.64 + -->
32.65 + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
32.66 + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
32.67 + <xsd:element name="root" msdata:IsDataSet="true">
32.68 + <xsd:complexType>
32.69 + <xsd:choice maxOccurs="unbounded">
32.70 + <xsd:element name="metadata">
32.71 + <xsd:complexType>
32.72 + <xsd:sequence>
32.73 + <xsd:element name="value" type="xsd:string" minOccurs="0" />
32.74 + </xsd:sequence>
32.75 + <xsd:attribute name="name" use="required" type="xsd:string" />
32.76 + <xsd:attribute name="type" type="xsd:string" />
32.77 + <xsd:attribute name="mimetype" type="xsd:string" />
32.78 + <xsd:attribute ref="xml:space" />
32.79 + </xsd:complexType>
32.80 + </xsd:element>
32.81 + <xsd:element name="assembly">
32.82 + <xsd:complexType>
32.83 + <xsd:attribute name="alias" type="xsd:string" />
32.84 + <xsd:attribute name="name" type="xsd:string" />
32.85 + </xsd:complexType>
32.86 + </xsd:element>
32.87 + <xsd:element name="data">
32.88 + <xsd:complexType>
32.89 + <xsd:sequence>
32.90 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
32.91 + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
32.92 + </xsd:sequence>
32.93 + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
32.94 + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
32.95 + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
32.96 + <xsd:attribute ref="xml:space" />
32.97 + </xsd:complexType>
32.98 + </xsd:element>
32.99 + <xsd:element name="resheader">
32.100 + <xsd:complexType>
32.101 + <xsd:sequence>
32.102 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
32.103 + </xsd:sequence>
32.104 + <xsd:attribute name="name" type="xsd:string" use="required" />
32.105 + </xsd:complexType>
32.106 + </xsd:element>
32.107 + </xsd:choice>
32.108 + </xsd:complexType>
32.109 + </xsd:element>
32.110 + </xsd:schema>
32.111 + <resheader name="resmimetype">
32.112 + <value>text/microsoft-resx</value>
32.113 + </resheader>
32.114 + <resheader name="version">
32.115 + <value>2.0</value>
32.116 + </resheader>
32.117 + <resheader name="reader">
32.118 + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
32.119 + </resheader>
32.120 + <resheader name="writer">
32.121 + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
32.122 + </resheader>
32.123 + <metadata name="fontDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
32.124 + <value>17, 17</value>
32.125 + </metadata>
32.126 + <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
32.127 + <value>126, 17</value>
32.128 + </metadata>
32.129 + <metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
32.130 + <value>206, 17</value>
32.131 + </metadata>
32.132 +</root>
32.133 \ No newline at end of file
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/Server/MarqueeLabel.cs Tue Aug 12 20:55:50 2014 +0200
33.3 @@ -0,0 +1,293 @@
33.4 +using System;
33.5 +using System.Collections.Generic;
33.6 +using System.ComponentModel;
33.7 +using System.Diagnostics;
33.8 +using System.Linq;
33.9 +using System.Text;
33.10 +using System.Threading.Tasks;
33.11 +//using System.Timers;
33.12 +using System.Windows.Forms;
33.13 +using System.Drawing;
33.14 +
33.15 +namespace SharpDisplayManager
33.16 +{
33.17 + [System.ComponentModel.DesignerCategory("Code")]
33.18 + public class MarqueeLabel : Label
33.19 + {
33.20 + private bool iOwnTimer;
33.21 + private StringFormat iStringFormat;
33.22 + private SolidBrush iBrush;
33.23 + private SizeF iTextSize;
33.24 + private SizeF iSeparatorSize;
33.25 +
33.26 + [Category("Appearance")]
33.27 + [Description("Separator in our scrolling loop.")]
33.28 + [DefaultValue(" | ")]
33.29 + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
33.30 + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
33.31 + public string Separator { get; set; }
33.32 +
33.33 + [Category("Behavior")]
33.34 + [Description("How fast is our text scrolling, in pixels per second.")]
33.35 + [DefaultValue(32)]
33.36 + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
33.37 + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
33.38 + public int PixelsPerSecond { get; set; }
33.39 +
33.40 + [Category("Behavior")]
33.41 + [Description("Use an internal or an external timer.")]
33.42 + [DefaultValue(true)]
33.43 + [Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
33.44 + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
33.45 + public bool OwnTimer
33.46 + {
33.47 + get
33.48 + {
33.49 + return iOwnTimer;
33.50 + }
33.51 + set
33.52 + {
33.53 + iOwnTimer = value;
33.54 +
33.55 + if (iOwnTimer)
33.56 + {
33.57 + Timer = new Timer();
33.58 + Timer.Interval = 10;
33.59 + Timer.Tick += new EventHandler(Timer_Tick);
33.60 + Timer.Start();
33.61 + }
33.62 + else
33.63 + {
33.64 + if (Timer != null)
33.65 + Timer.Dispose();
33.66 + Timer = null;
33.67 + }
33.68 +
33.69 + }
33.70 + }
33.71 +
33.72 + private int CurrentPosition { get; set; }
33.73 + private Timer Timer { get; set; }
33.74 + private DateTime LastTickTime { get; set; }
33.75 + private double PixelsLeft { get; set; }
33.76 + //DateTime a = new DateTime(2010, 05, 12, 13, 15, 00);
33.77 + //DateTime b = new DateTime(2010, 05, 12, 13, 45, 00);
33.78 + //Console.WriteLine(b.Subtract(a).TotalMinutes);
33.79 +
33.80 + public MarqueeLabel()
33.81 + {
33.82 + UseCompatibleTextRendering = true;
33.83 + //PixelsPerSecond = 32;
33.84 + LastTickTime = DateTime.Now;
33.85 + PixelsLeft = 0;
33.86 + iBrush = new SolidBrush(ForeColor);
33.87 + }
33.88 +
33.89 + public void UpdateAnimation(DateTime aLastTickTime, DateTime aNewTickTime)
33.90 + {
33.91 + if (!NeedToScroll())
33.92 + {
33.93 + CurrentPosition = 0;
33.94 + return;
33.95 + }
33.96 +
33.97 + while (CurrentPosition > (iTextSize.Width + iSeparatorSize.Width))
33.98 + {
33.99 + CurrentPosition -= ((int)(iTextSize.Width + iSeparatorSize.Width));
33.100 + }
33.101 +
33.102 + PixelsLeft += aNewTickTime.Subtract(aLastTickTime).TotalSeconds * PixelsPerSecond;
33.103 +
33.104 + //Keep track of our pixels left over
33.105 + //PixelsLeft = offset - Math.Truncate(offset);
33.106 + double offset = Math.Truncate(PixelsLeft);
33.107 + PixelsLeft -= offset;
33.108 +
33.109 + CurrentPosition += Convert.ToInt32(offset);
33.110 +
33.111 + /*
33.112 + if (offset > 1.0)
33.113 + {
33.114 + BackColor = Color.Red;
33.115 + }
33.116 + else if (offset==1.0)
33.117 + {
33.118 + if (BackColor != Color.White)
33.119 + {
33.120 + BackColor = Color.White;
33.121 + }
33.122 +
33.123 + }
33.124 + else
33.125 + {
33.126 + //Too slow
33.127 + //BackColor = Color.Green;
33.128 + }*/
33.129 +
33.130 + //Only redraw if something has changed
33.131 + if (offset != 0)
33.132 + {
33.133 + Invalidate();
33.134 + }
33.135 + }
33.136 +
33.137 + void Timer_Tick(object sender, EventArgs e)
33.138 + {
33.139 + DateTime NewTickTime = DateTime.Now;
33.140 + //
33.141 + UpdateAnimation(LastTickTime, NewTickTime);
33.142 + //
33.143 + LastTickTime = NewTickTime;
33.144 + }
33.145 +
33.146 + private StringFormat GetStringFormatFromContentAllignment(ContentAlignment ca)
33.147 + {
33.148 + StringFormat format = new StringFormat();
33.149 + format = StringFormat.GenericTypographic;
33.150 + switch (ca)
33.151 + {
33.152 + case ContentAlignment.TopCenter:
33.153 + format.Alignment = StringAlignment.Near;
33.154 + format.LineAlignment = StringAlignment.Center;
33.155 + break;
33.156 + case ContentAlignment.TopLeft:
33.157 + format.Alignment = StringAlignment.Near;
33.158 + format.LineAlignment = StringAlignment.Near;
33.159 + break;
33.160 + case ContentAlignment.TopRight:
33.161 + format.Alignment = StringAlignment.Near;
33.162 + format.LineAlignment = StringAlignment.Far;
33.163 + break;
33.164 + case ContentAlignment.MiddleCenter:
33.165 + format.Alignment = StringAlignment.Center;
33.166 + format.LineAlignment = StringAlignment.Center;
33.167 + break;
33.168 + case ContentAlignment.MiddleLeft:
33.169 + format.Alignment = StringAlignment.Center;
33.170 + format.LineAlignment = StringAlignment.Near;
33.171 + break;
33.172 + case ContentAlignment.MiddleRight:
33.173 + format.Alignment = StringAlignment.Center;
33.174 + format.LineAlignment = StringAlignment.Far;
33.175 + break;
33.176 + case ContentAlignment.BottomCenter:
33.177 + format.Alignment = StringAlignment.Far;
33.178 + format.LineAlignment = StringAlignment.Center;
33.179 + break;
33.180 + case ContentAlignment.BottomLeft:
33.181 + format.Alignment = StringAlignment.Far;
33.182 + format.LineAlignment = StringAlignment.Near;
33.183 + break;
33.184 + case ContentAlignment.BottomRight:
33.185 + format.Alignment = StringAlignment.Far;
33.186 + format.LineAlignment = StringAlignment.Far;
33.187 + break;
33.188 + }
33.189 +
33.190 + format.FormatFlags |= StringFormatFlags.NoWrap;
33.191 + format.FormatFlags |= StringFormatFlags.NoClip;
33.192 + format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
33.193 + format.Trimming = StringTrimming.None;
33.194 +
33.195 + return format;
33.196 + }
33.197 +
33.198 + protected override void OnForeColorChanged(EventArgs e)
33.199 + {
33.200 + //Color has changed recreate our brush
33.201 + iBrush = new SolidBrush(ForeColor);
33.202 +
33.203 + base.OnForeColorChanged(e);
33.204 + }
33.205 +
33.206 +
33.207 + private void HandleTextSizeChange()
33.208 + {
33.209 + //For all string measurements and drawing issues refer to the following article:
33.210 + // http://stackoverflow.com/questions/1203087/why-is-graphics-measurestring-returning-a-higher-than-expected-number
33.211 + //Update text size according to text and font
33.212 + Graphics g = this.CreateGraphics();
33.213 + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
33.214 + iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
33.215 + iTextSize = g.MeasureString(Text, Font, Int32.MaxValue, iStringFormat);
33.216 + iSeparatorSize = g.MeasureString(Separator, Font, Int32.MaxValue, iStringFormat);
33.217 +
33.218 + if (NeedToScroll())
33.219 + {
33.220 + //Always align left when scrolling
33.221 + iStringFormat.Alignment = StringAlignment.Near;
33.222 + }
33.223 + }
33.224 +
33.225 + protected override void OnTextChanged(EventArgs e)
33.226 + {
33.227 + HandleTextSizeChange();
33.228 +
33.229 + base.OnTextChanged(e);
33.230 + }
33.231 +
33.232 + protected override void OnFontChanged(EventArgs e)
33.233 + {
33.234 + HandleTextSizeChange();
33.235 +
33.236 + base.OnFontChanged(e);
33.237 + }
33.238 +
33.239 + protected override void OnTextAlignChanged(EventArgs e)
33.240 + {
33.241 + iStringFormat = GetStringFormatFromContentAllignment(TextAlign);
33.242 +
33.243 + base.OnTextAlignChanged(e);
33.244 +
33.245 + }
33.246 +
33.247 + protected override void OnPaint(PaintEventArgs e)
33.248 + {
33.249 + //Disable anti-aliasing
33.250 + e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
33.251 + if (NeedToScroll())
33.252 + {
33.253 + //Draw the first one
33.254 + e.Graphics.TranslateTransform(-(float)CurrentPosition, 0);
33.255 + e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
33.256 + //Draw separator
33.257 + e.Graphics.TranslateTransform(iTextSize.Width, 0);
33.258 + e.Graphics.DrawString(Separator, Font, iBrush, ClientRectangle, iStringFormat);
33.259 + //Draw the last one
33.260 + e.Graphics.TranslateTransform(iSeparatorSize.Width, 0);
33.261 + e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
33.262 + }
33.263 + else
33.264 + {
33.265 + e.Graphics.DrawString(Text, Font, iBrush, ClientRectangle, iStringFormat);
33.266 + }
33.267 +
33.268 +
33.269 +
33.270 + //DrawText is not working without anti-aliasing. See: stackoverflow.com/questions/8283631/graphics-drawstring-vs-textrenderer-drawtextwhich-can-deliver-better-quality
33.271 + //TextRenderer.DrawText(e.Graphics, Text, Font, ClientRectangle, ForeColor, BackColor, iTextFormatFlags);
33.272 +
33.273 + //base.OnPaint(e);
33.274 + }
33.275 +
33.276 + public bool NeedToScroll()
33.277 + {
33.278 + //if (Width < e.Graphics.MeasureString(Text, Font).Width)
33.279 + if (Width < iTextSize.Width)
33.280 + {
33.281 + return true;
33.282 + }
33.283 + return false;
33.284 + }
33.285 +
33.286 + protected override void Dispose(bool disposing)
33.287 + {
33.288 + if (disposing)
33.289 + {
33.290 + if (Timer != null)
33.291 + Timer.Dispose();
33.292 + }
33.293 + Timer = null;
33.294 + }
33.295 + }
33.296 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/Server/Program.cs Tue Aug 12 20:55:50 2014 +0200
34.3 @@ -0,0 +1,24 @@
34.4 +using System;
34.5 +using System.Collections.Generic;
34.6 +using System.Linq;
34.7 +using System.Threading.Tasks;
34.8 +using System.Windows.Forms;
34.9 +
34.10 +namespace SharpDisplayManager
34.11 +{
34.12 + static class Program
34.13 + {
34.14 + public static MainForm iMainForm;
34.15 + /// <summary>
34.16 + /// The main entry point for the application.
34.17 + /// </summary>
34.18 + [STAThread]
34.19 + static void Main()
34.20 + {
34.21 + Application.EnableVisualStyles();
34.22 + Application.SetCompatibleTextRenderingDefault(false);
34.23 + iMainForm = new MainForm();
34.24 + Application.Run(iMainForm);
34.25 + }
34.26 + }
34.27 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/Server/Properties/AssemblyInfo.cs Tue Aug 12 20:55:50 2014 +0200
35.3 @@ -0,0 +1,36 @@
35.4 +using System.Reflection;
35.5 +using System.Runtime.CompilerServices;
35.6 +using System.Runtime.InteropServices;
35.7 +
35.8 +// General Information about an assembly is controlled through the following
35.9 +// set of attributes. Change these attribute values to modify the information
35.10 +// associated with an assembly.
35.11 +[assembly: AssemblyTitle("SharpDisplayManager")]
35.12 +[assembly: AssemblyDescription("")]
35.13 +[assembly: AssemblyConfiguration("")]
35.14 +[assembly: AssemblyCompany("")]
35.15 +[assembly: AssemblyProduct("SharpDisplayManager")]
35.16 +[assembly: AssemblyCopyright("Copyright © 2014")]
35.17 +[assembly: AssemblyTrademark("")]
35.18 +[assembly: AssemblyCulture("")]
35.19 +
35.20 +// Setting ComVisible to false makes the types in this assembly not visible
35.21 +// to COM components. If you need to access a type in this assembly from
35.22 +// COM, set the ComVisible attribute to true on that type.
35.23 +[assembly: ComVisible(false)]
35.24 +
35.25 +// The following GUID is for the ID of the typelib if this project is exposed to COM
35.26 +[assembly: Guid("5da0f26b-76a6-41e8-832c-5b593b3a75b0")]
35.27 +
35.28 +// Version information for an assembly consists of the following four values:
35.29 +//
35.30 +// Major Version
35.31 +// Minor Version
35.32 +// Build Number
35.33 +// Revision
35.34 +//
35.35 +// You can specify all the values or you can default the Build and Revision Numbers
35.36 +// by using the '*' as shown below:
35.37 +// [assembly: AssemblyVersion("1.0.*")]
35.38 +[assembly: AssemblyVersion("1.0.0.0")]
35.39 +[assembly: AssemblyFileVersion("1.0.0.0")]
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/Server/Properties/Resources.Designer.cs Tue Aug 12 20:55:50 2014 +0200
36.3 @@ -0,0 +1,71 @@
36.4 +//------------------------------------------------------------------------------
36.5 +// <auto-generated>
36.6 +// This code was generated by a tool.
36.7 +// Runtime Version:4.0.30319.18063
36.8 +//
36.9 +// Changes to this file may cause incorrect behavior and will be lost if
36.10 +// the code is regenerated.
36.11 +// </auto-generated>
36.12 +//------------------------------------------------------------------------------
36.13 +
36.14 +namespace SharpDisplayManager.Properties
36.15 +{
36.16 +
36.17 +
36.18 + /// <summary>
36.19 + /// A strongly-typed resource class, for looking up localized strings, etc.
36.20 + /// </summary>
36.21 + // This class was auto-generated by the StronglyTypedResourceBuilder
36.22 + // class via a tool like ResGen or Visual Studio.
36.23 + // To add or remove a member, edit your .ResX file then rerun ResGen
36.24 + // with the /str option, or rebuild your VS project.
36.25 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
36.26 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
36.27 + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
36.28 + internal class Resources
36.29 + {
36.30 +
36.31 + private static global::System.Resources.ResourceManager resourceMan;
36.32 +
36.33 + private static global::System.Globalization.CultureInfo resourceCulture;
36.34 +
36.35 + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
36.36 + internal Resources()
36.37 + {
36.38 + }
36.39 +
36.40 + /// <summary>
36.41 + /// Returns the cached ResourceManager instance used by this class.
36.42 + /// </summary>
36.43 + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
36.44 + internal static global::System.Resources.ResourceManager ResourceManager
36.45 + {
36.46 + get
36.47 + {
36.48 + if ((resourceMan == null))
36.49 + {
36.50 + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpDisplayManager.Properties.Resources", typeof(Resources).Assembly);
36.51 + resourceMan = temp;
36.52 + }
36.53 + return resourceMan;
36.54 + }
36.55 + }
36.56 +
36.57 + /// <summary>
36.58 + /// Overrides the current thread's CurrentUICulture property for all
36.59 + /// resource lookups using this strongly typed resource class.
36.60 + /// </summary>
36.61 + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
36.62 + internal static global::System.Globalization.CultureInfo Culture
36.63 + {
36.64 + get
36.65 + {
36.66 + return resourceCulture;
36.67 + }
36.68 + set
36.69 + {
36.70 + resourceCulture = value;
36.71 + }
36.72 + }
36.73 + }
36.74 +}
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/Server/Properties/Resources.resx Tue Aug 12 20:55:50 2014 +0200
37.3 @@ -0,0 +1,117 @@
37.4 +<?xml version="1.0" encoding="utf-8"?>
37.5 +<root>
37.6 + <!--
37.7 + Microsoft ResX Schema
37.8 +
37.9 + Version 2.0
37.10 +
37.11 + The primary goals of this format is to allow a simple XML format
37.12 + that is mostly human readable. The generation and parsing of the
37.13 + various data types are done through the TypeConverter classes
37.14 + associated with the data types.
37.15 +
37.16 + Example:
37.17 +
37.18 + ... ado.net/XML headers & schema ...
37.19 + <resheader name="resmimetype">text/microsoft-resx</resheader>
37.20 + <resheader name="version">2.0</resheader>
37.21 + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
37.22 + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
37.23 + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
37.24 + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
37.25 + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
37.26 + <value>[base64 mime encoded serialized .NET Framework object]</value>
37.27 + </data>
37.28 + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
37.29 + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
37.30 + <comment>This is a comment</comment>
37.31 + </data>
37.32 +
37.33 + There are any number of "resheader" rows that contain simple
37.34 + name/value pairs.
37.35 +
37.36 + Each data row contains a name, and value. The row also contains a
37.37 + type or mimetype. Type corresponds to a .NET class that support
37.38 + text/value conversion through the TypeConverter architecture.
37.39 + Classes that don't support this are serialized and stored with the
37.40 + mimetype set.
37.41 +
37.42 + The mimetype is used for serialized objects, and tells the
37.43 + ResXResourceReader how to depersist the object. This is currently not
37.44 + extensible. For a given mimetype the value must be set accordingly:
37.45 +
37.46 + Note - application/x-microsoft.net.object.binary.base64 is the format
37.47 + that the ResXResourceWriter will generate, however the reader can
37.48 + read any of the formats listed below.
37.49 +
37.50 + mimetype: application/x-microsoft.net.object.binary.base64
37.51 + value : The object must be serialized with
37.52 + : System.Serialization.Formatters.Binary.BinaryFormatter
37.53 + : and then encoded with base64 encoding.
37.54 +
37.55 + mimetype: application/x-microsoft.net.object.soap.base64
37.56 + value : The object must be serialized with
37.57 + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
37.58 + : and then encoded with base64 encoding.
37.59 +
37.60 + mimetype: application/x-microsoft.net.object.bytearray.base64
37.61 + value : The object must be serialized into a byte array
37.62 + : using a System.ComponentModel.TypeConverter
37.63 + : and then encoded with base64 encoding.
37.64 + -->
37.65 + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
37.66 + <xsd:element name="root" msdata:IsDataSet="true">
37.67 + <xsd:complexType>
37.68 + <xsd:choice maxOccurs="unbounded">
37.69 + <xsd:element name="metadata">
37.70 + <xsd:complexType>
37.71 + <xsd:sequence>
37.72 + <xsd:element name="value" type="xsd:string" minOccurs="0" />
37.73 + </xsd:sequence>
37.74 + <xsd:attribute name="name" type="xsd:string" />
37.75 + <xsd:attribute name="type" type="xsd:string" />
37.76 + <xsd:attribute name="mimetype" type="xsd:string" />
37.77 + </xsd:complexType>
37.78 + </xsd:element>
37.79 + <xsd:element name="assembly">
37.80 + <xsd:complexType>
37.81 + <xsd:attribute name="alias" type="xsd:string" />
37.82 + <xsd:attribute name="name" type="xsd:string" />
37.83 + </xsd:complexType>
37.84 + </xsd:element>
37.85 + <xsd:element name="data">
37.86 + <xsd:complexType>
37.87 + <xsd:sequence>
37.88 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
37.89 + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
37.90 + </xsd:sequence>
37.91 + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
37.92 + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
37.93 + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
37.94 + </xsd:complexType>
37.95 + </xsd:element>
37.96 + <xsd:element name="resheader">
37.97 + <xsd:complexType>
37.98 + <xsd:sequence>
37.99 + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
37.100 + </xsd:sequence>
37.101 + <xsd:attribute name="name" type="xsd:string" use="required" />
37.102 + </xsd:complexType>
37.103 + </xsd:element>
37.104 + </xsd:choice>
37.105 + </xsd:complexType>
37.106 + </xsd:element>
37.107 + </xsd:schema>
37.108 + <resheader name="resmimetype">
37.109 + <value>text/microsoft-resx</value>
37.110 + </resheader>
37.111 + <resheader name="version">
37.112 + <value>2.0</value>
37.113 + </resheader>
37.114 + <resheader name="reader">
37.115 + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
37.116 + </resheader>
37.117 + <resheader name="writer">
37.118 + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
37.119 + </resheader>
37.120 +</root>
37.121 \ No newline at end of file
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/Server/Properties/Settings.Designer.cs Tue Aug 12 20:55:50 2014 +0200
38.3 @@ -0,0 +1,86 @@
38.4 +//------------------------------------------------------------------------------
38.5 +// <auto-generated>
38.6 +// This code was generated by a tool.
38.7 +// Runtime Version:4.0.30319.18444
38.8 +//
38.9 +// Changes to this file may cause incorrect behavior and will be lost if
38.10 +// the code is regenerated.
38.11 +// </auto-generated>
38.12 +//------------------------------------------------------------------------------
38.13 +
38.14 +namespace SharpDisplayManager.Properties {
38.15 +
38.16 +
38.17 + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
38.18 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
38.19 + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
38.20 +
38.21 + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
38.22 +
38.23 + public static Settings Default {
38.24 + get {
38.25 + return defaultInstance;
38.26 + }
38.27 + }
38.28 +
38.29 + [global::System.Configuration.UserScopedSettingAttribute()]
38.30 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
38.31 + [global::System.Configuration.DefaultSettingValueAttribute("1")]
38.32 + public int DisplayBrightness {
38.33 + get {
38.34 + return ((int)(this["DisplayBrightness"]));
38.35 + }
38.36 + set {
38.37 + this["DisplayBrightness"] = value;
38.38 + }
38.39 + }
38.40 +
38.41 + [global::System.Configuration.UserScopedSettingAttribute()]
38.42 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
38.43 + [global::System.Configuration.DefaultSettingValueAttribute("Microsoft Sans Serif, 9.75pt")]
38.44 + public global::System.Drawing.Font DisplayFont {
38.45 + get {
38.46 + return ((global::System.Drawing.Font)(this["DisplayFont"]));
38.47 + }
38.48 + set {
38.49 + this["DisplayFont"] = value;
38.50 + }
38.51 + }
38.52 +
38.53 + [global::System.Configuration.UserScopedSettingAttribute()]
38.54 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
38.55 + [global::System.Configuration.DefaultSettingValueAttribute("False")]
38.56 + public bool DisplayShowBorders {
38.57 + get {
38.58 + return ((bool)(this["DisplayShowBorders"]));
38.59 + }
38.60 + set {
38.61 + this["DisplayShowBorders"] = value;
38.62 + }
38.63 + }
38.64 +
38.65 + [global::System.Configuration.UserScopedSettingAttribute()]
38.66 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
38.67 + [global::System.Configuration.DefaultSettingValueAttribute("False")]
38.68 + public bool DisplayConnectOnStartup {
38.69 + get {
38.70 + return ((bool)(this["DisplayConnectOnStartup"]));
38.71 + }
38.72 + set {
38.73 + this["DisplayConnectOnStartup"] = value;
38.74 + }
38.75 + }
38.76 +
38.77 + [global::System.Configuration.UserScopedSettingAttribute()]
38.78 + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
38.79 + [global::System.Configuration.DefaultSettingValueAttribute("False")]
38.80 + public bool DisplayReverseScreen {
38.81 + get {
38.82 + return ((bool)(this["DisplayReverseScreen"]));
38.83 + }
38.84 + set {
38.85 + this["DisplayReverseScreen"] = value;
38.86 + }
38.87 + }
38.88 + }
38.89 +}
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/Server/Properties/Settings.settings Tue Aug 12 20:55:50 2014 +0200
39.3 @@ -0,0 +1,21 @@
39.4 +<?xml version='1.0' encoding='utf-8'?>
39.5 +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SharpDisplayManager.Properties" GeneratedClassName="Settings">
39.6 + <Profiles />
39.7 + <Settings>
39.8 + <Setting Name="DisplayBrightness" Type="System.Int32" Scope="User">
39.9 + <Value Profile="(Default)">1</Value>
39.10 + </Setting>
39.11 + <Setting Name="DisplayFont" Type="System.Drawing.Font" Scope="User">
39.12 + <Value Profile="(Default)">Microsoft Sans Serif, 9.75pt</Value>
39.13 + </Setting>
39.14 + <Setting Name="DisplayShowBorders" Type="System.Boolean" Scope="User">
39.15 + <Value Profile="(Default)">False</Value>
39.16 + </Setting>
39.17 + <Setting Name="DisplayConnectOnStartup" Type="System.Boolean" Scope="User">
39.18 + <Value Profile="(Default)">False</Value>
39.19 + </Setting>
39.20 + <Setting Name="DisplayReverseScreen" Type="System.Boolean" Scope="User">
39.21 + <Value Profile="(Default)">False</Value>
39.22 + </Setting>
39.23 + </Settings>
39.24 +</SettingsFile>
39.25 \ No newline at end of file
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/Server/Servers.cs Tue Aug 12 20:55:50 2014 +0200
40.3 @@ -0,0 +1,27 @@
40.4 +using System;
40.5 +using System.Windows.Forms;
40.6 +
40.7 +namespace SharpDisplayManager
40.8 +{
40.9 + /// <summary>
40.10 + /// Implement our display service.
40.11 + /// This class is instantiated anew whenever a client send a request.
40.12 + /// </summary>
40.13 + class DisplayServer : IDisplayService
40.14 + {
40.15 + //From IDisplayService
40.16 + public void SetText(int aLineIndex, string aText)
40.17 + {
40.18 + if (aLineIndex == 0)
40.19 + {
40.20 + Program.iMainForm.marqueeLabelTop.Text = aText;
40.21 + }
40.22 + else if (aLineIndex == 1)
40.23 + {
40.24 + Program.iMainForm.marqueeLabelBottom.Text = aText;
40.25 + }
40.26 + }
40.27 +
40.28 + }
40.29 +
40.30 +}
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/Server/Services.cs Tue Aug 12 20:55:50 2014 +0200
41.3 @@ -0,0 +1,12 @@
41.4 +using System;
41.5 +using System.ServiceModel;
41.6 +
41.7 +namespace SharpDisplayManager
41.8 +{
41.9 + [ServiceContract]
41.10 + public interface IDisplayService
41.11 + {
41.12 + [OperationContract]
41.13 + void SetText(int aLineIndex, string aText);
41.14 + }
41.15 +}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/Server/SharpDisplayManager.csproj Tue Aug 12 20:55:50 2014 +0200
42.3 @@ -0,0 +1,100 @@
42.4 +<?xml version="1.0" encoding="utf-8"?>
42.5 +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
42.6 + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
42.7 + <PropertyGroup>
42.8 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
42.9 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
42.10 + <ProjectGuid>{1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}</ProjectGuid>
42.11 + <OutputType>WinExe</OutputType>
42.12 + <AppDesignerFolder>Properties</AppDesignerFolder>
42.13 + <RootNamespace>SharpDisplayManager</RootNamespace>
42.14 + <AssemblyName>SharpDisplayManager</AssemblyName>
42.15 + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
42.16 + <FileAlignment>512</FileAlignment>
42.17 + </PropertyGroup>
42.18 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
42.19 + <PlatformTarget>AnyCPU</PlatformTarget>
42.20 + <DebugSymbols>true</DebugSymbols>
42.21 + <DebugType>full</DebugType>
42.22 + <Optimize>false</Optimize>
42.23 + <OutputPath>..\..\bin\MiniDisplay\Debug\</OutputPath>
42.24 + <DefineConstants>DEBUG;TRACE</DefineConstants>
42.25 + <ErrorReport>prompt</ErrorReport>
42.26 + <WarningLevel>4</WarningLevel>
42.27 + </PropertyGroup>
42.28 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
42.29 + <PlatformTarget>AnyCPU</PlatformTarget>
42.30 + <DebugType>pdbonly</DebugType>
42.31 + <Optimize>true</Optimize>
42.32 + <OutputPath>..\..\bin\MiniDisplay\Release\</OutputPath>
42.33 + <DefineConstants>TRACE</DefineConstants>
42.34 + <ErrorReport>prompt</ErrorReport>
42.35 + <WarningLevel>4</WarningLevel>
42.36 + </PropertyGroup>
42.37 + <ItemGroup>
42.38 + <Reference Include="Microsoft.VisualBasic" />
42.39 + <Reference Include="Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
42.40 + <Reference Include="System" />
42.41 + <Reference Include="System.Core" />
42.42 + <Reference Include="System.ServiceModel" />
42.43 + <Reference Include="System.Xml.Linq" />
42.44 + <Reference Include="System.Data.DataSetExtensions" />
42.45 + <Reference Include="Microsoft.CSharp" />
42.46 + <Reference Include="System.Data" />
42.47 + <Reference Include="System.Deployment" />
42.48 + <Reference Include="System.Drawing" />
42.49 + <Reference Include="System.Windows.Forms" />
42.50 + <Reference Include="System.Xml" />
42.51 + </ItemGroup>
42.52 + <ItemGroup>
42.53 + <Compile Include="CbtHook.cs" />
42.54 + <Compile Include="DialogBox.cs" />
42.55 + <Compile Include="Display.cs" />
42.56 + <Compile Include="MainForm.cs">
42.57 + <SubType>Form</SubType>
42.58 + </Compile>
42.59 + <Compile Include="MainForm.Designer.cs">
42.60 + <DependentUpon>MainForm.cs</DependentUpon>
42.61 + </Compile>
42.62 + <Compile Include="MarqueeLabel.cs" />
42.63 + <Compile Include="Program.cs" />
42.64 + <Compile Include="Properties\AssemblyInfo.cs" />
42.65 + <Compile Include="Servers.cs" />
42.66 + <Compile Include="Services.cs" />
42.67 + <Compile Include="Win32API.cs" />
42.68 + <Compile Include="WindowsHook.cs" />
42.69 + <Compile Include="WndProcRetHook.cs" />
42.70 + <EmbeddedResource Include="MainForm.resx">
42.71 + <DependentUpon>MainForm.cs</DependentUpon>
42.72 + </EmbeddedResource>
42.73 + <EmbeddedResource Include="Properties\Resources.resx">
42.74 + <Generator>ResXFileCodeGenerator</Generator>
42.75 + <LastGenOutput>Resources.Designer.cs</LastGenOutput>
42.76 + <SubType>Designer</SubType>
42.77 + </EmbeddedResource>
42.78 + <Compile Include="Properties\Resources.Designer.cs">
42.79 + <AutoGen>True</AutoGen>
42.80 + <DependentUpon>Resources.resx</DependentUpon>
42.81 + </Compile>
42.82 + <None Include="Properties\Settings.settings">
42.83 + <Generator>SettingsSingleFileGenerator</Generator>
42.84 + <LastGenOutput>Settings.Designer.cs</LastGenOutput>
42.85 + </None>
42.86 + <Compile Include="Properties\Settings.Designer.cs">
42.87 + <AutoGen>True</AutoGen>
42.88 + <DependentUpon>Settings.settings</DependentUpon>
42.89 + <DesignTimeSharedInput>True</DesignTimeSharedInput>
42.90 + </Compile>
42.91 + </ItemGroup>
42.92 + <ItemGroup>
42.93 + <None Include="App.config" />
42.94 + </ItemGroup>
42.95 + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
42.96 + <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
42.97 + Other similar extension points exist, see Microsoft.Common.targets.
42.98 + <Target Name="BeforeBuild">
42.99 + </Target>
42.100 + <Target Name="AfterBuild">
42.101 + </Target>
42.102 + -->
42.103 +</Project>
42.104 \ No newline at end of file
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/Server/SharpDisplayManager.sln Tue Aug 12 20:55:50 2014 +0200
43.3 @@ -0,0 +1,26 @@
43.4 +
43.5 +Microsoft Visual Studio Solution File, Format Version 12.00
43.6 +# Visual Studio 2012
43.7 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDisplayManager", "SharpDisplayManager.csproj", "{1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}"
43.8 +EndProject
43.9 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDisplayClient", "..\Client\SharpDisplayClient.csproj", "{7EE64074-8CDB-4448-B40C-81B75D6B31CD}"
43.10 +EndProject
43.11 +Global
43.12 + GlobalSection(SolutionConfigurationPlatforms) = preSolution
43.13 + Debug|Any CPU = Debug|Any CPU
43.14 + Release|Any CPU = Release|Any CPU
43.15 + EndGlobalSection
43.16 + GlobalSection(ProjectConfigurationPlatforms) = postSolution
43.17 + {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43.18 + {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.Build.0 = Debug|Any CPU
43.19 + {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.ActiveCfg = Release|Any CPU
43.20 + {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.Build.0 = Release|Any CPU
43.21 + {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43.22 + {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
43.23 + {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
43.24 + {7EE64074-8CDB-4448-B40C-81B75D6B31CD}.Release|Any CPU.Build.0 = Release|Any CPU
43.25 + EndGlobalSection
43.26 + GlobalSection(SolutionProperties) = preSolution
43.27 + HideSolutionNode = FALSE
43.28 + EndGlobalSection
43.29 +EndGlobal
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/Server/Win32API.cs Tue Aug 12 20:55:50 2014 +0200
44.3 @@ -0,0 +1,100 @@
44.4 +//=============================================================================
44.5 +// COPYRIGHT: Prosoft-Lanz
44.6 +//=============================================================================
44.7 +//
44.8 +// $Workfile: Win32API.cs $
44.9 +//
44.10 +// PROJECT : CodeProject Components
44.11 +// VERSION : 1.00
44.12 +// CREATION : 19.02.2003
44.13 +// AUTHOR : JCL
44.14 +//
44.15 +// DETAILS : This class implement Win32 API calls
44.16 +// and the contants used for these calls.
44.17 +//
44.18 +//-----------------------------------------------------------------------------
44.19 +using System;
44.20 +using System.Text;
44.21 +using System.Drawing;
44.22 +using System.Windows.Forms;
44.23 +using System.Runtime.InteropServices;
44.24 +
44.25 +namespace CodeProject.Win32API
44.26 +{
44.27 + ///////////////////////////////////////////////////////////////////////
44.28 + #region Generic declarations
44.29 +
44.30 + /// <summary>
44.31 + /// Rectangle parameters exposed as a structure.
44.32 + /// </summary>
44.33 + public struct RECT
44.34 + {
44.35 + /// <summary>
44.36 + /// Rectangle members.
44.37 + /// </summary>
44.38 + public int left, top, right, bottom;
44.39 + }
44.40 +
44.41 + #endregion
44.42 +
44.43 + ///////////////////////////////////////////////////////////////////////
44.44 + #region Util class
44.45 +
44.46 + /// <summary>
44.47 + /// Utility functions.
44.48 + /// </summary>
44.49 + public sealed class API
44.50 + {
44.51 + private API() {} // To remove the constructor from the documentation!
44.52 +
44.53 + /// <summary>
44.54 + /// Get true multiscreen size.
44.55 + /// </summary>
44.56 + public static Rectangle TrueScreenRect
44.57 + {
44.58 + get
44.59 + {
44.60 + // get the biggest screen area
44.61 + Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea;
44.62 + int left = rectScreen.Left;
44.63 + int top = rectScreen.Top;
44.64 + int right = rectScreen.Right;
44.65 + int bottom = rectScreen.Bottom;
44.66 + foreach (Screen screen in Screen.AllScreens)
44.67 + {
44.68 + left = Math.Min(left, screen.WorkingArea.Left);
44.69 + right = Math.Max(right, screen.WorkingArea.Right);
44.70 + top = Math.Min(top, screen.WorkingArea.Top);
44.71 + bottom = Math.Max(bottom, screen.WorkingArea.Bottom);
44.72 + }
44.73 + return new Rectangle(left, top, right-left, bottom-top);
44.74 + }
44.75 + }
44.76 + }
44.77 +
44.78 + #endregion
44.79 +
44.80 + ///////////////////////////////////////////////////////////////////////
44.81 + #region USER32 class
44.82 +
44.83 + /// <summary>
44.84 + /// Class to expose USER32 API functions.
44.85 + /// </summary>
44.86 + public sealed class USER32
44.87 + {
44.88 + private USER32() {} // To remove the constructor from the documentation!
44.89 +
44.90 + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
44.91 + internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect);
44.92 +
44.93 + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
44.94 + internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int w, int h, int repaint);
44.95 +
44.96 + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
44.97 + internal static extern IntPtr GetActiveWindow();
44.98 +
44.99 + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
44.100 + internal static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
44.101 + }
44.102 + #endregion
44.103 +}
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/Server/WindowsHook.cs Tue Aug 12 20:55:50 2014 +0200
45.3 @@ -0,0 +1,186 @@
45.4 +//=============================================================================
45.5 +// COPYRIGHT: Prosoft-Lanz
45.6 +//=============================================================================
45.7 +//
45.8 +// $Workfile: WindowsHook.cs $
45.9 +//
45.10 +// PROJECT : CodeProject Components
45.11 +// VERSION : 1.00
45.12 +// CREATION : 19.02.2003
45.13 +// AUTHOR : JCL
45.14 +//
45.15 +// DETAILS : This class implement the Windows hook mechanism.
45.16 +// From MSDN, Dino Esposito.
45.17 +//
45.18 +//-----------------------------------------------------------------------------
45.19 +using System;
45.20 +using System.Runtime.InteropServices;
45.21 +
45.22 +namespace CodeProject.Win32API.Hook
45.23 +{
45.24 + ///////////////////////////////////////////////////////////////////////
45.25 + #region Class HookEventArgs
45.26 +
45.27 + /// Class used for hook event arguments.
45.28 + public class HookEventArgs : EventArgs
45.29 + {
45.30 + /// Event code parameter.
45.31 + public int code;
45.32 + /// wParam parameter.
45.33 + public IntPtr wParam;
45.34 + /// lParam parameter.
45.35 + public IntPtr lParam;
45.36 +
45.37 + internal HookEventArgs(int code, IntPtr wParam, IntPtr lParam)
45.38 + {
45.39 + this.code = code;
45.40 + this.wParam = wParam;
45.41 + this.lParam = lParam;
45.42 + }
45.43 + }
45.44 +
45.45 + #endregion
45.46 +
45.47 + ///////////////////////////////////////////////////////////////////////
45.48 + #region Enum HookType
45.49 +
45.50 + /// Hook Types.
45.51 + public enum HookType : int
45.52 + {
45.53 + /// <value>0</value>
45.54 + WH_JOURNALRECORD = 0,
45.55 + /// <value>1</value>
45.56 + WH_JOURNALPLAYBACK = 1,
45.57 + /// <value>2</value>
45.58 + WH_KEYBOARD = 2,
45.59 + /// <value>3</value>
45.60 + WH_GETMESSAGE = 3,
45.61 + /// <value>4</value>
45.62 + WH_CALLWNDPROC = 4,
45.63 + /// <value>5</value>
45.64 + WH_CBT = 5,
45.65 + /// <value>6</value>
45.66 + WH_SYSMSGFILTER = 6,
45.67 + /// <value>7</value>
45.68 + WH_MOUSE = 7,
45.69 + /// <value>8</value>
45.70 + WH_HARDWARE = 8,
45.71 + /// <value>9</value>
45.72 + WH_DEBUG = 9,
45.73 + /// <value>10</value>
45.74 + WH_SHELL = 10,
45.75 + /// <value>11</value>
45.76 + WH_FOREGROUNDIDLE = 11,
45.77 + /// <value>12</value>
45.78 + WH_CALLWNDPROCRET = 12,
45.79 + /// <value>13</value>
45.80 + WH_KEYBOARD_LL = 13,
45.81 + /// <value>14</value>
45.82 + WH_MOUSE_LL = 14
45.83 + }
45.84 + #endregion
45.85 +
45.86 + ///////////////////////////////////////////////////////////////////////
45.87 + #region Class WindowsHook
45.88 +
45.89 + /// <summary>
45.90 + /// Class to expose the windows hook mechanism.
45.91 + /// </summary>
45.92 + public class WindowsHook
45.93 + {
45.94 + /// <summary>
45.95 + /// Hook delegate method.
45.96 + /// </summary>
45.97 + public delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
45.98 +
45.99 + // internal properties
45.100 + internal IntPtr hHook = IntPtr.Zero;
45.101 + internal HookProc filterFunc = null;
45.102 + internal HookType hookType;
45.103 +
45.104 + /// <summary>
45.105 + /// Hook delegate method.
45.106 + /// </summary>
45.107 + public delegate void HookEventHandler(object sender, HookEventArgs e);
45.108 +
45.109 + /// <summary>
45.110 + /// Hook invoke event.
45.111 + /// </summary>
45.112 + public event HookEventHandler HookInvoke;
45.113 +
45.114 + internal void OnHookInvoke(HookEventArgs e)
45.115 + {
45.116 + if (HookInvoke != null)
45.117 + HookInvoke(this, e);
45.118 + }
45.119 +
45.120 + /// <summary>
45.121 + /// Construct a HookType hook.
45.122 + /// </summary>
45.123 + /// <param name="hook">Hook type.</param>
45.124 + public WindowsHook(HookType hook)
45.125 + {
45.126 + hookType = hook;
45.127 + filterFunc = new HookProc(this.CoreHookProc);
45.128 + }
45.129 + /// <summary>
45.130 + /// Construct a HookType hook giving a hook filter delegate method.
45.131 + /// </summary>
45.132 + /// <param name="hook">Hook type</param>
45.133 + /// <param name="func">Hook filter event.</param>
45.134 + public WindowsHook(HookType hook, HookProc func)
45.135 + {
45.136 + hookType = hook;
45.137 + filterFunc = func;
45.138 + }
45.139 +
45.140 + // default hook filter function
45.141 + internal int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
45.142 + {
45.143 + if (code < 0)
45.144 + return CallNextHookEx(hHook, code, wParam, lParam);
45.145 +
45.146 + // let clients determine what to do
45.147 + HookEventArgs e = new HookEventArgs(code, wParam, lParam);
45.148 + OnHookInvoke(e);
45.149 +
45.150 + // yield to the next hook in the chain
45.151 + return CallNextHookEx(hHook, code, wParam, lParam);
45.152 + }
45.153 +
45.154 + /// <summary>
45.155 + /// Install the hook.
45.156 + /// </summary>
45.157 + public void Install()
45.158 + {
45.159 + hHook = SetWindowsHookEx(hookType, filterFunc, IntPtr.Zero, (int)AppDomain.GetCurrentThreadId());
45.160 + }
45.161 +
45.162 +
45.163 + /// <summary>
45.164 + /// Uninstall the hook.
45.165 + /// </summary>
45.166 + public void Uninstall()
45.167 + {
45.168 + if (hHook != IntPtr.Zero)
45.169 + {
45.170 + UnhookWindowsHookEx(hHook);
45.171 + hHook = IntPtr.Zero;
45.172 + }
45.173 + }
45.174 +
45.175 + #region Win32 Imports
45.176 +
45.177 + [DllImport("user32.dll")]
45.178 + internal static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
45.179 +
45.180 + [DllImport("user32.dll")]
45.181 + internal static extern int UnhookWindowsHookEx(IntPtr hhook);
45.182 +
45.183 + [DllImport("user32.dll")]
45.184 + internal static extern int CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam);
45.185 +
45.186 + #endregion
45.187 + }
45.188 + #endregion
45.189 +}
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/Server/WndProcRetHook.cs Tue Aug 12 20:55:50 2014 +0200
46.3 @@ -0,0 +1,135 @@
46.4 +//=============================================================================
46.5 +// COPYRIGHT: Prosoft-Lanz
46.6 +//=============================================================================
46.7 +//
46.8 +// $Workfile: WndProcRetHook.cs $
46.9 +//
46.10 +// PROJECT : CodeProject Components
46.11 +// VERSION : 1.00
46.12 +// CREATION : 19.02.2003
46.13 +// AUTHOR : JCL
46.14 +//
46.15 +// DETAILS : This class implement the WH_CALLWNDPROCRET Windows hook mechanism.
46.16 +// From MSDN, Dino Esposito.
46.17 +//
46.18 +// WindowCreate, WindowDestroye and WindowActivate user events.
46.19 +//
46.20 +//-----------------------------------------------------------------------------
46.21 +using System;
46.22 +using System.Runtime.InteropServices;
46.23 +using System.Diagnostics;
46.24 +
46.25 +namespace CodeProject.Win32API.Hook
46.26 +{
46.27 + ///////////////////////////////////////////////////////////////////////
46.28 + #region Enum WndMessage
46.29 +
46.30 + /// <summary>
46.31 + /// windows message.
46.32 + /// </summary>
46.33 + public enum WndMessage : int
46.34 + {
46.35 + /// Sent to the dialog procedure immediately before the dialog is displayed.
46.36 + WM_INITDIALOG = 0x0110,
46.37 + /// Sent to the dialog procedure immediately before the dialog is displayed.
46.38 + WM_UNKNOWINIT = 0x0127
46.39 + }
46.40 + #endregion
46.41 +
46.42 + ///////////////////////////////////////////////////////////////////////
46.43 + #region Class WndProcRetEventArgs
46.44 +
46.45 + /// Class used for WH_CALLWNDPROCRET hook event arguments.
46.46 + public class WndProcRetEventArgs : EventArgs
46.47 + {
46.48 + /// wParam parameter.
46.49 + public IntPtr wParam;
46.50 + /// lParam parameter.
46.51 + public IntPtr lParam;
46.52 + /// CWPRETSTRUCT structure.
46.53 + public CwPRetStruct cw;
46.54 +
46.55 + internal WndProcRetEventArgs(IntPtr wParam, IntPtr lParam)
46.56 + {
46.57 + this.wParam = wParam;
46.58 + this.lParam = lParam;
46.59 + cw = new CwPRetStruct();
46.60 + Marshal.PtrToStructure(lParam, cw);
46.61 + }
46.62 + }
46.63 +
46.64 + /// <summary>
46.65 + /// CWPRETSTRUCT structure.
46.66 + /// </summary>
46.67 + [StructLayout(LayoutKind.Sequential)]
46.68 + public class CwPRetStruct
46.69 + {
46.70 + /// Return value.
46.71 + public int lResult;
46.72 + /// lParam parameter.
46.73 + public int lParam;
46.74 + /// wParam parameter.
46.75 + public int wParam;
46.76 + /// Specifies the message.
46.77 + public WndMessage message;
46.78 + /// Handle to the window that processed the message.
46.79 + public IntPtr hwnd;
46.80 + }
46.81 +
46.82 + #endregion
46.83 +
46.84 + ///////////////////////////////////////////////////////////////////////
46.85 + #region Class WndProcRetHook
46.86 +
46.87 + /// <summary>
46.88 + /// Class to expose the windows WH_CALLWNDPROCRET hook mechanism.
46.89 + /// </summary>
46.90 + public class WndProcRetHook : WindowsHook
46.91 + {
46.92 + /// <summary>
46.93 + /// WH_CALLWNDPROCRET hook delegate method.
46.94 + /// </summary>
46.95 + public delegate void WndProcEventHandler(object sender, WndProcRetEventArgs e);
46.96 +
46.97 + private IntPtr hWndHooked;
46.98 +
46.99 + /// <summary>
46.100 + /// Window procedure event.
46.101 + /// </summary>
46.102 + public event WndProcEventHandler WndProcRet;
46.103 +
46.104 + /// <summary>
46.105 + /// Construct a WH_CALLWNDPROCRET hook.
46.106 + /// </summary>
46.107 + /// <param name="hWndHooked">
46.108 + /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
46.109 + /// </param>
46.110 + public WndProcRetHook(IntPtr hWndHooked) : base(HookType.WH_CALLWNDPROCRET)
46.111 + {
46.112 + this.hWndHooked = hWndHooked;
46.113 + this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
46.114 + }
46.115 + /// <summary>
46.116 + /// Construct a WH_CALLWNDPROCRET hook giving a hook filter delegate method.
46.117 + /// </summary>
46.118 + /// <param name="hWndHooked">
46.119 + /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
46.120 + /// </param>
46.121 + /// <param name="func">Hook filter event.</param>
46.122 + public WndProcRetHook(IntPtr hWndHooked, HookProc func) : base(HookType.WH_CALLWNDPROCRET, func)
46.123 + {
46.124 + this.hWndHooked = hWndHooked;
46.125 + this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
46.126 + }
46.127 +
46.128 + // handles the hook event
46.129 + private void WndProcRetHookInvoked(object sender, HookEventArgs e)
46.130 + {
46.131 + WndProcRetEventArgs wpe = new WndProcRetEventArgs(e.wParam, e.lParam);
46.132 + if ((hWndHooked == IntPtr.Zero || wpe.cw.hwnd == hWndHooked) && WndProcRet != null)
46.133 + WndProcRet(this, wpe);
46.134 + return;
46.135 + }
46.136 + }
46.137 + #endregion
46.138 +}
47.1 --- a/Servers.cs Tue Aug 12 20:37:57 2014 +0200
47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
47.3 @@ -1,27 +0,0 @@
47.4 -using System;
47.5 -using System.Windows.Forms;
47.6 -
47.7 -namespace SharpDisplayManager
47.8 -{
47.9 - /// <summary>
47.10 - /// Implement our display service.
47.11 - /// This class is instantiated anew whenever a client send a request.
47.12 - /// </summary>
47.13 - class DisplayServer : IDisplayService
47.14 - {
47.15 - //From IDisplayService
47.16 - public void SetText(int aLineIndex, string aText)
47.17 - {
47.18 - if (aLineIndex == 0)
47.19 - {
47.20 - Program.iMainForm.marqueeLabelTop.Text = aText;
47.21 - }
47.22 - else if (aLineIndex == 1)
47.23 - {
47.24 - Program.iMainForm.marqueeLabelBottom.Text = aText;
47.25 - }
47.26 - }
47.27 -
47.28 - }
47.29 -
47.30 -}
48.1 --- a/Services.cs Tue Aug 12 20:37:57 2014 +0200
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,12 +0,0 @@
48.4 -using System;
48.5 -using System.ServiceModel;
48.6 -
48.7 -namespace SharpDisplayManager
48.8 -{
48.9 - [ServiceContract]
48.10 - public interface IDisplayService
48.11 - {
48.12 - [OperationContract]
48.13 - void SetText(int aLineIndex, string aText);
48.14 - }
48.15 -}
49.1 --- a/SharpDisplayManager.csproj Tue Aug 12 20:37:57 2014 +0200
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,100 +0,0 @@
49.4 -<?xml version="1.0" encoding="utf-8"?>
49.5 -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
49.6 - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
49.7 - <PropertyGroup>
49.8 - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
49.9 - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
49.10 - <ProjectGuid>{1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}</ProjectGuid>
49.11 - <OutputType>WinExe</OutputType>
49.12 - <AppDesignerFolder>Properties</AppDesignerFolder>
49.13 - <RootNamespace>SharpDisplayManager</RootNamespace>
49.14 - <AssemblyName>SharpDisplayManager</AssemblyName>
49.15 - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
49.16 - <FileAlignment>512</FileAlignment>
49.17 - </PropertyGroup>
49.18 - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
49.19 - <PlatformTarget>AnyCPU</PlatformTarget>
49.20 - <DebugSymbols>true</DebugSymbols>
49.21 - <DebugType>full</DebugType>
49.22 - <Optimize>false</Optimize>
49.23 - <OutputPath>bin\Debug\</OutputPath>
49.24 - <DefineConstants>DEBUG;TRACE</DefineConstants>
49.25 - <ErrorReport>prompt</ErrorReport>
49.26 - <WarningLevel>4</WarningLevel>
49.27 - </PropertyGroup>
49.28 - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
49.29 - <PlatformTarget>AnyCPU</PlatformTarget>
49.30 - <DebugType>pdbonly</DebugType>
49.31 - <Optimize>true</Optimize>
49.32 - <OutputPath>bin\Release\</OutputPath>
49.33 - <DefineConstants>TRACE</DefineConstants>
49.34 - <ErrorReport>prompt</ErrorReport>
49.35 - <WarningLevel>4</WarningLevel>
49.36 - </PropertyGroup>
49.37 - <ItemGroup>
49.38 - <Reference Include="Microsoft.VisualBasic" />
49.39 - <Reference Include="Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
49.40 - <Reference Include="System" />
49.41 - <Reference Include="System.Core" />
49.42 - <Reference Include="System.ServiceModel" />
49.43 - <Reference Include="System.Xml.Linq" />
49.44 - <Reference Include="System.Data.DataSetExtensions" />
49.45 - <Reference Include="Microsoft.CSharp" />
49.46 - <Reference Include="System.Data" />
49.47 - <Reference Include="System.Deployment" />
49.48 - <Reference Include="System.Drawing" />
49.49 - <Reference Include="System.Windows.Forms" />
49.50 - <Reference Include="System.Xml" />
49.51 - </ItemGroup>
49.52 - <ItemGroup>
49.53 - <Compile Include="CbtHook.cs" />
49.54 - <Compile Include="DialogBox.cs" />
49.55 - <Compile Include="Display.cs" />
49.56 - <Compile Include="MainForm.cs">
49.57 - <SubType>Form</SubType>
49.58 - </Compile>
49.59 - <Compile Include="MainForm.Designer.cs">
49.60 - <DependentUpon>MainForm.cs</DependentUpon>
49.61 - </Compile>
49.62 - <Compile Include="MarqueeLabel.cs" />
49.63 - <Compile Include="Program.cs" />
49.64 - <Compile Include="Properties\AssemblyInfo.cs" />
49.65 - <Compile Include="Servers.cs" />
49.66 - <Compile Include="Services.cs" />
49.67 - <Compile Include="Win32API.cs" />
49.68 - <Compile Include="WindowsHook.cs" />
49.69 - <Compile Include="WndProcRetHook.cs" />
49.70 - <EmbeddedResource Include="MainForm.resx">
49.71 - <DependentUpon>MainForm.cs</DependentUpon>
49.72 - </EmbeddedResource>
49.73 - <EmbeddedResource Include="Properties\Resources.resx">
49.74 - <Generator>ResXFileCodeGenerator</Generator>
49.75 - <LastGenOutput>Resources.Designer.cs</LastGenOutput>
49.76 - <SubType>Designer</SubType>
49.77 - </EmbeddedResource>
49.78 - <Compile Include="Properties\Resources.Designer.cs">
49.79 - <AutoGen>True</AutoGen>
49.80 - <DependentUpon>Resources.resx</DependentUpon>
49.81 - </Compile>
49.82 - <None Include="Properties\Settings.settings">
49.83 - <Generator>SettingsSingleFileGenerator</Generator>
49.84 - <LastGenOutput>Settings.Designer.cs</LastGenOutput>
49.85 - </None>
49.86 - <Compile Include="Properties\Settings.Designer.cs">
49.87 - <AutoGen>True</AutoGen>
49.88 - <DependentUpon>Settings.settings</DependentUpon>
49.89 - <DesignTimeSharedInput>True</DesignTimeSharedInput>
49.90 - </Compile>
49.91 - </ItemGroup>
49.92 - <ItemGroup>
49.93 - <None Include="App.config" />
49.94 - </ItemGroup>
49.95 - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49.96 - <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
49.97 - Other similar extension points exist, see Microsoft.Common.targets.
49.98 - <Target Name="BeforeBuild">
49.99 - </Target>
49.100 - <Target Name="AfterBuild">
49.101 - </Target>
49.102 - -->
49.103 -</Project>
49.104 \ No newline at end of file
50.1 --- a/SharpDisplayManager.sln Tue Aug 12 20:37:57 2014 +0200
50.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
50.3 @@ -1,20 +0,0 @@
50.4 -
50.5 -Microsoft Visual Studio Solution File, Format Version 12.00
50.6 -# Visual Studio 2012
50.7 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDisplayManager", "SharpDisplayManager.csproj", "{1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}"
50.8 -EndProject
50.9 -Global
50.10 - GlobalSection(SolutionConfigurationPlatforms) = preSolution
50.11 - Debug|Any CPU = Debug|Any CPU
50.12 - Release|Any CPU = Release|Any CPU
50.13 - EndGlobalSection
50.14 - GlobalSection(ProjectConfigurationPlatforms) = postSolution
50.15 - {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50.16 - {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Debug|Any CPU.Build.0 = Debug|Any CPU
50.17 - {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.ActiveCfg = Release|Any CPU
50.18 - {1DA8C1B3-18C5-4E74-BE4E-0B0E15FBAF49}.Release|Any CPU.Build.0 = Release|Any CPU
50.19 - EndGlobalSection
50.20 - GlobalSection(SolutionProperties) = preSolution
50.21 - HideSolutionNode = FALSE
50.22 - EndGlobalSection
50.23 -EndGlobal
51.1 --- a/Win32API.cs Tue Aug 12 20:37:57 2014 +0200
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,100 +0,0 @@
51.4 -//=============================================================================
51.5 -// COPYRIGHT: Prosoft-Lanz
51.6 -//=============================================================================
51.7 -//
51.8 -// $Workfile: Win32API.cs $
51.9 -//
51.10 -// PROJECT : CodeProject Components
51.11 -// VERSION : 1.00
51.12 -// CREATION : 19.02.2003
51.13 -// AUTHOR : JCL
51.14 -//
51.15 -// DETAILS : This class implement Win32 API calls
51.16 -// and the contants used for these calls.
51.17 -//
51.18 -//-----------------------------------------------------------------------------
51.19 -using System;
51.20 -using System.Text;
51.21 -using System.Drawing;
51.22 -using System.Windows.Forms;
51.23 -using System.Runtime.InteropServices;
51.24 -
51.25 -namespace CodeProject.Win32API
51.26 -{
51.27 - ///////////////////////////////////////////////////////////////////////
51.28 - #region Generic declarations
51.29 -
51.30 - /// <summary>
51.31 - /// Rectangle parameters exposed as a structure.
51.32 - /// </summary>
51.33 - public struct RECT
51.34 - {
51.35 - /// <summary>
51.36 - /// Rectangle members.
51.37 - /// </summary>
51.38 - public int left, top, right, bottom;
51.39 - }
51.40 -
51.41 - #endregion
51.42 -
51.43 - ///////////////////////////////////////////////////////////////////////
51.44 - #region Util class
51.45 -
51.46 - /// <summary>
51.47 - /// Utility functions.
51.48 - /// </summary>
51.49 - public sealed class API
51.50 - {
51.51 - private API() {} // To remove the constructor from the documentation!
51.52 -
51.53 - /// <summary>
51.54 - /// Get true multiscreen size.
51.55 - /// </summary>
51.56 - public static Rectangle TrueScreenRect
51.57 - {
51.58 - get
51.59 - {
51.60 - // get the biggest screen area
51.61 - Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea;
51.62 - int left = rectScreen.Left;
51.63 - int top = rectScreen.Top;
51.64 - int right = rectScreen.Right;
51.65 - int bottom = rectScreen.Bottom;
51.66 - foreach (Screen screen in Screen.AllScreens)
51.67 - {
51.68 - left = Math.Min(left, screen.WorkingArea.Left);
51.69 - right = Math.Max(right, screen.WorkingArea.Right);
51.70 - top = Math.Min(top, screen.WorkingArea.Top);
51.71 - bottom = Math.Max(bottom, screen.WorkingArea.Bottom);
51.72 - }
51.73 - return new Rectangle(left, top, right-left, bottom-top);
51.74 - }
51.75 - }
51.76 - }
51.77 -
51.78 - #endregion
51.79 -
51.80 - ///////////////////////////////////////////////////////////////////////
51.81 - #region USER32 class
51.82 -
51.83 - /// <summary>
51.84 - /// Class to expose USER32 API functions.
51.85 - /// </summary>
51.86 - public sealed class USER32
51.87 - {
51.88 - private USER32() {} // To remove the constructor from the documentation!
51.89 -
51.90 - [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
51.91 - internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect);
51.92 -
51.93 - [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
51.94 - internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int w, int h, int repaint);
51.95 -
51.96 - [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
51.97 - internal static extern IntPtr GetActiveWindow();
51.98 -
51.99 - [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
51.100 - internal static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);
51.101 - }
51.102 - #endregion
51.103 -}
52.1 --- a/WindowsHook.cs Tue Aug 12 20:37:57 2014 +0200
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,186 +0,0 @@
52.4 -//=============================================================================
52.5 -// COPYRIGHT: Prosoft-Lanz
52.6 -//=============================================================================
52.7 -//
52.8 -// $Workfile: WindowsHook.cs $
52.9 -//
52.10 -// PROJECT : CodeProject Components
52.11 -// VERSION : 1.00
52.12 -// CREATION : 19.02.2003
52.13 -// AUTHOR : JCL
52.14 -//
52.15 -// DETAILS : This class implement the Windows hook mechanism.
52.16 -// From MSDN, Dino Esposito.
52.17 -//
52.18 -//-----------------------------------------------------------------------------
52.19 -using System;
52.20 -using System.Runtime.InteropServices;
52.21 -
52.22 -namespace CodeProject.Win32API.Hook
52.23 -{
52.24 - ///////////////////////////////////////////////////////////////////////
52.25 - #region Class HookEventArgs
52.26 -
52.27 - /// Class used for hook event arguments.
52.28 - public class HookEventArgs : EventArgs
52.29 - {
52.30 - /// Event code parameter.
52.31 - public int code;
52.32 - /// wParam parameter.
52.33 - public IntPtr wParam;
52.34 - /// lParam parameter.
52.35 - public IntPtr lParam;
52.36 -
52.37 - internal HookEventArgs(int code, IntPtr wParam, IntPtr lParam)
52.38 - {
52.39 - this.code = code;
52.40 - this.wParam = wParam;
52.41 - this.lParam = lParam;
52.42 - }
52.43 - }
52.44 -
52.45 - #endregion
52.46 -
52.47 - ///////////////////////////////////////////////////////////////////////
52.48 - #region Enum HookType
52.49 -
52.50 - /// Hook Types.
52.51 - public enum HookType : int
52.52 - {
52.53 - /// <value>0</value>
52.54 - WH_JOURNALRECORD = 0,
52.55 - /// <value>1</value>
52.56 - WH_JOURNALPLAYBACK = 1,
52.57 - /// <value>2</value>
52.58 - WH_KEYBOARD = 2,
52.59 - /// <value>3</value>
52.60 - WH_GETMESSAGE = 3,
52.61 - /// <value>4</value>
52.62 - WH_CALLWNDPROC = 4,
52.63 - /// <value>5</value>
52.64 - WH_CBT = 5,
52.65 - /// <value>6</value>
52.66 - WH_SYSMSGFILTER = 6,
52.67 - /// <value>7</value>
52.68 - WH_MOUSE = 7,
52.69 - /// <value>8</value>
52.70 - WH_HARDWARE = 8,
52.71 - /// <value>9</value>
52.72 - WH_DEBUG = 9,
52.73 - /// <value>10</value>
52.74 - WH_SHELL = 10,
52.75 - /// <value>11</value>
52.76 - WH_FOREGROUNDIDLE = 11,
52.77 - /// <value>12</value>
52.78 - WH_CALLWNDPROCRET = 12,
52.79 - /// <value>13</value>
52.80 - WH_KEYBOARD_LL = 13,
52.81 - /// <value>14</value>
52.82 - WH_MOUSE_LL = 14
52.83 - }
52.84 - #endregion
52.85 -
52.86 - ///////////////////////////////////////////////////////////////////////
52.87 - #region Class WindowsHook
52.88 -
52.89 - /// <summary>
52.90 - /// Class to expose the windows hook mechanism.
52.91 - /// </summary>
52.92 - public class WindowsHook
52.93 - {
52.94 - /// <summary>
52.95 - /// Hook delegate method.
52.96 - /// </summary>
52.97 - public delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
52.98 -
52.99 - // internal properties
52.100 - internal IntPtr hHook = IntPtr.Zero;
52.101 - internal HookProc filterFunc = null;
52.102 - internal HookType hookType;
52.103 -
52.104 - /// <summary>
52.105 - /// Hook delegate method.
52.106 - /// </summary>
52.107 - public delegate void HookEventHandler(object sender, HookEventArgs e);
52.108 -
52.109 - /// <summary>
52.110 - /// Hook invoke event.
52.111 - /// </summary>
52.112 - public event HookEventHandler HookInvoke;
52.113 -
52.114 - internal void OnHookInvoke(HookEventArgs e)
52.115 - {
52.116 - if (HookInvoke != null)
52.117 - HookInvoke(this, e);
52.118 - }
52.119 -
52.120 - /// <summary>
52.121 - /// Construct a HookType hook.
52.122 - /// </summary>
52.123 - /// <param name="hook">Hook type.</param>
52.124 - public WindowsHook(HookType hook)
52.125 - {
52.126 - hookType = hook;
52.127 - filterFunc = new HookProc(this.CoreHookProc);
52.128 - }
52.129 - /// <summary>
52.130 - /// Construct a HookType hook giving a hook filter delegate method.
52.131 - /// </summary>
52.132 - /// <param name="hook">Hook type</param>
52.133 - /// <param name="func">Hook filter event.</param>
52.134 - public WindowsHook(HookType hook, HookProc func)
52.135 - {
52.136 - hookType = hook;
52.137 - filterFunc = func;
52.138 - }
52.139 -
52.140 - // default hook filter function
52.141 - internal int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
52.142 - {
52.143 - if (code < 0)
52.144 - return CallNextHookEx(hHook, code, wParam, lParam);
52.145 -
52.146 - // let clients determine what to do
52.147 - HookEventArgs e = new HookEventArgs(code, wParam, lParam);
52.148 - OnHookInvoke(e);
52.149 -
52.150 - // yield to the next hook in the chain
52.151 - return CallNextHookEx(hHook, code, wParam, lParam);
52.152 - }
52.153 -
52.154 - /// <summary>
52.155 - /// Install the hook.
52.156 - /// </summary>
52.157 - public void Install()
52.158 - {
52.159 - hHook = SetWindowsHookEx(hookType, filterFunc, IntPtr.Zero, (int)AppDomain.GetCurrentThreadId());
52.160 - }
52.161 -
52.162 -
52.163 - /// <summary>
52.164 - /// Uninstall the hook.
52.165 - /// </summary>
52.166 - public void Uninstall()
52.167 - {
52.168 - if (hHook != IntPtr.Zero)
52.169 - {
52.170 - UnhookWindowsHookEx(hHook);
52.171 - hHook = IntPtr.Zero;
52.172 - }
52.173 - }
52.174 -
52.175 - #region Win32 Imports
52.176 -
52.177 - [DllImport("user32.dll")]
52.178 - internal static extern IntPtr SetWindowsHookEx(HookType code, HookProc func, IntPtr hInstance, int threadID);
52.179 -
52.180 - [DllImport("user32.dll")]
52.181 - internal static extern int UnhookWindowsHookEx(IntPtr hhook);
52.182 -
52.183 - [DllImport("user32.dll")]
52.184 - internal static extern int CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam);
52.185 -
52.186 - #endregion
52.187 - }
52.188 - #endregion
52.189 -}
53.1 --- a/WndProcRetHook.cs Tue Aug 12 20:37:57 2014 +0200
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,135 +0,0 @@
53.4 -//=============================================================================
53.5 -// COPYRIGHT: Prosoft-Lanz
53.6 -//=============================================================================
53.7 -//
53.8 -// $Workfile: WndProcRetHook.cs $
53.9 -//
53.10 -// PROJECT : CodeProject Components
53.11 -// VERSION : 1.00
53.12 -// CREATION : 19.02.2003
53.13 -// AUTHOR : JCL
53.14 -//
53.15 -// DETAILS : This class implement the WH_CALLWNDPROCRET Windows hook mechanism.
53.16 -// From MSDN, Dino Esposito.
53.17 -//
53.18 -// WindowCreate, WindowDestroye and WindowActivate user events.
53.19 -//
53.20 -//-----------------------------------------------------------------------------
53.21 -using System;
53.22 -using System.Runtime.InteropServices;
53.23 -using System.Diagnostics;
53.24 -
53.25 -namespace CodeProject.Win32API.Hook
53.26 -{
53.27 - ///////////////////////////////////////////////////////////////////////
53.28 - #region Enum WndMessage
53.29 -
53.30 - /// <summary>
53.31 - /// windows message.
53.32 - /// </summary>
53.33 - public enum WndMessage : int
53.34 - {
53.35 - /// Sent to the dialog procedure immediately before the dialog is displayed.
53.36 - WM_INITDIALOG = 0x0110,
53.37 - /// Sent to the dialog procedure immediately before the dialog is displayed.
53.38 - WM_UNKNOWINIT = 0x0127
53.39 - }
53.40 - #endregion
53.41 -
53.42 - ///////////////////////////////////////////////////////////////////////
53.43 - #region Class WndProcRetEventArgs
53.44 -
53.45 - /// Class used for WH_CALLWNDPROCRET hook event arguments.
53.46 - public class WndProcRetEventArgs : EventArgs
53.47 - {
53.48 - /// wParam parameter.
53.49 - public IntPtr wParam;
53.50 - /// lParam parameter.
53.51 - public IntPtr lParam;
53.52 - /// CWPRETSTRUCT structure.
53.53 - public CwPRetStruct cw;
53.54 -
53.55 - internal WndProcRetEventArgs(IntPtr wParam, IntPtr lParam)
53.56 - {
53.57 - this.wParam = wParam;
53.58 - this.lParam = lParam;
53.59 - cw = new CwPRetStruct();
53.60 - Marshal.PtrToStructure(lParam, cw);
53.61 - }
53.62 - }
53.63 -
53.64 - /// <summary>
53.65 - /// CWPRETSTRUCT structure.
53.66 - /// </summary>
53.67 - [StructLayout(LayoutKind.Sequential)]
53.68 - public class CwPRetStruct
53.69 - {
53.70 - /// Return value.
53.71 - public int lResult;
53.72 - /// lParam parameter.
53.73 - public int lParam;
53.74 - /// wParam parameter.
53.75 - public int wParam;
53.76 - /// Specifies the message.
53.77 - public WndMessage message;
53.78 - /// Handle to the window that processed the message.
53.79 - public IntPtr hwnd;
53.80 - }
53.81 -
53.82 - #endregion
53.83 -
53.84 - ///////////////////////////////////////////////////////////////////////
53.85 - #region Class WndProcRetHook
53.86 -
53.87 - /// <summary>
53.88 - /// Class to expose the windows WH_CALLWNDPROCRET hook mechanism.
53.89 - /// </summary>
53.90 - public class WndProcRetHook : WindowsHook
53.91 - {
53.92 - /// <summary>
53.93 - /// WH_CALLWNDPROCRET hook delegate method.
53.94 - /// </summary>
53.95 - public delegate void WndProcEventHandler(object sender, WndProcRetEventArgs e);
53.96 -
53.97 - private IntPtr hWndHooked;
53.98 -
53.99 - /// <summary>
53.100 - /// Window procedure event.
53.101 - /// </summary>
53.102 - public event WndProcEventHandler WndProcRet;
53.103 -
53.104 - /// <summary>
53.105 - /// Construct a WH_CALLWNDPROCRET hook.
53.106 - /// </summary>
53.107 - /// <param name="hWndHooked">
53.108 - /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
53.109 - /// </param>
53.110 - public WndProcRetHook(IntPtr hWndHooked) : base(HookType.WH_CALLWNDPROCRET)
53.111 - {
53.112 - this.hWndHooked = hWndHooked;
53.113 - this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
53.114 - }
53.115 - /// <summary>
53.116 - /// Construct a WH_CALLWNDPROCRET hook giving a hook filter delegate method.
53.117 - /// </summary>
53.118 - /// <param name="hWndHooked">
53.119 - /// Handle of the window to be hooked. IntPtr.Zero to hook all window.
53.120 - /// </param>
53.121 - /// <param name="func">Hook filter event.</param>
53.122 - public WndProcRetHook(IntPtr hWndHooked, HookProc func) : base(HookType.WH_CALLWNDPROCRET, func)
53.123 - {
53.124 - this.hWndHooked = hWndHooked;
53.125 - this.HookInvoke += new HookEventHandler(WndProcRetHookInvoked);
53.126 - }
53.127 -
53.128 - // handles the hook event
53.129 - private void WndProcRetHookInvoked(object sender, HookEventArgs e)
53.130 - {
53.131 - WndProcRetEventArgs wpe = new WndProcRetEventArgs(e.wParam, e.lParam);
53.132 - if ((hWndHooked == IntPtr.Zero || wpe.cw.hwnd == hWndHooked) && WndProcRet != null)
53.133 - WndProcRet(this, wpe);
53.134 - return;
53.135 - }
53.136 - }
53.137 - #endregion
53.138 -}