Exemple #1
0
 public void ExecuteCommand(System.Windows.Input.ICommand command, object parameter)
 {
     if (command == ApplicationCommands.Delete)
     {
         DeleteSelection();
     }
 }
Exemple #2
0
 public ShortcutCommandWrapper(System.Windows.Input.ICommand baseCommand, string featureName)
 {
     Debug.Assert(baseCommand != null);
     Debug.Assert(featureName != null);
     this.baseCommand = baseCommand;
     this.featureName = featureName;
 }
Exemple #3
0
        public ScanViewModel(IMobileBarcodeScanner scanner)
        {
            this.scanner = scanner;

            GenerateQRCodeCommand = new MvxCommand <string>(selectedBarcode =>
            {
                //TODO geneerate the QR Code
            });

            ScanOnceCommand         = new MvxCommand(ScanOnce);
            ScanContinuouslyCommand = new MvxCommand(ScanContinuously);


            ButtonCancel = new MvxCommand(() =>
            {
                ShowViewModel <MapViewModel>();
            });

            ButtonMenu = new MvxCommand(() =>
            {
                ShowViewModel <ScanmenuViewModel>();
            });

            ButtonDone = new MvxCommand(() =>
            {
                ShowViewModel <VehicleDetailsViewModel>();
            });
        }
 public CustomersVM(CustomerService customersService)
 {
     _customersService      = customersService;
     _addCustomerCommand    = new Command(() => AddCustomer());
     _saveCustomersCommand  = new Command(async() => await SaveCustomersAsync());
     _loadCustomersCommand  = new Command(async() => await LoadCustomersAsync());
     _deleteSelectedCommand = new Command(async() => await DeleteSelectedItemAsync());
 }
Exemple #5
0
        private void OperationItemBorder_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            ButtonToolsMenu.ContextMenu.IsOpen = false;
            e.Handled = true;
            dynamic x = sender;

            System.Windows.Input.ICommand perform = x.DataContext.Perform;
            perform.Execute(null);
        }
Exemple #6
0
 public bool CanExecuteCommand(System.Windows.Input.ICommand command, object parameter)
 {
     if (command == ApplicationCommands.Delete)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #7
0
        public ScanViewModel(IMobileBarcodeScanner scanner)
        {
            this.scanner = scanner;

            ScanOnceCommand = new MvxCommand(ScanOnce);

            ButtonCancel = new MvxCommand(() =>
            {
                ShowViewModel <ScanViewModel>();
            });
        }
 /// <summary>
 /// Registers a WPF command for use with the &lt;MenuItem command="name"&gt; syntax.
 /// </summary>
 public static void RegisterKnownCommand(string name, System.Windows.Input.ICommand command)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (command == null)
     {
         throw new ArgumentNullException("command");
     }
     lock (knownCommands) {
         knownCommands.Add(name, command);
     }
 }
Exemple #9
0
 /// <summary>
 /// 执行方法
 /// </summary>
 /// <param name="command"></param>
 /// <param name="parameter"></param>
 public void ExecuteCommand(System.Windows.Input.ICommand command, object parameter)
 {
     if (command == ApplicationCommands.Delete)
     {
         foreach (var e in View.Selection.Select(p => p.ModelElement))
         {
             if (e is ShapeBase)
             {
                 Shapes.Remove(e as ShapeBase);
             }
         }
         UpdateView();
     }
 }
Exemple #10
0
 private void Setup(EventAggregator eventAggregator, OrderService orderService, OrderItemService orderItemService, InventoryItemService inventoryService, MainWindowVM mainVM)
 {
     _orderService              = orderService;
     _orderItemService          = orderItemService;
     _inventoryService          = inventoryService;
     _mainVM                    = mainVM;
     _eventAggregator           = eventAggregator;
     _orderItems                = new ObservableCollection <OrderItemVM>();
     _saveOrderCommand          = new Command(async() => await SaveAsync());
     _addOrderItemCommand       = new Command(() => AddOrderItem(), () => CanAdd);
     _deleteSelectedItemCommand = new Command(async() => await DeleteSelectedItemAsync());
     _submitOrderCommand        = new Command(async() => await SubmitAsync());
     _shipOrderCommand          = new Command(async() => await ShipAsync());
     _refreshCommand            = new Command(async() => await LoadOrderItemsAsync());
 }
 internal HMouseEventArgsWPF(
     double x,
     double y,
     double row,
     double column,
     int delta,
     System.Windows.Input.ICommand button)
 {
     this.x      = x;
     this.y      = y;
     this.row    = row;
     this.column = column;
     this.delta  = delta;
     this.button = button;
 }
Exemple #12
0
        private static void OnCommandChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RadRating rating = sender as RadRating;

            if (rating.canExecuteChangedHandler != null)
            {
                rating.canExecuteChangedHandler.Unsubscribe();
            }

            System.Windows.Input.ICommand command = args.NewValue as System.Windows.Input.ICommand;
            if (command != null)
            {
                rating.canExecuteChangedHandler = new WeakEventHandler <EventArgs>(command, rating, KnownEvents.CanExecuteChanged);
                rating.UpdateIsReadOnlyFromCommand();
            }
        }
        public UcSerial()
        {
            InfoTextList          = new ObservableCollection <object>();
            this.Command          = new RelayCommand(this.CommandReceived);
            this.DispatcherObject = System.Windows.Threading.Dispatcher.CurrentDispatcher;

            this.CollectionParities  = new ObservableCollection <SerialParity>(Enum.GetValues(typeof(SerialParity)).Cast <SerialParity>());
            this.CollectionStoptBits = new ObservableCollection <SerialStopBitCount>(Enum.GetValues(typeof(SerialStopBitCount)).Cast <SerialStopBitCount>());
            this.CollectionDataBits  = new ObservableCollection <SerialDataBits>(Enum.GetValues(typeof(SerialDataBits)).Cast <SerialDataBits>());
            this.CollectionBaudrates = new ObservableCollection <uint>();
            this.CollectionBaudrates.Add(9600);
            this.CollectionBaudrates.Add(19200);
            this.CollectionBaudrates.Add(115200);
            this.CollectionPorts = new ObservableCollection <string>();
            this.GetComPorts();

            InitializeComponent();
            this.DataContext = this;
        }
Exemple #14
0
        internal static void ClearBindingIfSet(
            ICommand uiCommand,
            FrameworkElement target,
            DependencyProperty targetProperty)
        {
            BindingExpression bindingExpression;

            bindingExpression = target.GetBindingExpression(targetProperty);

            if (bindingExpression != null)
            {
                object bindingSource;
                bindingSource = bindingExpression.ParentBinding.Source;

                if (bindingSource != null && bindingSource == uiCommand)
                {
                    target.ClearValue(targetProperty);
                }
            }
        }
Exemple #15
0
        internal static bool Execute(object sender, System.Windows.Input.ICommand command, object commandParameter)
        {
            if (command != null)
            {
                RoutedCommand routedCommand = command as RoutedCommand;
                IInputElement inputElement  = sender as IInputElement;
                if (routedCommand != null && routedCommand.CanExecute(commandParameter, inputElement))
                {
                    routedCommand.Execute(commandParameter, inputElement);
                    return(true);
                }
                else if (command.CanExecute(commandParameter))
                {
                    command.Execute(commandParameter);
                    return(true);
                }
            }

            return(false);
        }
Exemple #16
0
        internal static void BindToLabelPropertyIfUnset(
            ICommand uiCommand,
            FrameworkElement target,
            DependencyProperty labelProperty)
        {
            string localLabel    = null;
            var    localLabelAsI = target.ReadLocalValue(labelProperty);

            if (localLabelAsI != null)
            {
                localLabel = localLabelAsI.ToString();
            }

            if (localLabelAsI == DependencyProperty.UnsetValue || string.IsNullOrEmpty(localLabel))
            {
                target.SetBinding(labelProperty, new Binding {
                    Path = "Label", Source = uiCommand
                });
            }
        }
Exemple #17
0
        private void RaiseCommandExecute()
        {
            System.Windows.Input.ICommand command = this.Command;
            if (command != null)
            {
                object parameter = this.ReadLocalValue(RadRating.CommandParameterProperty);
                if (parameter == DependencyProperty.UnsetValue)
                {
                    parameter = this.Value;
                }
                else
                {
                    parameter = this.GetValue(RadRating.CommandParameterProperty);
                }

                if (command.CanExecute(parameter))
                {
                    command.Execute(parameter);
                }
            }
        }
Exemple #18
0
        public override void Init()
        {
            var abc = Start.ViewManager.GetText(Texts.WAIT_PREPERA_DATA);

            Login = new DelegateCommand()
            {
                ExecuteCommand    = executeCommand_Login,
                CanExecuteCommand = canExecuteCommand_Login
            };
            ChangeTheme = new DelegateCommand()
            {
                ExecuteCommand = executeCommand_ChangeTheme
            };
            ChangeLanguage = new DelegateCommand()
            {
                ExecuteCommand = executeCommand_ChangeLanguage
            };
            Test = new DelegateCommand()
            {
                ExecuteCommand = executeCommand_Test
            };
        }
        public void Initialize()
        {

            _container.RegisterType<IHttpCallsProvider, HttpCallsProvider>(new ContainerControlledLifetimeManager());

              httpcallsprovider = _container.Resolve<IHttpCallsProvider>();
              _container.RegisterType<IKeyValuePersister<string, string>, AppKeyValuePersister<string>>();

              _container.RegisterType<ICapturingService, CapturingService>();

              startFiddlerCommand = new DelegateCommand(StartFiddler, CanStart);
              closeFiddlerCommand = new DelegateCommand(CloseFiddler, CanClose);
              applicationExitCommand = new DelegateCommand(ApplicationExited, CanApplicationExit);
              GlobalCommands.FiddlerApplicationCloseCommand.RegisterCommand(closeFiddlerCommand);
              GlobalCommands.FiddlerApplicationStartCommand.RegisterCommand(startFiddlerCommand);
            GlobalCommands.ApplicationExitCommand.RegisterCommand(applicationExitCommand);
            _container.RegisterType<ICertificateService, CertificateService>(new ContainerControlledLifetimeManager());
            capturingService = _container.Resolve<ICapturingService>();
              capturingService.Start();


        }
Exemple #20
0
        internal static void BindToLabelPropertyIfUnset(
            ICommand uiCommand,
            DependencyObject target,
            DependencyProperty labelProperty)
        {
            string localLabel    = null;
            var    localLabelAsI = target.ReadLocalValue(labelProperty);

            if (localLabelAsI != null)
            {
                localLabel = localLabelAsI.ToString();
            }

            if (localLabelAsI == DependencyProperty.UnsetValue || string.IsNullOrEmpty(localLabel))
            {
                if (target is IDependencyObjectStoreProvider dosp)
                {
                    dosp.Store.SetBinding(labelProperty, new Binding {
                        Path = "Label", Source = uiCommand
                    });
                }
            }
        }
Exemple #21
0
 /// <summary>
 /// 是否可以执行方法
 /// </summary>
 /// <param name="command"></param>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public bool CanExecuteCommand(System.Windows.Input.ICommand command, object parameter)
 {
     return(command == ApplicationCommands.Delete && View.Selection.Count > 0);
 }
Exemple #22
0
			public ShortcutCommandWrapper(System.Windows.Input.ICommand baseCommand, string featureName)
			{
				Debug.Assert(baseCommand != null);
				Debug.Assert(featureName != null);
				this.baseCommand = baseCommand;
				this.featureName = featureName;
			}
Exemple #23
0
			public AmbiguousCommandWrapper(System.Windows.Input.ICommand first, System.Windows.Input.ICommand second)
			{
				this.first = first;
				this.second = second;
			}
Exemple #24
0
 public AbstractViewModel()
 {
     this.iCommand = this;
 }
Exemple #25
0
 internal static bool Execute(object sender, System.Windows.Input.ICommand command)
 {
     return(Execute(sender, command, null));
 }
Exemple #26
0
 public AmbiguousCommandWrapper(System.Windows.Input.ICommand first, System.Windows.Input.ICommand second)
 {
     this.first  = first;
     this.second = second;
 }
Exemple #27
0
		private static void CheckThatTheDefaultInputBindingCollectionContainsAllCommandsThanNeedToBeBound(MyReadOnlyObservableCollection<InputBinding> inputBindings)
		{
			//gets all commands that are assigned
			var assignedCommands = inputBindings.Select(binding => binding.Command).ToList();

			//the following commands don't have to be assigned:
			var definitelyUnassigned = new ICommand[] { Commands.InsertCharacter,	//treated specially: It's associated directly to 
														//Commands.PlaceCaret,
														//Commands.ExtendAndPlaceCaret,
														Commands.MoveCaretRightOut,	//No such caret movement exist in Word's Equation Editor, but
														Commands.MoveCaretLeftOut };//they are useful as template to be copied and modified

			//gets the first command that isn't assigned but should be
			var unassignedCommand = assignedCommands.Where(command => !command.IsAnyOf(definitelyUnassigned))//definitelyUnassigned has the commands that don't need to be assigned
													.FirstOrDefault(not<ICommand>(assignedCommands.Contains));        //get the first that isn't assigned in the result


			Contract.Assert(unassignedCommand == null, string.Format("Forgot to assign {0}", unassignedCommand));
		}
Exemple #28
0
 internal static void AddGestureToInputBindingOwner(UIElement inputBindingOwner, KeyGesture kg, System.Windows.Input.ICommand shortcutCommand, string featureName)
 {
     if (inputBindingOwner != null && kg != null && shortcutCommand != null)
     {
         // wrap the shortcut command so that it can report to UDC with
         // different activation method
         if (!string.IsNullOrEmpty(featureName))
         {
             shortcutCommand = new ShortcutCommandWrapper(shortcutCommand, featureName);
         }
         // try to find an existing input binding which conflicts with this shortcut
         var existingInputBinding =
             (from InputBinding b in inputBindingOwner.InputBindings
              let gesture = b.Gesture as KeyGesture
                            where gesture != null &&
                            gesture.Key == kg.Key &&
                            gesture.Modifiers == kg.Modifiers
                            select b
             ).FirstOrDefault();
         if (existingInputBinding != null)
         {
             // modify the existing input binding to allow calling both commands
             existingInputBinding.Command = new AmbiguousCommandWrapper(existingInputBinding.Command, shortcutCommand);
         }
         else
         {
             inputBindingOwner.InputBindings.Add(new InputBinding(shortcutCommand, kg));
         }
     }
 }