From 2aeab450471cb80b59002da7da80faf251a0c4f4 Mon Sep 17 00:00:00 2001
From: asmrobot <asmrobot@hotmail.com>
Date: Mon, 25 Nov 2019 15:02:53 +0000
Subject: [PATCH] sigle computer
---
src/RichCreator/MainWindow.xaml.cs | 111 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 78 insertions(+), 33 deletions(-)
diff --git a/src/RichCreator/MainWindow.xaml.cs b/src/RichCreator/MainWindow.xaml.cs
index 91c9320..7add8d6 100644
--- a/src/RichCreator/MainWindow.xaml.cs
+++ b/src/RichCreator/MainWindow.xaml.cs
@@ -22,6 +22,7 @@
using RichCreator.Maps.Kalete;
using ZTImage.Collections;
using System.Collections.Generic;
+using System.Windows.Media.Imaging;
namespace RichCreator
{
@@ -34,7 +35,7 @@
public MainWindow()
{
InitializeComponent();
- G.Instance.EnableWriter(this.writeDebug, this.writeInfo, this.writeRemainTime, this.CancelConfirm,this.stopTaskUI);
+ G.Instance.EnableWriter(this.writeDebug, this.writeInfo, this.writeRemainTime, this.CancelConfirm,this.stopTaskUI,this.updateState);
viewModel = new ConfigViewModel();
this.DataContext = viewModel;
}
@@ -121,6 +122,36 @@
private void ClearLog_Click(object sender, RoutedEventArgs e)
{
this.LogTB.Text = string.Empty;
+ }
+
+
+ /// <summary>
+ /// 折叠日志
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void LogTBExpand_Click(object sender, RoutedEventArgs e)
+ {
+ var btn = sender as Button;
+ Image img = btn.Content as Image;
+ BitmapImage bitmap = null;
+ if (this.LogTB.Visibility == Visibility.Collapsed)
+ {
+ //当前是隐藏状态
+ this.LogTB.Visibility = Visibility.Visible;
+ this.LogTBClearBtn.Visibility = Visibility.Visible;
+ //todo:让日志图像设为up.png
+ bitmap = new BitmapImage(new Uri("pack://application:,,,/Images/up.png"));
+
+ }
+ else
+ {
+ this.LogTB.Visibility = Visibility.Collapsed;
+ this.LogTBClearBtn.Visibility = Visibility.Collapsed;
+ //todo:让日志图像设为down.png
+ bitmap = new BitmapImage(new Uri("pack://application:,,,/Images/down.png"));
+ }
+ img.Source = bitmap;
}
/// <summary>
@@ -297,46 +328,40 @@
/// </summary>
private void TestToNextDoor()
{
- ZTRectangle gameRect = ZTRectangle.Empty;
- WindowUtils.GetDnfRect(out gameRect);
+ //ZTRectangle gameRect = ZTRectangle.Empty;
+ //WindowUtils.GetDnfRect(out gameRect);
- HouseInfo house = new HouseInfo(1, MapType.Kalete, false, null,null);
- DnfRole role = new DnfRole(gameRect);
- role.SetHouse(house);
+ //HouseInfo house = new HouseInfo(1, MapType.Kalete, false, null,null);
+ //DnfRole role = new DnfRole(gameRect);
+ //role.SetHouse(house);
- Image<Hsv, byte> hsvImage = new Image<Hsv, byte>(gameRect.End.X - gameRect.Start.X, gameRect.End.Y - gameRect.Start.Y );
- Task.Run(() => {
- WindowUtils.SetDnfToTop();
- Thread.Sleep(10);
+ //Image<Hsv, byte> hsvImage = new Image<Hsv, byte>(gameRect.End.X - gameRect.Start.X, gameRect.End.Y - gameRect.Start.Y );
+ //Task.Run(() => {
+ // WindowUtils.SetDnfToTop();
+ // Thread.Sleep(10);
- Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
- image.ROI = new System.Drawing.Rectangle(gameRect.Start.X, gameRect.Start.Y, gameRect.End.X - gameRect.Start.X, gameRect.End.Y - gameRect.Start.Y);
- CvInvoke.CvtColor(image, hsvImage, Emgu.CV.CvEnum.ColorConversion.Rgb2Hsv);
- image.ROI = System.Drawing.Rectangle.Empty;
+ // Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
+ // image.ROI = new System.Drawing.Rectangle(gameRect.Start.X, gameRect.Start.Y, gameRect.End.X - gameRect.Start.X, gameRect.End.Y - gameRect.Start.Y);
+ // CvInvoke.CvtColor(image, hsvImage, Emgu.CV.CvEnum.ColorConversion.Rgb2Hsv);
+ // image.ROI = System.Drawing.Rectangle.Empty;
- //定位点
- ParametersPoint locationCoor = DnfCVHelper.GetLocationPoint(image, gameRect);
- if (locationCoor.Equals(ParametersPoint.Empty))
- {
- //找不到定位点
- G.Instance.InfoWriter("找不到定位点");
- return;
- }
+ // //定位点
+ // ParametersPoint locationCoor = DnfCVHelper.GetLocationPoint(image, gameRect);
+ // if (locationCoor.Equals(ParametersPoint.Empty))
+ // {
+ // //找不到定位点
+ // G.Instance.InfoWriter("找不到定位点");
+ // return;
+ // }
- ZTPoint rolePosition = DnfCVHelper.FindRole(hsvImage, gameRect);
- role.UpdatePosition(rolePosition);
+ // ZTPoint rolePosition = DnfCVHelper.FindRole(hsvImage, gameRect);
+ // role.UpdatePosition(rolePosition);
- ZTPoint start=house.ScreenToMapCoordinate(DnfRole.CBToHalfPosition(rolePosition), locationCoor);
-
-
- ZTPoint roleFootPosition = house.ScreenToMapCoordinate(role.Position, locationCoor);
- ZTPoint ngp = DnfRole.HalfToFootPosition(house.HousePathInfo.NextGates[0].Point);
- role.MoveToMapPoint(roleFootPosition, ngp);
-
- G.Instance.InfoWriter($"测试进入下一关的门完成");
- });
+ // role.ToNextGateMove(locationCoor, house.HousePathInfo.NextGates[0].Point);
+ // G.Instance.InfoWriter($"测试进入下一关的门完成");
+ //});
}
@@ -521,6 +546,19 @@
}
/// <summary>
+ /// 更新指定状态
+ /// </summary>
+ /// <param name="index"></param>
+ /// <param name="text"></param>
+ private void updateState(Int32 index, string text)
+ {
+ this.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ this.StateList.Items[index] = text;
+ }));
+ }
+
+ /// <summary>
/// 开始任务UI设置
/// </summary>
private void startTaskUI()
@@ -584,6 +622,12 @@
}
+ //初始状态
+ for (Int32 i = 0; i < StateProvider.States.Length; i++)
+ {
+ this.StateList.Items.Add(StateProvider.States[i].HeaderText+":"+ StateProvider.States[i].Value);
+ }
+
}
@@ -594,5 +638,6 @@
IntPtr intPtr = (new WindowInteropHelper(this)).Handle;
SystemHotKey.UnRegHotKey(intPtr, hotKeyID);
}
+
}
}
--
Gitblit v1.9.3