当前位置: 首页>>代码示例>>C#>>正文


C# Command.RelayCommand类代码示例

本文整理汇总了C#中GalaSoft.MvvmLight.Command.RelayCommand的典型用法代码示例。如果您正苦于以下问题:C# RelayCommand类的具体用法?C# RelayCommand怎么用?C# RelayCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RelayCommand类属于GalaSoft.MvvmLight.Command命名空间,在下文中一共展示了RelayCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainViewModel

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            scoreStorage = new ScoreStorage();
            HighScores = new ObservableCollection<Score>(scoreStorage.GetScores());
            game = new Game();
            game.PlayerLost += GameOnPlayerLost;
            game.PlayerTooFast += GameOnPlayerTooFast;
            game.PlayerWon += GameOnPlayerWon;
            game.CountdownTick += GameOnCountdownTick;
            game.WaitForItStarted += GameOnWaitForItStarted;
            game.TapDanceStarted += GameOnTapDanceStarted;
            game.ButtonsCanBeClickedChanged += GameOnButtonsCanBeClickedChanged;

            patternTimer = new DispatcherTimer();
            patternTimer.Tick += PatternTimerOnTick;
            patternTimer.Interval = buttonLightingTime;

            Button1Command = new RelayCommand(() => game.ButtonClicked(0), () => game.ButtonsCanBeClicked);
            Button2Command = new RelayCommand(() => game.ButtonClicked(1), () => game.ButtonsCanBeClicked);
            Button3Command = new RelayCommand(() => game.ButtonClicked(2), () => game.ButtonsCanBeClicked);
            Button4Command = new RelayCommand(() => game.ButtonClicked(3), () => game.ButtonsCanBeClicked);
            StartRetryCommand = new RelayCommand(() => StartNewPattern(game.GetNewPattern()), () => true);

            Button1BackColor = new SolidColorBrush(Colors.Black);
            Button2BackColor = new SolidColorBrush(Colors.Black);
            Button3BackColor = new SolidColorBrush(Colors.Black);
            Button4BackColor = new SolidColorBrush(Colors.Black);
            StartRetryText = "Start";
            SetNumberButtonsToDefault();
        }
开发者ID:koenmetsu,项目名称:WP7.TapDance,代码行数:33,代码来源:MainViewModel.cs

示例2: WorkshopViewModelBase

 protected WorkshopViewModelBase()
 {
     if (IsInDesignModeStatic)
     {
         Head = "X:123, Y:456, Z:7890";
         Neck = "X:123, Y:456, Z:7890";
         LeftShoulder = "X:123, Y:456, Z:7890";
         RightShoulder = "X:123, Y:456, Z:7890";
         Torso = "X:123, Y:456, Z:7890";
         LeftElbow = "X:123, Y:456, Z:7890";
         RightElbow = "X:123, Y:456, Z:7890";
         LeftHand = "X:123, Y:456, Z:7890";
         RightHand = "X:123, Y:456, Z:7890";
         LeftHand = "X:123, Y:456, Z:7890";
         RightHand = "X:123, Y:456, Z:7890";
         LeftHip = "X:123, Y:456, Z:7890";
         RightHip = "X:123, Y:456, Z:7890";
         LeftKnee = "X:123, Y:456, Z:7890";
         RightKnee = "X:123, Y:456, Z:7890";
         LeftFoot = "X:123, Y:456, Z:7890";
         RightFoot = "X:123, Y:456, Z:7890";
     }
     else
     {
         Kinect = MyKinect.Instance;
         PointerColor = new SolidColorBrush(Color.FromRgb(139, 0, 0));
         Messages = new ObservableCollection<string>();
         Start = new RelayCommand<RoutedEventArgs>(e => SafeStartKinect());
         Stop = new RelayCommand<RoutedEventArgs>(e => SafeStopKinect());
     }
 }
开发者ID:atosorigin,项目名称:Kinect,代码行数:31,代码来源:WorkshopViewModelBase.cs

