Exemplo n.º 1
0
        /// <summary>
        /// Handles click on the Main button. By default shows/hides Buttonstack,
        /// with CTRL pressed shows Run dialog instead, and with CTRL+SHIFT in DEBUG
        /// mode shows RestartExplorer instance for purposes of localization
        /// </summary>
        private void ShowButtonStack(object sender, RoutedEventArgs e)
        {
            if (!BtnStck.IsInstantited)
            {
                return;
            }

            KillArrow();

            if ((Control.ModifierKeys & Keys.Control) > 0)
            {
#if DEBUG
                if ((Control.ModifierKeys & Keys.Shift) > 0)
                {
                    new RestartExplorer().ShowDialog();
                    return;
                }
#endif
                ShowRunDialog(this, null);
                return;
            }

            MfuList.UpdateStartMfu();
            BtnStck.Instance.Show();//XP:955ms 0_o
            var screenPoint = new API.POINT();
            API.GetCursorPos(ref screenPoint);
            GetSetWndPosition(BtnStck.Instance, screenPoint,
                              sender == Keyboard.PrimaryDevice && SettingsManager.Instance.AltZAutoCornerEnabled);
            //  ^^^ means "Command came from KB and Auto-cornering enabled"
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handles DragDrop event putting file names to custom MFU list
 /// </summary>
 private void Power8Drop(object sender, DragEventArgs e)
 {
     foreach (var fileOrFolder in (string[])e.Data.GetData(DataFormats.FileDrop))
     {
         MfuList.Add2Custom(null, fileOrFolder);
     }
     MfuList.UpdateStartMfu(); //we use 2nd way to invoke Add2Cutsom, so must
     //update the MFU list explicitly
 }
Exemplo n.º 3
0
 /// <summary>
 /// Routine to be performed after some PowerItem's IsPinned property was changed
 /// </summary>
 /// <param name="pi">Item whose property has changed</param>
 private void PinInternal(PowerItem pi)
 {
     try
     {
         MfuList.PinUnpin(pi);
         dataGrid.ScrollIntoView(pi);
     }
     catch (IndexOutOfRangeException)
     {
         Util.DispatchCaughtException(new Exception(Properties.Resources.Err_NoPiExtracted));
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Handles specific key presses when focus is in Data grid:
        /// - Enter starts the selected PowerItem, if any;
        /// - Tab/Shift-Tab moves focus to correct controls so that grid doesn't
        /// hold focus inside. There are arrow buttons for that.
        /// </summary>
        private void DataGridPreviewKeyDown(object sender, KeyEventArgs e)
        {
            var pi = dataGrid.SelectedItem as PowerItem;

            switch (e.Key)
            {
            case Key.Enter:
                if (pi != null && !pi.AreItemsDisplayed)
                {
                    e.Handled = true;
                    InvokeFromDataGrid(pi);
                }
                break;

            case Key.Tab:
                e.Handled = true; //todo: check why CTRL is tested differently in other places
                if (pi != null && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                {                 //CTRL+Tab >> put path to item to search bar
                    var t = "\"" + PowerItemTree.GetResolvedTarget(pi) + "\" ";
                    SearchBox.Text = t;
                    SearchBox.Focus();
                    SearchBox.CaretIndex = t.Length;
                }
                else if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                {
                    AllItemsMenuRoot.Focus();     //SHIFT+Tab >> focus backwards
                }
                else
                {
                    SearchBox.Focus();     //Tab >> focus forwards
                }
                break;

            case Key.Up:
            case Key.Down:
                if (pi != null && pi.AreItemsDisplayed)
                {
                    return;     //Do not handle keys when JL is in focus
                }
                //Not in search view when we press Up/Down
                if ((System.Windows.Forms.Control.ModifierKeys & Keys.Control) > 0 && dataGrid.ItemsSource.Equals(MfuItems))
                {                                                    //with CTRL
                    if (dataGrid.SelectedIndex > -1 && SettingsManager.Instance.MfuIsCustom)
                    {                                                //...and we have something selected, and we're in custom MFU...
                        var si = dataGrid.SelectedItem as PowerItem; //...and more than 1 in (un) pinned group
                        if (si != null && MfuItems.Count(m => m.IsPinned == si.IsPinned) > 1)
                        {                                            //=> move item itself
                            e.Handled = true;
                            dataGrid.Focus();                        //.Net 4.5 hack. Datagrid in .Net4.5 doesn't switch focus to new row
                            int       increment = (e.Key == Key.Up ? -1 : 1);
                            int       i         = dataGrid.SelectedIndex;
                            PowerItem target    = null;
                            do     //search for nearest item with same pinning state
                            {
                                i += increment;
                                if (i == -1)
                                {
                                    i = MfuItems.Count - 1;
                                }
                                else if (i == MfuItems.Count)
                                {
                                    i = 0;
                                }
                                if (MfuItems[i].IsPinned == si.IsPinned)
                                {
                                    target = MfuItems[i];
                                }
                            } while (target == null);
                            MfuList.MoveCustomListItem(si, target);
                        }
                    }
                }
                else if ((System.Windows.Forms.Control.ModifierKeys & Keys.Control) == 0) //Not with CTRL,
                {                                                                         // regardless of source => just move selection
                    e.Handled = true;
                    var idx = dataGrid.SelectedIndex + (e.Key == Key.Up ? -1 : 1);
                    if (idx < 0)
                    {
                        idx = dataGrid.Items.Count - 1;
                    }
                    if (idx >= dataGrid.Items.Count)
                    {
                        idx = 0;
                    }
                    dataGrid.SelectedIndex = idx;
                }
                if (dataGrid.SelectedItem != null)     //when in search view and no hits/in clear custom list
                {
                    dataGrid.ScrollIntoView(dataGrid.SelectedItem);
                }
                break;

            case Key.P:
                if (pi != null && pi.IsMfuChild)
                {
                    e.Handled    = true;
                    pi.IsPinned ^= true;
                    PinInternal(pi);
                    dataGrid.Focus();
                }
                break;

            case Key.X:
                if (pi != null && dataGrid.ItemsSource.Equals(_searchView))
                {
                    e.Handled = true;
                    ExpandCollapseGroup(pi);
                    dataGrid.Focus();
                }
                break;

            case Key.Right:
            case Key.Left:
                if (pi != null)
                {
                    e.Handled             = true;
                    pi.AreItemsDisplayed ^= true;
                }
                break;
            }
        }