コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: dghkd/KomicAheGao
        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);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: dghkd/KomicAheGao
 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();
     }
 }