示例3: PostcardViewModel

        public PostcardViewModel(string name, IEnumerable<XElement> xmlRectangles)
        {
            Name = name;
            PictureFrames = xmlRectangles.Select(r => new PictureFrameViewModel(r)).ToList();

            SelectToggleCommand = new RelayCommand(() => Selected = !Selected);
        }
开发者ID:peerio,项目名称:ZonerPostcardManager,代码行数:7,代码来源:PostcardViewModel.cs

示例4: ViewViewModel

        public ViewViewModel()
        {
            chatService = ServiceLocator.Current.GetInstance<IChatService>();
            parentViewModel = ServiceLocator.Current.GetInstance<PhotosViewModel>();
            timer = new Timer(new TimerCallback((c) => {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    App.RootFrame.Navigate(new Uri("/View/PhotosPage.xaml", UriKind.RelativeOrAbsolute));
                });
            }),
            null,
            Timeout.Infinite,
            Timeout.Infinite);

            HideCommand = new RelayCommand(async () =>

            {
                timer.Change(TimeSpan.FromSeconds(6), TimeSpan.FromMilliseconds(-1));
                var contentList = await chatService.ReadPhotoContentAsync(
                    parentViewModel.SelectedPhoto.PhotoContentSecretId);
                var content = contentList.FirstOrDefault();
                if (content != null)
                {
                    Uri = chatService.ReadPhotoAsUri(content.Uri);
                    Stream = chatService.ReadPhotoAsStream(content.Uri);
                }
                else
                {
                    Uri = null;
                    Stream = null;
                }

            });
        }
开发者ID:yeenfei,项目名称:samples,代码行数:34,代码来源:ViewViewModel.cs

示例5: MainViewModel

        public MainViewModel()
        {
            timer = new Timer();
            service = new LMService.LMServiceClient();
            timer.Interval = 2000;
            timer.Elapsed += timer_Elapsed;

            MyTeam = new TeamViewModel();
            EnemyTeam = new TeamViewModel();
            SendSetupCommand = new RelayCommand(SendSetup);
            NewGameCommannd = new RelayCommand(NewGame);
            CanSendSetup = true;
            //Deze halen we later op vanuit de server
            Champions = new List<string>(){
              "Shaco",
              "Sona",
              "Vayne",
              "Leblanc",
              "Aatrox"
            };

            //Default setup
            MyTeam.Top = "Aatrox";
            MyTeam.Jungle = "Shaco";
            MyTeam.Mid = "Leblanc";
            MyTeam.Adc = "Vayne";
            MyTeam.Supp = "Sona";
        }
开发者ID:Bart-Mutsaers,项目名称:Prog6_uitwerkingen,代码行数:28,代码来源:MainViewModel.cs

示例6: AddOrganizationViewModel

 public AddOrganizationViewModel()
 {
     DoneCommand = new RelayCommand(() =>
     {
         AddEntry();
     });
 }
开发者ID:maskaravivek,项目名称:FoodMenu,代码行数:7,代码来源:AddOrganizationViewModel.cs

示例7: ReplyViewModel

        public ReplyViewModel(IBaconProvider baconProvider, Thing replyTargetThing, RelayCommand cancel, Action<Thing> convertIntoUIReply, bool isEdit = false)
        {
            _convertIntoUIReply = convertIntoUIReply;
            _cancel = cancel;
            _baconProvider = baconProvider;
            _redditService = _baconProvider.GetService<IRedditService>();
            _userService = _baconProvider.GetService<IUserService>();
            _markdownProcessor = _baconProvider.GetService<IMarkdownProcessor>();
            _replyTargetThing = replyTargetThing;

            if (isEdit)
            {
                Editing = true;
                EditingId = ((Comment)_replyTargetThing.Data).Name;
                ReplyBody = ((Comment)_replyTargetThing.Data).Body.Replace("&gt;", ">").Replace("&lt;", "<");
            }

			RefreshUserImpl();

            _addBold = new RelayCommand(AddBoldImpl);
            _addItalic = new RelayCommand(AddItalicImpl);
            _addStrike = new RelayCommand(AddStrikeImpl);
            _addSuper = new RelayCommand(AddSuperImpl);
            _addLink = new RelayCommand(AddLinkImpl);
            _addQuote = new RelayCommand(AddQuoteImpl);
            _addCode = new RelayCommand(AddCodeImpl);
            _addBullets = new RelayCommand(AddBulletsImpl);
            _addNumbers = new RelayCommand(AddNumbersImpl);
            _submit = new RelayCommand(SubmitImpl);
			_refreshUser = new RelayCommand(RefreshUserImpl);
        }
