Very simple command that takes an System.Action with no parameters and invokes the System.Action when the ICommand.Execute(object) method is invoked.
Inheritance: ICommand
コード例 #1
0
        public CameraClientViewModel()
        {
            FramesProcessed += async f => { await Task.Yield(); };
            Cameras = new CollectionViewSource();
            Resolutions = new CollectionViewSource();
            Dispatcher = Cameras.Dispatcher;

            CurrentImage = this.NewProperty(x => x.CurrentImage);
            SelectedCamera = this.NewProperty(x => x.SelectedCamera);
            SelectedResolution = this.NewProperty(x => x.SelectedResolution);
            Countdown = this.NewProperty(x => x.Countdown);
            CountdownVisible = this.NewProperty(x => x.CountdownVisible);
            RecordingVisibility = this.NewProperty(x => x.RecordingVisibility);
            CountdownVisible.Value = Visibility.Collapsed;
            RecordingVisibility.Value = Visibility.Collapsed;

            _controller = new ClientController();
            _controller.PrepareForRecording += PrepareForRecording;
            _controller.RecordingStarted += RecordingStarted;
            _controller.RecordingCompleted += RecordingCompleted;
            Record = new ActionCommand(RecordVideo);

            SelectedCamera.Changed += SelectedCameraChanged;
            SelectedResolution.Changed += SelectedResolutionChanged;
            _remote = new CameraClientRemoteControl(this, _controller);
        }
コード例 #2
0
 public ShowPartyInviteesViewModel(IPartyInviteeRepository repository)
 {
     _repository = repository;
     Add = new ActionCommand(OnAdd);
     BetterAdd = new ActionCommand(OnBetterAdd);
     RefreshList();
 }
コード例 #3
0
 public SniperInfoModel()
 {
     copyCoordsCommand = new ActionCommand(CopyCoords);
     PokeSnipersCommand = new ActionCommand(PokeSnipers);
     SniperVisibility = GlobalSettings.SniperVisibility;
     Created = DateTime.Now;
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonViewModel"/> class.
        /// </summary>
        public PersonViewModel()
        {
            ToggleReadOnlyCommand = new ActionCommand(ToggleReadOnly);

            FirstName = "First Name";
            LastName = "Last Name";
        }
コード例 #5
0
ファイル: NavigateCommand.cs プロジェクト: aries544/eXpand
 protected override void InternalExecute(ICommandAdapter adapter){
     var actionCommand = new ActionCommand();
     var parameterList = actionCommand.Parameters;
     parameterList.MainParameter=new MainParameter("Navigation");
     parameterList.ExtraParameter = Parameters.MainParameter;
     actionCommand.Execute(adapter);
 }
コード例 #6
0
        public MainWindowViewModel() {
            Pokemons = new ReadOnlyObservableCollection<SniperInfoModel>(GlobalVariables.PokemonsInternal);
            SettingsComand = new ActionCommand(ShowSettings);
            StartStopCommand = new ActionCommand(Startstop);
            DebugComand = new ActionCommand(ShowDebug);

            Settings.Default.DebugOutput = "Debug stuff in here!";
            //var poke = new SniperInfo {
            //    Id = PokemonId.Missingno,
            //    Latitude = 45.99999,
            //    Longitude = 66.6677,
            //    ExpirationTimestamp = DateTime.Now
            //};
            //var y = new SniperInfoModel {
            //    Info = poke,
            //    Icon = new BitmapImage(new Uri(Path.Combine(iconPath, $"{(int) poke.Id}.png")))
            //};
            //GlobalVariables.PokemonsInternal.Add(y);

            GlobalSettings.Output = new Output();
            Program p = new Program();
            Thread a = new Thread(p.Start) { IsBackground = true};
            //Start(); p
            a.Start();
        }
コード例 #7
0
        public MainViewModel()
        {
            //Console = Console.Default();
            var mmu = new Mmu();
            Console = new Console(
                new Cpu(mmu), mmu,
                new Gpu(mmu,
                    // TODO make palettes configurable from UI
                    //Colors.White,
                    //Colors.LightGray,
                    //Colors.DarkGray,
                    //Colors.Black),
                    //new Color { R = 0xB8, G = 0xC2, B = 0x66 },
                    //new Color { R = 0x7B, G = 0x8A, B = 0x32 },
                    //new Color { R = 0x43, G = 0x59, B = 0x1D },
                    //new Color { R = 0x13, G = 0x2C, B = 0x13 }),
                    Colors.GhostWhite,
                    Colors.LightSlateGray,
                    Colors.DarkSlateBlue,
                    Colors.Black),
                new Timer(mmu),
                new Controller(mmu));

            Title = "GameboyEm";
            OpenCommand = new ActionCommand(Open);
            LoadStateCommand = new ActionCommand(LoadState);
            SaveStateCommand = new ActionCommand(SaveState);
            CloseCommand = new ActionCommand(Application.Current.Shutdown);
            PowerOnCommand = new ActionCommand(PowerOn);
            PowerOffCommand = new ActionCommand(PowerOff);
            ResetCommand = new ActionCommand(Reset);
            DebuggerCommand = new ActionCommand(Debugger);
        }
コード例 #8
0
        public ExpensesViewModel(IUnityContainer container)
        {
            _container = container;
            CreateExpenseCommand = new ActionCommand(OnCreateExpense);

            GetExpenses();
        }
コード例 #9
0
        public DbDipViewModel()
        {
            Corpuses = new ObservableCollection<DipCorpus>();
            foreach(var corpus in CorpusesStorage.AllCorpuses())
            {
                Corpuses.Add(corpus);
            }
            AddCommand = new ActionCommand(() =>
            {
                StartProgress();

                var editor = GenericEdit.Create(new DipCorpus
                {
                    Name = "Новий корпус",
                    PinCount = 8,
                    CorpusWidthMm = 6
                }, corpus =>
                {
                    Corpuses.Add(corpus);
                    SaveCorpuses();
                });

                editor.ShowDialog();

                CompleteProgress();
            });

            EditCommand = new ActionCommand<DipCorpus>(item =>
            {
                StartProgress();
                // TODO Should copy instead of modification
                var editor = GenericEdit.Create(item, corpus =>
                {
                    SaveCorpuses();
                });

                editor.ShowDialog();

                CompleteProgress();
            });

            RemoveCommand = new ActionCommand<DipCorpus>(item =>
            {
                StartProgress();

                Corpuses.Remove(item);
                SaveCorpuses();

                CompleteProgress();
            });

            GenerateCommand = new ActionCommand<DipCorpus>(item =>
            {
                StartProgress();

                new DipBuilder(new SwContext()).Build(item);

                CompleteProgress();
            });
        }
コード例 #10
0
        //====================================================================================================
        public AddBookingViewModel(IMessageBoxService mboxService, IConfigService configService, 
            IParentVm parent, Booking model)
        {
            _parent = parent;
            _mboxService = mboxService;
            _configService = configService;

            //Get Configuration
            AvailableDurations = _configService.GetAvailableDurations();

            //Set Commands
            SubmitCommand = new ActionCommand(OnSubmit, _=>_isFormValid);
            CancelCommand = new ActionCommand(OnCancel);

            //Set up the screen for Add or Display.
            if (model.Id == -1)
            {
                Model = model;
                Caption = "Add New Booking";
                IsAddMode = true;
            }
            else
            {
                Model = model;
                Caption = "Existing Booking";
                IsAddMode = false;
            }
        }
コード例 #11
0
        /// <summary>
        /// Constructeur.
        /// </summary>
        public Equipement_SOViewModel()
            : base()
        {
            ManageSousTypeOuvrageCommand = new ActionCommand<object>(
                obj => ManageSousTypeOuvrage(), obj => true);

            this.OnViewActivated += (o, e) =>
            {
                if (!e.ViewParameter.Any(r => r.Key == "IsTopContainerLoaded"))
                {
                    EventAggregator.Publish("CustomTopContainer".AsViewNavigationArgs().AddNamedParameter("HideContainer", false));
                    EventAggregator.Publish("TypeEquipement".AsViewNavigationArgs().AddNamedParameter("IsTopContainerLoaded", true));
                }
                if (!e.ViewParameter.Any(p => p.Key == "IsExpanderLoaded"))
                {
                    EventAggregator.Publish("CustomExpander".AsViewNavigationArgs().AddNamedParameter("Title", Resources.Resource.EquipementExpanderTitle));
                    EventAggregator.Publish("Equipement_Expander".AsViewNavigationArgs().AddNamedParameter("IsExpanderLoaded", true).AddNamedParameter(Constants.SPECIFIC_VIEWMODEL_NAME, "Equipement_SO"));
                }
            };

            this.OnAddedEntity += (o, e) =>
            {
                ((EqSoutirage)this.SelectedEntity).DateControle = DateTime.Now;
                ((EqSoutirage)this.SelectedEntity).DateMiseEnServiceRedresseur = DateTime.Now;
            };

            this.OnAllServicesLoaded += (o, e) =>
            {
                RaisePropertyChanged(() => this.TypeRedresseurs);
                RaisePropertyChanged(() => this.TypeDeversoirs);
            };
        }
コード例 #12
0
        /// <summary>
        /// Constructeur par défaut
        /// </summary>
        public Equipement_LIViewModel()
            : base()
        {
            NavigateLiaisonCommand = new ActionCommand<object>(
                obj => NavigateToLiaison(obj), obj => true);

            NavigatePortionCommand = new ActionCommand<object>(
                obj => NavigateToPortion(obj), obj => true);

            this.OnSaveSuccess += (o, e) =>
            {
                //Si on a ajouté une LIEE, on doit ajouter le lien entre les LIEE
                this.RaisePropertyChanged(() => this.SelectedEntity);
            };

            this.OnViewActivated += (o, e) =>
            {
                if (!e.ViewParameter.Any(r => r.Key == "IsTopContainerLoaded"))
                {
                    EventAggregator.Publish("CustomTopContainer".AsViewNavigationArgs().AddNamedParameter("HideContainer", false));
                    EventAggregator.Publish("TypeEquipement".AsViewNavigationArgs().AddNamedParameter("IsTopContainerLoaded", true));
                }
                if (!e.ViewParameter.Any(p => p.Key == "IsExpanderLoaded"))
                {
                    EventAggregator.Publish("CustomExpander".AsViewNavigationArgs().AddNamedParameter("Title", Resources.Resource.EquipementExpanderTitle));
                    EventAggregator.Publish("Equipement_Expander".AsViewNavigationArgs().AddNamedParameter("IsExpanderLoaded", true).AddNamedParameter(Constants.SPECIFIC_VIEWMODEL_NAME, "Equipement_LI"));
                }
                LiaisonsCommunes = null;
            };

            this.OnDetailLoaded += (o, e) =>
            {
                Initialisation();
            };

            this.OnAddedEntity += (o, e) =>
            {
                Initialisation();
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
            };

            this.OnAllServicesLoaded += (o, e) =>
            {
                RaisePropertyChanged(() => this.TypeLiaisons);
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
            };

            this.OnSaveSuccess += (o, e) =>
            {
                LiaisonInterEeBeforeChange = ((EqLiaisonInterne)this.SelectedEntity).LiaisonInterEe;
                RaisePropertyChanged(() => this.IsLibelleInterEE);
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
            };

            this.OnDeleteSuccess += (o, e) =>
            {
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
            };
        }
コード例 #13
0
 public SelectedSecteurViewModel()
     : base()
 {
     ValidateCommand = new ActionCommand<object>(
         obj => Validate(), obj => true);
     CancelCommand = new ActionCommand<object>(
         obj => Cancel(), obj => true);
 }
コード例 #14
0
        public EdataFileViewModel(EdataManagerViewModel parentVm)
        {
            _parentVm = parentVm;

            CloseCommand = new ActionCommand((x) => ParentVm.CloseFile(this));
            DetailsCommand = new ActionCommand(DetailsExecute);
            AddRowCommand = new ActionCommand(AddRowExecute);
        }
コード例 #15
0
 public ExportTourneeViewModel()
     : base()
 {
     ExportCommand = new ActionCommand<object>(
         obj => Clicked(obj));
     CancelCommand = new ActionCommand<object>(
         obj => Cancel(), obj => true);
 }
コード例 #16
0
 public CreateEqEquipementTmpViewModel()
     : base()
 {
     ValidateCommand = new ActionCommand<object>(
         obj => Validate(), obj => true);
     CancelCommand = new ActionCommand<object>(
         obj => Cancel(), obj => true);
 }
コード例 #17
0
        public MainViewModel()
        {
            ReloadTenands();

            CreateTenantCommand = new ActionCommand(CreateTenant);
            AddNewTenantCommand = new ActionCommand(AddNewTenant);
            DeleteTenantCommand = new ActionCommand(DeleteTenant);
        }
コード例 #18
0
        public ObjectCopyResultViewModel(List<NdfObject> results, NdfEditorMainViewModel editor)
        {
            NewInstances = new ObservableCollection<NdfObject>(results);

            Editor = editor;

            DetailsCommand = new ActionCommand(DetailsExecute);
        }
コード例 #19
0
        public ReferenceSearchResultViewModel(List<NdfPropertyValue> results, NdfEditorMainViewModel editor)
        {
            Results = new ObservableCollection<NdfPropertyValue>(results);

            Editor = editor;

            DetailsCommand = new ActionCommand(DetailsExecute);
        }
コード例 #20
0
 public CreateInsInstrumentViewModel()
     : base()
 {
     ValidateCommand = new ActionCommand<object>(
         obj => Validate(), obj => true);
     CancelCommand = new ActionCommand<object>(
         obj => Cancel(), obj => true);
 }
コード例 #21
0
 public CreateUsrUtilisateurViewModel()
     : base()
 {
     ValidateCommand = new ActionCommand<object>(
         obj => Validate(), obj => true);
     CancelCommand = new ActionCommand<object>(
         obj => Cancel(), obj => true);
 }
コード例 #22
0
        public NdfEditorMainViewModel(NdfBinary ndf)
        {
            NdfBinary = ndf;

            InitializeNdfEditor();

            SaveNdfbinCommand = new ActionCommand(SaveNdfbinExecute, () => false);
        }
コード例 #23
0
        public ChatHistoryViewModel(Guid serverId)
        {
            _serverId = serverId;

            FilterCommand = new ActionCommand(() => RaisePropertyChanged("Log"));

            SelectedServers = serverId.ToString();
        }
コード例 #24
0
 public MainViewModel()
 {
     CurrentPage = new Uri("Views/Schema.xaml", UriKind.RelativeOrAbsolute);
     NavigateTo = new ActionCommand<string>(page =>
     {
         CurrentPage = new Uri(page, UriKind.RelativeOrAbsolute);
         RaisePropertyChanged("CurrentPage");
     });
 }
コード例 #25
0
 /// <summary>
 /// Constructeur par défaut
 /// </summary>
 public TreeViewGeoViewModel()
 {
     AddCommand = new ActionCommand<object>(
         obj => AddTreeItem(), obj => CanAdd);
     DeleteCommand = new ActionCommand<object>(
         obj => DeleteTreeItem(), obj => CanDelete);
     EditCommand = new ActionCommand<object>(
         obj => UpdateTreeItem(), obj => CanUpdate);
 }
コード例 #26
0
 public ProcessorViewModel()
 {
     BrowseInputFolderCommand = new ActionCommand(BrowseInputFolderExecuteCommand, () => true);
     BrowseOutputFolderCommand = new ActionCommand(BrowseOutputFolderExecuteCommand, () => true);
     ProcessCommand = new ActionCommand(ProcessImages, () =>
         FilesToProcess.Count > 0 && PercentOfOriginal > 0 && !String.IsNullOrEmpty(OutputFolder));
     FilesToProcess = new List<string>();
     SetDefaults();
 }
コード例 #27
0
        public CatalogShotsViewModel()
        {
            if (new LocalDeviceHelper().CheckNetWorkStatus())
                GetCatalogShot(ShotCatalog.Popular, 1, 10);
            else
                base.NetworkIsInvalid();

           MoreItemCommand = new ActionCommand<object>(MoreItem);
        }
コード例 #28
0
        public ApplicationViewModel(IBlogPostRepository repository)
        {
            if (repository == null) throw new ArgumentNullException(nameof(repository));
            this.repository = repository;

            BlogPosts = GetBlogPosts(repository);

            SaveCommand = new ActionCommand(SaveBlogPost);
        }
コード例 #29
0
        private bool WasActionInvoked( object parameter )
        {
            var wasInvoked = false;
            var command = new ActionCommand<object>( obj => wasInvoked = true );

            command.Execute( parameter );

            return wasInvoked;
        }
コード例 #30
0
ファイル: Shell.xaml.cs プロジェクト: RookieOne/RPG
        public Shell()
        {
            InitializeComponent();

            CombatCommand = new ActionCommand(OnCombat);

            Presenter.Register(AppPresenters.Shell, new ContentControlPresenter(content));

            DataContext = this;
        }
        public CredentialsViewModel()
        {
            LoginCommand  = new ActionCommand(_ => Result = AuthenticationDialogResult.Ok);
            CancelCommand = new ActionCommand(_ => Result = AuthenticationDialogResult.Cancel);

            LoginValidator = PropertyValidator.For(this, x => x.Login)
                             .Required(Resources.LoginRequired);

            PasswordValidator = PropertyValidator.For(this, x => x.Password)
                                .Required(Resources.PasswordRequired);

            ModelValidator = new ModelValidator(LoginValidator, PasswordValidator);
            ModelValidator.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(ModelValidator.IsValid))
                {
                    IsValid = ModelValidator.IsValid;
                }
            };
        }
