コード例 #1
0
 private void ItemList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (!(cItemList.GetItemAt(Mouse.GetPosition(this.cItemList))?.DataContext is ItemModel model))
     {
         return;
     }
     if (!MyLibUtil.RunApplication(model.FilePath, false))
     {
         AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToLaunch, model.FilePath));
     }
 }
コード例 #2
0
        /// <summary>
        /// launch app
        /// </summary>
        /// <param name="model"></param>
        private bool LaunchApp(ItemModel model)
        {
            var result = false;

            if (0 <= model.FileUrl.Length)
            {
                if (!MyLibUtil.RunApplication(model.FileUrl, false))
                {
                    AppUtil.ShowErrorMsg(string.Format(ErrorMsg.FailToLaunch, model.FileUrl));
                }
                else
                {
                    result = true;
                }
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// item dir
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemDir(object sender, ItemView.ItemEventArgs e)
        {
            var model = this.GetModel(e.Model.Index);
            var file  = FileUtil.Create(model.FileUrl);

            if (null == file)
            {
                return;
            }
            var fileDir = "";

            if (file.IsDirectory)
            {
                fileDir = file.FilePath;
            }
            else
            {
                fileDir = ((FileOperator)file).GetParendDir().FilePath;
            }
            MyLibUtil.RunApplication(fileDir, false);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemList_KeyDown(object sender, KeyEventArgs e)
        {
            var       selectedIndex = this.cItemList.SelectedIndex;
            ItemModel model         = null;

            if (0 <= selectedIndex)
            {
                model = this._itemList[selectedIndex];
            }
            bool updateOrder = false;

            if (Key.U == e.Key && this.IsModifierPressed(ModifierKeys.Shift) && this.IsModifierPressed(ModifierKeys.Control))
            {
                if (selectedIndex <= 0)
                {
                    return;
                }
                this._itemList.Remove(model);
                selectedIndex--;
                this._itemList.Insert(selectedIndex, model);
                updateOrder = true;
                e.Handled   = true;
            }
            else if (Key.D == e.Key && this.IsModifierPressed(ModifierKeys.Shift) && this.IsModifierPressed(ModifierKeys.Control))
            {
                if (-1 == selectedIndex || this._itemList.Count - 1 <= selectedIndex)
                {
                    return;
                }
                this._itemList.Remove(model);
                selectedIndex++;
                this._itemList.Insert(selectedIndex, model);
                updateOrder = true;
                e.Handled   = true;
            }
            else if (e.Key == Key.U && IsModifierPressed(ModifierKeys.Control))
            {
                e.Handled = true;
                var itemsModel = this.cItemList.SelectedItem as ItemModel;
                MyLibUtil.RunApplication(itemsModel.FilePath, false);
            }
            else if (e.Key == Key.C && IsModifierPressed(ModifierKeys.Control) && IsModifierPressed(ModifierKeys.Shift))
            {
                Clipboard.SetText(model.User);
            }
            else if (e.Key == Key.X && IsModifierPressed(ModifierKeys.Control) && IsModifierPressed(ModifierKeys.Shift))
            {
                Clipboard.SetText(model.Password);
            }
            else if (e.Key == Key.V && IsModifierPressed(ModifierKeys.Control))
            {
                e.Handled = true;
                Task.Run(() => {
                    System.Threading.Thread.Sleep(200);
                    _findSelf = false;
                    NativeMethods.EnumWindows(new NativeMethods.EnumWindowsDelegate(EnumWindowCallBack), IntPtr.Zero);
                });
            }
            if (updateOrder)
            {
                using (var table = new ItemsTable(this._profileDatabase)) {
                    if (table.UpdateRowOrdersByIds(this._itemList) == 0)
                    {
                        AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToUpdate, "item"));
                    }
                    else
                    {
                        this.cItemList.SelectedIndex = selectedIndex;
                    }
                    this._orderDescend = false;
                }
            }
        }