mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
check null before invoking event handlers (#12)
This commit is contained in:
parent
e2b384198a
commit
813d76126b
6 changed files with 17 additions and 17 deletions
|
@ -34,7 +34,7 @@ namespace CalculatorApp
|
||||||
if (newCurrentPosition != -1)
|
if (newCurrentPosition != -1)
|
||||||
{
|
{
|
||||||
m_currentPosition = newCurrentPosition;
|
m_currentPosition = newCurrentPosition;
|
||||||
CurrentChanged(this, null);
|
CurrentChanged?.Invoke(this, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
|
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
|
||||||
{
|
{
|
||||||
CurrentChanged(this, null);
|
CurrentChanged?.Invoke(this, null);
|
||||||
})).AsTask().Wait();
|
})).AsTask().Wait();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -60,7 +60,7 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentPosition = index;
|
m_currentPosition = index;
|
||||||
CurrentChanged(this, null);
|
CurrentChanged?.Invoke(this, null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ namespace CalculatorApp
|
||||||
void OnSourceBindableVectorChanged(Windows.UI.Xaml.Interop.IBindableObservableVector source, object e)
|
void OnSourceBindableVectorChanged(Windows.UI.Xaml.Interop.IBindableObservableVector source, object e)
|
||||||
{
|
{
|
||||||
Windows.Foundation.Collections.IVectorChangedEventArgs args = (Windows.Foundation.Collections.IVectorChangedEventArgs)e;
|
Windows.Foundation.Collections.IVectorChangedEventArgs args = (Windows.Foundation.Collections.IVectorChangedEventArgs)e;
|
||||||
VectorChanged(this, args);
|
VectorChanged?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler<object> CurrentChanged;
|
public event EventHandler<object> CurrentChanged;
|
||||||
|
|
|
@ -406,7 +406,7 @@ namespace CalculatorApp
|
||||||
|
|
||||||
private void OnEquationButtonClicked(object sender, RoutedEventArgs e)
|
private void OnEquationButtonClicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
EquationButtonClicked(this, new RoutedEventArgs());
|
EquationButtonClicked?.Invoke(this, new RoutedEventArgs());
|
||||||
|
|
||||||
SetEquationButtonTooltipAndAutomationName();
|
SetEquationButtonTooltipAndAutomationName();
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ namespace CalculatorApp
|
||||||
m_richEditBox.MathText = "";
|
m_richEditBox.MathText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveButtonClicked(this, new RoutedEventArgs());
|
RemoveButtonClicked?.Invoke(this, new RoutedEventArgs());
|
||||||
|
|
||||||
if (m_functionButton != null)
|
if (m_functionButton != null)
|
||||||
{
|
{
|
||||||
|
@ -452,7 +452,7 @@ namespace CalculatorApp
|
||||||
|
|
||||||
private void OnFunctionButtonClicked(object sender, RoutedEventArgs e)
|
private void OnFunctionButtonClicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
KeyGraphFeaturesButtonClicked(this, new RoutedEventArgs());
|
KeyGraphFeaturesButtonClicked?.Invoke(this, new RoutedEventArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFunctionMenuButtonClicked(object sender, RoutedEventArgs e)
|
private void OnFunctionMenuButtonClicked(object sender, RoutedEventArgs e)
|
||||||
|
@ -463,7 +463,7 @@ namespace CalculatorApp
|
||||||
m_richEditBox.SubmitEquation(EquationSubmissionSource.FOCUS_LOST);
|
m_richEditBox.SubmitEquation(EquationSubmissionSource.FOCUS_LOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyGraphFeaturesButtonClicked(this, new RoutedEventArgs());
|
KeyGraphFeaturesButtonClicked?.Invoke(this, new RoutedEventArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRichEditMenuOpened(object sender, object args)
|
private void OnRichEditMenuOpened(object sender, object args)
|
||||||
|
@ -614,12 +614,12 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EquationSubmitted(this, args);
|
EquationSubmitted?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEquationFormatRequested(object sender, MathRichEditBoxFormatRequest args)
|
private void OnEquationFormatRequested(object sender, MathRichEditBoxFormatRequest args)
|
||||||
{
|
{
|
||||||
EquationFormatRequested(this, args);
|
EquationFormatRequested?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
// Request the final formatting of the text
|
// Request the final formatting of the text
|
||||||
var formatRequest = new MathRichEditBoxFormatRequest(newVal);
|
var formatRequest = new MathRichEditBoxFormatRequest(newVal);
|
||||||
FormatRequest(this, formatRequest);
|
FormatRequest?.Invoke(this, formatRequest);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(formatRequest.FormattedText))
|
if (!string.IsNullOrEmpty(formatRequest.FormattedText))
|
||||||
{
|
{
|
||||||
|
@ -158,11 +158,11 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
|
|
||||||
SetValue(MathTextProperty, newVal);
|
SetValue(MathTextProperty, newVal);
|
||||||
EquationSubmitted(this, new MathRichEditBoxSubmission(true, source));
|
EquationSubmitted?.Invoke(this, new MathRichEditBoxSubmission(true, source));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EquationSubmitted(this, new MathRichEditBoxSubmission(false, source));
|
EquationSubmitted?.Invoke(this, new MathRichEditBoxSubmission(false, source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace CalculatorApp
|
||||||
private void Timer_Tick(object sender, object e)
|
private void Timer_Tick(object sender, object e)
|
||||||
{
|
{
|
||||||
m_timer.Stop();
|
m_timer.Stop();
|
||||||
Action(this, null);
|
Action?.Invoke(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DispatcherTimer m_timer;
|
private DispatcherTimer m_timer;
|
||||||
|
|
|
@ -407,7 +407,7 @@ namespace CalculatorApp
|
||||||
|
|
||||||
private void EquationTextBox_KeyGraphFeaturesButtonClicked(object sender, RoutedEventArgs e)
|
private void EquationTextBox_KeyGraphFeaturesButtonClicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
KeyGraphFeaturesRequested(this, GetViewModelFromEquationTextBox(sender));
|
KeyGraphFeaturesRequested?.Invoke(this, GetViewModelFromEquationTextBox(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EquationTextBox_EquationButtonClicked(object sender, RoutedEventArgs e)
|
private void EquationTextBox_EquationButtonClicked(object sender, RoutedEventArgs e)
|
||||||
|
@ -565,7 +565,7 @@ namespace CalculatorApp
|
||||||
|
|
||||||
private void EquationTextBox_EquationFormatRequested(object sender, MathRichEditBoxFormatRequest e)
|
private void EquationTextBox_EquationFormatRequested(object sender, MathRichEditBoxFormatRequest e)
|
||||||
{
|
{
|
||||||
EquationFormatRequested(sender, e);
|
EquationFormatRequested?.Invoke(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
|
private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace CalculatorApp
|
||||||
|
|
||||||
private void AlwaysOnTopButton_Click(object sender, RoutedEventArgs e)
|
private void AlwaysOnTopButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
AlwaysOnTopClick(this, e);
|
AlwaysOnTopClick?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Windows.ApplicationModel.Core.CoreApplicationViewTitleBar m_coreTitleBar;
|
private Windows.ApplicationModel.Core.CoreApplicationViewTitleBar m_coreTitleBar;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue