Example #1
0
        public ViewModelCrew()
        {
            if (Client.State == CommunicationState.Closed)
            {
                Client.Open();
            }

            crew = new Crew();

            AddEntityCommand = new RelayCommand(AddEntityCommand_Execute, AddEntityCommand_CanExecute);
            RemoveEntityCommand = new RelayCommand(RemoveEntityCommand_Execute, RemoveEntityCommand_CanExecute);
            AddToCrewCommand = new RelayCommand(AddToCrewCommand_Execute, AddToCrewCommand_CanExecute);
            RemoveFromCrewCommand = new RelayCommand(RemoveFromCrewCommand_Execute, RemoveFromCrewCommand_CanExecute);
            AddAllCommand = new RelayCommand(AddAllCommand_Execute, AddAllCommand_CanExecute);
            RemoveAllCommand = new RelayCommand(RemoveAllCommand_Execute, RemoveAllCommand_CanExecute);

            Crews = new ObservableCollection<Crew>(Client.GetEntityByType(EntityType.Crew).Cast<Crew>());
            AllMembers = new ObservableCollection<CrewMember>(Client.GetEntityByType(EntityType.CrewMember).Cast<CrewMember>().Where(member => string.IsNullOrEmpty(member.Crew)));
            CrewMembers = new ObservableCollection<CrewMember>();
            SelectedMembers = new ObservableCollection<CrewMember>();
            SelectedMembersToRemove = new ObservableCollection<CrewMember>();

            MakeProxy(this);

            try
            {
                proxy.Subscribe(EntityType.Crew.ToString());
                proxy.Subscribe(EntityType.CrewMember.ToString());
            }
            catch (Exception ex)
            {
                CrFSMLogger.CrFSMLogger.Instance.WriteToLog(ex);
            }
        }
Example #2
0
 /// <summary>
 /// Default constructor.  We set the initial view-model to 'FirstViewModel'.
 /// We also associate the commands with their execution actions.
 /// </summary>
 public MainViewModel()
 {
     CurrentViewModel = MainViewModel._firstViewModel;
     ViewRSSFeedCommand = new RelayCommand(param => ExecuteViewRSSFeedCommand());
     SettingViewCommand = new RelayCommand(param => ExecuteSettingViewCommand());
     SearchRSSViewCommand = new RelayCommand(param => ExecuteSearchRSSViewCommand());
 }
        public MainWindowViewModel(IDialogService dialogService)
        {
            this.dialogService = dialogService;

            ImplicitShowDialogCommand = new RelayCommand(ImplicitShowDialog);
            ExplicitShowDialogCommand = new RelayCommand(ExplicitShowDialog);
        }
        public PlayersViewModel()
        {
            Players = new ObservableCollection<Player>();

            #region RCON Events
            App.ArkRcon.PlayersUpdated += async (s, args) =>
            {
                Players.Clear();
                foreach (Ark.Models.Player player in args.Players)
                {
                    Players.Add(new Models.Player(player));
                }
                await UpdateSteamPlayerInfo();
            };
            #endregion
            
            #region Buttons and Events

            OpenSteamProfileCommand = new RelayCommand(OpenSteamProfile);
            CopySteamIDCommand = new RelayCommand(CopySteamID);
            CopyPlayerNameCommand = new RelayCommand(CopyPlayerName);
            KickSelectedCommand = new RelayCommand(KickSelectedPlayer);
            BanSelectedCommand = new RelayCommand(BanSelectedPlayer);
            WhitelistSelectedCommand = new RelayCommand(WhitelistSelectedPlayer);
            UnWhitelistSelectedCommand = new RelayCommand(UnWhitelistSelectedPlayer);
            PMSelectedPlayerCommand = new RelayCommand(PMSelectedPlayer);
            RefreshPlayersCommand = new RelayCommand(RefreshPlayers);
            
            #endregion

            PrivateMessage = string.Empty;

        }
        public CustomerListViewModel()
        {
            if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) return;

            //Customers = new ObservableCollection<Customer>(_customersRepo.GetCustomersAsync().Result);
            DeleteCommand = new RelayCommand(OnDelete, CanDelete);
        }
