- Add null check for plugin result

- Minor code changes
This commit is contained in:
Stone-Red-Code
2021-09-16 17:11:41 +02:00
parent 5bc35cf92b
commit 0f6e8437fd
9 changed files with 18 additions and 14 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ namespace DesktopMagic
}
// Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer()
CalendarService service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
+1 -1
View File
@@ -68,7 +68,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e);
//Set the window style to noactivate.
var helper = new WindowInteropHelper(this);
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
+3 -2
View File
@@ -61,7 +61,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e);
//Set the window style to noactivate.
var helper = new WindowInteropHelper(this);
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
@@ -88,9 +88,10 @@ namespace DesktopMagic
private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e)
{
string cpuUsage = GetCpuUsage();
Dispatcher.Invoke(() =>
{
textBlock.Text = GetCpuUsage();
textBlock.Text = cpuUsage;
});
}
+1 -1
View File
@@ -48,7 +48,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e);
//Set the window style to noactivate.
var helper = new WindowInteropHelper(this);
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
+1 -1
View File
@@ -45,7 +45,7 @@
</DockPanel>
<DockPanel Grid.Column="1" Margin="2.5,0,0,0">
<ComboBox x:Name="optionsComboBox" DockPanel.Dock="Top" Height="24" SelectedIndex="0" DisplayMemberPath="Item1" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" />
<ComboBox x:Name="optionsComboBox" DockPanel.Dock="Top" Height="24" SelectedIndex="0" DisplayMemberPath="Item1" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" Padding="4" VerticalAlignment="Center"/>
<ScrollViewer Background="#FFBBBBBB">
<Grid>
<StackPanel x:Name="optionsPanel" Margin="3,3,3,0" HorizontalAlignment="Stretch" Visibility="Collapsed" >
+1 -1
View File
@@ -321,7 +321,7 @@ namespace DesktopMagic
EditCheckBox_Click(null, null);
this.ShowInTaskbar = false;
this.Visibility = Visibility.Collapsed;
foreach (var item in Windows)
foreach (Window item in Windows)
{
WindowPos.SendWpfWindowBack(item);
WindowPos.SendWpfWindowBack(item);
@@ -76,7 +76,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e);
//Set the window style to noactivate.
var helper = new WindowInteropHelper(this);
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}
+8 -5
View File
@@ -146,7 +146,7 @@ namespace DesktopMagic
Assembly dll = Assembly.Load(assemblyBytes);
Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin));
foreach (var item in dll.GetTypes())
foreach (Type item in dll.GetTypes())
{
Debug.WriteLine(item.Name);
Debug.WriteLine(typeof(Plugin).Name);
@@ -249,11 +249,14 @@ namespace DesktopMagic
valueTimer.Stop();
}
//Update Image
Dispatcher.Invoke(() =>
if (result is not null)
{
image.Source = BitmapToImageSource(result);
});
//Update Image
Dispatcher.Invoke(() =>
{
image.Source = BitmapToImageSource(result);
});
}
}
}
catch (Exception ex)
+1 -1
View File
@@ -48,7 +48,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e);
//Set the window style to noactivate.
var helper = new WindowInteropHelper(this);
WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
}