コード例 #32
0
        public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, ContainerInfo container)
        {
            ArgUtil.NotNullOrEmpty(command.Data, "value");

            switch (command.Data.Trim().ToUpperInvariant())
            {
            case "ON":
                context.EchoOnActionCommand = true;
                context.Debug("Setting echo command value to 'on'");
                break;

            case "OFF":
                context.EchoOnActionCommand = false;
                context.Debug("Setting echo command value to 'off'");
                break;

            default:
                throw new Exception($"Invalid echo command value. Possible values can be: 'on', 'off'. Current value is: '{command.Data}'.");
            }
        }
コード例 #33
0
        public ZoomBoxOverlay(ModelsEx models) : base(models)
        {
            this.models = models;
            IsEnabled   = true;
            Layer       = models.Display.ActiveLayer;
            models.Overlay.Overlays.Add(this);
            models.Display.UserInfo = "Click left to start zoombox";

            if (prevRatio.HasValue)
            {
                curRatio  = prevRatio.Value;
                keepRatio = true;
            }

            ToggleRatioCommand = new ActionCommand(() => KeepRatio = !KeepRatio);
            View = new ZoomBoxToolbar
            {
                DataContext = this
            };
        }
コード例 #34
0
        public void ProcessCommand(IExecutionContext context, string line, ActionCommand command, ContainerInfo container)
        {
            var configurationStore = HostContext.GetService <IConfigurationStore>();
            var isHostedServer     = configurationStore.GetSettings().IsHostedServer;

            var allowUnsecureCommands = false;

            bool.TryParse(Environment.GetEnvironmentVariable(Constants.Variables.Actions.AllowUnsupportedCommands), out allowUnsecureCommands);

            // Apply environment from env context, env context contains job level env and action's env block
#if OS_WINDOWS
            var envContext = context.ExpressionValues["env"] as DictionaryContextData;
#else
            var envContext = context.ExpressionValues["env"] as CaseSensitiveDictionaryContextData;
#endif
            if (!allowUnsecureCommands && envContext.ContainsKey(Constants.Variables.Actions.AllowUnsupportedCommands))
            {
                bool.TryParse(envContext[Constants.Variables.Actions.AllowUnsupportedCommands].ToString(), out allowUnsecureCommands);
            }

            // TODO: Eventually remove isHostedServer and apply this to dotcom customers as well
            if (!isHostedServer && !allowUnsecureCommands)
            {
                throw new Exception(String.Format(Constants.Runner.UnsupportedCommandMessageDisabled, this.Command));
            }
            else if (!allowUnsecureCommands)
            {
                // Log Telemetry and let user know they shouldn't do this
                var issue = new Issue()
                {
                    Type    = IssueType.Error,
                    Message = String.Format(Constants.Runner.UnsupportedCommandMessage, this.Command)
                };
                issue.Data[Constants.Runner.InternalTelemetryIssueDataKey] = Constants.Runner.UnsupportedCommand;
                context.AddIssue(issue);
            }

            ArgUtil.NotNullOrEmpty(command.Data, "path");
            context.Global.PrependPath.RemoveAll(x => string.Equals(x, command.Data, StringComparison.CurrentCulture));
            context.Global.PrependPath.Add(command.Data);
        }
