chore: use file-scoped namespace
This commit is contained in:
1 parent
99d2fafb72
commit
bbf1b7d4c6
748 files changed
+57929
-58678
No files matched your search
@@ -1,13 +1,12 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class CancelRoutedEventArgs : RoutedEventArgs
|
||||
{
|
||||
public CancelRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
|
||||
{
|
||||
}
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public bool Cancel { get; set; }
|
||||
public class CancelRoutedEventArgs : RoutedEventArgs
|
||||
{
|
||||
public CancelRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public bool Cancel { get; set; }
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
using System.Windows;
|
||||
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class FunctionEventArgs<T> : RoutedEventArgs
|
||||
{
|
||||
public class FunctionEventArgs<T> : RoutedEventArgs
|
||||
public FunctionEventArgs(T info)
|
||||
{
|
||||
public FunctionEventArgs(T info)
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
|
||||
public FunctionEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
|
||||
{
|
||||
}
|
||||
|
||||
public T Info { get; set; }
|
||||
Info = info;
|
||||
}
|
||||
}
|
||||
|
||||
public FunctionEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
|
||||
{
|
||||
}
|
||||
|
||||
public T Info { get; set; }
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using System;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class KeyboardHookEventArgs : EventArgs
|
||||
{
|
||||
public class KeyboardHookEventArgs : EventArgs
|
||||
public bool IsSystemKey { get; }
|
||||
|
||||
public Key Key { get; }
|
||||
|
||||
public KeyboardHookEventArgs(int virtualKey, bool isSystemKey)
|
||||
{
|
||||
public bool IsSystemKey { get; }
|
||||
|
||||
public Key Key { get; }
|
||||
|
||||
public KeyboardHookEventArgs(int virtualKey, bool isSystemKey)
|
||||
{
|
||||
IsSystemKey = isSystemKey;
|
||||
Key = KeyInterop.KeyFromVirtualKey(virtualKey);
|
||||
}
|
||||
IsSystemKey = isSystemKey;
|
||||
Key = KeyInterop.KeyFromVirtualKey(virtualKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class MouseHookEventArgs : EventArgs
|
||||
{
|
||||
public MouseHookMessageType MessageType { get; set; }
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public InteropValues.POINT Point { get; set; }
|
||||
}
|
||||
}
|
||||
internal class MouseHookEventArgs : EventArgs
|
||||
{
|
||||
public MouseHookMessageType MessageType { get; set; }
|
||||
|
||||
public InteropValues.POINT Point { get; set; }
|
||||
}
|
||||
@@ -1,69 +1,68 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class DisposableObject : IDisposable
|
||||
{
|
||||
public class DisposableObject : IDisposable
|
||||
private EventHandler _disposing;
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
private EventHandler _disposing;
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
~DisposableObject()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public event EventHandler Disposing
|
||||
{
|
||||
add
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
ThrowIfDisposed();
|
||||
_disposing += value;
|
||||
}
|
||||
|
||||
~DisposableObject()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public event EventHandler Disposing
|
||||
{
|
||||
add
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
_disposing += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_disposing -= value;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ThrowIfDisposed()
|
||||
{
|
||||
if (IsDisposed) throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (IsDisposed) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_disposing?.Invoke(this, EventArgs.Empty);
|
||||
_disposing = null;
|
||||
DisposeManagedResources();
|
||||
}
|
||||
|
||||
DisposeNativeResources();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DisposeManagedResources()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void DisposeNativeResources()
|
||||
remove
|
||||
{
|
||||
_disposing -= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ThrowIfDisposed()
|
||||
{
|
||||
if (IsDisposed) throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (IsDisposed) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_disposing?.Invoke(this, EventArgs.Empty);
|
||||
_disposing = null;
|
||||
DisposeManagedResources();
|
||||
}
|
||||
|
||||
DisposeNativeResources();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DisposeManagedResources()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void DisposeNativeResources()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum BadgeStatus
|
||||
{
|
||||
public enum BadgeStatus
|
||||
{
|
||||
Text,
|
||||
Dot,
|
||||
Processing
|
||||
}
|
||||
}
|
||||
Text,
|
||||
Dot,
|
||||
Processing
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum ChatMessageType
|
||||
{
|
||||
public enum ChatMessageType
|
||||
{
|
||||
String,
|
||||
Image,
|
||||
Audio,
|
||||
Custom
|
||||
}
|
||||
}
|
||||
String,
|
||||
Image,
|
||||
Audio,
|
||||
Custom
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum ChatRoleType
|
||||
{
|
||||
public enum ChatRoleType
|
||||
{
|
||||
Sender,
|
||||
Receiver
|
||||
}
|
||||
}
|
||||
Sender,
|
||||
Receiver
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum ColLayoutStatus
|
||||
{
|
||||
public enum ColLayoutStatus
|
||||
{
|
||||
Xs,
|
||||
Sm,
|
||||
Md,
|
||||
Lg,
|
||||
Xl,
|
||||
Xxl,
|
||||
Auto
|
||||
}
|
||||
}
|
||||
Xs,
|
||||
Sm,
|
||||
Md,
|
||||
Lg,
|
||||
Xl,
|
||||
Xxl,
|
||||
Auto
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum DrawerShowMode
|
||||
{
|
||||
public enum DrawerShowMode
|
||||
{
|
||||
Cover,
|
||||
Push,
|
||||
Press
|
||||
}
|
||||
}
|
||||
Cover,
|
||||
Push,
|
||||
Press
|
||||
}
|
||||
@@ -3,76 +3,75 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class EnumDataProvider : ObjectDataProvider
|
||||
{
|
||||
public class EnumDataProvider : ObjectDataProvider
|
||||
public EnumDataProvider()
|
||||
{
|
||||
public EnumDataProvider()
|
||||
MethodName = nameof(GetValues);
|
||||
}
|
||||
|
||||
private Type _type;
|
||||
public Type Type
|
||||
{
|
||||
get => _type;
|
||||
set
|
||||
{
|
||||
MethodName = nameof(GetValues);
|
||||
_type = value;
|
||||
MethodParameters.Add(value);
|
||||
ObjectType = typeof(System.Enum);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _useAttributes;
|
||||
|
||||
public bool UseAttributes
|
||||
{
|
||||
get => _useAttributes;
|
||||
set
|
||||
{
|
||||
_useAttributes = value;
|
||||
ObjectType = value ? typeof(EnumDataProvider) : typeof(System.Enum);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<EnumItem> GetValues(Type enumType)
|
||||
{
|
||||
if (enumType == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(enumType));
|
||||
}
|
||||
|
||||
private Type _type;
|
||||
public Type Type
|
||||
{
|
||||
get => _type;
|
||||
set
|
||||
{
|
||||
_type = value;
|
||||
MethodParameters.Add(value);
|
||||
ObjectType = typeof(System.Enum);
|
||||
}
|
||||
}
|
||||
var resultList = new List<EnumItem>();
|
||||
|
||||
private bool _useAttributes;
|
||||
|
||||
public bool UseAttributes
|
||||
var values = System.Enum.GetValues(enumType);
|
||||
foreach (System.Enum value in values)
|
||||
{
|
||||
get => _useAttributes;
|
||||
set
|
||||
var fieldInfo = enumType.GetField(value.ToString());
|
||||
if (fieldInfo == null)
|
||||
{
|
||||
_useAttributes = value;
|
||||
ObjectType = value ? typeof(EnumDataProvider) : typeof(System.Enum);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<EnumItem> GetValues(Type enumType)
|
||||
{
|
||||
if (enumType == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(enumType));
|
||||
continue;
|
||||
}
|
||||
|
||||
var resultList = new List<EnumItem>();
|
||||
|
||||
var values = System.Enum.GetValues(enumType);
|
||||
foreach (System.Enum value in values)
|
||||
if (fieldInfo.GetCustomAttributes(typeof(BrowsableAttribute), true) is BrowsableAttribute[] { Length: > 0 } browsableAttributes)
|
||||
{
|
||||
var fieldInfo = enumType.GetField(value.ToString());
|
||||
if (fieldInfo == null)
|
||||
if (!browsableAttributes[0].Browsable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fieldInfo.GetCustomAttributes(typeof(BrowsableAttribute), true) is BrowsableAttribute[] { Length: > 0 } browsableAttributes)
|
||||
{
|
||||
if (!browsableAttributes[0].Browsable)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true) is DescriptionAttribute[] { Length: > 0 } descriptionAttributes)
|
||||
{
|
||||
resultList.Add(new EnumItem
|
||||
{
|
||||
Description = descriptionAttributes[0].Description,
|
||||
Value = value
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
if (fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true) is DescriptionAttribute[] { Length: > 0 } descriptionAttributes)
|
||||
{
|
||||
resultList.Add(new EnumItem
|
||||
{
|
||||
Description = descriptionAttributes[0].Description,
|
||||
Value = value
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,24 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum ExpandMode
|
||||
{
|
||||
public enum ExpandMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 最多只能显示一项,且不可折叠
|
||||
/// </summary>
|
||||
ShowOne,
|
||||
/// <summary>
|
||||
/// 最多只能显示一项,且不可折叠
|
||||
/// </summary>
|
||||
ShowOne,
|
||||
|
||||
/// <summary>
|
||||
/// 显示所有项,且不可折叠
|
||||
/// </summary>
|
||||
ShowAll,
|
||||
/// <summary>
|
||||
/// 显示所有项,且不可折叠
|
||||
/// </summary>
|
||||
ShowAll,
|
||||
|
||||
/// <summary>
|
||||
/// 类似ShowOne,但是控件的尺寸不随项的数量而改变
|
||||
/// </summary>
|
||||
Accordion,
|
||||
/// <summary>
|
||||
/// 类似ShowOne,但是控件的尺寸不随项的数量而改变
|
||||
/// </summary>
|
||||
Accordion,
|
||||
|
||||
/// <summary>
|
||||
/// 没有任何限制
|
||||
/// </summary>
|
||||
Freedom
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 没有任何限制
|
||||
/// </summary>
|
||||
Freedom
|
||||
}
|
||||
@@ -1,59 +1,58 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum HatchStyle
|
||||
{
|
||||
public enum HatchStyle
|
||||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
ForwardDiagonal,
|
||||
BackwardDiagonal,
|
||||
Cross,
|
||||
DiagonalCross,
|
||||
Percent05,
|
||||
Percent10,
|
||||
Percent20,
|
||||
Percent25,
|
||||
Percent30,
|
||||
Percent40,
|
||||
Percent50,
|
||||
Percent60,
|
||||
Percent70,
|
||||
Percent75,
|
||||
Percent80,
|
||||
Percent90,
|
||||
LightDownwardDiagonal,
|
||||
LightUpwardDiagonal,
|
||||
DarkDownwardDiagonal,
|
||||
DarkUpwardDiagonal,
|
||||
WideDownwardDiagonal,
|
||||
WideUpwardDiagonal,
|
||||
LightVertical,
|
||||
LightHorizontal,
|
||||
NarrowVertical,
|
||||
NarrowHorizontal,
|
||||
DarkVertical,
|
||||
DarkHorizontal,
|
||||
DashedDownwardDiagonal,
|
||||
DashedUpwardDiagonal,
|
||||
DashedHorizontal,
|
||||
DashedVertical,
|
||||
SmallConfetti,
|
||||
LargeConfetti,
|
||||
ZigZag,
|
||||
Wave,
|
||||
DiagonalBrick,
|
||||
HorizontalBrick,
|
||||
Weave,
|
||||
Plaid,
|
||||
Divot,
|
||||
DottedGrid,
|
||||
DottedDiamond,
|
||||
Shingle,
|
||||
Trellis,
|
||||
Sphere,
|
||||
SmallGrid,
|
||||
SmallCheckerBoard,
|
||||
LargeCheckerBoard,
|
||||
OutlinedDiamond,
|
||||
SolidDiamond
|
||||
}
|
||||
}
|
||||
Horizontal,
|
||||
Vertical,
|
||||
ForwardDiagonal,
|
||||
BackwardDiagonal,
|
||||
Cross,
|
||||
DiagonalCross,
|
||||
Percent05,
|
||||
Percent10,
|
||||
Percent20,
|
||||
Percent25,
|
||||
Percent30,
|
||||
Percent40,
|
||||
Percent50,
|
||||
Percent60,
|
||||
Percent70,
|
||||
Percent75,
|
||||
Percent80,
|
||||
Percent90,
|
||||
LightDownwardDiagonal,
|
||||
LightUpwardDiagonal,
|
||||
DarkDownwardDiagonal,
|
||||
DarkUpwardDiagonal,
|
||||
WideDownwardDiagonal,
|
||||
WideUpwardDiagonal,
|
||||
LightVertical,
|
||||
LightHorizontal,
|
||||
NarrowVertical,
|
||||
NarrowHorizontal,
|
||||
DarkVertical,
|
||||
DarkHorizontal,
|
||||
DashedDownwardDiagonal,
|
||||
DashedUpwardDiagonal,
|
||||
DashedHorizontal,
|
||||
DashedVertical,
|
||||
SmallConfetti,
|
||||
LargeConfetti,
|
||||
ZigZag,
|
||||
Wave,
|
||||
DiagonalBrick,
|
||||
HorizontalBrick,
|
||||
Weave,
|
||||
Plaid,
|
||||
Divot,
|
||||
DottedGrid,
|
||||
DottedDiamond,
|
||||
Shingle,
|
||||
Trellis,
|
||||
Sphere,
|
||||
SmallGrid,
|
||||
SmallCheckerBoard,
|
||||
LargeCheckerBoard,
|
||||
OutlinedDiamond,
|
||||
SolidDiamond
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace HandyControl.Data.Enum
|
||||
namespace HandyControl.Data.Enum;
|
||||
|
||||
public enum HitMode
|
||||
{
|
||||
public enum HitMode
|
||||
{
|
||||
Click,
|
||||
Hover,
|
||||
Focus,
|
||||
None
|
||||
}
|
||||
}
|
||||
Click,
|
||||
Hover,
|
||||
Focus,
|
||||
None
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
[Flags]
|
||||
internal enum ImageCodecFlags
|
||||
{
|
||||
[Flags]
|
||||
internal enum ImageCodecFlags
|
||||
{
|
||||
Encoder = 0x00000001,
|
||||
Decoder = 0x00000002,
|
||||
SupportBitmap = 0x00000004,
|
||||
SupportVector = 0x00000008,
|
||||
SeekableEncode = 0x00000010,
|
||||
BlockingDecode = 0x00000020,
|
||||
Builtin = 0x00010000,
|
||||
System = 0x00020000,
|
||||
User = 0x00040000
|
||||
}
|
||||
}
|
||||
Encoder = 0x00000001,
|
||||
Decoder = 0x00000002,
|
||||
SupportBitmap = 0x00000004,
|
||||
SupportVector = 0x00000008,
|
||||
SeekableEncode = 0x00000010,
|
||||
BlockingDecode = 0x00000020,
|
||||
Builtin = 0x00010000,
|
||||
System = 0x00020000,
|
||||
User = 0x00040000
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum InfoType
|
||||
{
|
||||
public enum InfoType
|
||||
{
|
||||
Success = 0,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal,
|
||||
Ask
|
||||
}
|
||||
}
|
||||
Success = 0,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal,
|
||||
Ask
|
||||
}
|
||||
@@ -1,30 +1,29 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// IP类型枚举
|
||||
/// </summary>
|
||||
public enum IpType
|
||||
{
|
||||
/// <summary>
|
||||
/// IP类型枚举
|
||||
/// A类IP地址
|
||||
/// </summary>
|
||||
public enum IpType
|
||||
{
|
||||
/// <summary>
|
||||
/// A类IP地址
|
||||
/// </summary>
|
||||
A = 0,
|
||||
/// <summary>
|
||||
/// B类IP地址
|
||||
/// </summary>
|
||||
B,
|
||||
/// <summary>
|
||||
/// C类IP地址
|
||||
/// </summary>
|
||||
C,
|
||||
/// <summary>
|
||||
/// D类IP地址
|
||||
/// </summary>
|
||||
D,
|
||||
/// <summary>
|
||||
/// E类IP地址
|
||||
/// </summary>
|
||||
E
|
||||
}
|
||||
}
|
||||
A = 0,
|
||||
/// <summary>
|
||||
/// B类IP地址
|
||||
/// </summary>
|
||||
B,
|
||||
/// <summary>
|
||||
/// C类IP地址
|
||||
/// </summary>
|
||||
C,
|
||||
/// <summary>
|
||||
/// D类IP地址
|
||||
/// </summary>
|
||||
D,
|
||||
/// <summary>
|
||||
/// E类IP地址
|
||||
/// </summary>
|
||||
E
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public enum LinearLayout
|
||||
{
|
||||
Stack,
|
||||
namespace HandyControl.Data;
|
||||
|
||||
Uniform
|
||||
}
|
||||
}
|
||||
public enum LinearLayout
|
||||
{
|
||||
Stack,
|
||||
|
||||
Uniform
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum MouseHookMessageType
|
||||
{
|
||||
public enum MouseHookMessageType
|
||||
{
|
||||
LeftButtonDown = 0x0201,
|
||||
LeftButtonUp = 0x0202,
|
||||
MouseMove = 0x0200,
|
||||
MouseWheel = 0x020A,
|
||||
RightButtonDown = 0x0204,
|
||||
RightButtonUp = 0x0205
|
||||
}
|
||||
}
|
||||
LeftButtonDown = 0x0201,
|
||||
LeftButtonUp = 0x0202,
|
||||
MouseMove = 0x0200,
|
||||
MouseWheel = 0x020A,
|
||||
RightButtonDown = 0x0204,
|
||||
RightButtonUp = 0x0205
|
||||
}
|
||||
@@ -1,25 +1,24 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum NotifyIconInfoType
|
||||
{
|
||||
public enum NotifyIconInfoType
|
||||
{
|
||||
/// <summary>
|
||||
/// No Icon.
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// No Icon.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// A Information Icon.
|
||||
/// </summary>
|
||||
Info,
|
||||
/// <summary>
|
||||
/// A Information Icon.
|
||||
/// </summary>
|
||||
Info,
|
||||
|
||||
/// <summary>
|
||||
/// A Warning Icon.
|
||||
/// </summary>
|
||||
Warning,
|
||||
/// <summary>
|
||||
/// A Warning Icon.
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
/// <summary>
|
||||
/// A Error Icon.
|
||||
/// </summary>
|
||||
Error
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// A Error Icon.
|
||||
/// </summary>
|
||||
Error
|
||||
}
|
||||
@@ -1,66 +1,65 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum PlacementType
|
||||
{
|
||||
public enum PlacementType
|
||||
{
|
||||
/// <summary>
|
||||
/// 左上
|
||||
/// </summary>
|
||||
LeftTop,
|
||||
/// <summary>
|
||||
/// 左上
|
||||
/// </summary>
|
||||
LeftTop,
|
||||
|
||||
/// <summary>
|
||||
/// 左
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// 左
|
||||
/// </summary>
|
||||
Left,
|
||||
|
||||
/// <summary>
|
||||
/// 左下
|
||||
/// </summary>
|
||||
LeftBottom,
|
||||
/// <summary>
|
||||
/// 左下
|
||||
/// </summary>
|
||||
LeftBottom,
|
||||
|
||||
/// <summary>
|
||||
/// 上左
|
||||
/// </summary>
|
||||
TopLeft,
|
||||
/// <summary>
|
||||
/// 上左
|
||||
/// </summary>
|
||||
TopLeft,
|
||||
|
||||
/// <summary>
|
||||
/// 上
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// 上
|
||||
/// </summary>
|
||||
Top,
|
||||
|
||||
/// <summary>
|
||||
/// 上右
|
||||
/// </summary>
|
||||
TopRight,
|
||||
/// <summary>
|
||||
/// 上右
|
||||
/// </summary>
|
||||
TopRight,
|
||||
|
||||
/// <summary>
|
||||
/// 右上
|
||||
/// </summary>
|
||||
RightTop,
|
||||
/// <summary>
|
||||
/// 右上
|
||||
/// </summary>
|
||||
RightTop,
|
||||
|
||||
/// <summary>
|
||||
/// 右
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// 右
|
||||
/// </summary>
|
||||
Right,
|
||||
|
||||
/// <summary>
|
||||
/// 右下
|
||||
/// </summary>
|
||||
RightBottom,
|
||||
/// <summary>
|
||||
/// 右下
|
||||
/// </summary>
|
||||
RightBottom,
|
||||
|
||||
/// <summary>
|
||||
/// 下左
|
||||
/// </summary>
|
||||
BottomLeft,
|
||||
/// <summary>
|
||||
/// 下左
|
||||
/// </summary>
|
||||
BottomLeft,
|
||||
|
||||
/// <summary>
|
||||
/// 下
|
||||
/// </summary>
|
||||
Bottom,
|
||||
/// <summary>
|
||||
/// 下
|
||||
/// </summary>
|
||||
Bottom,
|
||||
|
||||
/// <summary>
|
||||
/// 下右
|
||||
/// </summary>
|
||||
BottomRight,
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 下右
|
||||
/// </summary>
|
||||
BottomRight,
|
||||
}
|
||||
@@ -1,24 +1,23 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 表示一个操作的返回结果类型
|
||||
/// </summary>
|
||||
public enum ResultType
|
||||
{
|
||||
/// <summary>
|
||||
/// 表示一个操作的返回结果类型
|
||||
/// 成功
|
||||
/// </summary>
|
||||
public enum ResultType
|
||||
{
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
Success,
|
||||
Success,
|
||||
|
||||
/// <summary>
|
||||
/// 失败
|
||||
/// </summary>
|
||||
Failed,
|
||||
/// <summary>
|
||||
/// 失败
|
||||
/// </summary>
|
||||
Failed,
|
||||
|
||||
/// <summary>
|
||||
/// 无数据
|
||||
/// </summary>
|
||||
None
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 无数据
|
||||
/// </summary>
|
||||
None
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum ShowAnimation
|
||||
{
|
||||
public enum ShowAnimation
|
||||
{
|
||||
None,
|
||||
HorizontalMove,
|
||||
VerticalMove,
|
||||
Fade
|
||||
}
|
||||
}
|
||||
None,
|
||||
HorizontalMove,
|
||||
VerticalMove,
|
||||
Fade
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum SideMenuItemRole
|
||||
{
|
||||
public enum SideMenuItemRole
|
||||
{
|
||||
Header,
|
||||
Item
|
||||
}
|
||||
}
|
||||
Header,
|
||||
Item
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum SkinType
|
||||
{
|
||||
public enum SkinType
|
||||
{
|
||||
Default,
|
||||
Dark,
|
||||
Violet
|
||||
}
|
||||
}
|
||||
Default,
|
||||
Dark,
|
||||
Violet
|
||||
}
|
||||
@@ -1,23 +1,22 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 步骤状态
|
||||
/// </summary>
|
||||
public enum StepStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤状态
|
||||
/// 完成
|
||||
/// </summary>
|
||||
public enum StepStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 完成
|
||||
/// </summary>
|
||||
Complete,
|
||||
Complete,
|
||||
|
||||
/// <summary>
|
||||
/// 进行中
|
||||
/// </summary>
|
||||
UnderWay,
|
||||
/// <summary>
|
||||
/// 进行中
|
||||
/// </summary>
|
||||
UnderWay,
|
||||
|
||||
/// <summary>
|
||||
/// 等待中
|
||||
/// </summary>
|
||||
Waiting
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 等待中
|
||||
/// </summary>
|
||||
Waiting
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum StrokePosition
|
||||
{
|
||||
public enum StrokePosition
|
||||
{
|
||||
Center,
|
||||
Outside,
|
||||
Inside
|
||||
}
|
||||
}
|
||||
Center,
|
||||
Outside,
|
||||
Inside
|
||||
}
|
||||
@@ -1,27 +1,26 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 文本类型枚举
|
||||
/// </summary>
|
||||
public enum TextType
|
||||
{
|
||||
/// <summary>
|
||||
/// 文本类型枚举
|
||||
/// </summary>
|
||||
public enum TextType
|
||||
{
|
||||
Common,
|
||||
Phone,
|
||||
Mail,
|
||||
Url,
|
||||
Chinese,
|
||||
Number,
|
||||
Digits,
|
||||
PInt,
|
||||
NInt,
|
||||
Int,
|
||||
NnInt,
|
||||
NpInt,
|
||||
PDouble,
|
||||
NDouble,
|
||||
Double,
|
||||
NnDouble,
|
||||
NpDouble
|
||||
}
|
||||
}
|
||||
Common,
|
||||
Phone,
|
||||
Mail,
|
||||
Url,
|
||||
Chinese,
|
||||
Number,
|
||||
Digits,
|
||||
PInt,
|
||||
NInt,
|
||||
Int,
|
||||
NnInt,
|
||||
NpInt,
|
||||
PDouble,
|
||||
NDouble,
|
||||
Double,
|
||||
NnDouble,
|
||||
NpDouble
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 标题对齐方式
|
||||
/// </summary>
|
||||
public enum TitlePlacementType
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题对齐方式
|
||||
/// </summary>
|
||||
public enum TitlePlacementType
|
||||
{
|
||||
Left,
|
||||
Top
|
||||
}
|
||||
}
|
||||
Left,
|
||||
Top
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum TransitionMode
|
||||
{
|
||||
public enum TransitionMode
|
||||
{
|
||||
Right2Left,
|
||||
Left2Right,
|
||||
Bottom2Top,
|
||||
Top2Bottom,
|
||||
Right2LeftWithFade,
|
||||
Left2RightWithFade,
|
||||
Bottom2TopWithFade,
|
||||
Top2BottomWithFade,
|
||||
Fade,
|
||||
Custom
|
||||
}
|
||||
}
|
||||
Right2Left,
|
||||
Left2Right,
|
||||
Bottom2Top,
|
||||
Top2Bottom,
|
||||
Right2LeftWithFade,
|
||||
Left2RightWithFade,
|
||||
Bottom2TopWithFade,
|
||||
Top2BottomWithFade,
|
||||
Fade,
|
||||
Custom
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum VisualWrapping
|
||||
{
|
||||
public enum VisualWrapping
|
||||
{
|
||||
NoWrap,
|
||||
Wrap
|
||||
}
|
||||
}
|
||||
NoWrap,
|
||||
Wrap
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class EnumItem
|
||||
{
|
||||
public string Description { get; set; }
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public System.Enum Value { get; set; }
|
||||
}
|
||||
}
|
||||
public class EnumItem
|
||||
{
|
||||
public string Description { get; set; }
|
||||
|
||||
public System.Enum Value { get; set; }
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum FlexContentAlignment
|
||||
{
|
||||
public enum FlexContentAlignment
|
||||
{
|
||||
Stretch,
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
SpaceBetween,
|
||||
SpaceAround
|
||||
}
|
||||
}
|
||||
Stretch,
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
SpaceBetween,
|
||||
SpaceAround
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum FlexContentJustify
|
||||
{
|
||||
public enum FlexContentJustify
|
||||
{
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
SpaceBetween,
|
||||
SpaceAround
|
||||
}
|
||||
}
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
SpaceBetween,
|
||||
SpaceAround
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum FlexDirection
|
||||
{
|
||||
public enum FlexDirection
|
||||
{
|
||||
Row,
|
||||
RowReverse,
|
||||
Column,
|
||||
ColumnReverse
|
||||
}
|
||||
}
|
||||
Row,
|
||||
RowReverse,
|
||||
Column,
|
||||
ColumnReverse
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum FlexItemAlignment
|
||||
{
|
||||
public enum FlexItemAlignment
|
||||
{
|
||||
Auto,
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
Baseline,
|
||||
Stretch
|
||||
}
|
||||
}
|
||||
Auto,
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
Baseline,
|
||||
Stretch
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum FlexItemsAlignment
|
||||
{
|
||||
public enum FlexItemsAlignment
|
||||
{
|
||||
Stretch,
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
Baseline
|
||||
}
|
||||
}
|
||||
Stretch,
|
||||
FlexStart,
|
||||
FlexEnd,
|
||||
Center,
|
||||
Baseline
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public enum FlexWrap
|
||||
{
|
||||
public enum FlexWrap
|
||||
{
|
||||
NoWrap,
|
||||
Wrap,
|
||||
WrapReverse
|
||||
}
|
||||
}
|
||||
NoWrap,
|
||||
Wrap,
|
||||
WrapReverse
|
||||
}
|
||||
@@ -5,267 +5,266 @@ using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal class GPStream : InteropValues.IStream
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
internal class GPStream : InteropValues.IStream
|
||||
protected Stream DataStream;
|
||||
|
||||
// to support seeking ahead of the stream length...
|
||||
long _virtualPosition = -1;
|
||||
|
||||
internal GPStream(Stream stream)
|
||||
{
|
||||
protected Stream DataStream;
|
||||
|
||||
// to support seeking ahead of the stream length...
|
||||
long _virtualPosition = -1;
|
||||
|
||||
internal GPStream(Stream stream)
|
||||
if (!stream.CanSeek)
|
||||
{
|
||||
if (!stream.CanSeek)
|
||||
const int readBlock = 256;
|
||||
var bytes = new byte[readBlock];
|
||||
int readLen;
|
||||
var current = 0;
|
||||
do
|
||||
{
|
||||
const int readBlock = 256;
|
||||
var bytes = new byte[readBlock];
|
||||
int readLen;
|
||||
var current = 0;
|
||||
do
|
||||
if (bytes.Length < current + readBlock)
|
||||
{
|
||||
if (bytes.Length < current + readBlock)
|
||||
{
|
||||
var newData = new byte[bytes.Length * 2];
|
||||
Array.Copy(bytes, newData, bytes.Length);
|
||||
bytes = newData;
|
||||
}
|
||||
readLen = stream.Read(bytes, current, readBlock);
|
||||
current += readLen;
|
||||
} while (readLen != 0);
|
||||
|
||||
DataStream = new MemoryStream(bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
DataStream = stream;
|
||||
}
|
||||
}
|
||||
|
||||
private void ActualizeVirtualPosition()
|
||||
{
|
||||
if (_virtualPosition == -1) return;
|
||||
|
||||
if (_virtualPosition > DataStream.Length)
|
||||
DataStream.SetLength(_virtualPosition);
|
||||
|
||||
DataStream.Position = _virtualPosition;
|
||||
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
|
||||
public virtual InteropValues.IStream Clone()
|
||||
{
|
||||
NotImplemented();
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Commit(int grfCommitFlags)
|
||||
{
|
||||
DataStream.Flush();
|
||||
// Extend the length of the file if needed.
|
||||
ActualizeVirtualPosition();
|
||||
}
|
||||
|
||||
[
|
||||
UIPermission(SecurityAction.Demand, Window = UIPermissionWindow.AllWindows),
|
||||
SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)
|
||||
]
|
||||
public virtual long CopyTo(InteropValues.IStream pstm, long cb, long[] pcbRead)
|
||||
{
|
||||
|
||||
const int bufsize = 4096;
|
||||
var buffer = Marshal.AllocHGlobal(bufsize);
|
||||
if (buffer == IntPtr.Zero) throw new OutOfMemoryException();
|
||||
long written = 0;
|
||||
try
|
||||
{
|
||||
while (written < cb)
|
||||
{
|
||||
var toRead = bufsize;
|
||||
if (written + toRead > cb) toRead = (int) (cb - written);
|
||||
var read = Read(buffer, toRead);
|
||||
if (read == 0) break;
|
||||
if (pstm.Write(buffer, read) != read)
|
||||
{
|
||||
throw EFail("Wrote an incorrect number of bytes");
|
||||
}
|
||||
written += read;
|
||||
var newData = new byte[bytes.Length * 2];
|
||||
Array.Copy(bytes, newData, bytes.Length);
|
||||
bytes = newData;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
}
|
||||
if (pcbRead != null && pcbRead.Length > 0)
|
||||
{
|
||||
pcbRead[0] = written;
|
||||
}
|
||||
readLen = stream.Read(bytes, current, readBlock);
|
||||
current += readLen;
|
||||
} while (readLen != 0);
|
||||
|
||||
return written;
|
||||
DataStream = new MemoryStream(bytes);
|
||||
}
|
||||
|
||||
public virtual Stream GetDataStream()
|
||||
else
|
||||
{
|
||||
return DataStream;
|
||||
}
|
||||
|
||||
public virtual void LockRegion(long libOffset, long cb, int dwLockType)
|
||||
{
|
||||
}
|
||||
|
||||
protected static ExternalException EFail(string msg)
|
||||
{
|
||||
throw new ExternalException(msg, InteropMethods.E_FAIL);
|
||||
}
|
||||
|
||||
protected static void NotImplemented()
|
||||
{
|
||||
throw new ExternalException("NotImplemented");
|
||||
}
|
||||
|
||||
public virtual int Read(IntPtr buf, int length)
|
||||
{
|
||||
var buffer = new byte[length];
|
||||
var count = Read(buffer, length);
|
||||
Marshal.Copy(buffer, 0, buf, length);
|
||||
return count;
|
||||
}
|
||||
|
||||
public virtual int Read(byte[] buffer, int length)
|
||||
{
|
||||
ActualizeVirtualPosition();
|
||||
return DataStream.Read(buffer, 0, length);
|
||||
}
|
||||
|
||||
public virtual void Revert()
|
||||
{
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
public virtual long Seek(long offset, int origin)
|
||||
{
|
||||
var pos = _virtualPosition;
|
||||
if (_virtualPosition == -1)
|
||||
{
|
||||
pos = DataStream.Position;
|
||||
}
|
||||
var len = DataStream.Length;
|
||||
switch (origin)
|
||||
{
|
||||
case InteropValues.StreamConsts.STREAM_SEEK_SET:
|
||||
if (offset <= len)
|
||||
{
|
||||
DataStream.Position = offset;
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_virtualPosition = offset;
|
||||
}
|
||||
break;
|
||||
case InteropValues.StreamConsts.STREAM_SEEK_END:
|
||||
if (offset <= 0)
|
||||
{
|
||||
DataStream.Position = len + offset;
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_virtualPosition = len + offset;
|
||||
}
|
||||
break;
|
||||
case InteropValues.StreamConsts.STREAM_SEEK_CUR:
|
||||
if (offset + pos <= len)
|
||||
{
|
||||
DataStream.Position = pos + offset;
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_virtualPosition = offset + pos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return _virtualPosition != -1 ? _virtualPosition : DataStream.Position;
|
||||
}
|
||||
|
||||
public virtual void SetSize(long value)
|
||||
{
|
||||
DataStream.SetLength(value);
|
||||
}
|
||||
|
||||
public void Stat(IntPtr pstatstg, int grfStatFlag)
|
||||
{
|
||||
var stats = new STATSTG { cbSize = DataStream.Length };
|
||||
Marshal.StructureToPtr(stats, pstatstg, true);
|
||||
}
|
||||
|
||||
public virtual void UnlockRegion(long libOffset, long cb, int dwLockType)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int Write(IntPtr buf, int length)
|
||||
{
|
||||
var buffer = new byte[length];
|
||||
Marshal.Copy(buf, buffer, 0, length);
|
||||
return Write(buffer, length);
|
||||
}
|
||||
|
||||
public virtual int Write(byte[] buffer, int length)
|
||||
{
|
||||
ActualizeVirtualPosition();
|
||||
DataStream.Write(buffer, 0, length);
|
||||
return length;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class STATSTG
|
||||
{
|
||||
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
|
||||
public IntPtr pwcsName = IntPtr.Zero;
|
||||
public int type;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long cbSize;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long mtime;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long ctime;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long atime;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int grfMode;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int grfLocksSupported;
|
||||
|
||||
public int clsid_data1;
|
||||
[MarshalAs(UnmanagedType.I2)]
|
||||
public short clsid_data2;
|
||||
[MarshalAs(UnmanagedType.I2)]
|
||||
public short clsid_data3;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b0;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b1;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b2;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b3;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b4;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b5;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b6;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b7;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int grfStateBits;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int reserved;
|
||||
DataStream = stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ActualizeVirtualPosition()
|
||||
{
|
||||
if (_virtualPosition == -1) return;
|
||||
|
||||
if (_virtualPosition > DataStream.Length)
|
||||
DataStream.SetLength(_virtualPosition);
|
||||
|
||||
DataStream.Position = _virtualPosition;
|
||||
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
|
||||
public virtual InteropValues.IStream Clone()
|
||||
{
|
||||
NotImplemented();
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Commit(int grfCommitFlags)
|
||||
{
|
||||
DataStream.Flush();
|
||||
// Extend the length of the file if needed.
|
||||
ActualizeVirtualPosition();
|
||||
}
|
||||
|
||||
[
|
||||
UIPermission(SecurityAction.Demand, Window = UIPermissionWindow.AllWindows),
|
||||
SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)
|
||||
]
|
||||
public virtual long CopyTo(InteropValues.IStream pstm, long cb, long[] pcbRead)
|
||||
{
|
||||
|
||||
const int bufsize = 4096;
|
||||
var buffer = Marshal.AllocHGlobal(bufsize);
|
||||
if (buffer == IntPtr.Zero) throw new OutOfMemoryException();
|
||||
long written = 0;
|
||||
try
|
||||
{
|
||||
while (written < cb)
|
||||
{
|
||||
var toRead = bufsize;
|
||||
if (written + toRead > cb) toRead = (int) (cb - written);
|
||||
var read = Read(buffer, toRead);
|
||||
if (read == 0) break;
|
||||
if (pstm.Write(buffer, read) != read)
|
||||
{
|
||||
throw EFail("Wrote an incorrect number of bytes");
|
||||
}
|
||||
written += read;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(buffer);
|
||||
}
|
||||
if (pcbRead != null && pcbRead.Length > 0)
|
||||
{
|
||||
pcbRead[0] = written;
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
public virtual Stream GetDataStream()
|
||||
{
|
||||
return DataStream;
|
||||
}
|
||||
|
||||
public virtual void LockRegion(long libOffset, long cb, int dwLockType)
|
||||
{
|
||||
}
|
||||
|
||||
protected static ExternalException EFail(string msg)
|
||||
{
|
||||
throw new ExternalException(msg, InteropMethods.E_FAIL);
|
||||
}
|
||||
|
||||
protected static void NotImplemented()
|
||||
{
|
||||
throw new ExternalException("NotImplemented");
|
||||
}
|
||||
|
||||
public virtual int Read(IntPtr buf, int length)
|
||||
{
|
||||
var buffer = new byte[length];
|
||||
var count = Read(buffer, length);
|
||||
Marshal.Copy(buffer, 0, buf, length);
|
||||
return count;
|
||||
}
|
||||
|
||||
public virtual int Read(byte[] buffer, int length)
|
||||
{
|
||||
ActualizeVirtualPosition();
|
||||
return DataStream.Read(buffer, 0, length);
|
||||
}
|
||||
|
||||
public virtual void Revert()
|
||||
{
|
||||
NotImplemented();
|
||||
}
|
||||
|
||||
public virtual long Seek(long offset, int origin)
|
||||
{
|
||||
var pos = _virtualPosition;
|
||||
if (_virtualPosition == -1)
|
||||
{
|
||||
pos = DataStream.Position;
|
||||
}
|
||||
var len = DataStream.Length;
|
||||
switch (origin)
|
||||
{
|
||||
case InteropValues.StreamConsts.STREAM_SEEK_SET:
|
||||
if (offset <= len)
|
||||
{
|
||||
DataStream.Position = offset;
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_virtualPosition = offset;
|
||||
}
|
||||
break;
|
||||
case InteropValues.StreamConsts.STREAM_SEEK_END:
|
||||
if (offset <= 0)
|
||||
{
|
||||
DataStream.Position = len + offset;
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_virtualPosition = len + offset;
|
||||
}
|
||||
break;
|
||||
case InteropValues.StreamConsts.STREAM_SEEK_CUR:
|
||||
if (offset + pos <= len)
|
||||
{
|
||||
DataStream.Position = pos + offset;
|
||||
_virtualPosition = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_virtualPosition = offset + pos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return _virtualPosition != -1 ? _virtualPosition : DataStream.Position;
|
||||
}
|
||||
|
||||
public virtual void SetSize(long value)
|
||||
{
|
||||
DataStream.SetLength(value);
|
||||
}
|
||||
|
||||
public void Stat(IntPtr pstatstg, int grfStatFlag)
|
||||
{
|
||||
var stats = new STATSTG { cbSize = DataStream.Length };
|
||||
Marshal.StructureToPtr(stats, pstatstg, true);
|
||||
}
|
||||
|
||||
public virtual void UnlockRegion(long libOffset, long cb, int dwLockType)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int Write(IntPtr buf, int length)
|
||||
{
|
||||
var buffer = new byte[length];
|
||||
Marshal.Copy(buf, buffer, 0, length);
|
||||
return Write(buffer, length);
|
||||
}
|
||||
|
||||
public virtual int Write(byte[] buffer, int length)
|
||||
{
|
||||
ActualizeVirtualPosition();
|
||||
DataStream.Write(buffer, 0, length);
|
||||
return length;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class STATSTG
|
||||
{
|
||||
|
||||
[SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")]
|
||||
public IntPtr pwcsName = IntPtr.Zero;
|
||||
public int type;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long cbSize;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long mtime;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long ctime;
|
||||
[MarshalAs(UnmanagedType.I8)]
|
||||
public long atime;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int grfMode;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int grfLocksSupported;
|
||||
|
||||
public int clsid_data1;
|
||||
[MarshalAs(UnmanagedType.I2)]
|
||||
public short clsid_data2;
|
||||
[MarshalAs(UnmanagedType.I2)]
|
||||
public short clsid_data3;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b0;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b1;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b2;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b3;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b4;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b5;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b6;
|
||||
[MarshalAs(UnmanagedType.U1)]
|
||||
public byte clsid_b7;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int grfStateBits;
|
||||
[MarshalAs(UnmanagedType.I4)]
|
||||
public int reserved;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal class GifFrameDimension
|
||||
{
|
||||
internal class GifFrameDimension
|
||||
public GifFrameDimension(Guid guid) => Guid = guid;
|
||||
|
||||
public Guid Guid { get; }
|
||||
|
||||
public static GifFrameDimension Time { get; } = new(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}"));
|
||||
|
||||
public static GifFrameDimension Resolution { get; } = new(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}"));
|
||||
|
||||
public static GifFrameDimension Page { get; } = new(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}"));
|
||||
|
||||
public override bool Equals(object o) => o is GifFrameDimension format && Guid == format.Guid;
|
||||
|
||||
public override int GetHashCode() => Guid.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
public GifFrameDimension(Guid guid) => Guid = guid;
|
||||
|
||||
public Guid Guid { get; }
|
||||
|
||||
public static GifFrameDimension Time { get; } = new(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}"));
|
||||
|
||||
public static GifFrameDimension Resolution { get; } = new(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}"));
|
||||
|
||||
public static GifFrameDimension Page { get; } = new(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}"));
|
||||
|
||||
public override bool Equals(object o) => o is GifFrameDimension format && Guid == format.Guid;
|
||||
|
||||
public override int GetHashCode() => Guid.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Equals(this, Time)) return "Time";
|
||||
if (Equals(this, Resolution)) return "Resolution";
|
||||
if (Equals(this, Page)) return "Page";
|
||||
return "[FrameDimension: " + Guid + "]";
|
||||
}
|
||||
if (Equals(this, Time)) return "Time";
|
||||
if (Equals(this, Resolution)) return "Resolution";
|
||||
if (Equals(this, Page)) return "Page";
|
||||
return "[FrameDimension: " + Guid + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,95 +2,94 @@
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class GifImageInfo
|
||||
{
|
||||
public class GifImageInfo
|
||||
private const int PropertyTagFrameDelay = 0x5100;
|
||||
|
||||
private int _frame;
|
||||
|
||||
private readonly int[] _frameDelay;
|
||||
|
||||
public int FrameCount { get; }
|
||||
|
||||
internal GifImage Image { get; }
|
||||
|
||||
public bool Animated { get; }
|
||||
|
||||
public EventHandler FrameChangedHandler { get; set; }
|
||||
|
||||
internal int FrameTimer { get; set; }
|
||||
|
||||
public bool FrameDirty { get; private set; }
|
||||
|
||||
public int Frame
|
||||
{
|
||||
private const int PropertyTagFrameDelay = 0x5100;
|
||||
|
||||
private int _frame;
|
||||
|
||||
private readonly int[] _frameDelay;
|
||||
|
||||
public int FrameCount { get; }
|
||||
|
||||
internal GifImage Image { get; }
|
||||
|
||||
public bool Animated { get; }
|
||||
|
||||
public EventHandler FrameChangedHandler { get; set; }
|
||||
|
||||
internal int FrameTimer { get; set; }
|
||||
|
||||
public bool FrameDirty { get; private set; }
|
||||
|
||||
public int Frame
|
||||
get => _frame;
|
||||
set
|
||||
{
|
||||
get => _frame;
|
||||
set
|
||||
if (_frame != value)
|
||||
{
|
||||
if (_frame != value)
|
||||
if (value < 0 || value >= FrameCount)
|
||||
{
|
||||
if (value < 0 || value >= FrameCount)
|
||||
{
|
||||
throw new ArgumentException("InvalidFrame");
|
||||
}
|
||||
throw new ArgumentException("InvalidFrame");
|
||||
}
|
||||
|
||||
if (Animated)
|
||||
{
|
||||
_frame = value;
|
||||
FrameDirty = true;
|
||||
if (Animated)
|
||||
{
|
||||
_frame = value;
|
||||
FrameDirty = true;
|
||||
|
||||
OnFrameChanged(EventArgs.Empty);
|
||||
}
|
||||
OnFrameChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GifImageInfo(GifImage image)
|
||||
{
|
||||
Image = image;
|
||||
Animated = ImageAnimator.CanAnimate(image);
|
||||
|
||||
if (Animated)
|
||||
{
|
||||
FrameCount = image.GetFrameCount(GifFrameDimension.Time);
|
||||
|
||||
var frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);
|
||||
|
||||
// If the image does not have a frame delay, we just return 0.
|
||||
//
|
||||
if (frameDelayItem != null)
|
||||
{
|
||||
// Convert the frame delay from byte[] to int
|
||||
//
|
||||
var values = frameDelayItem.Value;
|
||||
_frameDelay = new int[FrameCount];
|
||||
for (var i = 0; i < FrameCount; ++i)
|
||||
{
|
||||
_frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FrameCount = 1;
|
||||
}
|
||||
|
||||
_frameDelay ??= new int[FrameCount];
|
||||
}
|
||||
|
||||
public int FrameDelay(int frame) => _frameDelay[frame];
|
||||
|
||||
internal void UpdateFrame()
|
||||
{
|
||||
if (FrameDirty)
|
||||
{
|
||||
Image.SelectActiveFrame(GifFrameDimension.Time, Frame);
|
||||
FrameDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnFrameChanged(EventArgs e) => FrameChangedHandler?.Invoke(Image, e);
|
||||
}
|
||||
}
|
||||
|
||||
public GifImageInfo(GifImage image)
|
||||
{
|
||||
Image = image;
|
||||
Animated = ImageAnimator.CanAnimate(image);
|
||||
|
||||
if (Animated)
|
||||
{
|
||||
FrameCount = image.GetFrameCount(GifFrameDimension.Time);
|
||||
|
||||
var frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);
|
||||
|
||||
// If the image does not have a frame delay, we just return 0.
|
||||
//
|
||||
if (frameDelayItem != null)
|
||||
{
|
||||
// Convert the frame delay from byte[] to int
|
||||
//
|
||||
var values = frameDelayItem.Value;
|
||||
_frameDelay = new int[FrameCount];
|
||||
for (var i = 0; i < FrameCount; ++i)
|
||||
{
|
||||
_frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FrameCount = 1;
|
||||
}
|
||||
|
||||
_frameDelay ??= new int[FrameCount];
|
||||
}
|
||||
|
||||
public int FrameDelay(int frame) => _frameDelay[frame];
|
||||
|
||||
internal void UpdateFrame()
|
||||
{
|
||||
if (FrameDirty)
|
||||
{
|
||||
Image.SelectActiveFrame(GifFrameDimension.Time, Frame);
|
||||
FrameDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnFrameChanged(EventArgs e) => FrameChangedHandler?.Invoke(Image, e);
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class GifPropertyItem
|
||||
{
|
||||
public class GifPropertyItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Len { get; set; }
|
||||
public int Len { get; set; }
|
||||
|
||||
public short Type { get; set; }
|
||||
public short Type { get; set; }
|
||||
|
||||
public byte[] Value { get; set; }
|
||||
}
|
||||
}
|
||||
public byte[] Value { get; set; }
|
||||
}
|
||||
@@ -2,113 +2,112 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class GifPropertyItemInternal : IDisposable
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class GifPropertyItemInternal : IDisposable
|
||||
public int id;
|
||||
public int len;
|
||||
public short type;
|
||||
public IntPtr value = IntPtr.Zero;
|
||||
|
||||
internal GifPropertyItemInternal()
|
||||
{
|
||||
public int id;
|
||||
public int len;
|
||||
public short type;
|
||||
public IntPtr value = IntPtr.Zero;
|
||||
}
|
||||
|
||||
internal GifPropertyItemInternal()
|
||||
public byte[] Value
|
||||
{
|
||||
get
|
||||
{
|
||||
}
|
||||
if (len == 0)
|
||||
return null;
|
||||
|
||||
public byte[] Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (len == 0)
|
||||
return null;
|
||||
var bytes = new byte[len];
|
||||
|
||||
var bytes = new byte[len];
|
||||
|
||||
Marshal.Copy(value,
|
||||
bytes,
|
||||
0,
|
||||
len);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
~GifPropertyItemInternal()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (value != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(value);
|
||||
value = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
internal static GifPropertyItemInternal ConvertFromPropertyItem(GifPropertyItem propItem)
|
||||
{
|
||||
var propItemInternal = new GifPropertyItemInternal
|
||||
{
|
||||
id = propItem.Id,
|
||||
len = 0,
|
||||
type = propItem.Type
|
||||
};
|
||||
|
||||
var propItemValue = propItem.Value;
|
||||
if (propItemValue != null)
|
||||
{
|
||||
var length = propItemValue.Length;
|
||||
propItemInternal.len = length;
|
||||
propItemInternal.value = Marshal.AllocHGlobal(length);
|
||||
Marshal.Copy(propItemValue, 0, propItemInternal.value, length);
|
||||
}
|
||||
|
||||
return propItemInternal;
|
||||
}
|
||||
|
||||
internal static GifPropertyItem[] ConvertFromMemory(IntPtr propdata, int count)
|
||||
{
|
||||
var props = new GifPropertyItem[count];
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
GifPropertyItemInternal propcopy = null;
|
||||
try
|
||||
{
|
||||
propcopy = (GifPropertyItemInternal) InteropMethods.PtrToStructure(propdata,
|
||||
typeof(GifPropertyItemInternal));
|
||||
|
||||
props[i] = new GifPropertyItem
|
||||
{
|
||||
Id = propcopy.id,
|
||||
Len = propcopy.len,
|
||||
Type = propcopy.type,
|
||||
Value = propcopy.Value
|
||||
};
|
||||
|
||||
// this calls Marshal.Copy and creates a copy of the original memory into a byte array.
|
||||
|
||||
propcopy.value = IntPtr.Zero; // we dont actually own this memory so dont free it.
|
||||
}
|
||||
finally
|
||||
{
|
||||
propcopy?.Dispose();
|
||||
}
|
||||
|
||||
propdata = (IntPtr) ((long) propdata + Marshal.SizeOf(typeof(GifPropertyItemInternal)));
|
||||
}
|
||||
|
||||
return props;
|
||||
Marshal.Copy(value,
|
||||
bytes,
|
||||
0,
|
||||
len);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
~GifPropertyItemInternal()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (value != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(value);
|
||||
value = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
internal static GifPropertyItemInternal ConvertFromPropertyItem(GifPropertyItem propItem)
|
||||
{
|
||||
var propItemInternal = new GifPropertyItemInternal
|
||||
{
|
||||
id = propItem.Id,
|
||||
len = 0,
|
||||
type = propItem.Type
|
||||
};
|
||||
|
||||
var propItemValue = propItem.Value;
|
||||
if (propItemValue != null)
|
||||
{
|
||||
var length = propItemValue.Length;
|
||||
propItemInternal.len = length;
|
||||
propItemInternal.value = Marshal.AllocHGlobal(length);
|
||||
Marshal.Copy(propItemValue, 0, propItemInternal.value, length);
|
||||
}
|
||||
|
||||
return propItemInternal;
|
||||
}
|
||||
|
||||
internal static GifPropertyItem[] ConvertFromMemory(IntPtr propdata, int count)
|
||||
{
|
||||
var props = new GifPropertyItem[count];
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
GifPropertyItemInternal propcopy = null;
|
||||
try
|
||||
{
|
||||
propcopy = (GifPropertyItemInternal) InteropMethods.PtrToStructure(propdata,
|
||||
typeof(GifPropertyItemInternal));
|
||||
|
||||
props[i] = new GifPropertyItem
|
||||
{
|
||||
Id = propcopy.id,
|
||||
Len = propcopy.len,
|
||||
Type = propcopy.type,
|
||||
Value = propcopy.Value
|
||||
};
|
||||
|
||||
// this calls Marshal.Copy and creates a copy of the original memory into a byte array.
|
||||
|
||||
propcopy.value = IntPtr.Zero; // we dont actually own this memory so dont free it.
|
||||
}
|
||||
finally
|
||||
{
|
||||
propcopy?.Dispose();
|
||||
}
|
||||
|
||||
propdata = (IntPtr) ((long) propdata + Marshal.SizeOf(typeof(GifPropertyItemInternal)));
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
using HandyControl.Controls;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal class ChangeScope : DisposableObject
|
||||
{
|
||||
internal class ChangeScope : DisposableObject
|
||||
private readonly GlowWindow _window;
|
||||
|
||||
public ChangeScope(GlowWindow window)
|
||||
{
|
||||
private readonly GlowWindow _window;
|
||||
|
||||
public ChangeScope(GlowWindow window)
|
||||
{
|
||||
_window = window;
|
||||
_window.DeferGlowChangesCount++;
|
||||
}
|
||||
|
||||
protected override void DisposeManagedResources()
|
||||
{
|
||||
_window.DeferGlowChangesCount--;
|
||||
if (_window.DeferGlowChangesCount == 0) _window.EndDeferGlowChanges();
|
||||
}
|
||||
_window = window;
|
||||
_window.DeferGlowChangesCount++;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeManagedResources()
|
||||
{
|
||||
_window.DeferGlowChangesCount--;
|
||||
if (_window.DeferGlowChangesCount == 0) _window.EndDeferGlowChanges();
|
||||
}
|
||||
}
|
||||
@@ -4,111 +4,110 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal class GlowBitmap : DisposableObject
|
||||
{
|
||||
internal class GlowBitmap : DisposableObject
|
||||
internal const int GlowBitmapPartCount = 16;
|
||||
|
||||
private const int BytesPerPixelBgra32 = 4;
|
||||
|
||||
private static readonly CachedBitmapInfo[] _transparencyMasks = new CachedBitmapInfo[GlowBitmapPartCount];
|
||||
|
||||
private readonly InteropValues.BITMAPINFO _bitmapInfo;
|
||||
|
||||
private readonly IntPtr _pbits;
|
||||
|
||||
internal GlowBitmap(IntPtr hdcScreen, int width, int height)
|
||||
{
|
||||
internal const int GlowBitmapPartCount = 16;
|
||||
_bitmapInfo.biSize = Marshal.SizeOf(typeof(InteropValues.BITMAPINFOHEADER));
|
||||
_bitmapInfo.biPlanes = 1;
|
||||
_bitmapInfo.biBitCount = 32;
|
||||
_bitmapInfo.biCompression = 0;
|
||||
_bitmapInfo.biXPelsPerMeter = 0;
|
||||
_bitmapInfo.biYPelsPerMeter = 0;
|
||||
_bitmapInfo.biWidth = width;
|
||||
_bitmapInfo.biHeight = -height;
|
||||
|
||||
private const int BytesPerPixelBgra32 = 4;
|
||||
Handle = InteropMethods.CreateDIBSection(
|
||||
hdcScreen,
|
||||
ref _bitmapInfo,
|
||||
0u,
|
||||
out _pbits,
|
||||
IntPtr.Zero,
|
||||
0u);
|
||||
}
|
||||
|
||||
private static readonly CachedBitmapInfo[] _transparencyMasks = new CachedBitmapInfo[GlowBitmapPartCount];
|
||||
internal IntPtr Handle { get; }
|
||||
|
||||
private readonly InteropValues.BITMAPINFO _bitmapInfo;
|
||||
internal IntPtr DIBits => _pbits;
|
||||
|
||||
private readonly IntPtr _pbits;
|
||||
internal int Width => _bitmapInfo.biWidth;
|
||||
|
||||
internal GlowBitmap(IntPtr hdcScreen, int width, int height)
|
||||
internal int Height => -_bitmapInfo.biHeight;
|
||||
|
||||
protected override void DisposeNativeResources() => InteropMethods.DeleteObject(Handle);
|
||||
|
||||
private static byte PremultiplyAlpha(byte channel, byte alpha) => (byte) (channel * alpha / 255.0);
|
||||
|
||||
internal static GlowBitmap Create(GlowDrawingContext drawingContext, GlowBitmapPart bitmapPart, Color color)
|
||||
{
|
||||
var orCreateAlphaMask =
|
||||
GetOrCreateAlphaMask(bitmapPart);
|
||||
|
||||
var glowBitmap =
|
||||
new GlowBitmap(
|
||||
drawingContext.ScreenDC,
|
||||
orCreateAlphaMask.Width,
|
||||
orCreateAlphaMask.Height);
|
||||
|
||||
for (var i = 0; i < orCreateAlphaMask.DIBits.Length; i += BytesPerPixelBgra32)
|
||||
{
|
||||
_bitmapInfo.biSize = Marshal.SizeOf(typeof(InteropValues.BITMAPINFOHEADER));
|
||||
_bitmapInfo.biPlanes = 1;
|
||||
_bitmapInfo.biBitCount = 32;
|
||||
_bitmapInfo.biCompression = 0;
|
||||
_bitmapInfo.biXPelsPerMeter = 0;
|
||||
_bitmapInfo.biYPelsPerMeter = 0;
|
||||
_bitmapInfo.biWidth = width;
|
||||
_bitmapInfo.biHeight = -height;
|
||||
|
||||
Handle = InteropMethods.CreateDIBSection(
|
||||
hdcScreen,
|
||||
ref _bitmapInfo,
|
||||
0u,
|
||||
out _pbits,
|
||||
IntPtr.Zero,
|
||||
0u);
|
||||
var b = orCreateAlphaMask.DIBits[i + 3];
|
||||
var val = PremultiplyAlpha(color.R, b);
|
||||
var val2 = PremultiplyAlpha(color.G, b);
|
||||
var val3 = PremultiplyAlpha(color.B, b);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i, val3);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 1, val2);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 2, val);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 3, b);
|
||||
}
|
||||
|
||||
internal IntPtr Handle { get; }
|
||||
return glowBitmap;
|
||||
}
|
||||
|
||||
internal IntPtr DIBits => _pbits;
|
||||
|
||||
internal int Width => _bitmapInfo.biWidth;
|
||||
|
||||
internal int Height => -_bitmapInfo.biHeight;
|
||||
|
||||
protected override void DisposeNativeResources() => InteropMethods.DeleteObject(Handle);
|
||||
|
||||
private static byte PremultiplyAlpha(byte channel, byte alpha) => (byte) (channel * alpha / 255.0);
|
||||
|
||||
internal static GlowBitmap Create(GlowDrawingContext drawingContext, GlowBitmapPart bitmapPart, Color color)
|
||||
private static CachedBitmapInfo GetOrCreateAlphaMask(GlowBitmapPart bitmapPart)
|
||||
{
|
||||
if (_transparencyMasks[(int) bitmapPart] == null)
|
||||
{
|
||||
var orCreateAlphaMask =
|
||||
GetOrCreateAlphaMask(bitmapPart);
|
||||
var bitmapImage = new BitmapImage(new Uri($"pack://application:,,,/HandyControl;Component/Resources/Images/GlowWindow/{bitmapPart}.png"));
|
||||
|
||||
var glowBitmap =
|
||||
new GlowBitmap(
|
||||
drawingContext.ScreenDC,
|
||||
orCreateAlphaMask.Width,
|
||||
orCreateAlphaMask.Height);
|
||||
var array = new byte[BytesPerPixelBgra32 * bitmapImage.PixelWidth * bitmapImage.PixelHeight];
|
||||
var stride = BytesPerPixelBgra32 * bitmapImage.PixelWidth;
|
||||
bitmapImage.CopyPixels(array, stride, 0);
|
||||
bitmapImage.Freeze();
|
||||
|
||||
for (var i = 0; i < orCreateAlphaMask.DIBits.Length; i += BytesPerPixelBgra32)
|
||||
{
|
||||
var b = orCreateAlphaMask.DIBits[i + 3];
|
||||
var val = PremultiplyAlpha(color.R, b);
|
||||
var val2 = PremultiplyAlpha(color.G, b);
|
||||
var val3 = PremultiplyAlpha(color.B, b);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i, val3);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 1, val2);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 2, val);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 3, b);
|
||||
}
|
||||
|
||||
return glowBitmap;
|
||||
_transparencyMasks[(int) bitmapPart] =
|
||||
new CachedBitmapInfo(
|
||||
array,
|
||||
bitmapImage.PixelWidth,
|
||||
bitmapImage.PixelHeight);
|
||||
}
|
||||
|
||||
private static CachedBitmapInfo GetOrCreateAlphaMask(GlowBitmapPart bitmapPart)
|
||||
return _transparencyMasks[(int) bitmapPart];
|
||||
}
|
||||
|
||||
private sealed class CachedBitmapInfo
|
||||
{
|
||||
internal readonly byte[] DIBits;
|
||||
internal readonly int Height;
|
||||
internal readonly int Width;
|
||||
|
||||
internal CachedBitmapInfo(byte[] diBits, int width, int height)
|
||||
{
|
||||
if (_transparencyMasks[(int) bitmapPart] == null)
|
||||
{
|
||||
var bitmapImage = new BitmapImage(new Uri($"pack://application:,,,/HandyControl;Component/Resources/Images/GlowWindow/{bitmapPart}.png"));
|
||||
|
||||
var array = new byte[BytesPerPixelBgra32 * bitmapImage.PixelWidth * bitmapImage.PixelHeight];
|
||||
var stride = BytesPerPixelBgra32 * bitmapImage.PixelWidth;
|
||||
bitmapImage.CopyPixels(array, stride, 0);
|
||||
bitmapImage.Freeze();
|
||||
|
||||
_transparencyMasks[(int) bitmapPart] =
|
||||
new CachedBitmapInfo(
|
||||
array,
|
||||
bitmapImage.PixelWidth,
|
||||
bitmapImage.PixelHeight);
|
||||
}
|
||||
|
||||
return _transparencyMasks[(int) bitmapPart];
|
||||
}
|
||||
|
||||
private sealed class CachedBitmapInfo
|
||||
{
|
||||
internal readonly byte[] DIBits;
|
||||
internal readonly int Height;
|
||||
internal readonly int Width;
|
||||
|
||||
internal CachedBitmapInfo(byte[] diBits, int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
DIBits = diBits;
|
||||
}
|
||||
Width = width;
|
||||
Height = height;
|
||||
DIBits = diBits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,21 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal enum GlowBitmapPart
|
||||
{
|
||||
internal enum GlowBitmapPart
|
||||
{
|
||||
CornerTopLeft,
|
||||
CornerTopRight,
|
||||
CornerBottomLeft,
|
||||
CornerBottomRight,
|
||||
TopLeft,
|
||||
Top,
|
||||
TopRight,
|
||||
LeftTop,
|
||||
Left,
|
||||
LeftBottom,
|
||||
BottomLeft,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
RightTop,
|
||||
Right,
|
||||
RightBottom
|
||||
}
|
||||
}
|
||||
CornerTopLeft,
|
||||
CornerTopRight,
|
||||
CornerBottomLeft,
|
||||
CornerBottomRight,
|
||||
TopLeft,
|
||||
Top,
|
||||
TopRight,
|
||||
LeftTop,
|
||||
Left,
|
||||
LeftBottom,
|
||||
BottomLeft,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
RightTop,
|
||||
Right,
|
||||
RightBottom
|
||||
}
|
||||
@@ -1,51 +1,50 @@
|
||||
using System;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal class GlowDrawingContext : DisposableObject
|
||||
{
|
||||
internal class GlowDrawingContext : DisposableObject
|
||||
private readonly GlowBitmap _windowBitmap;
|
||||
|
||||
internal InteropValues.BLENDFUNCTION Blend;
|
||||
|
||||
internal GlowDrawingContext(int width, int height)
|
||||
{
|
||||
private readonly GlowBitmap _windowBitmap;
|
||||
|
||||
internal InteropValues.BLENDFUNCTION Blend;
|
||||
|
||||
internal GlowDrawingContext(int width, int height)
|
||||
{
|
||||
ScreenDC = InteropMethods.GetDC(IntPtr.Zero);
|
||||
if (ScreenDC == IntPtr.Zero) return;
|
||||
WindowDC = InteropMethods.CreateCompatibleDC(ScreenDC);
|
||||
if (WindowDC == IntPtr.Zero) return;
|
||||
BackgroundDC = InteropMethods.CreateCompatibleDC(ScreenDC);
|
||||
if (BackgroundDC == IntPtr.Zero) return;
|
||||
Blend.BlendOp = 0;
|
||||
Blend.BlendFlags = 0;
|
||||
Blend.SourceConstantAlpha = 255;
|
||||
Blend.AlphaFormat = 1;
|
||||
_windowBitmap = new GlowBitmap(ScreenDC, width, height);
|
||||
InteropMethods.SelectObject(WindowDC, _windowBitmap.Handle);
|
||||
}
|
||||
|
||||
internal bool IsInitialized =>
|
||||
ScreenDC != IntPtr.Zero && WindowDC != IntPtr.Zero &&
|
||||
BackgroundDC != IntPtr.Zero && _windowBitmap != null;
|
||||
|
||||
internal IntPtr ScreenDC { get; }
|
||||
|
||||
internal IntPtr WindowDC { get; }
|
||||
|
||||
internal IntPtr BackgroundDC { get; }
|
||||
|
||||
internal int Width => _windowBitmap.Width;
|
||||
|
||||
internal int Height => _windowBitmap.Height;
|
||||
|
||||
protected override void DisposeManagedResources() => _windowBitmap.Dispose();
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
if (ScreenDC != IntPtr.Zero) InteropMethods.ReleaseDC(IntPtr.Zero, ScreenDC);
|
||||
if (WindowDC != IntPtr.Zero) InteropMethods.DeleteDC(WindowDC);
|
||||
if (BackgroundDC != IntPtr.Zero) InteropMethods.DeleteDC(BackgroundDC);
|
||||
}
|
||||
ScreenDC = InteropMethods.GetDC(IntPtr.Zero);
|
||||
if (ScreenDC == IntPtr.Zero) return;
|
||||
WindowDC = InteropMethods.CreateCompatibleDC(ScreenDC);
|
||||
if (WindowDC == IntPtr.Zero) return;
|
||||
BackgroundDC = InteropMethods.CreateCompatibleDC(ScreenDC);
|
||||
if (BackgroundDC == IntPtr.Zero) return;
|
||||
Blend.BlendOp = 0;
|
||||
Blend.BlendFlags = 0;
|
||||
Blend.SourceConstantAlpha = 255;
|
||||
Blend.AlphaFormat = 1;
|
||||
_windowBitmap = new GlowBitmap(ScreenDC, width, height);
|
||||
InteropMethods.SelectObject(WindowDC, _windowBitmap.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsInitialized =>
|
||||
ScreenDC != IntPtr.Zero && WindowDC != IntPtr.Zero &&
|
||||
BackgroundDC != IntPtr.Zero && _windowBitmap != null;
|
||||
|
||||
internal IntPtr ScreenDC { get; }
|
||||
|
||||
internal IntPtr WindowDC { get; }
|
||||
|
||||
internal IntPtr BackgroundDC { get; }
|
||||
|
||||
internal int Width => _windowBitmap.Width;
|
||||
|
||||
internal int Height => _windowBitmap.Height;
|
||||
|
||||
protected override void DisposeManagedResources() => _windowBitmap.Dispose();
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
if (ScreenDC != IntPtr.Zero) InteropMethods.ReleaseDC(IntPtr.Zero, ScreenDC);
|
||||
if (WindowDC != IntPtr.Zero) InteropMethods.DeleteDC(WindowDC);
|
||||
if (BackgroundDC != IntPtr.Zero) InteropMethods.DeleteDC(BackgroundDC);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class HandyControlConfig
|
||||
{
|
||||
public string Lang { get; set; }
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public int TimelineFrameRate { get; set; } = 60;
|
||||
}
|
||||
}
|
||||
public class HandyControlConfig
|
||||
{
|
||||
public string Lang { get; set; }
|
||||
|
||||
public int TimelineFrameRate { get; set; } = 60;
|
||||
}
|
||||
@@ -2,101 +2,100 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public abstract class HwndWrapper : DisposableObject
|
||||
{
|
||||
public abstract class HwndWrapper : DisposableObject
|
||||
private IntPtr _handle;
|
||||
|
||||
private bool _isHandleCreationAllowed = true;
|
||||
|
||||
private ushort _wndClassAtom;
|
||||
|
||||
private Delegate _wndProc;
|
||||
|
||||
protected ushort WindowClassAtom
|
||||
{
|
||||
private IntPtr _handle;
|
||||
|
||||
private bool _isHandleCreationAllowed = true;
|
||||
|
||||
private ushort _wndClassAtom;
|
||||
|
||||
private Delegate _wndProc;
|
||||
|
||||
protected ushort WindowClassAtom
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_wndClassAtom == 0) _wndClassAtom = CreateWindowClassCore();
|
||||
return _wndClassAtom;
|
||||
}
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureHandle();
|
||||
return _handle;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsWindowSubclassed => false;
|
||||
|
||||
protected virtual ushort CreateWindowClassCore() => RegisterClass(Guid.NewGuid().ToString());
|
||||
|
||||
protected virtual void DestroyWindowClassCore()
|
||||
{
|
||||
if (_wndClassAtom != 0)
|
||||
{
|
||||
var moduleHandle = InteropMethods.GetModuleHandle(null);
|
||||
InteropMethods.UnregisterClass(new IntPtr(_wndClassAtom), moduleHandle);
|
||||
_wndClassAtom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected ushort RegisterClass(string className)
|
||||
{
|
||||
var wndClass = default(InteropValues.WNDCLASS);
|
||||
wndClass.cbClsExtra = 0;
|
||||
wndClass.cbWndExtra = 0;
|
||||
wndClass.hbrBackground = IntPtr.Zero;
|
||||
wndClass.hCursor = IntPtr.Zero;
|
||||
wndClass.hIcon = IntPtr.Zero;
|
||||
wndClass.lpfnWndProc = _wndProc = new InteropValues.WndProc(WndProc);
|
||||
wndClass.lpszClassName = className;
|
||||
wndClass.lpszMenuName = null;
|
||||
wndClass.style = 0u;
|
||||
return InteropMethods.RegisterClass(ref wndClass);
|
||||
}
|
||||
|
||||
private void SubclassWndProc()
|
||||
{
|
||||
_wndProc = new InteropValues.WndProc(WndProc);
|
||||
InteropMethods.SetWindowLong(_handle, -4, Marshal.GetFunctionPointerForDelegate(_wndProc));
|
||||
}
|
||||
|
||||
protected abstract IntPtr CreateWindowCore();
|
||||
|
||||
protected virtual void DestroyWindowCore()
|
||||
{
|
||||
if (_handle != IntPtr.Zero)
|
||||
{
|
||||
InteropMethods.DestroyWindow(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam) =>
|
||||
InteropMethods.DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
|
||||
public void EnsureHandle()
|
||||
{
|
||||
if (_handle == IntPtr.Zero)
|
||||
{
|
||||
if (!_isHandleCreationAllowed) return;
|
||||
_isHandleCreationAllowed = false;
|
||||
_handle = CreateWindowCore();
|
||||
if (IsWindowSubclassed) SubclassWndProc();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
_isHandleCreationAllowed = false;
|
||||
DestroyWindowCore();
|
||||
DestroyWindowClassCore();
|
||||
if (_wndClassAtom == 0) _wndClassAtom = CreateWindowClassCore();
|
||||
return _wndClassAtom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureHandle();
|
||||
return _handle;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsWindowSubclassed => false;
|
||||
|
||||
protected virtual ushort CreateWindowClassCore() => RegisterClass(Guid.NewGuid().ToString());
|
||||
|
||||
protected virtual void DestroyWindowClassCore()
|
||||
{
|
||||
if (_wndClassAtom != 0)
|
||||
{
|
||||
var moduleHandle = InteropMethods.GetModuleHandle(null);
|
||||
InteropMethods.UnregisterClass(new IntPtr(_wndClassAtom), moduleHandle);
|
||||
_wndClassAtom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected ushort RegisterClass(string className)
|
||||
{
|
||||
var wndClass = default(InteropValues.WNDCLASS);
|
||||
wndClass.cbClsExtra = 0;
|
||||
wndClass.cbWndExtra = 0;
|
||||
wndClass.hbrBackground = IntPtr.Zero;
|
||||
wndClass.hCursor = IntPtr.Zero;
|
||||
wndClass.hIcon = IntPtr.Zero;
|
||||
wndClass.lpfnWndProc = _wndProc = new InteropValues.WndProc(WndProc);
|
||||
wndClass.lpszClassName = className;
|
||||
wndClass.lpszMenuName = null;
|
||||
wndClass.style = 0u;
|
||||
return InteropMethods.RegisterClass(ref wndClass);
|
||||
}
|
||||
|
||||
private void SubclassWndProc()
|
||||
{
|
||||
_wndProc = new InteropValues.WndProc(WndProc);
|
||||
InteropMethods.SetWindowLong(_handle, -4, Marshal.GetFunctionPointerForDelegate(_wndProc));
|
||||
}
|
||||
|
||||
protected abstract IntPtr CreateWindowCore();
|
||||
|
||||
protected virtual void DestroyWindowCore()
|
||||
{
|
||||
if (_handle != IntPtr.Zero)
|
||||
{
|
||||
InteropMethods.DestroyWindow(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam) =>
|
||||
InteropMethods.DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
|
||||
public void EnsureHandle()
|
||||
{
|
||||
if (_handle == IntPtr.Zero)
|
||||
{
|
||||
if (!_isHandleCreationAllowed) return;
|
||||
_isHandleCreationAllowed = false;
|
||||
_handle = CreateWindowCore();
|
||||
if (IsWindowSubclassed) SubclassWndProc();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
_isHandleCreationAllowed = false;
|
||||
DestroyWindowCore();
|
||||
DestroyWindowClassCore();
|
||||
}
|
||||
}
|
||||
@@ -2,40 +2,39 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class GrowlInfo
|
||||
{
|
||||
public class GrowlInfo
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public bool ShowDateTime { get; set; } = true;
|
||||
public bool ShowDateTime { get; set; } = true;
|
||||
|
||||
public int WaitTime { get; set; } = 6;
|
||||
public int WaitTime { get; set; } = 6;
|
||||
|
||||
public string CancelStr { get; set; } = Properties.Langs.Lang.Cancel;
|
||||
public string CancelStr { get; set; } = Properties.Langs.Lang.Cancel;
|
||||
|
||||
public string ConfirmStr { get; set; } = Properties.Langs.Lang.Confirm;
|
||||
public string ConfirmStr { get; set; } = Properties.Langs.Lang.Confirm;
|
||||
|
||||
public Func<bool, bool> ActionBeforeClose { get; set; }
|
||||
public Func<bool, bool> ActionBeforeClose { get; set; }
|
||||
|
||||
public bool StaysOpen { get; set; }
|
||||
public bool StaysOpen { get; set; }
|
||||
|
||||
public bool IsCustom { get; set; }
|
||||
public bool IsCustom { get; set; }
|
||||
|
||||
public InfoType Type { get; set; }
|
||||
public InfoType Type { get; set; }
|
||||
|
||||
public Geometry Icon { get; set; }
|
||||
public Geometry Icon { get; set; }
|
||||
|
||||
public string IconKey { get; set; }
|
||||
public string IconKey { get; set; }
|
||||
|
||||
public Brush IconBrush { get; set; }
|
||||
public Brush IconBrush { get; set; }
|
||||
|
||||
public string IconBrushKey { get; set; }
|
||||
public string IconBrushKey { get; set; }
|
||||
|
||||
public bool ShowCloseButton { get; set; } = true;
|
||||
public bool ShowCloseButton { get; set; } = true;
|
||||
|
||||
public string Token { get; set; }
|
||||
public string Token { get; set; }
|
||||
|
||||
public FlowDirection FlowDirection { get; set; }
|
||||
}
|
||||
}
|
||||
public FlowDirection FlowDirection { get; set; }
|
||||
}
|
||||
@@ -3,156 +3,155 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal sealed class ImageCodecInfo
|
||||
{
|
||||
internal sealed class ImageCodecInfo
|
||||
private string _dllName;
|
||||
|
||||
public Guid Clsid { get; set; }
|
||||
|
||||
public Guid FormatID { get; set; }
|
||||
|
||||
public string CodecName { get; set; }
|
||||
|
||||
public string DllName
|
||||
{
|
||||
private string _dllName;
|
||||
|
||||
public Guid Clsid { get; set; }
|
||||
|
||||
public Guid FormatID { get; set; }
|
||||
|
||||
public string CodecName { get; set; }
|
||||
|
||||
public string DllName
|
||||
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
|
||||
get
|
||||
{
|
||||
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
|
||||
get
|
||||
if (_dllName != null)
|
||||
{
|
||||
if (_dllName != null)
|
||||
{
|
||||
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, _dllName).Demand();
|
||||
}
|
||||
return _dllName;
|
||||
}
|
||||
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, value).Demand();
|
||||
}
|
||||
_dllName = value;
|
||||
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, _dllName).Demand();
|
||||
}
|
||||
return _dllName;
|
||||
}
|
||||
|
||||
public string FormatDescription { get; set; }
|
||||
|
||||
public string FilenameExtension { get; set; }
|
||||
|
||||
public string MimeType { get; set; }
|
||||
|
||||
public ImageCodecFlags Flags { get; set; }
|
||||
|
||||
public int Version { get; set; }
|
||||
|
||||
public byte[][] SignaturePatterns { get; set; }
|
||||
|
||||
public byte[][] SignatureMasks { get; set; }
|
||||
|
||||
public static ImageCodecInfo[] GetImageDecoders()
|
||||
[SuppressMessage("Microsoft.Security", "CA2103:ReviewImperativeSecurity")]
|
||||
set
|
||||
{
|
||||
ImageCodecInfo[] imageCodecs;
|
||||
|
||||
var status = InteropMethods.Gdip.GdipGetImageDecodersSize(out var numDecoders, out var size);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
if (value != null)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, value).Demand();
|
||||
}
|
||||
|
||||
var memory = Marshal.AllocHGlobal(size);
|
||||
|
||||
try
|
||||
{
|
||||
status = InteropMethods.Gdip.GdipGetImageDecoders(numDecoders, size, memory);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
imageCodecs = ConvertFromMemory(memory, numDecoders);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(memory);
|
||||
}
|
||||
|
||||
return imageCodecs;
|
||||
}
|
||||
|
||||
public static ImageCodecInfo[] GetImageEncoders()
|
||||
{
|
||||
ImageCodecInfo[] imageCodecs;
|
||||
|
||||
var status = InteropMethods.Gdip.GdipGetImageEncodersSize(out var numEncoders, out var size);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
var memory = Marshal.AllocHGlobal(size);
|
||||
|
||||
try
|
||||
{
|
||||
status = InteropMethods.Gdip.GdipGetImageEncoders(numEncoders, size, memory);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
imageCodecs = ConvertFromMemory(memory, numEncoders);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(memory);
|
||||
}
|
||||
|
||||
return imageCodecs;
|
||||
}
|
||||
|
||||
public static ImageCodecInfo[] ConvertFromMemory(IntPtr memoryStart, int numCodecs)
|
||||
{
|
||||
var codecs = new ImageCodecInfo[numCodecs];
|
||||
|
||||
int index;
|
||||
|
||||
for (index = 0; index < numCodecs; index++)
|
||||
{
|
||||
var curcodec = (IntPtr) ((long) memoryStart + Marshal.SizeOf(typeof(InteropValues.ImageCodecInfoPrivate)) * index);
|
||||
var codecp = new InteropValues.ImageCodecInfoPrivate();
|
||||
InteropMethods.PtrToStructure(curcodec, codecp);
|
||||
|
||||
codecs[index] = new ImageCodecInfo
|
||||
{
|
||||
Clsid = codecp.Clsid,
|
||||
FormatID = codecp.FormatID,
|
||||
CodecName = Marshal.PtrToStringUni(codecp.CodecName),
|
||||
DllName = Marshal.PtrToStringUni(codecp.DllName),
|
||||
FormatDescription = Marshal.PtrToStringUni(codecp.FormatDescription),
|
||||
FilenameExtension = Marshal.PtrToStringUni(codecp.FilenameExtension),
|
||||
MimeType = Marshal.PtrToStringUni(codecp.MimeType),
|
||||
Flags = (ImageCodecFlags) codecp.Flags,
|
||||
Version = codecp.Version,
|
||||
SignaturePatterns = new byte[codecp.SigCount][],
|
||||
SignatureMasks = new byte[codecp.SigCount][]
|
||||
};
|
||||
|
||||
for (var j = 0; j < codecp.SigCount; j++)
|
||||
{
|
||||
codecs[index].SignaturePatterns[j] = new byte[codecp.SigSize];
|
||||
codecs[index].SignatureMasks[j] = new byte[codecp.SigSize];
|
||||
|
||||
Marshal.Copy((IntPtr) ((long) codecp.SigMask + j * codecp.SigSize), codecs[index].SignatureMasks[j], 0, codecp.SigSize);
|
||||
Marshal.Copy((IntPtr) ((long) codecp.SigPattern + j * codecp.SigSize), codecs[index].SignaturePatterns[j], 0, codecp.SigSize);
|
||||
}
|
||||
}
|
||||
|
||||
return codecs;
|
||||
_dllName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string FormatDescription { get; set; }
|
||||
|
||||
public string FilenameExtension { get; set; }
|
||||
|
||||
public string MimeType { get; set; }
|
||||
|
||||
public ImageCodecFlags Flags { get; set; }
|
||||
|
||||
public int Version { get; set; }
|
||||
|
||||
public byte[][] SignaturePatterns { get; set; }
|
||||
|
||||
public byte[][] SignatureMasks { get; set; }
|
||||
|
||||
public static ImageCodecInfo[] GetImageDecoders()
|
||||
{
|
||||
ImageCodecInfo[] imageCodecs;
|
||||
|
||||
var status = InteropMethods.Gdip.GdipGetImageDecodersSize(out var numDecoders, out var size);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
var memory = Marshal.AllocHGlobal(size);
|
||||
|
||||
try
|
||||
{
|
||||
status = InteropMethods.Gdip.GdipGetImageDecoders(numDecoders, size, memory);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
imageCodecs = ConvertFromMemory(memory, numDecoders);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(memory);
|
||||
}
|
||||
|
||||
return imageCodecs;
|
||||
}
|
||||
|
||||
public static ImageCodecInfo[] GetImageEncoders()
|
||||
{
|
||||
ImageCodecInfo[] imageCodecs;
|
||||
|
||||
var status = InteropMethods.Gdip.GdipGetImageEncodersSize(out var numEncoders, out var size);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
var memory = Marshal.AllocHGlobal(size);
|
||||
|
||||
try
|
||||
{
|
||||
status = InteropMethods.Gdip.GdipGetImageEncoders(numEncoders, size, memory);
|
||||
|
||||
if (status != InteropMethods.Gdip.Ok)
|
||||
{
|
||||
throw InteropMethods.Gdip.StatusException(status);
|
||||
}
|
||||
|
||||
imageCodecs = ConvertFromMemory(memory, numEncoders);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(memory);
|
||||
}
|
||||
|
||||
return imageCodecs;
|
||||
}
|
||||
|
||||
public static ImageCodecInfo[] ConvertFromMemory(IntPtr memoryStart, int numCodecs)
|
||||
{
|
||||
var codecs = new ImageCodecInfo[numCodecs];
|
||||
|
||||
int index;
|
||||
|
||||
for (index = 0; index < numCodecs; index++)
|
||||
{
|
||||
var curcodec = (IntPtr) ((long) memoryStart + Marshal.SizeOf(typeof(InteropValues.ImageCodecInfoPrivate)) * index);
|
||||
var codecp = new InteropValues.ImageCodecInfoPrivate();
|
||||
InteropMethods.PtrToStructure(curcodec, codecp);
|
||||
|
||||
codecs[index] = new ImageCodecInfo
|
||||
{
|
||||
Clsid = codecp.Clsid,
|
||||
FormatID = codecp.FormatID,
|
||||
CodecName = Marshal.PtrToStringUni(codecp.CodecName),
|
||||
DllName = Marshal.PtrToStringUni(codecp.DllName),
|
||||
FormatDescription = Marshal.PtrToStringUni(codecp.FormatDescription),
|
||||
FilenameExtension = Marshal.PtrToStringUni(codecp.FilenameExtension),
|
||||
MimeType = Marshal.PtrToStringUni(codecp.MimeType),
|
||||
Flags = (ImageCodecFlags) codecp.Flags,
|
||||
Version = codecp.Version,
|
||||
SignaturePatterns = new byte[codecp.SigCount][],
|
||||
SignatureMasks = new byte[codecp.SigCount][]
|
||||
};
|
||||
|
||||
for (var j = 0; j < codecp.SigCount; j++)
|
||||
{
|
||||
codecs[index].SignaturePatterns[j] = new byte[codecp.SigSize];
|
||||
codecs[index].SignatureMasks[j] = new byte[codecp.SigSize];
|
||||
|
||||
Marshal.Copy((IntPtr) ((long) codecp.SigMask + j * codecp.SigSize), codecs[index].SignatureMasks[j], 0, codecp.SigSize);
|
||||
Marshal.Copy((IntPtr) ((long) codecp.SigPattern + j * codecp.SigSize), codecs[index].SignaturePatterns[j], 0, codecp.SigSize);
|
||||
}
|
||||
}
|
||||
|
||||
return codecs;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,27 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class MessageBoxInfo
|
||||
{
|
||||
public class MessageBoxInfo
|
||||
{
|
||||
public string Message { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public string Caption { get; set; }
|
||||
public string Caption { get; set; }
|
||||
|
||||
public MessageBoxButton Button { get; set; } = MessageBoxButton.OK;
|
||||
public MessageBoxButton Button { get; set; } = MessageBoxButton.OK;
|
||||
|
||||
public Geometry Icon { get; set; }
|
||||
public Geometry Icon { get; set; }
|
||||
|
||||
public string IconKey { get; set; }
|
||||
public string IconKey { get; set; }
|
||||
|
||||
public Brush IconBrush { get; set; }
|
||||
public Brush IconBrush { get; set; }
|
||||
|
||||
public string IconBrushKey { get; set; }
|
||||
public string IconBrushKey { get; set; }
|
||||
|
||||
public MessageBoxResult DefaultResult { get; set; } = MessageBoxResult.None;
|
||||
public MessageBoxResult DefaultResult { get; set; } = MessageBoxResult.None;
|
||||
|
||||
public Style Style { get; set; }
|
||||
public Style Style { get; set; }
|
||||
|
||||
public string StyleKey { get; set; }
|
||||
}
|
||||
}
|
||||
public string StyleKey { get; set; }
|
||||
}
|
||||
@@ -3,77 +3,76 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public readonly struct SystemVersionInfo
|
||||
{
|
||||
public readonly struct SystemVersionInfo
|
||||
public static SystemVersionInfo Windows10 => new(10, 0, 10240);
|
||||
|
||||
public static SystemVersionInfo Windows10_1809 => new(10, 0, 17763);
|
||||
|
||||
public static SystemVersionInfo Windows10_1903 => new(10, 0, 18362);
|
||||
|
||||
public SystemVersionInfo(int major, int minor, int build)
|
||||
{
|
||||
public static SystemVersionInfo Windows10 => new(10, 0, 10240);
|
||||
|
||||
public static SystemVersionInfo Windows10_1809 => new(10, 0, 17763);
|
||||
|
||||
public static SystemVersionInfo Windows10_1903 => new(10, 0, 18362);
|
||||
|
||||
public SystemVersionInfo(int major, int minor, int build)
|
||||
{
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
Build = build;
|
||||
}
|
||||
|
||||
public int Major { get; }
|
||||
|
||||
public int Minor { get; }
|
||||
|
||||
public int Build { get; }
|
||||
|
||||
public bool Equals(SystemVersionInfo other) => Major == other.Major && Minor == other.Minor && Build == other.Build;
|
||||
|
||||
public override bool Equals(object obj) => obj is SystemVersionInfo other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Major.GetHashCode() ^ Minor.GetHashCode() ^ Build.GetHashCode();
|
||||
|
||||
public static bool operator ==(SystemVersionInfo left, SystemVersionInfo right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(SystemVersionInfo left, SystemVersionInfo right) => !(left == right);
|
||||
|
||||
public int CompareTo(SystemVersionInfo other)
|
||||
{
|
||||
if (Major != other.Major)
|
||||
{
|
||||
return Major.CompareTo(other.Major);
|
||||
}
|
||||
|
||||
if (Minor != other.Minor)
|
||||
{
|
||||
return Minor.CompareTo(other.Minor);
|
||||
}
|
||||
|
||||
if (Build != other.Build)
|
||||
{
|
||||
return Build.CompareTo(other.Build);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is SystemVersionInfo other))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
return CompareTo(other);
|
||||
}
|
||||
|
||||
public static bool operator <(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) < 0;
|
||||
|
||||
public static bool operator <=(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) <= 0;
|
||||
|
||||
public static bool operator >(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) > 0;
|
||||
|
||||
public static bool operator >=(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) >= 0;
|
||||
|
||||
public override string ToString() => $"{Major}.{Minor}.{Build}";
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
Build = build;
|
||||
}
|
||||
}
|
||||
|
||||
public int Major { get; }
|
||||
|
||||
public int Minor { get; }
|
||||
|
||||
public int Build { get; }
|
||||
|
||||
public bool Equals(SystemVersionInfo other) => Major == other.Major && Minor == other.Minor && Build == other.Build;
|
||||
|
||||
public override bool Equals(object obj) => obj is SystemVersionInfo other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Major.GetHashCode() ^ Minor.GetHashCode() ^ Build.GetHashCode();
|
||||
|
||||
public static bool operator ==(SystemVersionInfo left, SystemVersionInfo right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(SystemVersionInfo left, SystemVersionInfo right) => !(left == right);
|
||||
|
||||
public int CompareTo(SystemVersionInfo other)
|
||||
{
|
||||
if (Major != other.Major)
|
||||
{
|
||||
return Major.CompareTo(other.Major);
|
||||
}
|
||||
|
||||
if (Minor != other.Minor)
|
||||
{
|
||||
return Minor.CompareTo(other.Minor);
|
||||
}
|
||||
|
||||
if (Build != other.Build)
|
||||
{
|
||||
return Build.CompareTo(other.Build);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is SystemVersionInfo other))
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
return CompareTo(other);
|
||||
}
|
||||
|
||||
public static bool operator <(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) < 0;
|
||||
|
||||
public static bool operator <=(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) <= 0;
|
||||
|
||||
public static bool operator >(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) > 0;
|
||||
|
||||
public static bool operator >=(SystemVersionInfo left, SystemVersionInfo right) => left.CompareTo(right) >= 0;
|
||||
|
||||
public override string ToString() => $"{Major}.{Minor}.{Build}";
|
||||
}
|
||||
@@ -1,25 +1,24 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class OperationResult
|
||||
{
|
||||
public static OperationResult<bool> Failed(string message = "")
|
||||
{
|
||||
return new()
|
||||
{
|
||||
ResultType = ResultType.Failed,
|
||||
Message = message,
|
||||
Data = false
|
||||
};
|
||||
}
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public static OperationResult<bool> Success(string message = "")
|
||||
public class OperationResult
|
||||
{
|
||||
public static OperationResult<bool> Failed(string message = "")
|
||||
{
|
||||
return new()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
ResultType = ResultType.Success,
|
||||
Message = message,
|
||||
Data = true
|
||||
};
|
||||
}
|
||||
ResultType = ResultType.Failed,
|
||||
Message = message,
|
||||
Data = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static OperationResult<bool> Success(string message = "")
|
||||
{
|
||||
return new()
|
||||
{
|
||||
ResultType = ResultType.Success,
|
||||
Message = message,
|
||||
Data = true
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,22 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 表示一个操作的返回结果信息
|
||||
/// </summary>
|
||||
public class OperationResult<T> : OperationResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 表示一个操作的返回结果信息
|
||||
/// 操作结果
|
||||
/// </summary>
|
||||
public class OperationResult<T> : OperationResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作结果
|
||||
/// </summary>
|
||||
public ResultType ResultType { get; set; }
|
||||
public ResultType ResultType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public T Data { get; set; }
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public T Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作消息(包含错误原因等数据)
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 操作消息(包含错误原因等数据)
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
@@ -1,70 +1,69 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
internal struct PanelUvSize
|
||||
{
|
||||
internal struct PanelUvSize
|
||||
private readonly Orientation _orientation;
|
||||
|
||||
public Size ScreenSize => new(U, V);
|
||||
|
||||
public double U { get; set; }
|
||||
|
||||
public double V { get; set; }
|
||||
|
||||
public double Width
|
||||
{
|
||||
private readonly Orientation _orientation;
|
||||
|
||||
public Size ScreenSize => new(U, V);
|
||||
|
||||
public double U { get; set; }
|
||||
|
||||
public double V { get; set; }
|
||||
|
||||
public double Width
|
||||
get => _orientation == Orientation.Horizontal ? U : V;
|
||||
private set
|
||||
{
|
||||
get => _orientation == Orientation.Horizontal ? U : V;
|
||||
private set
|
||||
if (_orientation == Orientation.Horizontal)
|
||||
{
|
||||
if (_orientation == Orientation.Horizontal)
|
||||
{
|
||||
U = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
V = value;
|
||||
}
|
||||
U = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double Height
|
||||
{
|
||||
get => _orientation == Orientation.Horizontal ? V : U;
|
||||
private set
|
||||
else
|
||||
{
|
||||
if (_orientation == Orientation.Horizontal)
|
||||
{
|
||||
V = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
U = value;
|
||||
}
|
||||
V = value;
|
||||
}
|
||||
}
|
||||
|
||||
public PanelUvSize(Orientation orientation, double width, double height)
|
||||
{
|
||||
U = V = 0d;
|
||||
_orientation = orientation;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public PanelUvSize(Orientation orientation, Size size)
|
||||
{
|
||||
U = V = 0d;
|
||||
_orientation = orientation;
|
||||
Width = size.Width;
|
||||
Height = size.Height;
|
||||
}
|
||||
|
||||
public PanelUvSize(Orientation orientation)
|
||||
{
|
||||
U = V = 0d;
|
||||
_orientation = orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double Height
|
||||
{
|
||||
get => _orientation == Orientation.Horizontal ? V : U;
|
||||
private set
|
||||
{
|
||||
if (_orientation == Orientation.Horizontal)
|
||||
{
|
||||
V = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
U = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PanelUvSize(Orientation orientation, double width, double height)
|
||||
{
|
||||
U = V = 0d;
|
||||
_orientation = orientation;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public PanelUvSize(Orientation orientation, Size size)
|
||||
{
|
||||
U = V = 0d;
|
||||
_orientation = orientation;
|
||||
Width = size.Width;
|
||||
Height = size.Height;
|
||||
}
|
||||
|
||||
public PanelUvSize(Orientation orientation)
|
||||
{
|
||||
U = V = 0d;
|
||||
_orientation = orientation;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +1,62 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色范围
|
||||
/// </summary>
|
||||
public class ColorRange : IValueRange<Color>
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色范围
|
||||
/// </summary>
|
||||
public class ColorRange : IValueRange<Color>
|
||||
private Color _start;
|
||||
|
||||
public Color Start
|
||||
{
|
||||
private Color _start;
|
||||
|
||||
public Color Start
|
||||
get => _start;
|
||||
set
|
||||
{
|
||||
get => _start;
|
||||
set
|
||||
{
|
||||
_start = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
private Color _end;
|
||||
|
||||
public Color End
|
||||
{
|
||||
get => _end;
|
||||
set
|
||||
{
|
||||
_end = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 颜色差值
|
||||
/// </summary>
|
||||
private readonly int[] _subColorArr = new int[4];
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
_subColorArr[0] = _start.A - _end.A;
|
||||
_subColorArr[1] = _start.R - _end.R;
|
||||
_subColorArr[2] = _start.G - _end.G;
|
||||
_subColorArr[3] = _start.B - _end.B;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定比例处的颜色
|
||||
/// </summary>
|
||||
/// <param name="range">范围(0-1)</param>
|
||||
/// <returns></returns>
|
||||
public Color GetColor(double range)
|
||||
{
|
||||
if (range < 0 || range > 1) return default;
|
||||
return Color.FromArgb((byte) (_start.A - _subColorArr[0] * range), (byte) (_start.R - _subColorArr[1] * range),
|
||||
(byte) (_start.G - _subColorArr[2] * range), (byte) (_start.B - _subColorArr[3] * range));
|
||||
_start = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _end;
|
||||
|
||||
public Color End
|
||||
{
|
||||
get => _end;
|
||||
set
|
||||
{
|
||||
_end = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 颜色差值
|
||||
/// </summary>
|
||||
private readonly int[] _subColorArr = new int[4];
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
_subColorArr[0] = _start.A - _end.A;
|
||||
_subColorArr[1] = _start.R - _end.R;
|
||||
_subColorArr[2] = _start.G - _end.G;
|
||||
_subColorArr[3] = _start.B - _end.B;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定比例处的颜色
|
||||
/// </summary>
|
||||
/// <param name="range">范围(0-1)</param>
|
||||
/// <returns></returns>
|
||||
public Color GetColor(double range)
|
||||
{
|
||||
if (range < 0 || range > 1) return default;
|
||||
return Color.FromArgb((byte) (_start.A - _subColorArr[0] * range), (byte) (_start.R - _subColorArr[1] * range),
|
||||
(byte) (_start.G - _subColorArr[2] * range), (byte) (_start.B - _subColorArr[3] * range));
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public struct DateTimeRange : IValueRange<DateTime>
|
||||
{
|
||||
public struct DateTimeRange : IValueRange<DateTime>
|
||||
public DateTimeRange(DateTime start)
|
||||
{
|
||||
public DateTimeRange(DateTime start)
|
||||
{
|
||||
Start = start;
|
||||
End = start;
|
||||
}
|
||||
|
||||
public DateTimeRange(DateTime start, DateTime end)
|
||||
{
|
||||
Start = start;
|
||||
End = end;
|
||||
}
|
||||
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
public DateTime End { get; set; }
|
||||
|
||||
public double TotalMilliseconds => (End - Start).TotalMilliseconds;
|
||||
Start = start;
|
||||
End = start;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTimeRange(DateTime start, DateTime end)
|
||||
{
|
||||
Start = start;
|
||||
End = end;
|
||||
}
|
||||
|
||||
public DateTime Start { get; set; }
|
||||
|
||||
public DateTime End { get; set; }
|
||||
|
||||
public double TotalMilliseconds => (End - Start).TotalMilliseconds;
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public struct DoubleRange : IValueRange<double>
|
||||
{
|
||||
public double Start { get; set; }
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public double End { get; set; }
|
||||
}
|
||||
}
|
||||
public struct DoubleRange : IValueRange<double>
|
||||
{
|
||||
public double Start { get; set; }
|
||||
|
||||
public double End { get; set; }
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public interface IValueRange<T>
|
||||
{
|
||||
T Start { get; set; }
|
||||
namespace HandyControl.Data;
|
||||
|
||||
T End { get; set; }
|
||||
}
|
||||
}
|
||||
public interface IValueRange<T>
|
||||
{
|
||||
T Start { get; set; }
|
||||
|
||||
T End { get; set; }
|
||||
}
|
||||
@@ -1,375 +1,374 @@
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
public class ResourceToken
|
||||
{
|
||||
public class ResourceToken
|
||||
{
|
||||
#region Basic
|
||||
#region Basic
|
||||
|
||||
#region Geometry
|
||||
#region Geometry
|
||||
|
||||
public const string CalendarGeometry = nameof(CalendarGeometry);
|
||||
public const string CalendarGeometry = nameof(CalendarGeometry);
|
||||
|
||||
public const string DeleteGeometry = nameof(DeleteGeometry);
|
||||
public const string DeleteGeometry = nameof(DeleteGeometry);
|
||||
|
||||
public const string DeleteFillCircleGeometry = nameof(DeleteFillCircleGeometry);
|
||||
public const string DeleteFillCircleGeometry = nameof(DeleteFillCircleGeometry);
|
||||
|
||||
public const string CloseGeometry = nameof(CloseGeometry);
|
||||
public const string CloseGeometry = nameof(CloseGeometry);
|
||||
|
||||
public const string UpGeometry = nameof(UpGeometry);
|
||||
public const string UpGeometry = nameof(UpGeometry);
|
||||
|
||||
public const string DownGeometry = nameof(DownGeometry);
|
||||
public const string DownGeometry = nameof(DownGeometry);
|
||||
|
||||
public const string ClockGeometry = nameof(ClockGeometry);
|
||||
public const string ClockGeometry = nameof(ClockGeometry);
|
||||
|
||||
public const string LeftGeometry = nameof(LeftGeometry);
|
||||
public const string LeftGeometry = nameof(LeftGeometry);
|
||||
|
||||
public const string RightGeometry = nameof(RightGeometry);
|
||||
public const string RightGeometry = nameof(RightGeometry);
|
||||
|
||||
public const string RotateLeftGeometry = nameof(RotateLeftGeometry);
|
||||
public const string RotateLeftGeometry = nameof(RotateLeftGeometry);
|
||||
|
||||
public const string EnlargeGeometry = nameof(EnlargeGeometry);
|
||||
public const string EnlargeGeometry = nameof(EnlargeGeometry);
|
||||
|
||||
public const string ReduceGeometry = nameof(ReduceGeometry);
|
||||
public const string ReduceGeometry = nameof(ReduceGeometry);
|
||||
|
||||
public const string DownloadGeometry = nameof(DownloadGeometry);
|
||||
public const string DownloadGeometry = nameof(DownloadGeometry);
|
||||
|
||||
public const string SaveGeometry = nameof(SaveGeometry);
|
||||
public const string SaveGeometry = nameof(SaveGeometry);
|
||||
|
||||
public const string WindowsGeometry = nameof(WindowsGeometry);
|
||||
public const string WindowsGeometry = nameof(WindowsGeometry);
|
||||
|
||||
public const string FullScreenGeometry = nameof(FullScreenGeometry);
|
||||
public const string FullScreenGeometry = nameof(FullScreenGeometry);
|
||||
|
||||
public const string FullScreenReturnGeometry = nameof(FullScreenReturnGeometry);
|
||||
public const string FullScreenReturnGeometry = nameof(FullScreenReturnGeometry);
|
||||
|
||||
public const string SearchGeometry = nameof(SearchGeometry);
|
||||
public const string SearchGeometry = nameof(SearchGeometry);
|
||||
|
||||
public const string UpDownGeometry = nameof(UpDownGeometry);
|
||||
public const string UpDownGeometry = nameof(UpDownGeometry);
|
||||
|
||||
public const string WindowMinGeometry = nameof(WindowMinGeometry);
|
||||
public const string WindowMinGeometry = nameof(WindowMinGeometry);
|
||||
|
||||
public const string CheckedGeometry = nameof(CheckedGeometry);
|
||||
public const string CheckedGeometry = nameof(CheckedGeometry);
|
||||
|
||||
public const string EyeOpenGeometry = nameof(EyeOpenGeometry);
|
||||
public const string EyeOpenGeometry = nameof(EyeOpenGeometry);
|
||||
|
||||
public const string EyeCloseGeometry = nameof(EyeCloseGeometry);
|
||||
public const string EyeCloseGeometry = nameof(EyeCloseGeometry);
|
||||
|
||||
public const string WindowRestoreGeometry = nameof(WindowRestoreGeometry);
|
||||
public const string WindowRestoreGeometry = nameof(WindowRestoreGeometry);
|
||||
|
||||
public const string WindowMaxGeometry = nameof(WindowMaxGeometry);
|
||||
public const string WindowMaxGeometry = nameof(WindowMaxGeometry);
|
||||
|
||||
public const string AudioGeometry = nameof(AudioGeometry);
|
||||
public const string AudioGeometry = nameof(AudioGeometry);
|
||||
|
||||
public const string BubbleTailGeometry = nameof(BubbleTailGeometry);
|
||||
public const string BubbleTailGeometry = nameof(BubbleTailGeometry);
|
||||
|
||||
public const string StarGeometry = nameof(StarGeometry);
|
||||
public const string StarGeometry = nameof(StarGeometry);
|
||||
|
||||
public const string AddGeometry = nameof(AddGeometry);
|
||||
public const string AddGeometry = nameof(AddGeometry);
|
||||
|
||||
public const string SubGeometry = nameof(SubGeometry);
|
||||
public const string SubGeometry = nameof(SubGeometry);
|
||||
|
||||
public const string AllGeometry = nameof(AllGeometry);
|
||||
public const string AllGeometry = nameof(AllGeometry);
|
||||
|
||||
public const string DragGeometry = nameof(DragGeometry);
|
||||
public const string DragGeometry = nameof(DragGeometry);
|
||||
|
||||
public const string DropperGeometry = nameof(DropperGeometry);
|
||||
public const string DropperGeometry = nameof(DropperGeometry);
|
||||
|
||||
public const string SuccessGeometry = nameof(SuccessGeometry);
|
||||
public const string SuccessGeometry = nameof(SuccessGeometry);
|
||||
|
||||
public const string InfoGeometry = nameof(InfoGeometry);
|
||||
public const string InfoGeometry = nameof(InfoGeometry);
|
||||
|
||||
public const string ErrorGeometry = nameof(ErrorGeometry);
|
||||
public const string ErrorGeometry = nameof(ErrorGeometry);
|
||||
|
||||
public const string WarningGeometry = nameof(WarningGeometry);
|
||||
public const string WarningGeometry = nameof(WarningGeometry);
|
||||
|
||||
public const string AskGeometry = nameof(AskGeometry);
|
||||
public const string AskGeometry = nameof(AskGeometry);
|
||||
|
||||
public const string FatalGeometry = nameof(FatalGeometry);
|
||||
public const string FatalGeometry = nameof(FatalGeometry);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Brush
|
||||
#region Brush
|
||||
|
||||
public const string PrimaryBrush = nameof(PrimaryBrush);
|
||||
public const string PrimaryBrush = nameof(PrimaryBrush);
|
||||
|
||||
public const string DarkPrimaryBrush = nameof(DarkPrimaryBrush);
|
||||
public const string DarkPrimaryBrush = nameof(DarkPrimaryBrush);
|
||||
|
||||
public const string SuccessBrush = nameof(SuccessBrush);
|
||||
public const string SuccessBrush = nameof(SuccessBrush);
|
||||
|
||||
public const string DarkSuccessBrush = nameof(DarkSuccessBrush);
|
||||
public const string DarkSuccessBrush = nameof(DarkSuccessBrush);
|
||||
|
||||
public const string InfoBrush = nameof(InfoBrush);
|
||||
public const string InfoBrush = nameof(InfoBrush);
|
||||
|
||||
public const string DarkInfoBrush = nameof(DarkInfoBrush);
|
||||
public const string DarkInfoBrush = nameof(DarkInfoBrush);
|
||||
|
||||
public const string DangerBrush = nameof(DangerBrush);
|
||||
public const string DangerBrush = nameof(DangerBrush);
|
||||
|
||||
public const string DarkDangerBrush = nameof(DarkDangerBrush);
|
||||
public const string DarkDangerBrush = nameof(DarkDangerBrush);
|
||||
|
||||
public const string WarningBrush = nameof(WarningBrush);
|
||||
public const string WarningBrush = nameof(WarningBrush);
|
||||
|
||||
public const string DarkWarningBrush = nameof(DarkWarningBrush);
|
||||
public const string DarkWarningBrush = nameof(DarkWarningBrush);
|
||||
|
||||
public const string AccentBrush = nameof(AccentBrush);
|
||||
public const string AccentBrush = nameof(AccentBrush);
|
||||
|
||||
public const string DarkAccentBrush = nameof(DarkAccentBrush);
|
||||
public const string DarkAccentBrush = nameof(DarkAccentBrush);
|
||||
|
||||
public const string PrimaryTextBrush = nameof(PrimaryTextBrush);
|
||||
public const string PrimaryTextBrush = nameof(PrimaryTextBrush);
|
||||
|
||||
public const string SecondaryTextBrush = nameof(SecondaryTextBrush);
|
||||
public const string SecondaryTextBrush = nameof(SecondaryTextBrush);
|
||||
|
||||
public const string ThirdlyTextBrush = nameof(ThirdlyTextBrush);
|
||||
public const string ThirdlyTextBrush = nameof(ThirdlyTextBrush);
|
||||
|
||||
public const string ReverseTextBrush = nameof(ReverseTextBrush);
|
||||
public const string ReverseTextBrush = nameof(ReverseTextBrush);
|
||||
|
||||
public const string TextIconBrush = nameof(TextIconBrush);
|
||||
public const string TextIconBrush = nameof(TextIconBrush);
|
||||
|
||||
public const string BorderBrush = nameof(BorderBrush);
|
||||
public const string BorderBrush = nameof(BorderBrush);
|
||||
|
||||
public const string SecondaryBorderBrush = nameof(SecondaryBorderBrush);
|
||||
public const string SecondaryBorderBrush = nameof(SecondaryBorderBrush);
|
||||
|
||||
public const string BackgroundBrush = nameof(BackgroundBrush);
|
||||
public const string BackgroundBrush = nameof(BackgroundBrush);
|
||||
|
||||
public const string RegionBrush = nameof(RegionBrush);
|
||||
public const string RegionBrush = nameof(RegionBrush);
|
||||
|
||||
public const string SecondaryRegionBrush = nameof(SecondaryRegionBrush);
|
||||
public const string SecondaryRegionBrush = nameof(SecondaryRegionBrush);
|
||||
|
||||
public const string ThirdlyRegionBrush = nameof(ThirdlyRegionBrush);
|
||||
public const string ThirdlyRegionBrush = nameof(ThirdlyRegionBrush);
|
||||
|
||||
public const string TitleBrush = nameof(TitleBrush);
|
||||
public const string TitleBrush = nameof(TitleBrush);
|
||||
|
||||
public const string DefaultBrush = nameof(DefaultBrush);
|
||||
public const string DefaultBrush = nameof(DefaultBrush);
|
||||
|
||||
public const string DarkDefaultBrush = nameof(DarkDefaultBrush);
|
||||
public const string DarkDefaultBrush = nameof(DarkDefaultBrush);
|
||||
|
||||
public const string DarkMaskBrush = nameof(DarkMaskBrush);
|
||||
public const string DarkMaskBrush = nameof(DarkMaskBrush);
|
||||
|
||||
public const string DarkOpacityBrush = nameof(DarkOpacityBrush);
|
||||
public const string DarkOpacityBrush = nameof(DarkOpacityBrush);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Converter
|
||||
#region Converter
|
||||
|
||||
public const string Boolean2BooleanReConverter = nameof(Boolean2BooleanReConverter);
|
||||
public const string Boolean2BooleanReConverter = nameof(Boolean2BooleanReConverter);
|
||||
|
||||
public const string Boolean2VisibilityReConverter = nameof(Boolean2VisibilityReConverter);
|
||||
public const string Boolean2VisibilityReConverter = nameof(Boolean2VisibilityReConverter);
|
||||
|
||||
public const string BooleanArr2VisibilityConverter = nameof(BooleanArr2VisibilityConverter);
|
||||
public const string BooleanArr2VisibilityConverter = nameof(BooleanArr2VisibilityConverter);
|
||||
|
||||
public const string Long2FileSizeConverter = nameof(Long2FileSizeConverter);
|
||||
public const string Long2FileSizeConverter = nameof(Long2FileSizeConverter);
|
||||
|
||||
public const string String2VisibilityConverter = nameof(String2VisibilityConverter);
|
||||
public const string String2VisibilityConverter = nameof(String2VisibilityConverter);
|
||||
|
||||
public const string String2VisibilityReConverter = nameof(String2VisibilityReConverter);
|
||||
public const string String2VisibilityReConverter = nameof(String2VisibilityReConverter);
|
||||
|
||||
public const string Boolean2VisibilityConverter = nameof(Boolean2VisibilityConverter);
|
||||
public const string Boolean2VisibilityConverter = nameof(Boolean2VisibilityConverter);
|
||||
|
||||
public const string TreeViewItemMarginConverter = nameof(TreeViewItemMarginConverter);
|
||||
public const string TreeViewItemMarginConverter = nameof(TreeViewItemMarginConverter);
|
||||
|
||||
public const string Color2HexStringConverter = nameof(Color2HexStringConverter);
|
||||
public const string Color2HexStringConverter = nameof(Color2HexStringConverter);
|
||||
|
||||
public const string Object2BooleanConverter = nameof(Object2BooleanConverter);
|
||||
public const string Object2BooleanConverter = nameof(Object2BooleanConverter);
|
||||
|
||||
public const string Boolean2StringConverter = nameof(Boolean2StringConverter);
|
||||
public const string Boolean2StringConverter = nameof(Boolean2StringConverter);
|
||||
|
||||
public const string Int2StringConverter = nameof(Int2StringConverter);
|
||||
public const string Int2StringConverter = nameof(Int2StringConverter);
|
||||
|
||||
public const string BorderClipConverter = nameof(BorderClipConverter);
|
||||
public const string BorderClipConverter = nameof(BorderClipConverter);
|
||||
|
||||
public const string BorderCircularClipConverter = nameof(BorderCircularClipConverter);
|
||||
public const string BorderCircularClipConverter = nameof(BorderCircularClipConverter);
|
||||
|
||||
public const string BorderCircularConverter = nameof(BorderCircularConverter);
|
||||
public const string BorderCircularConverter = nameof(BorderCircularConverter);
|
||||
|
||||
public const string Object2VisibilityConverter = nameof(Object2VisibilityConverter);
|
||||
public const string Object2VisibilityConverter = nameof(Object2VisibilityConverter);
|
||||
|
||||
public const string Number2PercentageConverter = nameof(Number2PercentageConverter);
|
||||
public const string Number2PercentageConverter = nameof(Number2PercentageConverter);
|
||||
|
||||
public const string RectangleCircularConverter = nameof(RectangleCircularConverter);
|
||||
public const string RectangleCircularConverter = nameof(RectangleCircularConverter);
|
||||
|
||||
public const string ThicknessSplitConverter = nameof(ThicknessSplitConverter);
|
||||
public const string ThicknessSplitConverter = nameof(ThicknessSplitConverter);
|
||||
|
||||
public const string CornerRadiusSplitConverter = nameof(CornerRadiusSplitConverter);
|
||||
public const string CornerRadiusSplitConverter = nameof(CornerRadiusSplitConverter);
|
||||
|
||||
public const string MenuScrollingVisibilityConverter = nameof(MenuScrollingVisibilityConverter);
|
||||
public const string MenuScrollingVisibilityConverter = nameof(MenuScrollingVisibilityConverter);
|
||||
|
||||
public const string Double2GridLengthConverter = nameof(Double2GridLengthConverter);
|
||||
public const string Double2GridLengthConverter = nameof(Double2GridLengthConverter);
|
||||
|
||||
public const string DoubleMinConverter = nameof(DoubleMinConverter);
|
||||
public const string DoubleMinConverter = nameof(DoubleMinConverter);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Effect
|
||||
#region Effect
|
||||
|
||||
public const string EffectShadowColor = nameof(EffectShadowColor);
|
||||
public const string EffectShadowColor = nameof(EffectShadowColor);
|
||||
|
||||
public const string EffectShadow1 = nameof(EffectShadow1);
|
||||
public const string EffectShadow1 = nameof(EffectShadow1);
|
||||
|
||||
public const string EffectShadow2 = nameof(EffectShadow2);
|
||||
public const string EffectShadow2 = nameof(EffectShadow2);
|
||||
|
||||
public const string EffectShadow3 = nameof(EffectShadow3);
|
||||
public const string EffectShadow3 = nameof(EffectShadow3);
|
||||
|
||||
public const string EffectShadow4 = nameof(EffectShadow4);
|
||||
public const string EffectShadow4 = nameof(EffectShadow4);
|
||||
|
||||
public const string EffectShadow5 = nameof(EffectShadow5);
|
||||
public const string EffectShadow5 = nameof(EffectShadow5);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Color
|
||||
#region Color
|
||||
|
||||
public const string PrimaryColor = nameof(PrimaryColor);
|
||||
public const string PrimaryColor = nameof(PrimaryColor);
|
||||
|
||||
public const string DarkPrimaryColor = nameof(DarkPrimaryColor);
|
||||
public const string DarkPrimaryColor = nameof(DarkPrimaryColor);
|
||||
|
||||
public const string DangerColor = nameof(DangerColor);
|
||||
public const string DangerColor = nameof(DangerColor);
|
||||
|
||||
public const string DarkDangerColor = nameof(DarkDangerColor);
|
||||
public const string DarkDangerColor = nameof(DarkDangerColor);
|
||||
|
||||
public const string WarningColor = nameof(WarningColor);
|
||||
public const string WarningColor = nameof(WarningColor);
|
||||
|
||||
public const string DarkWarningColor = nameof(DarkWarningColor);
|
||||
public const string DarkWarningColor = nameof(DarkWarningColor);
|
||||
|
||||
public const string InfoColor = nameof(InfoColor);
|
||||
public const string InfoColor = nameof(InfoColor);
|
||||
|
||||
public const string DarkInfoColor = nameof(DarkInfoColor);
|
||||
public const string DarkInfoColor = nameof(DarkInfoColor);
|
||||
|
||||
public const string SuccessColor = nameof(SuccessColor);
|
||||
public const string SuccessColor = nameof(SuccessColor);
|
||||
|
||||
public const string DarkSuccessColor = nameof(DarkSuccessColor);
|
||||
public const string DarkSuccessColor = nameof(DarkSuccessColor);
|
||||
|
||||
public const string PrimaryTextColor = nameof(PrimaryTextColor);
|
||||
public const string PrimaryTextColor = nameof(PrimaryTextColor);
|
||||
|
||||
public const string SecondaryTextColor = nameof(SecondaryTextColor);
|
||||
public const string SecondaryTextColor = nameof(SecondaryTextColor);
|
||||
|
||||
public const string ThirdlyTextColor = nameof(ThirdlyTextColor);
|
||||
public const string ThirdlyTextColor = nameof(ThirdlyTextColor);
|
||||
|
||||
public const string ReverseTextColor = nameof(ReverseTextColor);
|
||||
public const string ReverseTextColor = nameof(ReverseTextColor);
|
||||
|
||||
public const string TextIconColor = nameof(TextIconColor);
|
||||
public const string TextIconColor = nameof(TextIconColor);
|
||||
|
||||
public const string BorderColor = nameof(BorderColor);
|
||||
public const string BorderColor = nameof(BorderColor);
|
||||
|
||||
public const string SecondaryBorderColor = nameof(SecondaryBorderColor);
|
||||
public const string SecondaryBorderColor = nameof(SecondaryBorderColor);
|
||||
|
||||
public const string BackgroundColor = nameof(BackgroundColor);
|
||||
public const string BackgroundColor = nameof(BackgroundColor);
|
||||
|
||||
public const string RegionColor = nameof(RegionColor);
|
||||
public const string RegionColor = nameof(RegionColor);
|
||||
|
||||
public const string SecondaryRegionColor = nameof(SecondaryRegionColor);
|
||||
public const string SecondaryRegionColor = nameof(SecondaryRegionColor);
|
||||
|
||||
public const string ThirdlyRegionColor = nameof(ThirdlyRegionColor);
|
||||
public const string ThirdlyRegionColor = nameof(ThirdlyRegionColor);
|
||||
|
||||
public const string TitleColor = nameof(TitleColor);
|
||||
public const string TitleColor = nameof(TitleColor);
|
||||
|
||||
public const string SecondaryTitleColor = nameof(SecondaryTitleColor);
|
||||
public const string SecondaryTitleColor = nameof(SecondaryTitleColor);
|
||||
|
||||
public const string DefaultColor = nameof(DefaultColor);
|
||||
public const string DefaultColor = nameof(DefaultColor);
|
||||
|
||||
public const string DarkDefaultColor = nameof(DarkDefaultColor);
|
||||
public const string DarkDefaultColor = nameof(DarkDefaultColor);
|
||||
|
||||
public const string AccentColor = nameof(AccentColor);
|
||||
public const string AccentColor = nameof(AccentColor);
|
||||
|
||||
public const string DarkAccentColor = nameof(DarkAccentColor);
|
||||
public const string DarkAccentColor = nameof(DarkAccentColor);
|
||||
|
||||
public const string DarkMaskColor = nameof(DarkMaskColor);
|
||||
public const string DarkMaskColor = nameof(DarkMaskColor);
|
||||
|
||||
public const string DarkOpacityColor = nameof(DarkOpacityColor);
|
||||
public const string DarkOpacityColor = nameof(DarkOpacityColor);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Behavior
|
||||
#region Behavior
|
||||
|
||||
public const string BehaviorXY200 = nameof(BehaviorXY200);
|
||||
public const string BehaviorXY200 = nameof(BehaviorXY200);
|
||||
|
||||
public const string BehaviorX200 = nameof(BehaviorX200);
|
||||
public const string BehaviorX200 = nameof(BehaviorX200);
|
||||
|
||||
public const string BehaviorY200 = nameof(BehaviorY200);
|
||||
public const string BehaviorY200 = nameof(BehaviorY200);
|
||||
|
||||
public const string BehaviorXY400 = nameof(BehaviorXY400);
|
||||
public const string BehaviorXY400 = nameof(BehaviorXY400);
|
||||
|
||||
public const string BehaviorX400 = nameof(BehaviorX400);
|
||||
public const string BehaviorX400 = nameof(BehaviorX400);
|
||||
|
||||
public const string BehaviorY400 = nameof(BehaviorY400);
|
||||
public const string BehaviorY400 = nameof(BehaviorY400);
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Internal
|
||||
#region Internal
|
||||
|
||||
internal const string BlurGradientValue = nameof(BlurGradientValue);
|
||||
internal const string BlurGradientValue = nameof(BlurGradientValue);
|
||||
|
||||
internal const string ButtonCustom = nameof(ButtonCustom);
|
||||
internal const string ButtonCustom = nameof(ButtonCustom);
|
||||
|
||||
internal const string PaginationButtonStyle = nameof(PaginationButtonStyle);
|
||||
internal const string PaginationButtonStyle = nameof(PaginationButtonStyle);
|
||||
|
||||
internal const string WindowWin10 = nameof(WindowWin10);
|
||||
internal const string WindowWin10 = nameof(WindowWin10);
|
||||
|
||||
internal const string WindowBlur = nameof(WindowBlur);
|
||||
internal const string WindowBlur = nameof(WindowBlur);
|
||||
|
||||
internal const string WindowGlow = nameof(WindowGlow);
|
||||
internal const string WindowGlow = nameof(WindowGlow);
|
||||
|
||||
internal const string Window4ScreenshotStyle = nameof(Window4ScreenshotStyle);
|
||||
internal const string Window4ScreenshotStyle = nameof(Window4ScreenshotStyle);
|
||||
|
||||
internal const string AddTagButtonStyle = nameof(AddTagButtonStyle);
|
||||
internal const string AddTagButtonStyle = nameof(AddTagButtonStyle);
|
||||
|
||||
internal const string RadioGroupItemDefault = nameof(RadioGroupItemDefault);
|
||||
internal const string RadioGroupItemDefault = nameof(RadioGroupItemDefault);
|
||||
|
||||
internal const string RadioGroupItemSingle = nameof(RadioGroupItemSingle);
|
||||
internal const string RadioGroupItemSingle = nameof(RadioGroupItemSingle);
|
||||
|
||||
internal const string RadioGroupItemHorizontalFirst = nameof(RadioGroupItemHorizontalFirst);
|
||||
internal const string RadioGroupItemHorizontalFirst = nameof(RadioGroupItemHorizontalFirst);
|
||||
|
||||
internal const string RadioGroupItemHorizontalLast = nameof(RadioGroupItemHorizontalLast);
|
||||
internal const string RadioGroupItemHorizontalLast = nameof(RadioGroupItemHorizontalLast);
|
||||
|
||||
internal const string RadioGroupItemVerticalFirst = nameof(RadioGroupItemVerticalFirst);
|
||||
internal const string RadioGroupItemVerticalFirst = nameof(RadioGroupItemVerticalFirst);
|
||||
|
||||
internal const string RadioGroupItemVerticalLast = nameof(RadioGroupItemVerticalLast);
|
||||
internal const string RadioGroupItemVerticalLast = nameof(RadioGroupItemVerticalLast);
|
||||
|
||||
internal const string ButtonGroupItemDefault = nameof(ButtonGroupItemDefault);
|
||||
internal const string ButtonGroupItemDefault = nameof(ButtonGroupItemDefault);
|
||||
|
||||
internal const string ButtonGroupItemSingle = nameof(ButtonGroupItemSingle);
|
||||
internal const string ButtonGroupItemSingle = nameof(ButtonGroupItemSingle);
|
||||
|
||||
internal const string ButtonGroupItemHorizontalFirst = nameof(ButtonGroupItemHorizontalFirst);
|
||||
internal const string ButtonGroupItemHorizontalFirst = nameof(ButtonGroupItemHorizontalFirst);
|
||||
|
||||
internal const string ButtonGroupItemHorizontalLast = nameof(ButtonGroupItemHorizontalLast);
|
||||
internal const string ButtonGroupItemHorizontalLast = nameof(ButtonGroupItemHorizontalLast);
|
||||
|
||||
internal const string ButtonGroupItemVerticalFirst = nameof(ButtonGroupItemVerticalFirst);
|
||||
internal const string ButtonGroupItemVerticalFirst = nameof(ButtonGroupItemVerticalFirst);
|
||||
|
||||
internal const string ButtonGroupItemVerticalLast = nameof(ButtonGroupItemVerticalLast);
|
||||
internal const string ButtonGroupItemVerticalLast = nameof(ButtonGroupItemVerticalLast);
|
||||
|
||||
internal const string ToggleButtonGroupItemDefault = nameof(ToggleButtonGroupItemDefault);
|
||||
internal const string ToggleButtonGroupItemDefault = nameof(ToggleButtonGroupItemDefault);
|
||||
|
||||
internal const string ToggleButtonGroupItemSingle = nameof(ToggleButtonGroupItemSingle);
|
||||
internal const string ToggleButtonGroupItemSingle = nameof(ToggleButtonGroupItemSingle);
|
||||
|
||||
internal const string ToggleButtonGroupItemHorizontalFirst = nameof(ToggleButtonGroupItemHorizontalFirst);
|
||||
internal const string ToggleButtonGroupItemHorizontalFirst = nameof(ToggleButtonGroupItemHorizontalFirst);
|
||||
|
||||
internal const string ToggleButtonGroupItemHorizontalLast = nameof(ToggleButtonGroupItemHorizontalLast);
|
||||
internal const string ToggleButtonGroupItemHorizontalLast = nameof(ToggleButtonGroupItemHorizontalLast);
|
||||
|
||||
internal const string ToggleButtonGroupItemVerticalFirst = nameof(ToggleButtonGroupItemVerticalFirst);
|
||||
internal const string ToggleButtonGroupItemVerticalFirst = nameof(ToggleButtonGroupItemVerticalFirst);
|
||||
|
||||
internal const string ToggleButtonGroupItemVerticalLast = nameof(ToggleButtonGroupItemVerticalLast);
|
||||
internal const string ToggleButtonGroupItemVerticalLast = nameof(ToggleButtonGroupItemVerticalLast);
|
||||
|
||||
internal const string TabItemCapsuleDefault = nameof(TabItemCapsuleDefault);
|
||||
internal const string TabItemCapsuleDefault = nameof(TabItemCapsuleDefault);
|
||||
|
||||
internal const string TabItemCapsuleSingle = nameof(TabItemCapsuleSingle);
|
||||
internal const string TabItemCapsuleSingle = nameof(TabItemCapsuleSingle);
|
||||
|
||||
internal const string TabItemCapsuleHorizontalFirst = nameof(TabItemCapsuleHorizontalFirst);
|
||||
internal const string TabItemCapsuleHorizontalFirst = nameof(TabItemCapsuleHorizontalFirst);
|
||||
|
||||
internal const string TabItemCapsuleHorizontalLast = nameof(TabItemCapsuleHorizontalLast);
|
||||
internal const string TabItemCapsuleHorizontalLast = nameof(TabItemCapsuleHorizontalLast);
|
||||
|
||||
internal const string TabItemCapsuleVerticalFirst = nameof(TabItemCapsuleVerticalFirst);
|
||||
internal const string TabItemCapsuleVerticalFirst = nameof(TabItemCapsuleVerticalFirst);
|
||||
|
||||
internal const string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast);
|
||||
internal const string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast);
|
||||
|
||||
internal const string ComboBoxItemCapsuleDefault = nameof(ComboBoxItemCapsuleDefault);
|
||||
internal const string ComboBoxItemCapsuleDefault = nameof(ComboBoxItemCapsuleDefault);
|
||||
|
||||
internal const string ComboBoxItemCapsuleSingle = nameof(ComboBoxItemCapsuleSingle);
|
||||
internal const string ComboBoxItemCapsuleSingle = nameof(ComboBoxItemCapsuleSingle);
|
||||
|
||||
internal const string ComboBoxItemCapsuleHorizontalFirst = nameof(ComboBoxItemCapsuleHorizontalFirst);
|
||||
internal const string ComboBoxItemCapsuleHorizontalFirst = nameof(ComboBoxItemCapsuleHorizontalFirst);
|
||||
|
||||
internal const string ComboBoxItemCapsuleHorizontalLast = nameof(ComboBoxItemCapsuleHorizontalLast);
|
||||
internal const string ComboBoxItemCapsuleHorizontalLast = nameof(ComboBoxItemCapsuleHorizontalLast);
|
||||
|
||||
internal const string ComboBoxItemCapsuleVerticalFirst = nameof(ComboBoxItemCapsuleVerticalFirst);
|
||||
internal const string ComboBoxItemCapsuleVerticalFirst = nameof(ComboBoxItemCapsuleVerticalFirst);
|
||||
|
||||
internal const string ComboBoxItemCapsuleVerticalLast = nameof(ComboBoxItemCapsuleVerticalLast);
|
||||
internal const string ComboBoxItemCapsuleVerticalLast = nameof(ComboBoxItemCapsuleVerticalLast);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1,51 +1,50 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HandyControl.Data
|
||||
namespace HandyControl.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 装箱后的值类型(用于提高效率)
|
||||
/// </summary>
|
||||
internal static class ValueBoxes
|
||||
{
|
||||
/// <summary>
|
||||
/// 装箱后的值类型(用于提高效率)
|
||||
/// </summary>
|
||||
internal static class ValueBoxes
|
||||
{
|
||||
internal static object TrueBox = true;
|
||||
internal static object TrueBox = true;
|
||||
|
||||
internal static object FalseBox = false;
|
||||
internal static object FalseBox = false;
|
||||
|
||||
internal static object VerticalBox = Orientation.Vertical;
|
||||
internal static object VerticalBox = Orientation.Vertical;
|
||||
|
||||
internal static object HorizontalBox = Orientation.Horizontal;
|
||||
internal static object HorizontalBox = Orientation.Horizontal;
|
||||
|
||||
internal static object Double0Box = .0;
|
||||
internal static object Double0Box = .0;
|
||||
|
||||
internal static object Double01Box = .1;
|
||||
internal static object Double01Box = .1;
|
||||
|
||||
internal static object Double1Box = 1.0;
|
||||
internal static object Double1Box = 1.0;
|
||||
|
||||
internal static object Double10Box = 10.0;
|
||||
internal static object Double10Box = 10.0;
|
||||
|
||||
internal static object Double20Box = 20.0;
|
||||
internal static object Double20Box = 20.0;
|
||||
|
||||
internal static object Double100Box = 100.0;
|
||||
internal static object Double100Box = 100.0;
|
||||
|
||||
internal static object Double200Box = 200.0;
|
||||
internal static object Double200Box = 200.0;
|
||||
|
||||
internal static object Double300Box = 300.0;
|
||||
internal static object Double300Box = 300.0;
|
||||
|
||||
internal static object DoubleNeg1Box = -1.0;
|
||||
internal static object DoubleNeg1Box = -1.0;
|
||||
|
||||
internal static object Int0Box = 0;
|
||||
internal static object Int0Box = 0;
|
||||
|
||||
internal static object Int1Box = 1;
|
||||
internal static object Int1Box = 1;
|
||||
|
||||
internal static object Int2Box = 2;
|
||||
internal static object Int2Box = 2;
|
||||
|
||||
internal static object Int5Box = 5;
|
||||
internal static object Int5Box = 5;
|
||||
|
||||
internal static object Int99Box = 99;
|
||||
internal static object Int99Box = 99;
|
||||
|
||||
internal static object BooleanBox(bool value) => value ? TrueBox : FalseBox;
|
||||
internal static object BooleanBox(bool value) => value ? TrueBox : FalseBox;
|
||||
|
||||
internal static object OrientationBox(Orientation value) =>
|
||||
value == Orientation.Horizontal ? HorizontalBox : VerticalBox;
|
||||
}
|
||||
}
|
||||
internal static object OrientationBox(Orientation value) =>
|
||||
value == Orientation.Horizontal ? HorizontalBox : VerticalBox;
|
||||
}
|
||||
Reference in new issue
Block a user