Example #6
0
        //Constructor 
        public BaseViewModel() {

            CloseWindowCommand = new RelayCommand<Window>(CloseWindow);

            UndoCommand = new RelayCommand(undoRedoController.Undo, undoRedoController.CanUndo);
            RedoCommand = new RelayCommand(undoRedoController.Redo, undoRedoController.CanRedo);

            CutCommand = new RelayCommand(Cut, LampsAreSelected);
            CopyCommand = new RelayCommand(Copy, LampsAreSelected);
            PasteCommand = new RelayCommand(Paste);

            AddLampCommand = new RelayCommand<IList>(AddNewLamp);
            RemoveLampCommand = new RelayCommand(RemoveLamp, LampsAreSelected);

            dialogWindow = new DialogViews();
            NewDrawingCommand = new RelayCommand(NewDrawing);
            LoadDrawingCommand = new RelayCommand(LoadDrawing);
            SaveDrawingCommand = new RelayCommand(SaveDrawing);
            SaveAsDrawingCommand = new RelayCommand(SaveAsDrawing);
        
            LightSwitchCommand = new RelayCommand(LightSwitch);
            SwitchLampLightCommand = new RelayCommand(singleLampLightSwitch, LampsAreSelected);

            toggleSnappingCommand = new RelayCommand(toggleSnapping);
            toggleGridVisibilityCommand = new RelayCommand(toggleVisibility);
        }
        public TranslationAdornment(SnapshotSpan span, TranslationRequest request, Size viewportSize)
        {
            Span = span.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeExclusive);
            Request = request;
            Request.TranslationComplete += request_TranslationComplete;

            InitializeComponent();
            DataContext = this;

            SetMaxSize(viewportSize);

            _menu = spListBox.ContextMenu;
            _menu.KeyUp += (sender, args) =>
            {
                if (args.Key == Key.Left || args.Key == Key.Escape)
                {
                    CloseMenu();
                }
            };
            _menu.Opened += (sender, args) => { _closeMenuRequested = false; };
            _menu.Closed += (sender, args) => { _ignoreItemCommand = !_closeMenuRequested; };

            ItemCommand = new RelayCommand<ItemCommandParameter>(ItemCommandExecute);
            ItemOptionsCommand = new RelayCommand<ItemCommandParameter>(ItemOptionsCommandExecute);
            MenuCommand = new RelayCommand<MenuItem>(MenuCommandExecute);
        }
 public SearchViewModel(ISearchService searchService)
 {
     this.searchService = searchService;
     Search = new RelayCommand(SearchExecuted);
     ShowDetails = new RelayCommand<SearchResult>(ShowDetailsExecuted);
     Results = new List<SearchResult>();
 }
        public IntroductionViewModel(GenericDataAccess<string> dataAccess)
        {
            this.dataAccess = dataAccess;
            introduction = dataAccess.TryLoad();

            SaveCommand = new RelayCommand<object>(_ => Save());
        }
 public TerminalWindowViewModel()
     : base()
 {
     HomeCommand = new RelayCommand(Home);
     SearchServiceCommand = new RelayCommand(SearchService);
     UnloadedCommand = new RelayCommand(Dispose);
 }
        public ViewModel_MainWindow()
        {
            if (!DesignerProperties.GetIsInDesignMode(Application.Current.MainWindow))
            {
                this.TrackDetails.Title = "Initializing Spotify ...";
                if (Wrapper_Spotify.Init())
                {
                    Wrapper_Skype.Init();

                    Updater.I.Start();
                    StatusEffects.I.Start();

                    NameEffect.I.Start();
                    NameEffect.I.UpdateEffect(2);
                    NameEffect.I.UpdateTrackDetails("Jayson Ragasa ");

                    Wrapper_Spotify.TrackChanged += Wrapper_Spotify_TrackChanged;

                    Command_Update = new RelayCommand(Commnad_Update_Click);

                    this.Pattern = Properties.Settings.Default.Pattern;
                    this.SelectedEffect = Properties.Settings.Default.SelectedEffect;
                }
                else
                {
                    this.TrackDetails.Title = "Make sure you're running Spotify. Please restart this app";
                    Process.GetCurrentProcess().Kill();
                }
            }
        }