コード例 #35
0
        public CalibrationBaseVM(
            BusyObject busy,
            IRUSDevice device,
            Func <FileType, IEnumerable <IDataEntity>, Task> saveCalibrationFileAsync)
        {
            _device      = device;
            _calibrator  = instantiateCalibrator();
            DataProvider = _calibrator is IDataProvider
                ? (IDataProvider)_calibrator
                : (IDataProvider)(_device = new RUSDeviceDataProviderProxy(_device));
            _calibrator.RedirectAnyChangesTo(this, () => PropertyChanged, nameof(HasCalibrationBegun));
            IsBusy                       = busy;
            _fileGenerator               = new CalibrationFileGenerator(device, calibrationFileType, "01");
            _saveCalibrationFileAsync    = saveCalibrationFileAsync;
            _calibrator.PropertyChanged += (o, e) => updateModelBindings();
            updateModelBindings();

            StartMeasure = new ActionCommand <TMode>(startMeasureAsync,
                                                     m => canStartMeasure(m) && !IsBusy,
                                                     IsBusy, this, _calibrator);
            CancelMeasure = new ActionCommand(cancelMeasureAsync);
            FinishMeasure = new ActionCommand <TMode>(finishMeasureAsync,
                                                      m => canFinishMeasure(m) &&
                                                      _calibrator.State == MeasureState.WAITING_FOR_FINISH &&
                                                      (!m.IsSet || Equals(getModelsTestMode(m.Value), _calibrator.CurrentMode)),
                                                      _calibrator);
            ExportMeasureResults = new ActionCommand(exportMeasureResultAsync,
                                                     () => !IsBusy && canExport,
                                                     this, _calibrator, IsBusy);
            ImportMeasureResults = new ActionCommand(importMeasureResultAsync, IsBusy);
            SaveCalibrationFile  = new ActionCommand(saveCalibrationsAsync,
                                                     () => !IsBusy && _calibrator.CallibrationCanBeGenerated,
                                                     IsBusy, _calibrator);
            CancelMeasure.CanBeExecuted = false;
            Begin = new ActionCommand(beginAsync,
                                      () => !HasCalibrationBegun && !IsBusy,
                                      IsBusy, _calibrator);
            Discard = new ActionCommand(discardAsync,
                                        () => HasCalibrationBegun && !IsBusy,
                                        IsBusy, _calibrator);
        }
コード例 #36
0
        public void CommandExecute(ActionCommand command)
        {
            if (command.commandID == "Retrieve")
            {
                Retrieve();
            }
            else if (command.commandID == "Rope_Unroll")
            {
                isRopeUnrolled = true;
            }
            else if (command.commandID == "Rope_Cancel")
            {
                isRopeUnrolled = false;
                targetVehicle  = null;
            }
            else if (command.commandID == "Rope_Attach")
            {
                isRopeAttached = true;
            }
            else if (command.commandID == "Rope_Deattach")
            {
                isRopeAttached = false;
                targetVehicle  = null;
            }
            else if (command.commandID == "Tow_On")
            {
                isTowing = true;
            }
            else if (command.commandID == "Tow_Off")
            {
                isTowing = false;
            }
            else if (command.commandID == "Setting")
            {
                DestinyInternalCommand.instance.Quit_ActionCommand();
                DestinyInternalCommand.instance.Game_LockGame(true, true);
                UI_Canvas.gameObject.SetActive(true);
            }

            UpdateTowingEquipment();
        }
