private void On_BTN_MoveUp_Click(object sender, RoutedEventArgs e) { int idx = LB_Gaos.SelectedIndex; if (idx > 0) { _colle.Move(idx, idx - 1); GaoData.Data.MoveTo(idx, idx - 1); LB_Gaos.ScrollIntoView(LB_Gaos.SelectedItem); } }
private void On_BTN_Add_Click(object sender, RoutedEventArgs e) { GaoVM vm = new GaoVM(); vm.Name = TXT_Name.Text; vm.Text = TXT_Text.Text; GaoData.Data.AddData(vm); _colle.Add(vm); TXT_Text.Clear(); LB_Gaos.ScrollIntoView(vm); }
private void On_BTN_MoveBottom_Click(object sender, RoutedEventArgs e) { int idx = LB_Gaos.SelectedIndex; if (idx >= 0 && idx < LB_Gaos.Items.Count - 1) { _colle.Move(idx, LB_Gaos.Items.Count - 1); GaoData.Data.MoveTo(idx, LB_Gaos.Items.Count - 1); LB_Gaos.ScrollIntoView(LB_Gaos.SelectedItem); } }
private void On_BTN_Insert_Click(object sender, RoutedEventArgs e) { if (LB_Gaos.SelectedIndex != -1) { int idx = LB_Gaos.SelectedIndex + 1; GaoVM vm = new GaoVM(); vm.Name = TXT_Name.Text; vm.Text = TXT_Text.Text; GaoData.Data.Insert(idx, vm); _colle.Insert(idx, vm); TXT_Text.Clear(); LB_Gaos.ScrollIntoView(vm); } }
private void On_Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue == true) { System.Drawing.Point point = System.Windows.Forms.Control.MousePosition; PresentationSource source = PresentationSource.FromVisual(this); Screen screen = Screen.PrimaryScreen; double maxTop = screen.WorkingArea.Height / source.CompositionTarget.TransformToDevice.M22 - this.MaxHeight; double maxLeft = screen.WorkingArea.Width / source.CompositionTarget.TransformToDevice.M11 - this.Width; if (point.Y > maxTop) { this.Top = maxTop; } else { this.Top = point.Y / source.CompositionTarget.TransformToDevice.M22; } if (point.X > maxLeft) { this.Left = maxLeft; } else { this.Left = point.X / source.CompositionTarget.TransformToDevice.M11; } TXTBOX_Search.Text = ""; _gaoColle = GaoData.Data.GetCollection(); LB_Gaos.ItemsSource = null; LB_Gaos.ItemsSource = _gaoColle; LB_Gaos.SelectedIndex = 0; LB_Gaos.ScrollIntoView(LB_Gaos.SelectedItem); LB_ClipItems.SelectedIndex = 0; LB_ClipItems.ScrollIntoView(LB_ClipItems.SelectedItem); } }
private void On_Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Escape) { Close(); } else if (e.Key == Key.Enter) { if (_gaoPanel) { if (LB_Gaos.SelectedItem != null) { GaoVM vm = LB_Gaos.SelectedItem as GaoVM; vm.CmdSendText.Execute(null); } } else { if (LB_ClipItems.SelectedItem != null) { ClipboardVM vm = LB_ClipItems.SelectedItem as ClipboardVM; vm.CmdSendData.Execute(null); } } } else if (e.Key == Key.Up || e.Key == Key.Down) { if (_gaoPanel) { int idx = LB_Gaos.SelectedIndex + (e.Key == Key.Up ? -1 : 1); if (idx >= 0 && idx <= LB_Gaos.Items.Count) { LB_Gaos.SelectedIndex = idx; LB_Gaos.ScrollIntoView(LB_Gaos.SelectedItem); } } else { int idx = LB_ClipItems.SelectedIndex + (e.Key == Key.Up ? -1 : 1); if (idx >= 0 && idx <= LB_ClipItems.Items.Count) { LB_ClipItems.SelectedIndex = idx; LB_ClipItems.ScrollIntoView(LB_ClipItems.SelectedItem); } } } else if (e.Key == Key.Left || e.Key == Key.Right) { _gaoPanel = (e.Key == Key.Left); if (_gaoPanel) { LB_Gaos.Visibility = Visibility.Visible; LB_ClipItems.Visibility = Visibility.Collapsed; } else { LB_Gaos.Visibility = Visibility.Collapsed; LB_ClipItems.Visibility = Visibility.Visible; } } else { TXTBOX_Search.Focus(); } }