22 changed files with 394 additions and 46 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,37 @@ |
|||||
|
namespace JiLinApp.Docking.Ptz; |
||||
|
|
||||
|
public class PtzControlTypeConfig |
||||
|
{ |
||||
|
public string Type { get; set; } |
||||
|
|
||||
|
public string Name { get; set; } |
||||
|
} |
||||
|
|
||||
|
public class PtzControlTypeConfigHelper |
||||
|
{ |
||||
|
private static Dictionary<string, PtzControlTypeConfig> PctConfigDict { get; set; } |
||||
|
|
||||
|
public static void Init(List<PtzControlTypeConfig> ptzCtrlTypes) |
||||
|
{ |
||||
|
if (PctConfigDict != null) return; |
||||
|
Dictionary<string, PtzControlTypeConfig> dict = new(); |
||||
|
foreach (var cfg in ptzCtrlTypes) |
||||
|
{ |
||||
|
dict.Add(cfg.Name, cfg); |
||||
|
} |
||||
|
PctConfigDict ??= dict; |
||||
|
} |
||||
|
|
||||
|
public static PtzControlType GetControlType(string ctrlName) |
||||
|
{ |
||||
|
PctConfigDict.TryGetValue(ctrlName, out var cfg); |
||||
|
string ctrlType = cfg != null ? cfg.Type : ""; |
||||
|
return ctrlType switch |
||||
|
{ |
||||
|
"PelcoD" => PtzControlType.PelcoD, |
||||
|
"PelcoP" => PtzControlType.PelcoP, |
||||
|
"HikSdk" => PtzControlType.HikSdk, |
||||
|
_ => PtzControlType.None |
||||
|
}; |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
<Window x:Class="JiLinApp.Components.HikRealPlay" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
mc:Ignorable="d" |
||||
|
Title="HikRealPlay" Height="430" Width="640" ShowInTaskbar="False"> |
||||
|
<Image Name="player"> |
||||
|
</Image> |
||||
|
</Window> |
@ -0,0 +1,88 @@ |
|||||
|
using EC.Util.CameraSDK; |
||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Interop; |
||||
|
|
||||
|
namespace JiLinApp.Components; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// HikRealPlay.xaml 的交互逻辑
|
||||
|
/// </summary>
|
||||
|
public partial class HikRealPlay : Window |
||||
|
{ |
||||
|
#region
|
||||
|
|
||||
|
private HiKSDK hikSdk { get; } |
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
public HikRealPlay(HiKSDK hikSdk) |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
this.hikSdk = hikSdk; |
||||
|
} |
||||
|
|
||||
|
~HikRealPlay() |
||||
|
{ |
||||
|
StopPlay(); |
||||
|
} |
||||
|
|
||||
|
#region Base
|
||||
|
|
||||
|
public void StartPlay() |
||||
|
{ |
||||
|
IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(player)).Handle; |
||||
|
hikSdk.StartPlay(hwnd); |
||||
|
} |
||||
|
|
||||
|
public void StopPlay() |
||||
|
{ |
||||
|
hikSdk.StopPlay(); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
private const int GWL_STYLE = -16; |
||||
|
private const int WS_MAXIMIZEBOX = 0x10000; |
||||
|
private const int WS_MINIMIZEBOX = 0x20000; |
||||
|
private const int SWP_NOSIZE = 0x0001; |
||||
|
private const int SWP_NOMOVE = 0x0002; |
||||
|
private const int SWP_NOZORDER = 0x0004; |
||||
|
private const int SWP_FRAMECHANGED = 0x0020; |
||||
|
|
||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)] |
||||
|
private static extern int GetWindowLong32(IntPtr hWnd, int nIndex); |
||||
|
|
||||
|
[DllImport("user32.dll")] |
||||
|
private static extern int GetWindowLongPtr(IntPtr hwnd, int index); |
||||
|
|
||||
|
[DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)] |
||||
|
private static extern int SetWindowLong32(IntPtr hwnd, int index, int value); |
||||
|
|
||||
|
[DllImport("user32.dll")] |
||||
|
private static extern int SetWindowLongPtr(IntPtr hwnd, int index, int value); |
||||
|
|
||||
|
[DllImport("user32.dll")] |
||||
|
private static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); |
||||
|
|
||||
|
#region Util
|
||||
|
|
||||
|
public void HideMinButton() |
||||
|
{ |
||||
|
IntPtr hwnd = new WindowInteropHelper(this).Handle; |
||||
|
if (IntPtr.Size == 4) |
||||
|
{ |
||||
|
var currentStyle = GetWindowLong32(hwnd, GWL_STYLE); |
||||
|
_ = SetWindowLong32(hwnd, GWL_STYLE, (currentStyle & ~WS_MINIMIZEBOX)); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
var currentStyle = GetWindowLongPtr(hwnd, GWL_STYLE); |
||||
|
_ = SetWindowLongPtr(hwnd, GWL_STYLE, (currentStyle & ~WS_MINIMIZEBOX)); |
||||
|
} |
||||
|
//call SetWindowPos to make sure the SetWindowLongPtr take effect according to MSDN
|
||||
|
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
} |
Loading…
Reference in new issue