コード例 #37
0
        public Scene2DTools()
        {
            Tools = new ObservableCollection <Scene3DViewModelLib.Scene2DButtonModel>();

            InitializeComponent();

            //TODO: Actions in extra new Classes incl impl!

            {
                string        txt = "Grid On/Off";
                ActionCommand cmd = new ActionCommand(action => OnGridToogle(), canExecute => true, (b) => {
                    OnFocus(b ? txt : null);
                });
                Scene2DButtonModel buttonModelGrid = new Scene2DButtonModel("pack://application:,,,/Scene3DRes;component/res/grid.png", txt, cmd, Tools.Count);
                Tools.Add(buttonModelGrid);
            }
            {
                string        txt = "Camera Info On/Off";
                ActionCommand cmd = new ActionCommand(action => OnCameraInfoToogle(), canExecute => true, (b) => {
                    OnFocus(b ? txt : null);
                });
                Scene2DButtonModel buttonModelGrid = new Scene2DButtonModel("pack://application:,,,/Scene3DRes;component/res/cameraInfo.png", txt, cmd, Tools.Count);
                Tools.Add(buttonModelGrid);
            }
            {
                string        txt = "Show/Hide View Cube";
                ActionCommand cmd = new ActionCommand(action => OnViewCubeToogle(), canExecute => true, (b) => {
                    OnFocus(b ? txt : null);
                });
                Scene2DButtonModel buttonModelGrid = new Scene2DButtonModel("pack://application:,,,/Scene3DRes;component/res/viewCube.png", txt, cmd, Tools.Count);
                Tools.Add(buttonModelGrid);
            }
            {
                string        txt = "Show/Hide SkyBox";
                ActionCommand cmd = new ActionCommand(action => OnViewSkyBoxToogle(), canExecute => true, (b) => {
                    OnFocus(b ? txt : null);
                });
                Scene2DButtonModel buttonModelGrid = new Scene2DButtonModel("pack://application:,,,/Scene3DRes;component/res/skybox.png", txt, cmd, Tools.Count);
                Tools.Add(buttonModelGrid);
            }
        }
コード例 #38
0
        public MainWindowVm()
        {
            _uiDispatcher = Application.Current.Dispatcher;

            base.DisplayName = Texts.MainWindow_DisplayName;

            ShowTargetAssembliesCommand = new ActionCommand(x => ShowTargetAssemblies());
            NewQueryCommand             = new ActionCommand(x => AddQueryWorkspace());
            CloseAllQueriesCommand      = new ActionCommand(x => _workspaceHolder.CloseAll());

            Commands.Add(new IconCommandVm(Texts.Command_NewQueryWorkspace, Images.Command_NewQueryWorkspace.ToImageSource(), NewQueryCommand));
            Commands.Add(new IconCommandVm(Texts.Command_AddDll, Images.Command_AddAssembly.ToImageSource(), new ActionCommand(x => AddDll())));

            RefreshToolbarMenu();
            ToolbarCommands = new ReadOnlyObservableCollection <IconCommandVm>(_toolbarCommands);

            Commands.CollectionChanged      += delegate { RefreshToolbarMenu(); };
            _workspaceHolder.CurrentChanged += delegate { RefreshToolbarMenu(); };

            AddQueryWorkspace();
        }
コード例 #39
0
        internal Task SendActionCommandAsync(ActionCommand actionCommand)
        {
            var utf8ByteArray = SerializeToUtf8(actionCommand);

            return(Task.Run(async() =>
            {
                using (var client = new HttpClient())
                {
                    var stringContent = new ByteArrayContent(utf8ByteArray);
                    var url = string.Concat(Network.IP, ":", Network.PORT);
                    try
                    {
                        await client.PostAsync(url, stringContent);
                    }
                    catch (Exception)
                    {
                        // Fire and forget
                    }
                }
            }));
        }
コード例 #40
0
        public CustomDipViewModel()
        {
            PinCount        = 8;
            CorpusWidthMm   = 6.0;
            GenerateCommand = new ActionCommand(async() =>
            {
                StartProgress();

                // Do generation
                var model = new DipCorpus
                {
                    Name          = Name,
                    PinCount      = PinCount,
                    CorpusWidthMm = CorpusWidthMm
                };

                await Task.Run(() => new DipBuilder(new SwContext()).Build(model));

                CompleteProgress();
            });
        }
コード例 #41
0
        public ShotDetailViewModel(int shotId)
        {
            try
            {
                if (new LocalDeviceHelper().CheckNetWorkStatus())
                {
                    GetShotDetail(shotId);
                }
                else
                {
                    base.NetworkIsInvalid();
                }

                this.ShotId     = shotId;
                MoreItemCommand = new ActionCommand <object>(MoreItem);
            }
            catch (Exception se)
            {
                new UmengRegisterEventHelper().RegisterUmengEventByType(AnalysicEventType.AppExceptionReport, "", se);
            }
        }
