本文整理汇总了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);
}
示例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;
}
);
}
示例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");
}