129 lines
3.9 KiB
C#
129 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using Application = System.Windows.Forms.Application;
|
|
using MessageBox = System.Windows.MessageBox;
|
|
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
|
|
|
namespace JianGongYun.TRTC.Windows
|
|
{
|
|
/// <summary>
|
|
/// LiveWindowTopBlock.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class LiveWindowTopBlock : Window
|
|
{
|
|
LiveWindow LiveWindow { get; set; }
|
|
LiveWindowRightBottomBlock Child;
|
|
DpiScale dpi;
|
|
public LiveWindowTopBlock(LiveWindow _liveWindow)
|
|
{
|
|
InitializeComponent();
|
|
this.Left = (SystemParameters.WorkArea.Size.Width - this.Width) / 2;
|
|
LiveWindow = _liveWindow;
|
|
DataContext = LiveWindow.LiveWindowViewModel;
|
|
dpi = VisualTreeHelper.GetDpi(this);
|
|
|
|
Child = new LiveWindowRightBottomBlock(_liveWindow);
|
|
Child.Show();
|
|
}
|
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
{
|
|
Child.Close();
|
|
base.OnClosing(e);
|
|
}
|
|
|
|
private void ShowLiveWin_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
LiveWindow.Show();
|
|
this.Close();
|
|
}
|
|
|
|
bool down = false;
|
|
double initX = 0;
|
|
|
|
private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
down = false;
|
|
}
|
|
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
//this.DragMove();
|
|
initX = System.Windows.Forms.Control.MousePosition.X / dpi.DpiScaleX;
|
|
down = true;
|
|
}
|
|
//自定义拖动
|
|
private void Window_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (!down)
|
|
{
|
|
return;
|
|
}
|
|
var temp = System.Windows.Forms.Control.MousePosition.X / dpi.DpiScaleX;
|
|
var res = temp - initX;
|
|
if (this.Left + res < 0)
|
|
{
|
|
this.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
this.Left = 0;
|
|
}));
|
|
}
|
|
else if (this.Left + res > SystemParameters.WorkArea.Size.Width - this.ActualWidth)
|
|
{
|
|
this.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
this.Left = (int)SystemParameters.WorkArea.Size.Width - (int)this.ActualWidth;
|
|
}));
|
|
}
|
|
else
|
|
{
|
|
this.Dispatcher.Invoke(new Action(() =>
|
|
{
|
|
this.Left += res;
|
|
}));
|
|
}
|
|
initX = temp;
|
|
}
|
|
|
|
private void Window_MouseLeave(object sender, MouseEventArgs e)
|
|
{
|
|
down = false;
|
|
}
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.Dispatcher.Invoke(() =>
|
|
{
|
|
try
|
|
{
|
|
var old = Process.GetProcessesByName("Pointofix");
|
|
if (old.Length > 0)
|
|
{
|
|
foreach (var item in old)
|
|
{
|
|
item.Kill();
|
|
}
|
|
}
|
|
Process prc = new Process { StartInfo = new ProcessStartInfo { FileName = System.IO.Path.Combine(Environment.CurrentDirectory, "Pointofix.exe"), CreateNoWindow = false, UseShellExecute = false } };
|
|
prc.Start();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "提醒");
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
}
|