开发者ID:Synergex,项目名称:Baconography,代码行数:31,代码来源:ReplyViewModel.cs

示例8: UnshelveDetailsServiceModel

        public UnshelveDetailsServiceModel(ITeamPilgrimServiceModelProvider teamPilgrimServiceModelProvider, ITeamPilgrimVsService teamPilgrimVsService, ProjectCollectionServiceModel projectCollectionServiceModel, WorkspaceServiceModel workspaceServiceModel, UnshelveServiceModel unshelveServiceModel, Shelveset shelveset)
            : base(teamPilgrimServiceModelProvider, teamPilgrimVsService)
        {
            ProjectCollectionServiceModel = projectCollectionServiceModel;
            WorkspaceServiceModel = workspaceServiceModel;
            UnshelveServiceModel = unshelveServiceModel;
            Shelveset = shelveset;

            PendingChanges = new ObservableCollection<PendingChangeModel>();

            CancelCommand = new RelayCommand(Cancel, CanCancel);
            UnshelveCommand = new RelayCommand(Unshelve, CanUnshelve);

            SelectPendingChangesCommand = new RelayCommand<SelectPendingChangesCommandArgument>(SelectPendingChanges, CanSelectPendingChanges);
            SelectWorkItemsCommand = new RelayCommand<SelectWorkItemsCommandArgument>(SelectWorkItems, CanSelectWorkItems);

            PendingSet[] pendingSets;
            if (teamPilgrimServiceModelProvider.TryWorkspaceQueryShelvedChanges(WorkspaceServiceModel.Workspace, out pendingSets, shelveset.Name, shelveset.OwnerName, null))
            {
                PendingSet = pendingSets.First();

                foreach (var pendingChange in PendingSet.PendingChanges)
                {
                    PendingChanges.Add(new PendingChangeModel(pendingChange) { IncludeChange = true });
                }
            }

            PopulateSelectedPendingChangesSummary();
        }
开发者ID:BruceMellows,项目名称:TeamPilgrim,代码行数:29,代码来源:UnshelveDetailsServiceModel.cs

示例9: ClickToChangePictureViewModel

 public ClickToChangePictureViewModel()
 {
     _myImage1 = new BitmapImage(new Uri("ms-appx:///Images/110Banana.png"));
     _myImage2 = new BitmapImage(new Uri("ms-appx:///Images/110Lemon.png"));
     ClickCommand = new RelayCommand(ChangeIamges);
     ChangeIamges();
 }
开发者ID:Aadeelyoo,项目名称:MyMSDNSamples,代码行数:7,代码来源:ClickToChangePictureViewModel.cs

示例10: CheckInPageViewModel

 public CheckInPageViewModel()
 {
     CheckInCommand = new RelayCommand<int>(CheckIn);
     BackCommand = new RelayCommand(NavBack);
     //GetUsersName();
     Rooms = GetRooms();
 }
开发者ID:vtesin,项目名称:Levi9-GeoTagging,代码行数:7,代码来源:CheckInPageViewModel.cs

示例11: PlayerViewModel

        public PlayerViewModel(
            AudioPlayerHelper helper,
            ICollectionService service,
            IAppSettingsHelper appSettingsHelper)
        {
            _helper = helper;
            _service = service;
            _appSettingsHelper = appSettingsHelper;

            if (!IsInDesignMode)
            {
                helper.TrackChanged += HelperOnTrackChanged;
                helper.PlaybackStateChanged += HelperOnPlaybackStateChanged;
                helper.Shutdown += HelperOnShutdown;

                _nextRelayCommand = new RelayCommand(NextSong);
                _prevRelayCommand = new RelayCommand(PrevSong);
                _playPauseRelayCommand = new RelayCommand(PlayPauseToggle);

                _timer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(1)};
                _timer.Tick += TimerOnTick;
            }
            else
            {
                CurrentQueue = service.PlaybackQueue.FirstOrDefault();
                PlayPauseIcon = Symbol.Play;
            }
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:28,代码来源:PlayerViewModel.cs

