First draft

This commit is contained in:
Jonny007-MKD 2016-11-05 15:45:33 +01:00
parent e527a5a142
commit 46be7dd2bb
No known key found for this signature in database
GPG Key ID: 1D3536487644B3AD
17 changed files with 1611 additions and 0 deletions

20
MultiWallpaperMaker.sln Normal file
View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiWallpaperMaker", "MultiWallpaperMaker\MultiWallpaperMaker.csproj", "{F688D348-5421-4744-A3B3-BF78BAC328A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F688D348-5421-4744-A3B3-BF78BAC328A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F688D348-5421-4744-A3B3-BF78BAC328A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F688D348-5421-4744-A3B3-BF78BAC328A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F688D348-5421-4744-A3B3-BF78BAC328A1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@ -0,0 +1,123 @@
using System;
namespace Trigger.Classes.Device
{
/// <summary>
/// <para>A device. This is very abstract</para>
/// </summary>
public class Device
{
#region Enums
/// <summary><para>Type of the <see cref="Device"/></para></summary>
public enum DeviceType : byte
{
/// <summary><para>This is an IDE disk (HDD, SDD, ...)</para></summary>
IDE,
/// <summary><para>This is a floppy disk</para></summary>
Floppy,
/// <summary><para>This is a compact disk</para></summary>
CD,
/// <summary><para>This is a digital video disk</para></summary>
DVD,
/// <summary><para>This is a blue ray disk</para></summary>
BD,
/// <summary><para>This is a USB disk</para></summary>
USB,
/// <summary><para>This can be any disk</para></summary>
Any,
/// <summary><para>This is a screen</para></summary>
Screen,
}
#endregion
#region Properties
#region Instance
/// <summary><para>The name of the <see cref="Device"/></para></summary>
public string Name
{
get;
internal set;
}
/// <summary><para>The Id of the <see cref="Device"/></para></summary>
public string Id
{
get;
internal set;
}
/// <summary><para>The type of the <see cref="Device"/></para></summary>
public DeviceType Type
{
get;
internal set;
}
/// <summary><para>Get the model of this disk. This is the manufacturer's name.</para></summary>
public string Model
{
get;
internal set;
}
#endregion
#endregion
#region Constructor
/// <summary>
/// <para>Creates an instance of this <see cref="Device"/></para>
/// </summary>
public Device(string Id)
{
this.Id = Id;
}
#endregion
#region Operators
/// <summary>
/// <para>Gets a unique code of this <see cref="Device"/></para>
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return this.Id.GetHashCode();
}
/// <summary></summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <returns></returns>
public static bool operator ==(Device A, Device B)
{
if ((object)A == null)
return (object)B == null;
if ((object)B == null)
return false;
return A.Id == B.Id;
}
/// <summary></summary>
/// <param name="A"></param>
/// <param name="B"></param>
/// <returns></returns>
public static bool operator !=(Device A, Device B)
{
return !(A == B);
}
/// <summary>
/// <para>Compares to <see cref="Device"/>s (only the IDs)</para>
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object obj)
{
Device that = obj as Device;
if (that == null)
return false;
return this.Id == that.Id;
}
#endregion
}
}

91
MultiWallpaperMaker/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,91 @@
namespace MultiWallpaperMaker
{
partial class Form1
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(284, 262);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(227, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(45, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Flip X";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button3
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button3.Location = new System.Drawing.Point(227, 227);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(45, 23);
this.button3.TabIndex = 4;
this.button3.Text = "Save";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.button3);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
}
}