コード例 #42
0
        public Module()
        {
            _navigateToExampleCommand = new ActionCommand <Example>(example =>
            {
                var lastExamplePage = CurrentExample != null ? CurrentExample.Page as ExampleAppPage : null;

                CurrentExample = example;
                Navigator.Instance.Navigate(example);
                Navigator.Instance.Push(example);

                if (lastExamplePage != null)
                {
                    // Required to release memory on example switch
                    lastExamplePage.ViewModel = null;
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            });
        }
コード例 #43
0
 protected override void InternalExecute(ICommandAdapter adapter)
 {
     if (adapter.IsWinAdapter())
     {
         SaveAndCloseAction(adapter);
     }
     else
     {
         if (SaveAndCloseActionAvailable(adapter))
         {
             SaveAndCloseAction(adapter);
         }
         else
         {
             var actionCommand = new ActionCommand();
             actionCommand.Parameters.MainParameter  = new MainParameter("OK");
             actionCommand.Parameters.ExtraParameter = new MainParameter();
             actionCommand.Execute(adapter);
         }
     }
 }
コード例 #44
0
        ///  ########################### Konstruktor ###########################################

        public MaschinenkaufdatenViewModel(Maschinenkaufdaten Maschinenkaufdaten = null)
        {
            ///  ########################### Befehle Verknüpfen ###########################################
            Maschinenkauftabeldoubleclick = new ActionCommand(MaschinenkauftabeldoubleclickMethod);
            Maschinenkauftabelclick       = new ActionCommand(MaschinenkauftabelclickMethod);
            PressEnterKey = new ActionCommand(PressEnterKeyMethod);

            AddCommand    = new ActionCommand(Add);
            SaveCommand   = new ActionCommand(Save);
            DeleteCommand = new ActionCommand(Delete);


            DataService client = new DataService();

            Maschinenkauf = client.GetAllMaschinenkaufe();
            Maschinenart  = client.GetAllMaschinenarten();

            MaschinenartenIDs         = new ObservableCollection <int>(client.GetAllMaschinenarten().Select(p => p.Maschinenart_ID));
            MaschinenartenBezeichnung = new ObservableCollection <string>(client.GetAllMaschinenarten().Select(p => p.Maschinenartbezeichnung));
            client.Close();
        }
コード例 #45
0
        public MainViewModel()
        {
            rootTreeItem1 = new TreeItem();
            rootTreeItem2 = new TreeItem();

            // Pfad bei Bedarf anpassen
            var path = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.Parent.FullName;

            FillTree(Tree1, path, 0);
            FillTree(Tree2, path, 0);

            ExpandAllCommand   = new ActionCommand(() => Tree1.ExpandOrCollapseAll(true));
            CollapseAllCommand = new ActionCommand(() => Tree1.ExpandOrCollapseAll(false));
            OpenAppXamlCommand = new ActionCommand(OpenAppXaml);


            DragDropControllerTV1 = new DragDropController()
            {
                CanDrag = CanDragTV1, CanDrop = CanDropTV1, Drop = DropTV1
            };
        }
コード例 #46
0
        public override bool CanResolve(ActionCommand cmd)
        {
            var center = cmd.Owner.Target.GetPositionP3;

            for (int i = 0; i < _radius; i++)
            {
                var pos = center;
                pos[_axisDirection] += i;
                var cell = CombatArenaMap.Current.Get(pos);
                if (cell.Unit == null)
                {
                    continue;
                }
                if (_checkRequirements && !cmd.Action.Config.CanEffect(cmd.Action, cmd.Owner, cell.Unit))
                {
                    continue;
                }
                cmd.CheckHit(_targetDefense, _bonusStat, cell.Unit);
            }
            return(true);
        }
コード例 #47
0
        public SettingsViewModel(ISettingCollection settingCollection)
        {
            this.settingCollection = settingCollection;
            this.settingCollection.Load();

            ModifierKeys = Enum.GetValues(typeof(ModifierKeys)).Cast <ModifierKeys>().ToList();
            Keys         = Enum.GetValues(typeof(Keys)).Cast <Keys>().ToList();

            Enum.TryParse(this.settingCollection.Settings.FirstOrDefault(x => x.Key == "Modifier1").Value, out ModifierKeys modifierKey1);
            Modifier1 = modifierKey1;
            Enum.TryParse(this.settingCollection.Settings.FirstOrDefault(x => x.Key == "Modifier2").Value, out ModifierKeys modifierKey2);
            Modifier2 = modifierKey2;
            Enum.TryParse(this.settingCollection.Settings.FirstOrDefault(x => x.Key == "Key").Value, out Keys key);
            Key = key;

            SaveCommand = new ActionCommand(x =>
            {
                this.settingCollection.Save(Modifier1, Modifier2, Key);
                MessageBox.Show("Settings saved!");
            });
        }
コード例 #48
0
        protected MediaPlaybackViewModel(HistoryService historyService, IMediaService mediaService, VlcService mediaPlayerService)
        {
            _historyService = historyService;

            _mediaService = mediaService;
            _mediaService.StatusChanged += PlayerStateChanged;

            _vlcPlayerService = mediaPlayerService;

            _displayAlwaysOnRequest       = new DisplayRequest();
            _sliderPositionTimer          = new DispatcherTimer();
            _sliderPositionTimer.Tick    += FirePositionUpdate;
            _sliderPositionTimer.Interval = TimeSpan.FromMilliseconds(16);

            _skipAhead     = new ActionCommand(() => _mediaService.SkipAhead());
            _skipBack      = new ActionCommand(() => _mediaService.SkipBack());
            _playNext      = new PlayNextCommand();
            _playPrevious  = new PlayPreviousCommand();
            _playOrPause   = new PlayPauseCommand();
            _goBackCommand = new StopVideoCommand();
        }
コード例 #49
0
        protected TwitchAccountViewModel(ITwitchAuthentication twitchAuthentication,
                                         ITwitchConnection twitchConnection,
                                         AuthenticationType authType, object icon, object label, object toolTip, UserControl content)
            : base(icon, label, toolTip, content)
        {
            AuthType = authType;
            _twitchAuthentication = twitchAuthentication;
            _twitchConnection     = twitchConnection;
            ConnectCommand        = new ActionCommand(Connect);
            DisconnectCommand     = new ActionCommand(Disconnect);
            GenerateTokenCommand  = new ActionCommand(GenerateToken);
            ManualEntryCommand    = new ActionCommand(SwitchToManualEntry);

            if (!_twitchAuthentication.Credentials.ContainsKey(AuthType))
            {
                _twitchAuthentication.Credentials[AuthType] = new TwitchCredentials
                {
                    AuthType = authType
                };
            }
        }
コード例 #50
0
 public ViewModel()
 {
     CheckCommand = new ActionCommand(Validate);
     Validators.Add(new Validator()
     {
         PropertyName = nameof(Minimum), ErrorMessage = "Minimum muss >= 0 sein", CheckForError = () => Minimum < 0
     });
     Validators.Add(new Validator()
     {
         PropertyName = nameof(Maximum), ErrorMessage = "Maximum muss > 0 sein", CheckForError = () => Maximum <= 0
     });
     Validators.Add(new Validator()
     {
         PropertyName = nameof(Maximum), ErrorMessage = "Minimum muss kleiner als Maximum sein", CheckForError = () => Minimum >= Maximum
     });
     Validators.Add(new Validator()
     {
         PropertyName = nameof(Maximum), ErrorMessage = "Maximum muss durch 10 teilbar sein", CheckForError = () => (Maximum % 10) != 0
     });
     //Validators.Add(new Validator() { PropertyName = "Name", ErrorMessage = "Name darf nicht leer sein", CheckForError = () => string.IsNullOrEmpty(Name) });
 }
コード例 #51
0
        public MonitoringViewModel()
        {
            Numbers = new ObservableCollection <int>();
            Numbers.Add(2);
            Numbers.Add(5);
            Numbers.Add(10);

            sets = AppSetting.loadSettings();

            //
            myDisp   = Dispatcher.CurrentDispatcher;
            lstFiles = new ObservableCollection <Photo>();

            //
            this.startWatch();

            //
            actionCmd = new ActionCommand(changePath);

            this.teest = sets.WorkFolder;
        }
コード例 #52
0
        // treeview managers
        private void AddCommand(EventCommand esc)
        {
            TreeNode node = esc.Node;

            if (esc.QueueTrigger || esc.Locked)
            {
                if (esc.Queue == null)
                {
                    return;
                }
                List <ActionCommand> queue = esc.Queue.Commands;
                for (int i = 0; queue != null && i < queue.Count; i++)
                {
                    ActionCommand asc   = queue[i];
                    TreeNode      child = asc.Node;
                    node.Nodes.Add(child);
                }
            }
            // Add command
            this.treeView.Nodes.Add(node);
        }
コード例 #53
0
        public ModuleData(string moduleName, string moduleFolderName)
        {
            ModuleName                = moduleName;
            ModuleFolderName          = moduleFolderName;
            AddTemplateControlVisible = false;

            Templates = new ObservableImmutableList <TemplateEditorData>();
            KeyList   = new ObservableImmutableList <KeywordData>();

            BindingOperations.EnableCollectionSynchronization(Templates, TemplatesLock);
            BindingOperations.EnableCollectionSynchronization(KeyList, KeyListLock);

            LoadKeywords = new ActionCommand(() => { FileCommands.Load.LoadUserKeywords(this); });

            SaveSettingsCommand = new ActionCommand(() =>
            {
                FileCommands.Save.SaveModuleSettings(this);
                AppController.Main?.SaveAppSettings();
            });
            DefaultSettingsCommand = new TaskCommand(RevertSettingsToDefault, null, "Reset Settings?", "Revert settings to default?", "Changes will be lost.");
        }
コード例 #54
0
 public MainWindowViewModel()
 {
     ToggleArgumentCommand =
         new ActionCommand
         (
             x => true,
             (x) =>
     {
         ;
     }
         );
     FunctionOneCommand =
         new ActionCommand
         (
             x => true,
             (x) =>
     {
         ;
     }
         );
 }
コード例 #55
0
        public PlayerDetailViewModel(PlayerInTeam playerInTeamViewModel)
        {
            Model = new PlayerInTeamViewModel(playerInTeamViewModel);
            CurrentChartXPlayerStatistic = ChartXPlayerStatistic.Point;
            SetPointStatistic            = new ActionCommand(() => CurrentChartXPlayerStatistic = ChartXPlayerStatistic.Point);
            SetReboundStatistic          = new ActionCommand(() => CurrentChartXPlayerStatistic = ChartXPlayerStatistic.Rebound);
            SetAssistsStatistic          = new ActionCommand(() => CurrentChartXPlayerStatistic = ChartXPlayerStatistic.Assists);
            SetStealsStatistic           = new ActionCommand(() => CurrentChartXPlayerStatistic = ChartXPlayerStatistic.Steals);
            SetBlocksStatistic           = new ActionCommand(() => CurrentChartXPlayerStatistic = ChartXPlayerStatistic.Blocks);
            Search = new ActionCommand(() =>
            {
                UpdatePlayerStatisticsInDateRange();
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(ChartPoints)));
            });

            playerStatistics = new ObservableCollection <PlayerStatistics>(Model.Model.Player.PlayerStatistics.ToList());

            BiginingIntervalDate = DateTime.Now.AddYears(-10);
            EndIntervalDate      = DateTime.Now;
            UpdatePlayerStatisticsInDateRange();
        }
