Skip to content

Commit

Permalink
pictures for v0.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pestrela committed Apr 24, 2020
1 parent 692772c commit 7388f48
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 120 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ No installation needed, cmdr is portable. Unzip and start cmdr.exe.
Consult the [changelog](docs/development/Change_Log.md) for complete details


![cmdr_improvements](docs/pics/cmdr_improvements.png?raw=true "")
![cmdr_improvements1](docs/pics/cmdr_improvements1.png?raw=true "")
![cmdr_improvements2](docs/pics/cmdr_improvements2.png?raw=true "")

![cmdr_reports](docs/pics/cmdr_reports.png?raw=true "")
![cmdr_csv_export](docs/pics/cmdr_csv_export.png?raw=true "")


![cmdr_keyboard_shortcuts](docs/pics/cmdr_keyboard_shortcuts.png?raw=true "")
Expand Down
238 changes: 119 additions & 119 deletions cmdr/cmdr.Editor/Utils/WindowPlacement.cs
Original file line number Diff line number Diff line change
@@ -1,120 +1,120 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace cmdr.Editor.Utils
{
// RECT structure required by WINDOWPLACEMENT structure
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;

public RECT(int left, int top, int right, int bottom)
{
this.Left = left;
this.Top = top;
this.Right = right;
this.Bottom = bottom;
}
}

// POINT structure required by WINDOWPLACEMENT structure
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;

public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
}

// WINDOWPLACEMENT stores the position, size, and state of a window
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public POINT minPosition;
public POINT maxPosition;
public RECT normalPosition;
}

public static class WindowPlacement
{
private static Encoding encoding = new UTF8Encoding();
private static XmlSerializer serializer = new XmlSerializer(typeof(WINDOWPLACEMENT));

[DllImport("user32.dll")]
private static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);

[DllImport("user32.dll")]
private static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);

private const int SW_SHOWNORMAL = 1;
private const int SW_SHOWMINIMIZED = 2;

public static void SetPlacement(IntPtr windowHandle, string placementXml)
{
if (string.IsNullOrEmpty(placementXml)) {
return;
}

WINDOWPLACEMENT placement;
byte[] xmlBytes = encoding.GetBytes(placementXml);

try {
using (MemoryStream memoryStream = new MemoryStream(xmlBytes)) {
placement = (WINDOWPLACEMENT)serializer.Deserialize(memoryStream);
}

placement.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
placement.flags = 0;
placement.showCmd = (placement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : placement.showCmd);
SetWindowPlacement(windowHandle, ref placement);
}
catch (InvalidOperationException) {
// Parsing placement XML failed. Fail silently.
}
}

public static string GetPlacement(IntPtr windowHandle)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
GetWindowPlacement(windowHandle, out placement);

using (MemoryStream memoryStream = new MemoryStream()) {
using (XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8)) {
serializer.Serialize(xmlTextWriter, placement);
byte[] xmlBytes = memoryStream.ToArray();
return encoding.GetString(xmlBytes);
}
}
}

/*
public static void SetPlacement(this Window window, string placementXml)
{
WindowPlacement.SetPlacement(new WindowInteropHelper(window).Handle, placementXml);
}
public static string GetPlacement(this Window window)
{
return WindowPlacement.GetPlacement(new WindowInteropHelper(window).Handle);
}*/
}
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace cmdr.Editor.Utils
{
// RECT structure required by WINDOWPLACEMENT structure
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;

public RECT(int left, int top, int right, int bottom)
{
this.Left = left;
this.Top = top;
this.Right = right;
this.Bottom = bottom;
}
}

// POINT structure required by WINDOWPLACEMENT structure
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;

public POINT(int x, int y)
{
this.X = x;
this.Y = y;
}
}

// WINDOWPLACEMENT stores the position, size, and state of a window
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public POINT minPosition;
public POINT maxPosition;
public RECT normalPosition;
}

public static class WindowPlacement
{
private static Encoding encoding = new UTF8Encoding();
private static XmlSerializer serializer = new XmlSerializer(typeof(WINDOWPLACEMENT));

[DllImport("user32.dll")]
private static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);

[DllImport("user32.dll")]
private static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl);

private const int SW_SHOWNORMAL = 1;
private const int SW_SHOWMINIMIZED = 2;

public static void SetPlacement(IntPtr windowHandle, string placementXml)
{
if (string.IsNullOrEmpty(placementXml)) {
return;
}

WINDOWPLACEMENT placement;
byte[] xmlBytes = encoding.GetBytes(placementXml);

try {
using (MemoryStream memoryStream = new MemoryStream(xmlBytes)) {
placement = (WINDOWPLACEMENT)serializer.Deserialize(memoryStream);
}

placement.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
placement.flags = 0;
placement.showCmd = (placement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : placement.showCmd);
SetWindowPlacement(windowHandle, ref placement);
}
catch (InvalidOperationException) {
// Parsing placement XML failed. Fail silently.
}
}

public static string GetPlacement(IntPtr windowHandle)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
GetWindowPlacement(windowHandle, out placement);

using (MemoryStream memoryStream = new MemoryStream()) {
using (XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8)) {
serializer.Serialize(xmlTextWriter, placement);
byte[] xmlBytes = memoryStream.ToArray();
return encoding.GetString(xmlBytes);
}
}
}

/*
public static void SetPlacement(this Window window, string placementXml)
{
WindowPlacement.SetPlacement(new WindowInteropHelper(window).Handle, placementXml);
}
public static string GetPlacement(this Window window)
{
return WindowPlacement.GetPlacement(new WindowInteropHelper(window).Handle);
}*/
}
}

0 comments on commit 7388f48

Please sign in to comment.