Example #12
0
 /// <summary>
 /// Register commands
 /// </summary>
 private void RegisterCommands()
 {
     StopPlayingMediaCommand = new RelayCommand(() =>
     {
         Messenger.Default.Send(new StopPlayingMovieMessage());
     });
 }
 public AllSongsViewModel()
 {
     GoBackCommand = new RelayCommand(GoBack);
     AddToQueueCommand = new RelayCommand(AddToQueue);
     PlayCommand = new RelayCommand(Play);
     SongHits = (List<Song>)NavigationService.GetInstance().Content;   
 }
Example #14
0
		public UserPageViewModel()
		{
			Title = "Пользователи";
			Users = new ObservableCollection<CheckedItemViewModel<User>>(ClientManager.SecurityConfiguration.Users.Select(item => new CheckedItemViewModel<User>(item)));
			SelectAllCommand = new RelayCommand(() => Users.ForEach(item => item.IsChecked = true));
			SelectNoneCommand = new RelayCommand(() => Users.ForEach(item => item.IsChecked = false));
		}
        public PlanSchematicViewModel(RoadwayModel_TabVM parentVM)
            : base()
        {
            parentVM_ = parentVM;
             if (parentVM_ == null) return;

             isPortWindowMoving = false;
             startMovingPoint.X = startMovingPoint.Y = 0.0;

             currentCorridor_ = parentVM_.CurrentCorridor;
             ViewScaleFeetPerInch = 100.0;
             currentCorridor_ = parentVM_.CurrentCorridor;
             AdvanceDistance = 20.0;

             AdvanceStationAheadCmd = new RelayCommand(advanceStationAhead, () => canAdvanceAhead);
             canAdvanceAhead = true;

             AdvanceStationBackCmd = new RelayCommand(advanceStationBack, () => canAdvanceBack);
             canAdvanceBack = true;

             WindowCenterY = 2000.0;

             PlanStation = "";
             PlanOffset = "";
             PlanElevation = "";
             PlanCrossSlope = "";
        }
        public BluetoothConnectionManager()
        {
            BluetoothCancelCommand = new RelayCommand(AbortConnection);
            BluetoothDisconnectCommand = new RelayCommand(Disconnect);
            //reader = new DataReader(socket.InputStream);

        }
 public SwitchLanguageViewModel()
 {
     LangList = StaticDatas.GetLanguageList();
     loadConfigValue();
     ConfirmCommand = new RelayCommand(OnExecuteConfirmCommand, OnCanExecuteConfirmCommand);
     CancelCommand = new RelayCommand(OnExecuteCancelCommand);
 }
        public SuppliersListViewModel()
        {
            if (DesignerProperties.GetIsInDesignMode(
                new System.Windows.DependencyObject())) return;

            try
            {
                var suppliers = db.Suppliers.Include(s => s.Suburb);
                Suppliers = new ObservableCollection<Supplier>(suppliers.ToList());
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message.ToString());
            }
            try
            {
                var suburbs = db.Suburbs.ToList();
                Suburbs = new ObservableCollection<Suburb>(suburbs);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message.ToString());
            }

            _newSupplier = new Supplier();
            _searchResults = new ObservableCollection<Supplier>();

            DeleteSupplierCommand = new RelayCommand<Supplier>(onDeleteSupplier);
            UpdateSupplierCommand = new RelayCommand<Supplier>(onUpdateSupplier);
            AddSupplierCommand = new RelayCommand<Supplier>(onAddSupplier);
            FindSuppliersCommand = new RelayCommand<string>(onFindSuppliers);
        }
        /// <summary>
        /// For designer only
        /// </summary>
        public SimpleTextCaptureViewModel()
        {
            RefreshCommand = new RelayCommand(Refresh);

            Packets.Add(new PacketViewModel(new byte[]{ 1, 2, 3, 4, 5 }));
            Packets.Add(new PacketViewModel(new byte[] { 1, 2, 3, 4, 5 }));
        }