コード例 #56
0
        public TreeEditorViewModel(IEditorEnvironment editorEnvironment) : base(editorEnvironment)
        {
            RootNodes = new ReadOnlyObservableCollection <ITreeNode>(_rootNodes);

            // These commands are used for keyboard shortcuts
            DeleteNodeCommand    = new ActionCommand(DeleteSelectedNode, CanDeletedSelectedNode);
            CutNodeCommand       = new ActionCommand(CutNode, CanCutNode);
            CopyNodeCommand      = new ActionCommand(CopyNode, CanCopyNode);
            PasteNodeCommand     = new ActionCommand(PasteNode, CanPasteNode);
            DuplicateNodeCommand = new ActionCommand(DuplicateNode, CanDuplicateNode);
            UndoCommand          = new ActionCommand(Undo, CanUndo);
            RedoCommand          = new ActionCommand(Redo, CanRedo);

            ActiveContextMenuCommands = new ReadOnlyObservableCollection <ContextMenuCommand>(_activeContextMenuCommands);

            // Group catalog items by category
            var view             = CollectionViewSource.GetDefaultView(CatalogItems);
            var groupDescription = new PropertyGroupDescription(nameof(NodeCatalogItem.Category));

            view.GroupDescriptions.Add(groupDescription);
        }
コード例 #57
0
        public UsingDonutChartExampleViewModel()
        {
            _donutModels = new ObservableCollection <IPieSegmentViewModel>
            {
                new DonutSegmentViewModel {
                    Value = 48, Name = "Rent", Stroke = ToShade(Colors.Orange, 0.8), Fill = ToGradient(Colors.Orange), StrokeThickness = 2
                },
                new DonutSegmentViewModel {
                    Value = 19, Name = "Food", Stroke = ToShade(Colors.Green, 0.8), Fill = ToGradient(Colors.Green), StrokeThickness = 2
                },
                new DonutSegmentViewModel {
                    Value = 9, Name = "Utilities", Stroke = ToShade(Colors.DodgerBlue, 0.8), Fill = ToGradient(Colors.DodgerBlue), StrokeThickness = 2
                },
                new DonutSegmentViewModel {
                    Value = 9, Name = "Fun", Stroke = ToShade(Colors.Gray, 0.8), Fill = ToGradient(Colors.Gray), StrokeThickness = 2
                },
                new DonutSegmentViewModel {
                    Value = 10, Name = "Clothes", Stroke = ToShade(Colors.Firebrick, 0.8), Fill = ToGradient(Colors.Firebrick), StrokeThickness = 2
                },
                new DonutSegmentViewModel {
                    Value = 5, Name = "Phone", Stroke = ToShade(Colors.DarkSalmon, 0.8), Fill = ToGradient(Colors.DarkSalmon), StrokeThickness = 2
                }
            };

            AddNewItemCommand = new ActionCommand(() =>
            {
                _donutModels.Add(new DonutSegmentViewModel
                {
                    Value  = NewSegmentValue.ToDouble(),
                    Name   = NewSegmentText,
                    Fill   = ToGradient(((SolidColorBrush)NewSegmentBrush.Brush).Color),
                    Stroke = ToShade(((SolidColorBrush)NewSegmentBrush.Brush).Color, 0.8)
                });
            }, () =>
            {
                return(!NewSegmentText.IsNullOrEmpty() && (!NewSegmentValue.IsNullOrEmpty() && NewSegmentValue.ToDouble() > 0) && NewSegmentBrush != null);
            });

            SegmentSelectionCommand = new ActionCommand <NotifyCollectionChangedEventArgs>(OnSegmentSelectionExecute);
        }
