Ejemplo n.º 1
0
 /// <summary>
 /// コマンド実行を実行する
 /// </summary>
 private void ExecuteCommand()
 {
     //var task=_command.Execute(_executeParams);
     //await task;
     _command.Execute(_executeParams);
     _resultFilePath = _command.RecordPath;
 }
Ejemplo n.º 2
0
        public bool Rename(string oldKeyname, string newKeyname)
        {
            ValidateInputStringNotNull(oldKeyname, "oldKeyName");
            ValidateInputStringNotNull(newKeyname, "newKeyName");
            var command = new RenameCommand(oldKeyname, newKeyname);

            return(command.Execute());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets IsEditing to false when the ViewItem that contains an EditBox changes its size
        /// </summary>
        /// <param name="bCancelEdit"></param>
        private void OnSwitchToNormalMode(bool bCancelEdit = true)
        {
            lock (_lockObject)
            {
                if (_DestroyNotificationOnFocusChange == false)
                {
                    DestroyTip();
                }

                if (IsEditing == true)
                {
                    string sNewName = string.Empty;

                    if (_TextBox != null)
                    {
                        sNewName = _TextBox.Text;
                    }

                    if (bCancelEdit == false)
                    {
                        if (_TextBox != null)
                        {
                            // Tell the ViewModel (if any) that we'd like to rename this item
                            if (RenameCommand != null)
                            {
                                var tuple = new Tuple <string, object>(sNewName, RenameCommandParameter);
                                RenameCommand.Execute(tuple);
                            }
                        }
                    }
                    else
                    {
                        if (_TextBox != null)
                        {
                            _TextBox.Text = this.Text;

                            // Tell the ViewModel (if any) that renaming of this item has been cancelled
                            if (RenameCancelledCommand != null)
                            {
                                RenameCancelledCommand.Execute(RenameCommandParameter);
                            }
                        }
                    }

                    IsEditing = false;

                    Mouse.RemovePreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideElement);
                    ReleaseMouseCapture();

                    _PART_TextBlock.Focus();
                    _PART_TextBlock.Visibility = System.Windows.Visibility.Visible;

                    _PART_MeasureTextBlock.Visibility = System.Windows.Visibility.Hidden;
                }
            }
        }
Ejemplo n.º 4
0
        public FileList2()
        {
            //<Setter Property="SelectedItems" Value="{Binding SelectedItems, Mode=OneWayToSource}" />
            this.ItemContainerStyleSelector = new fileListItemStyleSelector();


            this.AddHandler(FileList2.SelectionChangedEvent, (RoutedEventHandler)((o, e) =>
            {
                BindableSelectedItems = SelectedItems;
            }));

            this.AddHandler(UIElement.KeyDownEvent, (KeyEventHandler) delegate(object sender, KeyEventArgs args)
            {
                switch (args.Key)
                {
                case Key.F2:
                    if (RenameCommand != null && RenameCommand.CanExecute(DataContext))
                    {
                        RenameCommand.Execute(DataContext);
                    }
                    break;
                }
            });


            this.AddHandler(GridViewColumnHeader.ClickEvent, (RoutedEventHandler) delegate(object sender, RoutedEventArgs args)
            {
                if (args.OriginalSource is GridViewColumnHeader)
                {
                    GridViewColumnHeader header = (GridViewColumnHeader)args.OriginalSource;
                    if (header.Column != null)
                    {
                        SortCriteria columnName = GetSortPropertyName(header.Column);

                        //if (string.IsNullOrEmpty(columnName))
                        //    return;

                        if (SortBy != columnName)
                        {
                            SetValue(SortByProperty, columnName);
                        }
                        else
                        if (SortDirection == ListSortDirection.Ascending)
                        {
                            SetValue(SortDirectionProperty, ListSortDirection.Descending);
                        }
                        else
                        {
                            SetValue(SortDirectionProperty, ListSortDirection.Ascending);
                        }

                        UpdateCollumnHeader();
                    }
                }
            });
        }
Ejemplo n.º 5
0
        public void ExecuteTest()
        {
            var command = new RenameCommand();

            command.Execute(new RenameExecuteParams
            {
                DestinationPath = @"d:\M1200",
                SourcePath      = @"D:\M1124_KB治具 - コピー",
                PrefixName      = "M1200",
                Signature       = "木下",
                Settings        = new Settings.OptionSettingsSerializer().Load()
            });
        }
Ejemplo n.º 6
0
        private void CONTENT_OFF_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Enter:
            case Key.Tab:
                IsInRenamingMode = false;
                RenameCommand?.Execute(CONTENT_OFF.Text);
                break;

            case Key.Escape:
                IsInRenamingMode = false;
                break;
            }
        }
Ejemplo n.º 7
0
        private void CONTENT_OFF_OnPreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            if (!IsInRenamingMode)
            {
                return;
            }

            if (CONTENT_OFF.ContextMenu.IsOpen)
            {
                return;
            }

            if (e.NewFocus == CONTENT_OFF)
            {
                return;
            }

            IsInRenamingMode = false;
            RenameCommand?.Execute(CONTENT_OFF.Text);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// サイレントモードを実行する
        /// </summary>
        /// <param name="param">パラメータ</param>
        /// <returns></returns>
        static void RunSilent(string[] param)
        {
            RenameLogger.ConsoleMode = true;
            NativeMethods.AttachConsole(uint.MaxValue);
            var args = param;

            //コマンドライン不正時の処理
            if (!IsValidCommandLine(args, out string msg))
            {
                var e = new CommandLineArgumentException(
                    msg, CommandLineArgumentErrorCategory.ApplyValueError);
                RenameLogger.WriteLog(new LogItem
                {
                    Exception = e,
                    Level     = LogLevel.Error,
                    Message   = InvalidCommandLineParam()
                });;
                throw e;
            }
            //実行コマンド
            var command = new RenameCommand();

            //実行
            command.Execute(new RenameExecuteParams
            {
                SourcePath      = args[0],
                DestinationPath = args[1],
                PrefixName      = args[2],
                Signature       = args[3],
                Settings        = new OptionSettingsSerializer().Load()
            });
            //変換結果を出力
            var outStream = Console.Out;

            foreach (var line in command.RecordItems)
            {
                outStream.WriteLine(line);
            }
            //コマンドの破棄
            command.Dispose();
        }
Ejemplo n.º 9
0
        protected virtual void setupCommands()
        {
            ContextMenuCommand = new SimpleCommand()
            {
                CanExecuteDelegate = (x) =>
                {
                    ViewerBaseVM vm = (x as ViewerBaseVM);
                    return(vm.IsContextMenuEnabled);
                },
                ExecuteDelegate = (x) =>
                {
                    ViewerBaseVM vm = (x as ViewerBaseVM);
                    if (vm.IsContextMenuEnabled)
                    {
                        Point pt = UITools.GetScreenMousePosition();
                        switch (vm.ContextMenu(pt))
                        {
                        case "open": if (ExpandCommand != null)
                            {
                                ExpandCommand.Execute(vm);
                            }
                            break;

                        case "rename": if (RenameCommand != null)
                            {
                                RenameCommand.Execute(vm);
                            }
                            break;

                        case "refresh": if (RefreshCommand != null)
                            {
                                RefreshCommand.Execute(vm);
                            }
                            break;
                        }
                    }
                }
            };

            RefreshCommand = new SimpleCommand()
            {
                ExecuteDelegate = (x) =>
                {
                    Refresh();
                }
            };

            //ExpandCommand = new SimpleCommand()
            //{
            //    CanExecuteDelegate =
            //        (x) =>
            //        {
            //            ViewerBaseViewModel<FI, DI, FSI> vm = (x as ViewerBaseViewModel<FI, DI, FSI>);
            //            return vm == null ? false : vm.CanExpand;
            //        },
            //    ExecuteDelegate =
            //       (x) =>
            //       {
            //           ViewerBaseViewModel<FI, DI, FSI> vm = (x as ViewerBaseViewModel<FI, DI, FSI>);
            //           vm.Expand();
            //       }
            //};
        }
