| | |
| | | using RichCreator.Maps.Kalete; |
| | | using ZTImage.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Windows.Media.Imaging; |
| | | |
| | | namespace RichCreator |
| | | { |
| | |
| | | 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; |
| | | } |
| | |
| | | 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> |
| | |
| | | /// </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($"测试进入下一关的门完成"); |
| | | //}); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /// <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() |
| | |
| | | |
| | | } |
| | | |
| | | //初始状态 |
| | | for (Int32 i = 0; i < StateProvider.States.Length; i++) |
| | | { |
| | | this.StateList.Items.Add(StateProvider.States[i].HeaderText+":"+ StateProvider.States[i].Value); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | IntPtr intPtr = (new WindowInteropHelper(this)).Handle; |
| | | SystemHotKey.UnRegHotKey(intPtr, hotKeyID); |
| | | } |
| | | |
| | | } |
| | | } |