コード例 #58
0
        public ServerMonitorChatViewModel(ILog log, ServerInfo serverInfo, IEventAggregator eventAggregator)
        {
            _log             = log;
            _serverId        = serverInfo.Id;
            _eventAggregator = eventAggregator;

            AutoScroll = true;
            EnableChat = true;

            _chatHelper = new ChatHelper(_log, _serverId);

            _eventAggregator.GetEvent <BEMessageEvent <BEChatMessage> >()
            .Subscribe(BeServerChatMessageHandler, ThreadOption.UIThread);

            _eventAggregator.GetEvent <BEMessageEvent <BEAdminLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);
            _eventAggregator.GetEvent <BEMessageEvent <BEPlayerLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);
            _eventAggregator.GetEvent <BEMessageEvent <BEBanLogMessage> >()
            .Subscribe(_beServer_PlayerLog, ThreadOption.UIThread);

            _eventAggregator.GetEvent <BEMessageEvent <BEItemsMessage <Player> > >()
            .Subscribe(_beServer_PlayerHandler);

            var global = new Player(-1, null, 0, 0, null, "GLOBAL", Player.PlayerState.Ingame);

            Players = new List <Player> {
                global
            };
            SelectedPlayer = global;

            ShowHistoryCommand = new ActionCommand(() =>
            {
                var model       = new ChatHistoryViewModel(_serverId);
                model.StartDate = DateTime.UtcNow.UtcToLocalFromSettings().AddHours(-5);
                var wnd         = new ChatHistory(model);
                wnd.Show();
                wnd.Activate();
            });
        }
コード例 #59
0
        public GameSettingsViewModel(
            GameStateModel gameState,
            INavigationService navigationService)
        {
            _gameState         = gameState;
            _navigationService = navigationService;

            _subscriptions = new CompositeDisposable();

            SaveCommand = new ActionCommand(
                execute: () =>
            {
                _gameState.Settings.Value = new GameSettingsModel(
                    _dominoSetType,
                    _memoryInterval);

                _navigationService.NavigateTo(null);
            },
                canExecute: Observable.CombineLatest(
                    _gameState.Settings,
                    this.ObserveProperty(x => x.DominoSetType),
                    this.ObserveProperty(x => x.MemoryInterval),
                    navigationService.CanNavigateTo,
                    (settings, dominoSetType, memoryInterval, canNavigateTo) =>
                    canNavigateTo &&
                    ((dominoSetType != settings.DominoSetType) ||
                     (memoryInterval != settings.MemoryInterval))))
                          .DisposeWith(_subscriptions);

            UndoCommand = new ActionCommand(
                execute: () =>
            {
                ReloadSettings();

                _navigationService.NavigateTo(null);
            })
                          .DisposeWith(_subscriptions);

            ReloadSettings();
        }
コード例 #60
0
        /// <summary>
        /// Constructs a new Window View Model
        /// </summary>
        /// <param name="window">The window itself</param>
        public WindowViewModel(Window window)
        {
            _window = window;

            // Initialize Commands
            MinimizeCommand    = new ActionCommand(() => _window.WindowState = WindowState.Minimized);
            MaximizeCommand    = new ActionCommand(() => _window.WindowState ^= WindowState.Maximized);
            CloseWindowCommand = new ActionCommand(() => _window.Close());
            SystemMenuCommand  = new ActionCommand(() => SystemCommands.ShowSystemMenu(_window, GetMousePosition()));

            // Fix the Window Resize Issue
            var _resizer = new WindowResizer(_window);

            // Listen out for Window events
            _window.StateChanged += (ss, ee) =>
            {
                OnGroupOfPropertyChanged(nameof(ResizeBorderThickness),
                                         nameof(OuterBorderPaddingThickness),
                                         nameof(WindowCornerRadius),
                                         nameof(TitleBarCornerRadius));
            };
        }