Example #20
0
        public AdminVM()
        {
            // Commands:
            AdminLoginCommand = new RelayCommand(DoAdminLogin);
            CloseApplicationCommand = new RelayCommand(CloseApplication);
            AdminChangePasswordCommand = new RelayCommand(ChangeAdminPassword);
            ShowChangePasswordCommand = new RelayCommand(ShowChangePassword);

            // Admin Commands for users
            DeleteSelectedUserCommand = new RelayCommand<User>(DeleteSelectedUser);
            AddNewUserCommand = new RelayCommand(AddNewUser);
            ShowLogForUser = new RelayCommand<User>(UserShowLog);

            // Admin Commands for products
            DeleteSelectedProductCommand = new RelayCommand<Product>(DeleteSelectedProduct);
            AddNewProductCommand = new RelayCommand(AddNewProduct);
            ShowLogForProduct = new RelayCommand<Product>(ProductShowLog);

            // Log commands:
            ShowFullUserLogCommand = new RelayCommand(ShowUsersLog);
            ShowFullAdminLogCommand = new RelayCommand(ShowAdminLog);
            ShowFullTransactionLogCommand = new RelayCommand(ShowTransactionsLog);

            // Admin commands for Load, Save and New
            SaveDataCommand = new RelayCommand(SaveCurrentData);
            LoadDataCommand = new RelayCommand(LoadExistingData);
            NewDataCommand = new RelayCommand(NewData);
            GenerateBillCommand = new RelayCommand(GenerateBill);
        }
 public CollectionBindingViewModel(IMessagePresenter messagePresenter)
 {
     Should.NotBeNull(messagePresenter, "messagePresenter");
     _messagePresenter = messagePresenter;
     AddCommand = new RelayCommand(Add);
     RemoveCommand = RelayCommandBase.FromAsyncHandler<CollectionItemModel>(Remove, CanRemove, this);
 }
        public PasswordEditorViewModel( IPasswordEditorModel model,
                                        DerivedPasswordViewModel.Factory derivedPasswordFactory,
                                        IExclusiveDelayedScheduler scheduler,
                                        IClipboardService clipboardService,
                                        IDialogService dialogService,
                                        IGuidToColorConverter guidToColor )
        {
            _model = model;
            _scheduler = scheduler;
            _clipboardService = clipboardService;
            _dialogService = dialogService;
            _guidToColor = guidToColor;
            _derivedPasswords = new ObservableCollection<DerivedPasswordViewModel>(
                _model.DerivedPasswords.Select( dp => derivedPasswordFactory( dp, _model ) ) );

            foreach ( DerivedPasswordViewModel passwordSlotViewModel in DerivedPasswords )
                passwordSlotViewModel.PropertyChanged += OnDerivedPasswordPropertyChanged;

            _saveCommand = new RelayCommand( ExecuteSave, CanExecuteSave );
            _copyCommand = new RelayCommand( ExecuteCopy, CanExecuteCopy );
            _deleteCommand = new RelayCommand( ExecuteDelete, CanExecuteDelete );

            _closeSelfCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.Self ) );
            _closeAllCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.All ) );
            _closeAllButSelfCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.AllButSelf ) );
            _closeToTheRightCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.RightOfSelf ) );
            _closeInsecureCommand = new RelayCommand( ( ) => RaiseCloseRequested( CloseEditorEventType.Insecure ) );

            Refresh( );
        }
 /// <summary>
 /// Initializes a new instance of the MongoDbDatabaseViewModel class.
 /// </summary>
 public MongoDbUserViewModel(string name, BsonDocument userDocument)
 {
     _name = name;
     _userDocument = userDocument;
     EditUser = new RelayCommand(InternalEditUser);
     ConfirmDeleteUser = new RelayCommand(InternalConfirmDeleteUser);
 }
        public SelectPlayersViewModel(GameCore core) : base(core)
        {
            AutomateSelections = new RelayCommand(() =>
            {
                var draftCards = core.GameState.Leagues.SelectMany(league => league.Teams.SelectMany(team => team.DraftCards));

                double additionalPlayerMultiplier = 1.4f;
                
                int numberOfSeniorPlayersNeeded = Convert.ToInt32(draftCards.Count(x => !x.MaxAge.HasValue) * additionalPlayerMultiplier);
                int numberOfYouthPlayersNeeded = Convert.ToInt32(draftCards.Count(x => x.MaxAge.HasValue) * additionalPlayerMultiplier);

                // Assumed max age value for simplicity
                int maxAge = 19;

                var bestAvailablePlayers = core.QueryService.GetPlayers(passive: false)
                    .OrderByDescending(x => x.CurrentAbility)
                    .Take(numberOfSeniorPlayersNeeded);

                PickedPlayerIds.AddRange(bestAvailablePlayers.Select(x => x.ID));
                PlayersAddedEvent(bestAvailablePlayers);

                var bestAvailableYoungPlayers = core.QueryService.GetPlayers(passive: false, filter: UnpickedPlayerPredicate)
                    .Where(x => x.Age <= maxAge)
                    .OrderByDescending(x => x.CurrentAbility)
                    .Take(numberOfYouthPlayersNeeded);

                PickedPlayerIds.AddRange(bestAvailableYoungPlayers.Select(x => x.ID));
                PlayersAddedEvent(bestAvailableYoungPlayers);
            });

            Reload(core);

            PickedPlayerIds = new List<int>();
        }
 public EditViewModel()
 {
     LeaveEditModeCommand = new RelayCommand(() =>
       {
     MessengerInstance.Send(new ChangeViewModelMessage() { ViewKind = ViewKind.None });
       });
 }
 public SelectRequestDatePageViewModel()
 {
     LoadedCommand = new RelayCommand(Loaded);
     UnloadedCommand = new RelayCommand(Unloaded);
     PrevCommand = new RelayCommand(Prev);
     NextCommand = new RelayCommand(Next);
 }
 public ThemeComponentSelectionControl()
 {
     InitializeComponent();
     (Content as FrameworkElement).DataContext = this;
     AddThemeComponentCommand = new RelayCommand(OnAddThemeComponentCommand);
     RemoveThemeComponentCommand = new RelayCommand(OnRemoveThemeComponentCommand);
 }
        /// <summary>
        ///     Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            LoadUrlCommand = new RelayCommand(OnLoadUrl);
            ParseUrlCommand = new RelayCommand(OnParseUrl, () => !string.IsNullOrEmpty(URL));
            ExportCommand = new RelayCommand(OnExport);
            GetUrlsCommand = new RelayCommand(OnGetUrls);

            _catalogObservableList = new ObservableCollection<CatalogNodeViewModel>();
            CatalogCollectionView = new ListCollectionView(_catalogObservableList);

            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
                URL = "http://hqfz.cnblgos.com";
                CnBlogName = "hqfz";
                var catalog = new CatalogNodeViewModel();
                catalog.CurrentEntity.Title = "Catalog1";
                var article = new ArticleViewModel();
                article.CurrentEntity.Title = "Article1";
                catalog.AddArticle(article);

                _catalogObservableList.Add(catalog);
            }
            else
            {
                // Code runs "for real"
                URL = "http://www.cnblogs.com/artech/default.html?page=1";
                CnBlogName = "artech";
            }
        }
 /// <summary>
 /// Initializes a new instance of the MongoDbIndexViewModel class.
 /// </summary>
 public MongoDbIndexViewModel(MongoDbCollectionViewModel collection, string name)
 {
     _collection = collection;
     _name = name;
     ConfirmDropIndex = new RelayCommand(InternalConfirmDropIndex);
     EditIndex = new RelayCommand(InternalEditIndex);
 }
        public RegisterRangeEditorViewModel(RangeModel originalRangeModel)
        {
            if (originalRangeModel == null)
                throw new ArgumentNullException(nameof(originalRangeModel));

            _originalRangeModel = originalRangeModel;

            _name = originalRangeModel.Name;
            _startingRegisterIndex = originalRangeModel.StartIndex;
            _registerType = originalRangeModel.RegisterType;

            if (originalRangeModel.Fields != null)
            {
                Fields.AddRange(originalRangeModel.Fields.Select(f => new FieldEditorViewModel(f.Clone())));
            }

            OkCommand = new RelayCommand(Ok, CanOk);
            CancelCommand = new RelayCommand(Cancel);

            MoveUpCommand = new RelayCommand(MoveUp, CanMoveUp);
            MoveDownCommand = new RelayCommand(MoveDown, CanMoveDown);
            DeleteCommand = new RelayCommand(Delete, CanDelete);
            MoveToTopCommand = new RelayCommand(MoveToTop, CanMoveToTop);
            MoveToBottomCommand = new RelayCommand(MoveToBottom, CanMoveToBottom);
            InsertAboveCommand = new RelayCommand(InsertAbove, CanInsertAbove);
            InsertBelowCommand = new RelayCommand(InsertBelow, CanInsertBelow);

            _fields.CollectionChanged += FieldsOnCollectionChanged;
        }