本文整理汇总了C#中System.ComponentModel.CancelEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# CancelEventArgs类的具体用法?C# CancelEventArgs怎么用?C# CancelEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CancelEventArgs类属于System.ComponentModel命名空间,在下文中一共展示了CancelEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window_Closing
private void Window_Closing(object sender, CancelEventArgs e)
{
var model = (MusicViewModel) DataContext;
model.SaveIfDirty();
SaveSettings();
}
示例2: textBox_Validating
private void textBox_Validating(object sender, CancelEventArgs e) {
var textBox = (TextBox)sender;
decimal value = 0;
if (allowOnlyInteger) {
int intValue;
if (!int.TryParse(textBox.Text, out intValue)) {
errorProvider.SetError(textBox, "Please enter a valid integer value.");
e.Cancel = true;
return;
} else {
value = intValue;
errorProvider.SetError(textBox, null);
}
} else {
if (!decimal.TryParse(textBox.Text, NumberStyles.Float, CultureInfo.CurrentCulture.NumberFormat, out value)) {
errorProvider.SetError(textBox, "Please enter a valid double value.");
e.Cancel = true;
return;
} else errorProvider.SetError(textBox, null);
}
if (textBox == minimumTextBox) Minimum = value;
else if (textBox == maximumTextBox) Maximum = value;
else if (textBox == stepSizeTextBox) Step = value;
okButton.Enabled = IsValid();
}
示例3: Close
private void Close(object sender, CancelEventArgs e)
{
if (_kinectSensor != null)
{
_kinectSensor.Close();
}
}
示例4: OnClosing
private void OnClosing(object sender, CancelEventArgs e)
{
if (!App.Locator.MainWindow.IsAuth)
{
this.Close();
}
}
示例5: WindowClosing
private void WindowClosing(object sender, CancelEventArgs e)
{
if(!Validate())
{
e.Cancel = true;
}
}
示例6: Window_OnClosing
private void Window_OnClosing(object sender, CancelEventArgs e)
{
var vm = (ElementListToolWindowViewModel)this.DataContext;
vm.Remove();
//((ToolWindow)sender).Hide();
//e.Cancel = true;
}
示例7: OnClosing
protected override void OnClosing(CancelEventArgs e)
{
RegisterOprate.SaveRegData(KeyName, tabs.SelectedIndex);
if (MessageBox.Show("确认退出?", "请确认", MessageBoxButtons.YesNo) == DialogResult.No)
e.Cancel = true;
base.OnClosing(e);
}
示例8: OnClosing
protected override void OnClosing(CancelEventArgs e)
{
if (null == mDockUrl)
{
e.Cancel = false;
}
else if (mDockUrl._isDirty())
{
string dockUrlName_ = mDockUrl._getDockUrlName();
if (null == dockUrlName_ || "" == dockUrlName_)
{
dockUrlName_ = "untitle";
}
DialogResult dialogResult_ = MessageBox.Show("是否保存?", dockUrlName_, MessageBoxButtons.OKCancel);
if (dialogResult_ == DialogResult.OK)
{
mDockUrl._runSave();
mDockUrl._runClose();
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
else
{
mDockUrl._runClose();
e.Cancel = false;
}
base.OnClosing(e);
}
示例9: OnClosing
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
e.Cancel = true;
Hide();
formControl.buttonShowGraph.Text = "Показать график";
}
示例10: MainWindowClosing
/// <summary> Shuts down the application when the main window closes. </summary>
/// <param name="sender"> The sender. </param>
/// <param name="e"> The event arguments. </param>
private void MainWindowClosing(object sender, CancelEventArgs e)
{
var vm = (MainWindowViewModel)this.DataContext;
vm.SaveSettings();
Application.Current.Shutdown();
}
示例11: OnClosing
protected override void OnClosing(CancelEventArgs e)
{
//Prevent disposal of dialog
e.Cancel = true;
base.OnClosing(e);
Hide();
}
示例12: OnClosing
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
if (checkBox1.Checked)
{
// User clicked 'ignore': set flag in VM.
log.DebugFormat("Setting IgnoreExcessiveVcpus flag to true for VM {0}", vm.Name);
VM copyVM = (VM)vm.Clone();
copyVM.IgnoreExcessiveVcpus = true;
// Save changes to server
try
{
vm.Locked = true;
copyVM.SaveChanges(vm.Connection.Session);
}
finally
{
vm.Locked = false;
}
}
else
{
// Select VM's settings (a.k.a. 'general') tab
if (Program.MainWindow.SelectObject(this.vm))
Program.MainWindow.SwitchToTab(MainWindow.Tab.Settings);
}
}
示例13: MammaView_OnClosing
private void MammaView_OnClosing(object sender, CancelEventArgs e)
{
var viewModel = DataContext as MammaViewModel;
if (viewModel != null && viewModel.SaveCommand.CanExecute(null))
{
var dialogResult = MessageBox.Show("Есть несохраненные изменения. Сохранить их?", "УЗД молочной железы",
MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Yes);
switch (dialogResult)
{
case MessageBoxResult.Yes:
viewModel.SaveCommand.Execute(null);
break;
case MessageBoxResult.Cancel:
e.Cancel = true;
break;
}
}
else
{
var dialogResult = MessageBox.Show("Вы уверны, что хотите выйти?", "УЗД молочной железы",
MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes);
if (dialogResult == MessageBoxResult.No)
{
e.Cancel = true;
}
}
}
示例14: OnNotInList
protected virtual void OnNotInList(CancelEventArgs e)
{
if (NotInList != null)
{
NotInList(this, e);
}
}
示例15: OnLogConsoleWindowClosing
void OnLogConsoleWindowClosing( object sender, CancelEventArgs e )
{
e.Cancel = true;
_logConsoleWindow.Visibility = System.Windows.Visibility.Collapsed;
_consoleWindowIsClosed = true;
OnPropertyChanged( "IsMaximized" );
}