示例12: ViewStockistPurchaseOrderViewModel

 public ViewStockistPurchaseOrderViewModel()
 {
     EditOrderCommand = new RelayCommand(EditOrder);
     ApproveOrderCommand = new RelayCommand(ApproveOrder);
     ViewOrderPageLoadedCommand = new RelayCommand(LoadOrder);
     CancelCommand = new RelayCommand(Cancel);
 }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:7,代码来源:ViewStockistPurchaseOrderViewModel.cs

示例13: PandocTaskViewModel

        public PandocTaskViewModel()
        {
            Model = new PandocTask();

            AddTargetFile = new RelayCommand(() =>
                {
                    Model.TargetFiles.Add(new TargetFile());
                });

            RemoveTargetFile = new RelayCommand<TargetFile>(file =>
                {
                    Model.TargetFiles.Remove(file);
                }, file => file != null);

            Do = new RelayCommand(() =>
                {
                    IsBusy = true;
                    Task.Factory.StartNew(() =>
                        {
                            Result = PandocRunner.Run(this.GetLocator().Config.Model.PandocExePath, Model).Last();
                        }).ContinueWith(task =>
                            {
                                IsBusy = false;
                            });
                }, () => !IsBusy);
        }
开发者ID:nagysa1313,项目名称:PandocGUI,代码行数:26,代码来源:PandocTaskViewModel.cs

示例14: StockistPurchaseOrderListingViewModel

 public StockistPurchaseOrderListingViewModel()
 {
     ViewSelectedOrderCommand = new RelayCommand<OrderItemSummary>(ViewSelectedOrder);
     CreateOrderCommand = new RelayCommand(CreateOrder);
     ViewPrintableOrderCommand = new RelayCommand<OrderItemSummary>(ViewPrintableOrder);
     ProcessOrderCommand = new RelayCommand<OrderItemSummary>(ProcessOrder);
 }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:7,代码来源:StockistPurchaseOrderListingViewModel.cs

示例15: SupplementaryReportViewModel

        public SupplementaryReportViewModel(IWorkListDataSource dataSource, string siteID, string accessionNumber, string caseURN, CaseConsultationList consultationList,
											bool isGlobalReadOnly = false, ReadingSiteType siteType = ReadingSiteType.interpretation)
        {
            this.DataSource = dataSource;

            // case info
            this.SiteID = siteID;
            this.AccessionNumber = accessionNumber;
            this.CaseURN = caseURN;
            this.ConsultationList = consultationList;
            this.CurrentSiteType = siteType;
            this.IsEditorReadOnly = isGlobalReadOnly;

            GetConsultationID();

            // retrieve all the supplementary reports for the case
            srModel = dataSource.GetSupplementalReports(this.CaseURN);

            ClearSRCommand = new RelayCommand(ClearSR, () => this.CanClearSR);
            AddNewSRCommand = new RelayCommand(AddNewSR, () => this.CanAddNewSR);
            UpdateSRCommand = new RelayCommand(UpdateSR, () => this.CanUpdateSR);
            VerifySRCommand = new RelayCommand(VerifySR, () => this.CanVerifySR);
            CompleteConsultationCommand = new RelayCommand(CompleteConsultation, () => this.CanCompleteConsultation);

            ClearSR();

            // retrieve the Esignature status at the case's primary site
            GetESignatureStatus();
        }
开发者ID:zhanghongzhitou,项目名称:Telepathology,代码行数:29,代码来源:SupplementaryReportViewModel.cs


注:本文中的GalaSoft.MvvmLight.Command.RelayCommand类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。