Ejemplo n.º 10
0
        private void setupCommands()
        {
            ContextMenuCommand = new SimpleCommand()
            {
                ExecuteDelegate = (x) =>
                {
                    NavigationItemViewModel <FI, DI, FSI> vm = this;

                    Point pt = UITools.GetScreenMousePosition();
                    switch (vm.ContextMenu(pt))
                    {
                    case "open": if (OpenCommand != null)
                        {
                            OpenCommand.Execute(vm);
                        }
                        break;

                    case "rename": if (RenameCommand != null)
                        {
                            RenameCommand.Execute(vm);
                        }
                        break;

                    case "refresh": if (RefreshCommand != null)
                        {
                            RefreshCommand.Execute(vm);
                        }
                        break;
                    }
                }
            };

            OpenCommand = new SimpleCommand()
            {
                ExecuteDelegate = (x) =>
                {
                    Profile.Open(EmbeddedDirectoryModel);
                }
            };

            RefreshCommand = new SimpleCommand()
            {
                CanExecuteDelegate = (x) =>
                {
                    return(_subDirectories != null && !_subDirectories.IsWorking);
                },
                ExecuteDelegate = (x) =>
                {
                    Refresh();
                }
            };

            PropertiesCommand = new SimpleCommand()
            {
                ExecuteDelegate = x =>
                {
                    System.Windows.Point position = Mouse.GetPosition(null);
                    Profile.ShowProperties(position, EmbeddedDirectoryModel);
                }
            };

            RenameCommand = new SimpleCommand()
            {
                CanExecuteDelegate = (x) =>
                {
                    return(!this.EmbeddedDirectoryModel.IsReadonly);
                },
                ExecuteDelegate = (x) =>
                {
                    EmbeddedDirectoryViewModel.IsEditing = true;
                }
            };

            DeleteCommand = new SimpleCommand()
            {
                CanExecuteDelegate = (x) =>
                {
                    return(EmbeddedDirectoryModel.IsReadonly);
                },
                ExecuteDelegate = (x) =>
                {
                    try
                    {
                        string caption = String.Format(Texts.strConfirmDelete,
                                                       1, "");

                        if (new WPFMessageBoxService().ShowYesNo(caption, CustomDialogIcons.Question)
                            == CustomDialogResults.Yes)
                        {
                            Profile.Delete(EmbeddedDirectoryModel, EmbeddedDirectoryViewModel.EmbeddedDirectoryModel);
                        }
                    }
                    catch (Exception ex)
                    {
                        new WPFMessageBoxService().ShowError(ex.Message);
                    }
                }
            };
        }
Ejemplo n.º 11
0
   protected virtual void tree_AfterNodeTextEdit(object sender, AfterNodeTextEditEventArgs e)
   {
      IMaxNode node = TreeMode.GetMaxNode(e.TreeNode);
      if (node == null)
         return;

      if (e.NewText != e.OldText)
      {
         RenameCommand cmd = new RenameCommand(new List<IMaxNode>(1) { node }, e.NewText);
         cmd.Execute(false);
      }

      //Note: setting treenode text to displayname and sorting are
      //      handled by nodenamechanged callback.

      MaxInterfaces.Global.EnableAccelerators();
   }
