private void MousePositionView_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { e.Handled = true; if (IsVisible && !_isDrag) { NotifyHelper.InvokeNotify(NotifyEventType.MousePointDataBind, new MousePointEventArgs() { MouseTriggerInfo = new MouseTriggerInfo() { MouseInfoEventType = MouseEventType.LeftClick, StartPoint = PointToScreen(e.GetPosition(this)) }, MonitorInfo = _monitorInfo }); } else if (IsVisible && _isDrag) { NotifyHelper.InvokeNotify(NotifyEventType.MousePointDataBind, new MousePointEventArgs() { MouseTriggerInfo = new MouseTriggerInfo() { MouseInfoEventType = MouseEventType.Drag, StartPoint = PointToScreen(_pathFigure.StartPoint), MiddlePoint = _pathFigure.Segments.Select(r => PointToScreen((r as LineSegment).Point)).ToList(), EndPoint = PointToScreen(e.GetPosition(this)), }, MonitorInfo = _monitorInfo }); } _isDrag = false; }
private void CaptureZone_MouseLeave(object sender, MouseEventArgs e) { if (_isDrag && IsVisible) { WindowState = WindowState.Minimized; int left = (int)(Canvas.GetLeft(_dragBorder) * _factor.X); int top = (int)(Canvas.GetTop(_dragBorder) * _factor.Y); int width = (int)(_dragBorder.Width * _factor.X); int height = (int)(_dragBorder.Height * _factor.Y); var rect = new Rect { Left = left, Right = width + left, Bottom = top + height, Top = top }; var image = DisplayHelper.Capture(_monitorInfo, rect); NotifyHelper.InvokeNotify(NotifyEventType.ScreenCaptureDataBInd, new CaptureEventArgs() { CaptureViewMode = _captureViewMode, MonitorInfo = _monitorInfo, CaptureImage = image, Position = rect }); e.Handled = true; WindowState = WindowState.Maximized; } _isDrag = false; }
private void Button_Click(object sender, RoutedEventArgs e) { var btn = sender as Button; if (btn.Equals(btnCapture)) { Capture(CaptureViewMode.Game); } if (btn.Equals(btnHpCapture)) { Capture(CaptureViewMode.HP); } if (btn.Equals(btnMpCapture)) { Capture(CaptureViewMode.Mp); } else if (btn.Equals(btnSave)) { var model = gameConfigView.CurrentTreeViewItem.DataContext <GameEventTriggerModel>(); if (model.IsImageSearchRequired) { model.Image = _bitmap; } else { model.Image = new Bitmap(1, 1); } if (model.EventType == EventType.RelativeToImage) { model.MouseTriggerInfo.StartPoint = new Point(gameConfigView.RelativePosition.X, gameConfigView.RelativePosition.Y); } NotifyHelper.InvokeNotify(NotifyEventType.Save, new SaveEventTriggerModelArgs() { CurrentEventTriggerModel = model, }); } else if (btn.Equals(btnDelete)) { var model = gameConfigView.CurrentTreeViewItem.DataContext <GameEventTriggerModel>(); NotifyHelper.InvokeNotify(NotifyEventType.Delete, new DeleteEventTriggerModelArgs() { CurrentEventTriggerModel = model, }); } else if (btn.Equals(btnAddSameContent)) { var item = gameConfigView.CopyCurrentItem(); if (item == null) { return; } NotifyHelper.InvokeNotify(NotifyEventType.Save, new SaveEventTriggerModelArgs() { CurrentEventTriggerModel = item, }); } }
private void TreeSaves_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (treeSaves.SelectedItem is EventTriggerModel item) { CurrentTreeViewItem = treeSaves.GetSelectItemFromObject <TreeGridViewItem>(treeSaves.SelectedItem) ?? _dummyTreeGridViewItem; NotifyHelper.InvokeNotify(NotifyEventType.SelctTreeViewItemChanged, new SelctTreeViewItemChangedEventArgs() { TreeViewItem = CurrentTreeViewItem }); if (CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType == EventType.Keyboard) { RadioButton_Click(rbKeyboard, null); } else if (CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType == EventType.Mouse) { RadioButton_Click(rbMouse, null); //btnMouseWheel.IsEnabled = true; //lblWheelData.Visibility = Visibility.Collapsed; //gridWheelData.Visibility = Visibility.Collapsed; //if (CurrentTreeViewItem.DataContext<EventTriggerModel>().MouseTriggerInfo.MouseInfoEventType == MouseEventType.Wheel) //{ // lblWheelData.Visibility = Visibility.Visible; // gridWheelData.Visibility = Visibility.Visible; //} } else if (CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType == EventType.Image) { RadioButton_Click(rbImage, null); } else if (CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType == EventType.RelativeToImage) { RadioButton_Click(rbRelativeToImage, null); } btnTreeItemUp.Visibility = btnTreeItemDown.Visibility = Visibility.Visible; if (item.SubEventTriggers.Count != 0) { lblRepeatSubItems.Visibility = Visibility.Visible; gridRepeat.Visibility = Visibility.Visible; } else { lblRepeatSubItems.Visibility = Visibility.Collapsed; gridRepeat.Visibility = Visibility.Collapsed; } if (item.ParentEventTriggerModel != EventTriggerModel.DummyParentEventModel) { checkChildImageDragToParent.IsEnabled = true; } else { checkChildImageDragToParent.IsEnabled = false; } } }
private void ConfigEventView_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { Clear(); NotifyHelper.InvokeNotify(NotifyEventType.SelctTreeViewItemChanged, new SelctTreeViewItemChangedEventArgs()); e.Handled = true; } base.OnPreviewKeyDown(e); }
private Task Save(object state) { var path = Environment.CurrentDirectory + $@"\{ConstHelper.DefaultConfigFile}"; File.WriteAllText(path, JsonHelper.SerializeObject(state, true)); NotifyHelper.InvokeNotify(NotifyEventType.ConfigChanged, new ConfigEventArgs() { Config = state as Config }); return(Task.CompletedTask); }
private void ComboProcess_SelectionChanged(object sender, SelectionChangedEventArgs e) { CheckFix_Checked(checkFix, null); if (comboProcess.SelectedItem is KeyValuePair <string, Process> item) { NotifyHelper.InvokeNotify(NotifyEventType.ComboProcessChanged, new ComboProcessChangedEventArgs() { Process = item.Value, }); } }
private void CaptureView_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { e.Handled = true; NotifyHelper.InvokeNotify(NotifyEventType.ScreenCaptureDataBInd, new CaptureEventArgs() { MonitorInfo = _monitorInfo, CaptureImage = null }); } base.OnPreviewKeyDown(e); }
private void MousePositionView_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { NotifyHelper.InvokeNotify(NotifyEventType.MousePointDataBind, new MousePointEventArgs() { MouseTriggerInfo = new MouseTriggerInfo() { MouseInfoEventType = MouseEventType.None, }, MonitorInfo = _monitorInfo }); e.Handled = true; } base.OnPreviewKeyDown(e); }
private void NotifyHelper_EventTriggerOrderChanged(EventTriggerOrderChangedEventArgs obj) { if (tab_content.SelectedContent is BaseContentView view) { var path = _viewMap[view.Tag.ToString()].SaveFilePath; _taskQueue.Enqueue(async() => { await view.Save(path); obj.SelectedTreeViewItem.IsSelected = true; NotifyHelper.InvokeNotify(NotifyEventType.TreeGridViewFocus, new TreeGridViewFocusEventArgs() { Mode = (InitialTab)Enum.Parse(typeof(InitialTab), view.Tag.ToString()) }); }); } }
private void MousePositionView_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) { e.Handled = true; if (IsVisible && !_isDrag) { NotifyHelper.InvokeNotify(NotifyEventType.MousePointDataBind, new MousePointEventArgs() { MouseTriggerInfo = new MouseTriggerInfo() { MouseInfoEventType = MouseEventType.RightClick, StartPoint = PointToScreen(e.GetPosition(this)) }, MonitorInfo = _monitorInfo }); } _isDrag = false; }
private void TreeSaves_Drop(object sender, DragEventArgs e) { if (_isDrag) { _isDrag = false; var targetRow = treeSaves.TryFindFromPoint <TreeGridViewItem>(e.GetPosition(treeSaves)); if (CurrentTreeViewItem == targetRow) { return; } ItemContainerPositionChange(targetRow); var item = CurrentTreeViewItem.DataContext <EventTriggerModel>(); Clear(); NotifyHelper.InvokeNotify(NotifyEventType.TreeItemOrderChanged, new EventTriggerOrderChangedEventArgs() { TriggerModel1 = item, TriggerModel2 = targetRow?.DataContext <EventTriggerModel>() }); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (sender.Equals(btnMouseCoordinate)) { //lblWheelData.Visibility = Visibility.Collapsed; //gridWheelData.Visibility = Visibility.Collapsed; if (CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo.MouseInfoEventType != MouseEventType.None) { CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo = new MouseTriggerInfo(); } ShowMousePoisitionView(); } else if (sender.Equals(btnTreeItemUp) || sender.Equals(btnTreeItemDown)) { if (CurrentTreeViewItem == null) { return; } var itemContainer = CurrentTreeViewItem.ParentItem == null?this.DataContext <CommonEventConfigViewModel>().TriggerSaves : CurrentTreeViewItem.ParentItem.DataContext <EventTriggerModel>().SubEventTriggers; var currentIndex = itemContainer.IndexOf(CurrentTreeViewItem.DataContext <EventTriggerModel>()); if (currentIndex > 0 && sender.Equals(btnTreeItemUp)) { itemContainer.Swap(currentIndex, currentIndex - 1); CurrentTreeViewItem = treeSaves.GetSelectItemFromObject <TreeGridViewItem>(itemContainer[currentIndex - 1]) ?? _dummyTreeGridViewItem; NotifyHelper.InvokeNotify(NotifyEventType.EventTriggerOrderChanged, new EventTriggerOrderChangedEventArgs() { TriggerModel1 = itemContainer[currentIndex], TriggerModel2 = itemContainer[currentIndex - 1] }); } else if (currentIndex < itemContainer.Count - 1 && sender.Equals(btnTreeItemDown)) { itemContainer.Swap(currentIndex, currentIndex + 1); CurrentTreeViewItem = treeSaves.GetSelectItemFromObject <TreeGridViewItem>(itemContainer[currentIndex + 1]) ?? _dummyTreeGridViewItem; NotifyHelper.InvokeNotify(NotifyEventType.EventTriggerOrderChanged, new EventTriggerOrderChangedEventArgs() { TriggerModel1 = itemContainer[currentIndex], TriggerModel2 = itemContainer[currentIndex + 1] }); } } //else if(sender.Equals(btnMouseWheel)) //{ // lblWheelData.Visibility = Visibility.Visible; // gridWheelData.Visibility = Visibility.Visible; // CurrentTreeViewItem.DataContext<EventTriggerModel>().MouseTriggerInfo.MouseInfoEventType = MouseEventType.Wheel; //} //else if(sender.Equals(btnWheelCancel)) //{ // lblWheelData.Visibility = Visibility.Collapsed; // gridWheelData.Visibility = Visibility.Collapsed; // CurrentTreeViewItem.DataContext<EventTriggerModel>().MouseTriggerInfo = new MouseTriggerInfo() // { // WheelData = 0, // MouseInfoEventType = MouseEventType.LeftClick, // EndPoint = CurrentTreeViewItem.DataContext<EventTriggerModel>().MouseTriggerInfo.EndPoint, // MiddlePoint = CurrentTreeViewItem.DataContext<EventTriggerModel>().MouseTriggerInfo.MiddlePoint, // StartPoint = CurrentTreeViewItem.DataContext<EventTriggerModel>().MouseTriggerInfo.StartPoint // }; //} }
private void Button_Click(object sender, RoutedEventArgs e) { var btn = sender as Button; if (btn.Equals(btnCapture)) { Capture(CaptureViewMode.Game); } else if (btn.Equals(btnHpCapture)) { if (_currentProcess == null) { (Application.Current.MainWindow as MetroWindow).MessageShow("Error", DocumentHelper.Get(Message.FailedPreconditionSelectProcess)); return; } Capture(CaptureViewMode.HP); } else if (btn.Equals(btnMpCapture)) { if (_currentProcess == null) { (Application.Current.MainWindow as MetroWindow).MessageShow("Error", DocumentHelper.Get(Message.FailedPreconditionSelectProcess)); return; } Capture(CaptureViewMode.Mp); } else if (btn.Equals(btnSave)) { var model = gameConfigView.CurrentTreeViewItem.DataContext <GameEventTriggerModel>(); if (model.ImageSearchRequired) { model.Image = _bitmap; } else { model.Image = new Bitmap(1, 1); } if (model.EventType == EventType.RelativeToImage) { model.MouseTriggerInfo.StartPoint = new Point(gameConfigView.RelativePosition.X, gameConfigView.RelativePosition.Y); } NotifyHelper.InvokeNotify(NotifyEventType.Save, new SaveEventTriggerModelArgs() { CurrentEventTriggerModel = model, }); } else if (btn.Equals(btnDelete)) { var model = gameConfigView.CurrentTreeViewItem.DataContext <GameEventTriggerModel>(); NotifyHelper.InvokeNotify(NotifyEventType.Delete, new DeleteEventTriggerModelArgs() { CurrentEventTriggerModel = model, }); } else if (btn.Equals(btnAddSameContent)) { var item = gameConfigView.CopyCurrentItem(); if (item == null) { return; } NotifyHelper.InvokeNotify(NotifyEventType.Save, new SaveEventTriggerModelArgs() { CurrentEventTriggerModel = item, }); } }