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


C# Command.ChangeCanExecute方法代码示例

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


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

示例1: ChangeCanExecute

		public void ChangeCanExecute ()
		{
			bool signaled = false;
			var cmd = new Command (() => { });

			cmd.CanExecuteChanged += (sender, args) => signaled = true;

			cmd.ChangeCanExecute ();
			Assert.True (signaled);
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:10,代码来源:CommandTests.cs

示例2: WaveRecorderViewModel

		/// <summary>
		/// Initializes a new instance of the <see cref="WaveRecorderViewModel"/> class.
		/// </summary>
		public WaveRecorderViewModel()
		{
			SampleRate = 16000;

			var app = Resolver.Resolve<IXFormsApp>();

			//this.FileName = System.IO.Path.Combine(app.AppDataDirectory, "audiosample.wav");
			FileName = Device.OnPlatform(
				System.IO.Path.Combine(app.AppDataDirectory, "audiosample.wav"),
				"audiosample.wav",
				System.IO.Path.Combine(app.AppDataDirectory, "audiosample.wav")
				);

			var device = Resolver.Resolve<IDevice>();

			if (device != null)
			{
				_audioStream = device.Microphone;
				_recorder = new WaveRecorder();
			}

			Record = new Command(
				() =>
				{
					_audioStream.OnBroadcast += audioStream_OnBroadcast;
					//this.audioStream.Start.Execute(this.SampleRate);
					_recorder.StartRecorder(
						_audioStream,
						device.FileManager.OpenFile(FileName, Platform.Services.IO.FileMode.Create, Platform.Services.IO.FileAccess.Write),
						SampleRate).ContinueWith(t =>
							{
								if (t.IsCompleted)
								{
									IsRecording = t.Result;
									System.Diagnostics.Debug.WriteLine("Microphone recorder {0}.", IsRecording ? "was started" : "failed to start.");
									Record.ChangeCanExecute();
									Stop.ChangeCanExecute();
								}
								else if (t.IsFaulted)
								{
									_audioStream.OnBroadcast -= audioStream_OnBroadcast;
								}
							});
				},
				() => RecordingEnabled &&
					_audioStream.SupportedSampleRates.Contains(SampleRate) &&
					!IsRecording &&
					device.FileManager != null
				);

			Stop = new Command(
				async () =>
				{
					_audioStream.OnBroadcast -= audioStream_OnBroadcast;
					await _recorder.StopRecorder();
					//this.audioStream.Stop.Execute(this);
					System.Diagnostics.Debug.WriteLine("Microphone recorder was stopped.");
					Record.ChangeCanExecute();
					Stop.ChangeCanExecute();
				},
				() =>
				{
					return IsRecording;
				}
				);
		}
开发者ID:nrogoff,项目名称:Xamarin-Forms-Labs,代码行数:69,代码来源:WaveRecorderViewModel.cs

示例3: TestCommandCanExecuteChanged

		public void TestCommandCanExecuteChanged()
		{
			bool first = true;
			var cmd = new Command (() => { }, () => {
				if (first) {
					first = false;
					return false;
				} else {
					return true;
				}
			});
			
			var cell = new TextCell { Command = cmd };
			Assert.IsFalse (cell.IsEnabled, "Cell was not disabled");

			cmd.ChangeCanExecute();

			Assert.IsTrue (cell.IsEnabled, "Cell was not reenabled");
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:19,代码来源:TextCellTests.cs


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