Ejemplo n.º 12
0
        protected void SetupCommands(Func <ExModel[]> getSelectionFunc,
                                     Func <DirectoryModel> getCurrentFunc, Func <System.Drawing.Point> getMousePositionFunc)
        {
            #region OpenCommand and ContextMenuCommand
            OpenCommand = new SimpleRoutedCommand(ApplicationCommands.Open)
            {
                CanExecuteDelegate = x => { return(getCurrentFunc() != null); },
                ExecuteDelegate    = x => { Process.Start(getCurrentFunc().EmbeddedDirectoryEntry.FullName); }
            };

            ContextMenuCommand = new SimpleRoutedCommand(ApplicationCommands.ContextMenu)
            {
                CanExecuteDelegate = x =>
                {
                    return(getSelectionFunc() != null && getSelectionFunc().Length > 0);
                },
                ExecuteDelegate = x =>
                {
                    ContextMenuWrapper _cmw = new ContextMenuWrapper();

                    _cmw.OnBeforeInvokeCommand += (InvokeCommandEventHandler) delegate(object sender, InvokeCommandEventArgs args)
                    {
                        if (args.Command == "open")
                        {
                            args.ContinueInvoke = false;
                        }
                        if (args.Command == "openas" && args.SelectedItems != null &&
                            args.SelectedItems.Length == 1)
                        {
                            args.ContinueInvoke = false;
                        }
                    };
                    var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray();

                    System.Drawing.Point pt = getMousePositionFunc();
                    string command          = _cmw.Popup(selectedItems, pt);
                    switch (command)
                    {
                    case "open": OpenCommand.Execute(null); break;

                    case "openas": OpenCommand.Execute(null); break;

                    case "rename": RenameCommand.Execute(null); break;

                    case "refresh": RefreshCommand.Execute(null); break;
                    }
                }
            };
            #endregion

            #region Delete, Copy and Paste
            DeleteCommand = new SimpleRoutedCommand(ApplicationCommands.Delete)
            {
                CanExecuteDelegate = x =>
                {
                    if (getSelectionFunc() != null && getSelectionFunc().Length > 0)
                    {
                        ;
                    }
                    {
                        var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray();
                        foreach (FileSystemInfoEx item in selectedItems)
                        {
                            if ((item.Attributes & FileAttributes.ReadOnly) != 0)
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                    //return false;
                },
                ExecuteDelegate = x =>
                {
                    var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray();
                    int itemCount     = selectedItems.Length;
                    if (System.Windows.Forms.MessageBox.Show(String.Format("Are you sure want to permanently remove these {0} item{1}?",
                                                                           itemCount, itemCount > 1 ? "s" : ""), "Delete", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        foreach (FileSystemInfoEx item in selectedItems)
                        {
                            item.Delete();
                        }
                    }
                }
            };

            CopyCommand = new SimpleRoutedCommand(ApplicationCommands.Copy)
            {
                CanExecuteDelegate = x =>
                {
                    return(getSelectionFunc() != null && getSelectionFunc().Length > 0);
                },
                ExecuteDelegate = x =>
                {
                    var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray();


                    StringCollection fileList = new StringCollection();

                    foreach (FileSystemInfoEx item in selectedItems)
                    {
                        fileList.Add(item.FullName);
                    }

                    Clipboard.Clear();
                    Clipboard.SetFileDropList(fileList);
                }
            };


            PasteCommand = new SimpleRoutedCommand(ApplicationCommands.Paste)
            {
                CanExecuteDelegate = x =>
                {
                    return
                        (getCurrentFunc() != null &&
                         ((getCurrentFunc().EmbeddedDirectoryEntry.Attributes & FileAttributes.ReadOnly) != 0) &&
                         Clipboard.ContainsFileDropList());
                },
                ExecuteDelegate = x =>
                {
                    DirectoryInfoEx         parentDir = getCurrentFunc().EmbeddedDirectoryEntry;
                    List <FileSystemInfoEx> entryList = new List <FileSystemInfoEx>();
                    foreach (string path in Clipboard.GetFileDropList())
                    {
                        IOTools.Copy(path, PathEx.Combine(parentDir.FullName, PathEx.GetFileName(path)));
                    }
                }
            };
            #endregion

            #region PropertiesCommand
            PropertiesCommand = new SimpleRoutedCommand(ApplicationCommands.Properties)
            {
                CanExecuteDelegate = x =>
                {
                    return(getSelectionFunc() != null && getSelectionFunc().Length > 0);
                },
                ExecuteDelegate = x =>
                {
                    System.Windows.Point position = Mouse.GetPosition(null);
                    var selectedItems             = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray();

                    ContextMenuHelper.InvokeCommand(getSelectionFunc()[0].EmbeddedEntry.Parent,
                                                    selectedItems, "properties", new System.Drawing.Point((int)position.X, (int)position.Y));
                }
            };
            #endregion
        }