View File

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Trigger.Classes.Screen;
namespace MultiWallpaperMaker
{
public partial class Form1 : Form
{
private string imagePath;
public string ImagePath {
get { return this.imagePath; }
set {
try {
this.Image = new Bitmap(System.Drawing.Image.FromFile(value));
this.imagePath = value;
} catch (Exception e) {
MessageBox.Show(e.Message);
}
}
}
public event EventHandler ImageChanged;
private Bitmap image;
public Bitmap Image {
get { return this.image; }
private set {
if ((object)this.image != null) this.image.Dispose();
this.image = value;
if (this.ImageChanged != null) this.ImageChanged(this, new EventArgs());
}
}
public Bitmap DisplayedImage {
get {
if ((object)this.image == null) return null;
Bitmap image = this.image.Clone() as Bitmap;
using (Graphics g = Graphics.FromImage(image)) {
Color c = Color.FromArgb((int)((uint)new Random().Next(0x00FFFFFF) | 0xFF000000));
SolidBrush brush = new SolidBrush(c);
Pen pen = new Pen(brush, 2);
foreach (var screen in this.Screens) {
g.DrawRectangle(pen, this.getRectangle(screen));
}
pen.Dispose();
}
return image;
}
}
private void updateDisplay() {
if ((object)this.pictureBox1.Image != null) this.pictureBox1.Image.Dispose();
this.pictureBox1.Image = this.DisplayedImage;
}
public double downscale;
public double Downscale {
get { return this.downscale; }
private set {
if (this.downscale == value) return;
this.downscale = value;
if (this.DownscaleChanged != null) this.DownscaleChanged(this, new EventArgs());
}
}
public event EventHandler DownscaleChanged;
public Point startPoint;
public Point StartPoint
{
get { return this.startPoint; }
private set {
if (this.startPoint == value) return;
this.startPoint = value;
if (this.StartPointChanged != null) this.StartPointChanged(this, new EventArgs());
}
}
public event EventHandler StartPointChanged;
public List<Trigger.Classes.Screen.ScreenEx> Screens { get; private set; }
private Nullable<Point> mouseDragStart;
public Form1()
{
InitializeComponent();
this.AllowDrop = true;
this.DragEnter += Form1_DragEnter;
this.DragDrop += Form1_DragDrop;
this.MouseWheel += (s, e) => this.Downscale += e.Delta / 10000.0;
this.ImageChanged += (s, e) => this.updateDisplay();
this.DownscaleChanged += (s, e) => this.updateDisplay();
this.StartPointChanged += (s, e) => this.updateDisplay();
this.pictureBox1.MouseDown += (s, e) => this.mouseDragStart = e.Location;
this.pictureBox1.MouseUp += (s, e) => this.mouseDragStart = null;
this.pictureBox1.MouseMove += Form1_MouseMove;
this.Screens = Trigger.Status.Screen.AllScreens;
this.Downscale = 1;
}
void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (this.mouseDragStart == null) return;
this.StartPoint += new Size(e.Location - new Size(this.mouseDragStart.Value));
this.mouseDragStart = e.Location;
}
void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
else e.Effect = DragDropEffects.None;
}
void Form1_DragDrop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;
string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop);
this.ImagePath = paths[0];
}
private void button1_Click(object sender, EventArgs e)
{
if ((object)this.Image == null) return;
this.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
if (this.ImageChanged != null) this.ImageChanged(this, new EventArgs());
}
private void button3_Click(object sender, EventArgs e)
{
if (this.Image == null) return;
string file = Path.GetDirectoryName(this.imagePath);
file = Path.Combine(file, Path.GetFileNameWithoutExtension(this.imagePath));
for (int i = 0; i < this.Screens.Count; i++) {
Bitmap image = this.Image.Clone(this.getRectangle(this.Screens[i]), this.Image.PixelFormat);
image.Save(file + i + ".bmp");
}
}
Rectangle getRectangle(ScreenEx screen) {
var location = this.StartPoint + new Size((int)(screen.Bounds.Location.X * this.Downscale), (int)(screen.Bounds.Location.Y * this.Downscale));
var size = new Size((int)(screen.Bounds.Size.Width * this.Downscale), (int)(screen.Bounds.Size.Height * this.Downscale));
return new Rectangle(location, size);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F688D348-5421-4744-A3B3-BF78BAC328A1}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MultiWallpaperMaker</RootNamespace>
<AssemblyName>MultiWallpaperMaker</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Device.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScreenAction.cs" />
<Compile Include="ScreenEx.cs" />
<Compile Include="ScreenSettingsDevMode.cs" />
<Compile Include="ScreenStatus.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MultiWallpaperMaker
{
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("MultiWallpaperMaker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MultiWallpaperMaker")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("b0c2bd4b-7045-4bff-9c98-c1519048f1bc")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.34209
//
// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
// der Code neu generiert wird.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MultiWallpaperMaker.Properties
{
/// <summary>
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
/// </summary>
// Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
// über ein Tool wie ResGen oder Visual Studio automatisch generiert.
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
// mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MultiWallpaperMaker.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
/// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MultiWallpaperMaker.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,124 @@
using System.Runtime.InteropServices;
using Trigger.Classes.Screen;
using System;
namespace Trigger.Actions
{
/// <summary>
/// <para>Actions dealing with screens and screen settings</para>
/// </summary>
public class Screen
{
#region Enums
internal enum DispChange : sbyte
{
/// <summary><para>The settings change was successful.</para></summary>
SUCCESSFUL = 0,
/// <summary><para>The computer must be restarted for the graphics mode to work.</para></summary>
RESTART = 1,
/// <summary><para>The display driver failed the specified graphics mode.</para></summary>
FAILED = -1,
/// <summary><para>The graphics mode is not supported.</para></summary>
BADMODE = -2,
/// <summary><para>Unable to write settings to the registry.</para></summary>
NOTUPDATED = -3,
/// <summary><para>An invalid set of flags was passed in.</para></summary>
BADFLAGS = -4,
/// <summary><para>An invalid parameter was passed in. This can include an invalid flag or combination of flags.</para></summary>
BADPARAM = -5,
/// <summary><para>The settings change was unsuccessful because the system is DualView capable.</para></summary>
BADDUALVIEW = -6,
}
/// <summary>
/// <para>Indicates how the graphics mode should be changed</para>
/// </summary>
[Flags]
internal enum CDS : int
{
///<summary><para>The mode is temporary in nature.</para><para>If you change to and from another desktop, this mode will not be reset.</para></summary>
FULLSCREEN = 0x00000004,
///<summary><para>The settings will be saved in the global settings area so that they will affect all users on the machine. Otherwise, only the settings for the user are modified. This flag is only valid when specified with the UPDATEREGISTRY flag.</para></summary>
GLOBAL = 0x00000008,
///<summary><para>The settings will be saved in the registry, but will not take effect. This flag is only valid when specified with the UPDATEREGISTRY flag.</para></summary>
NORESET = 0x10000000,
///<summary><para>The settings should be changed, even if the requested settings are the same as the current settings.</para></summary>
RESET = 0x40000000,
/// <summary></summary>
RESET_EX = 0x20000000,
///<summary><para>This device will become the primary device.</para></summary>
SET_PRIMARY = 0x00000010,
///<summary><para>The system tests if the requested graphics mode could be set.</para></summary>
TEST = 0x00000002,
///<summary><para>The graphics mode for the current screen will be changed dynamically and the graphics mode will be updated in the registry. The mode information is stored in the USER profile.</para></summary>
UPDATEREGISTRY = 0x00000001,
///<summary><para>When set, the lParam parameter is a pointer to a VIDEOPARAMETERS structure.</para></summary>
VIDEOPARAMETERS = 0x00000020,
///<summary><para>Enables settings changes to unsafe graphics modes.</para></summary>
ENABLE_UNSAFE_MODES = 0x00000100,
///<summary><para>Disables settings changes to unsafe graphics modes.</para></summary>
DISABLE_UNSAFE_MODES = 0x00000200,
}
#endregion
#region Dll imports
/// <summary>
/// <para>The ChangeDisplaySettingsEx function changes the settings of the specified display device to the specified graphics mode.</para>
/// </summary>
/// <param name="lpszDeviceName">
/// <para>String that specifies the display device whose graphics mode will change. Only display device names as returned by EnumDisplayDevices are valid.</para>
/// <para>The <paramref name="lpszDeviceName"/> parameter can be NULL. A NULL value specifies the default display device. The default device can be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag.</para>
/// </param>
/// <param name="lpDevMode"><para>A pointer to a <see cref="ScreenSettingsDevMode"/> structure that describes the new graphics mode. If <paramref name="lpDevMode"/> is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the <paramref name="lpDevMode"/> parameter and 0 for the <paramref name="dwFlags"/> parameter is the easiest way to return to the default mode after a dynamic mode change.</para></param>
/// <param name="hwnd"></param>
/// <param name="dwFlags"></param>
/// <param name="lParam"></param>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
internal static extern int ChangeDisplaySettingsEx(string lpszDeviceName, ref ScreenSettingsDevMode lpDevMode, IntPtr hwnd, int dwFlags, IntPtr lParam);
#endregion
#region Methods
/// <summary>
/// <para>The ChangeDisplaySettingsEx function changes the settings of the specified display device to the specified graphics mode.</para>
/// <para>Use this one if you are not sure</para>
/// </summary>
/// <param name="deviceName">
/// <para>String that specifies the display device whose graphics mode will change. Only display device names as returned by EnumDisplayDevices are valid.</para>
/// <para>The <paramref name="deviceName"/> parameter can be NULL. A NULL value specifies the default display device. The default device can be determined by calling EnumDisplayDevices and checking for the DISPLAY_DEVICE_PRIMARY_DEVICE flag.</para>
/// </param>
/// <param name="devMode"><para>A pointer to a <see cref="ScreenSettingsDevMode"/> structure that describes the new graphics mode. If <paramref name="devMode"/> is NULL, all the values currently in the registry will be used for the display setting. Passing NULL for the <paramref name="devMode"/> parameter and 0 for the <paramref name="dwFlags"/> parameter is the easiest way to return to the default mode after a dynamic mode change.</para></param>
/// <param name="dwFlags"></param>
/// <returns></returns>
internal static DispChange ChangeDisplaySettingsEx(string deviceName, ref ScreenSettingsDevMode devMode, CDS dwFlags)
{
return (DispChange)ChangeDisplaySettingsEx(deviceName, ref devMode, IntPtr.Zero, (int)dwFlags, IntPtr.Zero);
}
/// <summary>
/// <para>Updates the screen's settings</para>
/// </summary>
/// <param name="screen"></param>
/// <returns></returns>
public static bool UpdateScreen(ScreenEx screen)
{
ScreenSettingsDevMode devMode = screen.ToDEVMODE();
DispChange result = ChangeDisplaySettingsEx(screen.Name, ref devMode, CDS.RESET | CDS.UPDATEREGISTRY);
if (result >= 0)
return true;
else
return false;
}
/// <summary>
/// <para>Updates the screen's settings and sets it as primary screen</para>
/// </summary>
/// <param name="screen"></param>
/// <returns></returns>
public static bool UpdateScreenAndMakePrimary(ScreenEx screen)
{
ScreenSettingsDevMode devMode = screen.ToDEVMODE();
return ChangeDisplaySettingsEx(screen.Name, ref devMode, CDS.RESET | CDS.UPDATEREGISTRY | CDS.SET_PRIMARY) >= 0;
}
#endregion
}
}

View File

@ -0,0 +1,301 @@
using System;
using Systemm = System;
using Forms = System.Windows.Forms;
using System.Windows.Forms;
using System.Drawing;
namespace Trigger.Classes.Screen
{
/// <summary>For fixed-resolution display devices only, how the display presents a low-resolution mode on a higher-resolution display. For example, if a display device's resolution is fixed at 1024 x 768 pixels but its mode is set to 640 x 480 pixels, the device can either display a 640 x 480 image somewhere in the interior of the 1024 x 768 screen space or stretch the 640 x 480 image to fill the larger screen space</summary>
public enum FixedOutput : byte
{
/// <summary>The display's default setting.</summary>
Default = 0,
/// <summary>The low-resolution image is centered in the larger screen space.</summary>
Stretch = 1,
/// <summary>The low-resolution image is stretched to fill the larger screen space.</summary>
Center = 2,
}
/// <summary>Specifies the color resolution, in bits per pixel, of the display device</summary>
public enum ColorDepth : byte
{
/// <summary>4 Bit -> 16 Colors</summary>
_16_Colors = 4,
/// <summary>4 Bit -> 16 Colors</summary>
_4bit = 4,
/// <summary>8 Bit -> 256 Colors</summary>
_256_Colors = 8,
/// <summary>8 Bit -> 256 Colors</summary>
_8bit = 8,
/// <summary>16 Bit -> 65.536 Colors</summary>
_65536_Colors = 16,
/// <summary>16 Bit -> 65.536 Colors</summary>
_16bit = 16,
/// <summary>32 Bit -> 4.294.967.296 Colors</summary>
_4294967296_Colors = 32,
/// <summary>32 Bit -> 4.294.967.296 Colors</summary>
_32bit = 32,
}
/// <summary><para>A class that provides more information than <see cref="Screen"/></para></summary>
public class ScreenEx : Device.Device // : Forms.Screen
{
#region Properties
/// <summary><para>Gets the bounds of the display.</para></summary>
private Rectangle bounds;
/// <summary><para>Gets the bounds of the display.</para></summary>
public Rectangle Bounds
{
get { return bounds; }
set
{
bounds = value;
this.fields |= DM.PELSWIDTH | DM.PELSHEIGHT;
}
}
/// <summary><para>Specifies the color resolution, in bits per pixel, of the display device</para></summary>
private byte bitsPerPixel;
/// <summary><para>Specifies the color resolution, in bits per pixel, of the display device</para></summary>
public byte BitsPerPixel
{
get { return bitsPerPixel; }
set
{
bitsPerPixel = value;
fields |= DM.BITSPERPEL;
}
}
/// <summary><para>Specifies the color resolution, in bits per pixel, of the display device</para></summary>
public ColorDepth ColorDepth
{
get { return (ColorDepth)this.BitsPerPixel; }
set { this.BitsPerPixel = (byte)value; }
}
/// <summary><para>Gets a value indicating whether a particular display is the primary device.</para></summary>
private bool primary;
/// <summary><para>Gets a value indicating whether a particular display is the primary device.</para></summary>
public bool Primary
{
get { return primary; }
private set { primary = value; }
}
/// <summary>The version number of the initialization data specification on which the structure is based</summary>
private short specVersion;
/// <summary>The version number of the initialization data specification on which the structure is based</summary>
public short SpecVersion
{
get { return specVersion; }
private set { specVersion = value; }
}
/// <summary>The driver version number assigned by the driver developer</summary>
private short driverVersion;
/// <summary>The driver version number assigned by the driver developer</summary>
public short DriverVersion
{
get { return driverVersion; }
private set { driverVersion = value; }
}
/// <summary><para>For display devices only, the orientation at which images should be presented.</para></summary>
private Forms.ScreenOrientation orientation;
/// <summary><para>For display devices only, the orientation at which images should be presented.</para></summary>
public Forms.ScreenOrientation Orientation
{
get { return orientation; }
set
{
orientation = value;
fields |= DM.DISPLAYORIENTATION;
}
}
/// <summary>For fixed-resolution display devices only, how the display presents a low-resolution mode on a higher-resolution display. For example, if a display device's resolution is fixed at 1024 x 768 pixels but its mode is set to 640 x 480 pixels, the device can either display a 640 x 480 image somewhere in the interior of the 1024 x 768 screen space or stretch the 640 x 480 image to fill the larger screen space</summary>
private FixedOutput fixedOutput;
/// <summary>For fixed-resolution display devices only, how the display presents a low-resolution mode on a higher-resolution display. For example, if a display device's resolution is fixed at 1024 x 768 pixels but its mode is set to 640 x 480 pixels, the device can either display a 640 x 480 image somewhere in the interior of the 1024 x 768 screen space or stretch the 640 x 480 image to fill the larger screen space</summary>
public FixedOutput FixedOutput
{
get { return fixedOutput; }
set
{
fixedOutput = value;
fields |= DM.DISPLAYFIXEDOUTPUT;
}
}
/// <summary><para>The number of pixels per logical inch.</para></summary>
private short logPixels;
/// <summary><para>The number of pixels per logical inch.</para></summary>
public short LogPixels
{
get { return logPixels; }
set
{
logPixels = value;
fields |= DM.LOGPIXELS;
}
}
/// <summary><para>Specifies the device's display mode. This member can be a combination of the following values.</para></summary>
/// <example>
/// <para>GRAYSCALE: Specifies that the display is a noncolor device. If this flag is not set, color is assumed.</para>
/// <para>INTERLACED: Specifies that the display mode is interlaced. If the flag is not set, noninterlaced is assumed.</para>
/// </example>
private int displayFlags;
/// <summary><para>Specifies the device's display mode. This member can be a combination of the following values.</para></summary>
/// <example>
/// <para>GRAYSCALE: Specifies that the display is a noncolor device. If this flag is not set, color is assumed.</para>
/// <para>INTERLACED: Specifies that the display mode is interlaced. If the flag is not set, noninterlaced is assumed.</para>
/// </example>
public int DisplayFlags
{
get { return displayFlags; }
set
{
displayFlags = value;
fields |= DM.DISPLAYFLAGS;
}
}
/// <summary>
/// <para>Specifies the frequency, in hertz (cycles per second), of the display device in a particular mode. This value is also known as the display device's vertical refresh rate. Display drivers use this member. It is used, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.</para>
/// <para>May be the value 0 or 1. These values represent the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use display functions such as ChangeDisplaySettings.</para>
/// </summary>
private byte frequency;
/// <summary>
/// <para>Specifies the frequency, in hertz (cycles per second), of the display device in a particular mode. This value is also known as the display device's vertical refresh rate. Display drivers use this member. It is used, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.</para>
/// <para>May be the value 0 or 1. These values represent the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use display functions such as ChangeDisplaySettings.</para>
/// </summary>
public byte Frequency
{
get { return frequency; }
set
{
frequency = value;
fields |= DM.DISPLAYFREQUENCY;
}
}
/// <summary>Specifies whether certain members of the DEVMODE structure have been initialized. If a member is initialized, its corresponding bit is set, otherwise the bit is clear. A driver supports only those DEVMODE members that are appropriate for the printer or display technology.</summary>
/// <remarks>http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565%28v=vs.85%29.aspx</remarks>
private DM fields = 0;
#endregion
#region enum Field
/// <summary>
/// <para>Specifies whether certain members of the DEVMODE structure have been initialized. If a member is initialized, its corresponding bit is set, otherwise the bit is clear. A driver supports only those DEVMODE members that are appropriate for the printer or display technology.</para>
/// </summary>
[Flags]
private enum DM : int
{
///<summary><para></para></summary>
ORIENTATION = 0x00000001,
///<summary><para></para></summary>
PAPERSIZE = 0x00000002,
///<summary><para></para></summary>
PAPERLENGTH = 0x00000004,
///<summary><para></para></summary>
PAPERWIDTH = 0x00000008,
///<summary><para></para></summary>
SCALE = 0x00000010,
///<summary><para></para></summary>
COPIES = 0x00000100,
///<summary><para></para></summary>
DEFAULTSOURCE = 0x00000200,
///<summary><para></para></summary>
PRINTQUALITY = 0x00000400,
///<summary><para></para></summary>
POSITION = 0x00000020,
///<summary><para></para></summary>
DISPLAYORIENTATION = 0x00000080,
///<summary><para></para></summary>
DISPLAYFIXEDOUTPUT = 0x20000000,
///<summary><para></para></summary>
COLOR = 0x00000800,
///<summary><para></para></summary>
DUPLEX = 0x00001000,
///<summary><para></para></summary>
YRESOLUTION = 0x00002000,
///<summary><para></para></summary>
TTOPTION = 0x00004000,
///<summary><para></para></summary>
COLLATE = 0x00008000,
///<summary><para></para></summary>
FORMNAME = 0x00010000,
///<summary><para></para></summary>
LOGPIXELS = 0x00020000,
///<summary><para></para></summary>
BITSPERPEL = 0x00040000,
///<summary><para></para></summary>
PELSWIDTH = 0x00080000,
///<summary><para></para></summary>
PELSHEIGHT = 0x00100000,
///<summary><para></para></summary>
DISPLAYFLAGS = 0x00200000,
///<summary><para></para></summary>
NUP = 0x00000040,
///<summary><para></para></summary>
DISPLAYFREQUENCY = 0x00400000,
///<summary><para></para></summary>
ICMMETHOD = 0x00800000,
///<summary><para></para></summary>
ICMINTENT = 0x01000000,
///<summary><para></para></summary>
MEDIATYPE = 0x02000000,
///<summary><para></para></summary>
DITHERTYPE = 0x04000000,
///<summary><para></para></summary>
PANNINGWIDTH = 0x08000000,
///<summary><para></para></summary>
PANNINGHEIGHT = 0x10000000,
}
#endregion
#region Constructors
/// <summary>
/// <para>Create a new instance of <see cref="ScreenEx"/></para>
/// </summary>
/// <param name="screen"></param>
/// <param name="devMode">A <see cref="ScreenSettingsDevMode"/> received from <see cref="Status.Screen.EnumDisplaySettings"/></param>
public ScreenEx(Forms.Screen screen, ScreenSettingsDevMode devMode) : base(screen.DeviceName)
{
this.Type = DeviceType.Screen;
this.Name = screen.DeviceName;
this.BitsPerPixel = (byte)screen.BitsPerPixel;
this.Bounds = new Rectangle(screen.Bounds.Location, screen.Bounds.Size);
this.Primary = screen.Primary;
this.SpecVersion = devMode.dmSpecVersion;
this.DriverVersion = devMode.dmDriverVersion;
this.FixedOutput = (FixedOutput)devMode.dmDisplayFixedOutput;
this.LogPixels = devMode.dmLogPixels;
this.ColorDepth = (ColorDepth)devMode.dmBitsPerPel;
this.DisplayFlags = devMode.dmDisplayFlags;
this.Frequency = (byte)devMode.dmDisplayFrequency;
this.Orientation = (ScreenOrientation)devMode.dmDisplayOrientation;
this.fields = 0;
}
#endregion
#region Methods
/// <summary>
/// <para>Converts this class to a <see cref="ScreenSettingsDevMode"/> struct which then may be used to update the settings</para>
/// </summary>
/// <returns></returns>
public ScreenSettingsDevMode ToDEVMODE()
{
ScreenSettingsDevMode devMode = new ScreenSettingsDevMode(true);
devMode.dmBitsPerPel = this.BitsPerPixel;
devMode.dmDeviceName = this.Name;
devMode.dmDisplayFixedOutput = (int)this.FixedOutput;
devMode.dmDisplayFlags = this.DisplayFlags;
devMode.dmDisplayFrequency = this.Frequency;
devMode.dmDisplayOrientation = (int)this.Orientation;
devMode.dmDriverVersion = this.DriverVersion;
devMode.dmFields = (int)this.fields;
devMode.dmFormName = "";
devMode.dmLogPixels = this.LogPixels;
devMode.dmPelsHeight = this.Bounds.Height;
devMode.dmPelsWidth = this.Bounds.Width;
devMode.dmPositionX = this.Bounds.X;
devMode.dmPositionY = this.Bounds.Y;
devMode.dmSpecVersion = this.SpecVersion;
devMode.dmSize = (short)Systemm.Runtime.InteropServices.Marshal.SizeOf(devMode);
return devMode;
}
#endregion
}
}

View File

@ -0,0 +1,183 @@
using System;
using System.Runtime.InteropServices;
namespace Trigger.Classes.Screen
{
/// <summary>
/// <para> The <see cref="ScreenSettingsDevMode"/> (DEVMODE) data structure contains information about the initialization and environment of a printer or a display device.</para>
/// <para>Here it will only be used for screens</para>
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ScreenSettingsDevMode
{
/// <summary>The name of the device</summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string dmDeviceName;
/// <summary>The version number of the initialization data specification on which the structure is based</summary>
public short dmSpecVersion;
/// <summary>The driver version number assigned by the driver developer</summary>
public short dmDriverVersion;
/// <summary>Specifies the size, in bytes, of the DEVMODE structure, not including any private driver-specific data that might follow the structure's public members. Set this member to sizeof (DEVMODE) to indicate the version of the DEVMODE structure being used. </summary>
public short dmSize;
/// <summary>Contains the number of bytes of private driver-data that follow this structure. If a device driver does not use device-specific information, set this member to zero.</summary>
public short dmDriverExtra;
/// <summary>Specifies whether certain members of the DEVMODE structure have been initialized. If a member is initialized, its corresponding bit is set, otherwise the bit is clear. A driver supports only those DEVMODE members that are appropriate for the printer or display technology.</summary>
/// <remarks>http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565%28v=vs.85%29.aspx</remarks>
public int dmFields;
/// <summary>For display devices only, a POINTL structure that indicates the positional coordinates of the display device in reference to the desktop area. The primary display device is always located at coordinates (0,0).</summary>
public int dmPositionX;
/// <summary>For display devices only, a POINTL structure that indicates the positional coordinates of the display device in reference to the desktop area. The primary display device is always located at coordinates (0,0).</summary>
public int dmPositionY;
/// <summary><para>For display devices only, the orientation at which images should be presented. If DM_DISPLAYORIENTATION is not set, this member must be zero. If DM_DISPLAYORIENTATION is set, this member must be one of the following values</para></summary>
/// <example>
/// <para>DMDO_DEFAULT (0): The display orientation is the natural orientation of the display device; it should be used as the default.</para>
/// <para>DMDO_90 (1): The display orientation is rotated 90 degrees (measured clockwise) from DMDO_DEFAULT.</para>
/// <para>DMDO_180 (2): The display orientation is rotated 180 degrees (measured clockwise) from DMDO_DEFAULT.</para>
/// <para>DMDO_270 (3): The display orientation is rotated 270 degrees (measured clockwise) from DMDO_DEFAULT.</para>
/// </example>
/// <remarks>Windows 2000: Not supported</remarks>
public int dmDisplayOrientation;
/// <summary>For fixed-resolution display devices only, how the display presents a low-resolution mode on a higher-resolution display. For example, if a display device's resolution is fixed at 1024 x 768 pixels but its mode is set to 640 x 480 pixels, the device can either display a 640 x 480 image somewhere in the interior of the 1024 x 768 screen space or stretch the 640 x 480 image to fill the larger screen space. If DM_DISPLAYFIXEDOUTPUT is not set, this member must be zero. If DM_DISPLAYFIXEDOUTPUT is set, this member must be one of the following values</summary>
/// <example>
/// <para>DMDFO_DEFAULT: The display's default setting.</para>
/// <para>DMDFO_CENTER: The low-resolution image is centered in the larger screen space.</para>
/// <para>DMDFO_STRETCH: The low-resolution image is stretched to fill the larger screen space.</para>
/// </example>
/// <remarks>Windows 2000: Not supported</remarks>
public int dmDisplayFixedOutput;
/// <summary> Switches between color and monochrome on color printers. The following are the possible values:</summary>
/// <example><para>DMCOLOR_COLOR</para><para>DMCOLOR_MONOCHROME</para></example>
public short dmColor;
/// <summary><para>Selects duplex or double-sided printing for printers capable of duplex printing. Following are the possible values.</para></summary>
/// <example>
/// <para>DMDUP_SIMPLEX: Normal (nonduplex) printing.</para>
/// <para>DMDUP_HORIZONTAL: Short-edge binding, that is, the long edge of the page is horizontal.</para>
/// <para>DMDUP_VERTICAL: Long-edge binding, that is, the long edge of the page is vertical.</para>
/// </example>
public short dmDuplex;
/// <summary><para>Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution, in dots per inch, of the printer.</para></summary>
public short dmYResolution;
/// <summary><para> Specifies how TrueType fonts should be printed. This member can be one of the following values.</para></summary>
/// <example>
/// <para>DMTT_BITMAP: Prints TrueType fonts as graphics. This is the default action for dot-matrix printers.</para>
/// <para>DMTT_DOWNLOAD: Downloads TrueType fonts as soft fonts. This is the default action for Hewlett-Packard printers that use Printer Control Language (PCL).</para>
/// <para>DMTT_DOWNLOAD_OUTLINE: Downloads TrueType fonts as outline soft fonts. </para>
/// <para>DMTT_SUBDEV: Substitutes device fonts for TrueType fonts. This is the default action for PostScript printers.</para>
/// </example>
public short dmTTOption;
/// <summary><para> Specifies whether collation should be used when printing multiple copies. (This member is ignored unless the printer driver indicates support for collation by setting the dmFields member to DM_COLLATE.) This member can be one of the following values.</para></summary>
/// <example>
/// <para>DMCOLLATE_TRUE: Collate when printing multiple copies.</para>
/// <para>DMCOLLATE_FALSE: Do not collate when printing multiple copies.</para>
/// </example>
public short dmCollate;
/// <summary><para>A zero-terminated character array that specifies the name of the form to use; for example, "Letter" or "Legal". A complete set of names can be retrieved by using the EnumForms function.</para></summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string dmFormName;
/// <summary><para>The number of pixels per logical inch. Printer drivers do not use this member.</para></summary>
public short dmLogPixels;
/// <summary><para>Specifies the color resolution, in bits per pixel, of the display device (for example: 4 bits for 16 colors, 8 bits for 256 colors, or 16 bits for 65,536 colors). Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.</para></summary>
public short dmBitsPerPel;
/// <summary>Specifies the width, in pixels, of the visible device surface. Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.</summary>
public int dmPelsWidth;
/// <summary>Specifies the height, in pixels, of the visible device surface. Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.</summary>
public int dmPelsHeight;
/// <summary><para>Specifies the device's display mode. This member can be a combination of the following values.</para></summary>
/// <example>
/// <para>DM_GRAYSCALE: Specifies that the display is a noncolor device. If this flag is not set, color is assumed.</para>
/// <para>DM_INTERLACED: Specifies that the display mode is interlaced. If the flag is not set, noninterlaced is assumed.</para>
/// </example>
public int dmDisplayFlags;
/// <summary>
/// <para>Specifies the frequency, in hertz (cycles per second), of the display device in a particular mode. This value is also known as the display device's vertical refresh rate. Display drivers use this member. It is used, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.</para>
/// <para>When you call the EnumDisplaySettings function, the dmDisplayFrequency member may return with the value 0 or 1. These values represent the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use display functions such as ChangeDisplaySettings.</para>
/// </summary>
public int dmDisplayFrequency;
/// <summary><para>Specifies how ICM is handled. For a non-ICM application, this member determines if ICM is enabled or disabled. For ICM applications, the system examines this member to determine how to handle ICM support. This member can be one of the following predefined values, or a driver-defined value greater than or equal to the value of DMICMMETHOD_USER.</para></summary>
/// <example>
/// <para>DMICMMETHOD_NONE: Specifies that ICM is disabled.</para>
/// <para>DMICMMETHOD_SYSTEM: Specifies that ICM is handled by Windows.</para>
/// <para>DMICMMETHOD_DRIVER: Specifies that ICM is handled by the device driver.</para>
/// <para>DMICMMETHOD_DEVICE: Specifies that ICM is handled by the destination device.</para>
/// </example>
/// <remarks>The printer driver must provide a user interface for setting this member. Most printer drivers support only the DMICMMETHOD_SYSTEM or DMICMMETHOD_NONE value. Drivers for PostScript printers support all values.</remarks>
public int dmICMMethod;
/// <summary><para>Specifies which color matching method, or intent, should be used by default. This member is primarily for non-ICM applications. ICM applications can establish intents by using the ICM functions. This member can be one of the following predefined values, or a driver defined value greater than or equal to the value of DMICM_USER.</para></summary>
/// <example>
/// <para>DMICM_ABS_COLORIMETRIC: Color matching should optimize to match the exact color requested without white point mapping. This value is most appropriate for use with proofing.</para>
/// <para>DMICM_COLORIMETRIC: Color matching should optimize to match the exact color requested. This value is most appropriate for use with business logos or other images when an exact color match is desired.</para>
/// <para>DMICM_CONTRAST: Color matching should optimize for color contrast. This value is the most appropriate choice for scanned or photographic images when dithering is desired.</para>
/// <para>DMICM_SATURATE: Color matching should optimize for color saturation. This value is the most appropriate choice for business graphs when dithering is not desired.</para>
/// </example>
public int dmICMIntent;
/// <summary><para> Specifies the type of media being printed on. The member can be one of the following predefined values, or a driver-defined value greater than or equal to the value of DMMEDIA_USER.</para></summary>
/// <example>
/// <para>DMMEDIA_STANDARD: Plain paper.</para>
/// <para>DMMEDIA_GLOSSY: Glossy paper.</para>
/// <para>DMMEDIA_TRANSPARENCY: Transparent film.</para>
/// </example>
/// <remarks> To retrieve a list of the available media types for a printer, use the DeviceCapabilities function with the DC_MEDIATYPES flag.</remarks>
public int dmMediaType;
/// <summary><para> Specifies how dithering is to be done. The member can be one of the following predefined values, or a driver-defined value greater than or equal to the value of DMDITHER_USER.</para></summary>
/// <example>
/// <para>DMDITHER_NONE: No dithering.</para>
/// <para>DMDITHER_COARSE: Dithering with a coarse brush.</para>
/// <para>DMDITHER_FINE: Dithering with a fine brush.</para>
/// <para>DMDITHER_LINEART: Line art dithering, a special dithering method that produces well defined borders between black, white, and gray scaling. It is not suitable for images that include continuous graduations in intensity and hue, such as scanned photographs.</para>
/// <para>DMDITHER_GRAYSCALE: Device does gray scaling.</para>
/// </example>
public int dmDitherType;
/// <summary>Not used; must be zero.</summary>
public int dmReserved1;
/// <summary>Not used; must be zero.</summary>
public int dmReserved2;
/// <summary>This member must be zero.</summary>
public int dmPanningWidth;
/// <summary>This member must be zero.</summary>
public int dmPanningHeight;
/// <summary>
/// <para>You really should use this constructor!</para>
/// <para>Alternatively you have to set dmSize manually before using it: this.dmSize = (short)Marshal.SizeOf(this); </para>
/// </summary>
/// <param name="x">Does not matter</param>
public ScreenSettingsDevMode(bool x)
{
this.dmDeviceName = new String(new char[32]);
this.dmSpecVersion = new short();
this.dmDriverVersion = new short();
this.dmDriverExtra = new short();
this.dmFields = new int();
this.dmPositionX = new int();
this.dmPositionY = new int();
this.dmDisplayOrientation = new int();
this.dmDisplayFixedOutput = new int();
this.dmColor = new short();
this.dmDuplex = new short();
this.dmYResolution = new short();
this.dmTTOption = new short();
this.dmCollate = new short();
this.dmFormName = new String(new char[32]);
this.dmLogPixels = new short();
this.dmBitsPerPel = new short();
this.dmPelsWidth = new int();
this.dmPelsHeight = new int();
this.dmDisplayFlags = new int();
this.dmDisplayFrequency = new int();
this.dmICMMethod = new int();
this.dmICMIntent = new int();
this.dmMediaType = new int();
this.dmDitherType = new int();
this.dmReserved1 = 0;
this.dmReserved2 = 0;
this.dmPanningWidth = 0;
this.dmPanningHeight = 0;
this.dmSize = new short();
this.dmSize = (short)Marshal.SizeOf(this);
}
};
}

View File

@ -0,0 +1,112 @@
using System;
using Systemm = System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;
using Forms = System.Windows.Forms;
using System.Runtime.InteropServices;
using Trigger.Classes.Screen;
namespace Trigger.Status
{
/// <summary>
/// <para>Provides methods to examine the status of screen devices</para>
/// </summary>
static class Screen
{
#region DllImports
/// <summary>
/// <para>The EnumDisplaySettings function retrieves information about one of the graphics modes for a display device. To retrieve information for all the graphics modes of a display device, make a series of calls to this function.</para>
/// <para>The EnumDisplaySettings function sets values for the following five <see cref="ScreenSettingsDevMode"/> members:
/// <list type="unordered"></list>
/// <item>dmBitsPerPel</item>
/// <item>dmPelsWidth</item>
/// <item>dmPelsHeigh</item>t</item>
/// <item>dmDisplayFlags</item>
/// <item>dmDisplayFrequency</item>
/// </para>
/// </summary>
/// <param name="lpszDeviceName">
/// <para>A pointer to a null-terminated string that specifies the display device about whose graphics mode the function will obtain information.</para>
/// <para>This parameter is either NULL or a DISPLAY_DEVICE.DeviceName returned from EnumDisplayDevices. A NULL value specifies the current display device on the computer on which the calling thread is running.</para>
/// </param>
/// <param name="iModeNum">The type of information to be retrieved. This value can be a graphics mode index or one of the following values.
/// <list type="unordered">
/// <item>ENUM_CURRENT_SETTINGS</item>
/// <item>ENUM_REGISTRY_SETTINGS</item>
/// </list></param>
/// <param name="lpDevMode"><para>A pointer to a <see cref="ScreenSettingsDevMode"/> structure into which the function stores information about the specified graphics mode. Before calling EnumDisplaySettings, set the dmSize member to sizeof(DEVMODE), and set the dmDriverExtra member to indicate the size, in bytes, of the additional space available to receive private driver data.</para></param>
/// <returns>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.</returns>
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref ScreenSettingsDevMode lpDevMode);
#endregion
#region Properties
#region Screen
/// <summary><para>Gets a list of all displays on the system</para></summary>
public static List<ScreenEx> AllScreens
{
get
{
List<Forms.Screen> allScreens = new List<Forms.Screen>(Forms.Screen.AllScreens);
List<ScreenEx> allScreensEx = new List<ScreenEx>(allScreens.Count);
allScreens.ForEach(new Action<Forms.Screen>(screen => allScreensEx.Add(GetScreenSettings(screen))));
return allScreensEx;
}
}
/// <summary><para>Gets the primary screen</para></summary>
public static ScreenEx PrimaryScreen
{
get
{
return GetScreenSettings(Forms.Screen.PrimaryScreen);
}
}
/// <summary>
/// <para>Gets the orientation of the screen</para>
/// <para>But which screen?</para>
/// </summary>
public static ScreenOrientation ScreenOrientation
{
get
{
return SystemInformation.ScreenOrientation;
}
}
#endregion
#endregion
#region Methods
/// <summary>
/// <para>Returns the current System status</para>
/// </summary>
/// <returns></returns>
public static TreeNode GetStatus()
{
TreeNode tnMain = new TreeNode("Screens (" + AllScreens.Count + ")");
AllScreens.ForEach(new Action<ScreenEx>(screen =>
{
TreeNode tnScreen = tnMain.Nodes.Add(screen.Name);
tnScreen.Nodes.Add("Primary: " + screen.Primary.ToString());
tnScreen.Nodes.Add("Color depth: " + screen.BitsPerPixel + "bit");
tnScreen.Nodes.Add("Resolution: " + screen.Bounds.Width + "x" + screen.Bounds.Height);
tnScreen.Nodes.Add("Position: " + screen.Bounds.X + " | " + screen.Bounds.Y);
tnScreen.Nodes.Add("Display orientation: " + screen.Orientation.ToString());
tnScreen.Nodes.Add("Refresh rate: " + screen.Frequency);
}));
return tnMain;
}
public static ScreenEx GetScreenSettings(Forms.Screen screen)
{
ScreenSettingsDevMode DevMode = new ScreenSettingsDevMode(true);
if (EnumDisplaySettings(screen.DeviceName, -1 /*current settings*/, ref DevMode) == 0)
throw new Exception("EnumDisplaySettings (user32.dll) returned 0");
ScreenEx screenSettings = new ScreenEx(screen, DevMode);
return screenSettings;
}
#endregion
}
}