Beispiel #1
0
 /**
  * 设置字符串到剪贴板
  */
 internal static void SetStringClipboard(string str)
 {
     try {
         Clipboard.SetDataObject(str, true);
         QTUtility.AsteriskPlay();
     }
     catch {
         QTUtility.SoundPlay();
     }
 }
Beispiel #2
0
        public static void HandleReorder(IEnumerable <ToolStripItem> items)
        {
            int            dummy;
            List <UserApp> reordered = new List <UserApp>();

            ListFromNestedStructure(reordered, out dummy,
                                    items.OfType <QMenuItem>(), // todo: separators
                                    item => item.MenuItemArguments.App,
                                    item => item.MenuItemArguments.App.IsFolder
                        ? item.DropDown.Items.Cast <QMenuItem>()
                        : null);

            // Find the index of the first item in the level that was reordered.
            Stack <int> startIdx      = new Stack <int>();
            Stack <int> levelChildren = new Stack <int>();

            startIdx.Push(0);
            int children = int.MaxValue;
            int i        = 0;

            foreach (UserApp app in appList)
            {
                i++;
                while (children-- == 0)
                {
                    children = levelChildren.Pop();
                    startIdx.Pop();
                }
                if (app == reordered[0])
                {
                    break;
                }
                if (app.IsFolder)
                {
                    levelChildren.Push(children);
                    startIdx.Push(i);
                    children = app.ChildrenCount;
                }
            }

            i = startIdx.Pop();
            if (i + reordered.Count > appList.Count)
            {
                // This should never happen
                QTUtility.SoundPlay();
            }
            else
            {
                for (int j = 0; j < reordered.Count; j++)
                {
                    appList[i + j] = reordered[j];
                }
                SaveApps();
            }
        }
Beispiel #3
0
 /**
  * 设置字符串到剪贴板
  */
 internal static string GetStringClipboard()
 {
     try
     {
         if (Clipboard.ContainsText(TextDataFormat.Text))
         {
             string clipboardText = Clipboard.GetText(TextDataFormat.Text);
             QTUtility.AsteriskPlay();
             return(clipboardText);
         }
     }
     catch
     {
         QTUtility.SoundPlay();
     }
     return("");
 }
 private void ComputeFinished()
 {
     if (fCancellationPending)
     {
         SetButtonsEnabled(true);
         Text = MakeHashTypeText();
         fCancellationPending = false;
         qPendings.Clear();
     }
     else if (qPendings.Count > 0)
     {
         PathRowPairs pairs = qPendings.Dequeue();
         iThreadsCounter++;
         new HashInvoker(ComputeHashCore).BeginInvoke(pairs.Paths.ToArray(), pairs.Rows.ToArray(), cmbHashType.SelectedIndex, AsyncComplete, null);
     }
     else
     {
         SetButtonsEnabled(true);
         Text = MakeHashTypeText();
         int num   = 0;
         int num2  = 0;
         int count = 0;
         foreach (List <DataGridViewRow> list in dicResult.Values.Where(list => list.Count > 0))
         {
             if (list[0].Cells[2].ToolTipText == VALUE_ERROR)
             {
                 count = list.Count;
             }
             if (list.Count > 1)
             {
                 num2++;
                 num += list.Count;
             }
         }
         if (chbShowResult.Checked)
         {
             string str = (count > 1) ? "s." : ".";
             if (cMatched_Prv != num2)
             {
                 string str2 = (num > 1) ? "s" : string.Empty;
                 string str3 = (num2 > 1) ? "s" : string.Empty;
                 MessageForm.Show(Handle, ((num2 > 0) ? string.Concat(new object[] { num, " file", str2, " matched in ", num2, " ", MakeHashTypeText(), str3 }) : string.Empty) + ((count > 0) ? string.Concat(new object[] { (num2 > 0) ? ", " : string.Empty, count, " error", str }) : "."), "Result", MessageBoxIcon.Asterisk, 0x1388);
             }
             else if (cErr_Prv != count)
             {
                 MessageForm.Show(Handle, count + " error" + str, "Result", MessageBoxIcon.Hand, 0x1388);
             }
         }
         else if (cMatched_Prv != num2)
         {
             QTUtility.AsteriskPlay();
             // QTUtility.AsteriskPlay();
         }
         else if (cErr_Prv != count)
         {
             QTUtility.SoundPlay();
         }
         cMatched_Prv = num2;
         cErr_Prv     = count;
     }
 }
        private bool ProcessNewHotkey(KeyEventArgs e, Keys current, out Keys finalKey)
        {
            finalKey = Keys.None;
            Key          wpfKey     = (e.Key == Key.System ? e.SystemKey : e.Key);
            ModifierKeys wpfModKeys = Keyboard.Modifiers;

            // Ignore modifier keys.
            if (wpfKey == Key.LeftShift || wpfKey == Key.RightShift ||
                wpfKey == Key.LeftCtrl || wpfKey == Key.RightCtrl ||
                wpfKey == Key.LeftAlt || wpfKey == Key.RightAlt ||
                wpfKey == Key.LWin || wpfKey == Key.RWin)
            {
                return(false);
            }

            Keys hotkey = (Keys)KeyInterop.VirtualKeyFromKey(wpfKey);

            if (hotkey == Keys.Escape)
            {
                // Escape = clear
                return(true);
            }

            // Urgh, so many conversions between WPF and WinForms...
            Keys modkey = Keys.None;

            if ((wpfModKeys & ModifierKeys.Alt) != 0)
            {
                modkey |= Keys.Alt;
            }
            if ((wpfModKeys & ModifierKeys.Control) != 0)
            {
                modkey |= Keys.Control;
            }
            if ((wpfModKeys & ModifierKeys.Shift) != 0)
            {
                modkey |= Keys.Shift;
            }

            // don't allow keystrokes without at least one modifier key
            if (modkey == Keys.None)
            {
                return(false);
            }

            modkey |= hotkey;
            if (modkey == current)
            {
                // trying to assign the same hotkey
                return(false);
            }

            // keys not allowed even with any modifier keys
            switch (hotkey)
            {
            case Keys.None:
            case Keys.Enter:
            case Keys.ControlKey:
            case Keys.ShiftKey:
            case Keys.Menu:                             // Alt itself
            case Keys.NumLock:
            case Keys.ProcessKey:
            case Keys.IMEConvert:
            case Keys.IMENonconvert:
            case Keys.KanaMode:
            case Keys.KanjiMode:
                return(false);
            }

            // keys not allowed as one key
            switch (modkey)
            {
            case Keys.LWin:
            case Keys.RWin:
            case Keys.Delete:
            case Keys.Apps:
            case Keys.Tab:
            case Keys.Left:
            case Keys.Up:
            case Keys.Right:
            case Keys.Down:
                return(false);
            }

            // invalid key combinations
            switch (modkey)
            {
            case Keys.Control | Keys.C:
            case Keys.Control | Keys.A:
            case Keys.Control | Keys.Z:
            case Keys.Control | Keys.V:
            case Keys.Control | Keys.X:
            // case Keys.Alt | Keys.Left:
            // case Keys.Alt | Keys.Right:
            case Keys.Alt | Keys.F4:
                QTUtility.SoundPlay();
                return(false);
            }

            // check for key conflicts
            string Conflict =
                QTUtility.TextResourcesDic["Options_Page08_Keys"][6] +
                Environment.NewLine + "{0}" + Environment.NewLine + Environment.NewLine +
                QTUtility.TextResourcesDic["Options_Page08_Keys"][7];
            IHotkeyEntry conflictingEntry = tabbedPanel.Items
                                            .OfType <IHotkeyContainer>()
                                            .SelectMany(hc => hc.GetHotkeyEntries())
                                            .FirstOrDefault(entry => entry.ShortcutKey == modkey);

            if (conflictingEntry != null)
            {
                if (MessageBoxResult.OK != MessageBox.Show(
                        string.Format(Conflict, conflictingEntry.KeyActionText),
                        QTUtility.TextResourcesDic["Options_Page08_Keys"][8],
                        MessageBoxButton.OKCancel, MessageBoxImage.Warning))
                {
                    return(false);
                }
                conflictingEntry.ShortcutKey = Keys.None;
            }
            finalKey = modkey;
            return(true);
        }