- 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. // Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer() CalendarService service = new CalendarService(new BaseClientService.Initializer()
{ {
HttpClientInitializer = credential, HttpClientInitializer = credential,
ApplicationName = ApplicationName, ApplicationName = ApplicationName,
+1 -1
View File
@@ -68,7 +68,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
//Set the window style to noactivate. //Set the window style to noactivate.
var helper = new WindowInteropHelper(this); WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
+3 -2
View File
@@ -61,7 +61,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
//Set the window style to noactivate. //Set the window style to noactivate.
var helper = new WindowInteropHelper(this); WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); 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) private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e)
{ {
string cpuUsage = GetCpuUsage();
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
textBlock.Text = GetCpuUsage(); textBlock.Text = cpuUsage;
}); });
} }
+1 -1
View File
@@ -48,7 +48,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
//Set the window style to noactivate. //Set the window style to noactivate.
var helper = new WindowInteropHelper(this); WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
+1 -1
View File
@@ -45,7 +45,7 @@
</DockPanel> </DockPanel>
<DockPanel Grid.Column="1" Margin="2.5,0,0,0"> <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"> <ScrollViewer Background="#FFBBBBBB">
<Grid> <Grid>
<StackPanel x:Name="optionsPanel" Margin="3,3,3,0" HorizontalAlignment="Stretch" Visibility="Collapsed" > <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); EditCheckBox_Click(null, null);
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.Visibility = Visibility.Collapsed; this.Visibility = Visibility.Collapsed;
foreach (var item in Windows) foreach (Window item in Windows)
{ {
WindowPos.SendWpfWindowBack(item); WindowPos.SendWpfWindowBack(item);
WindowPos.SendWpfWindowBack(item); WindowPos.SendWpfWindowBack(item);
@@ -76,7 +76,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
//Set the window style to noactivate. //Set the window style to noactivate.
var helper = new WindowInteropHelper(this); WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }
+4 -1
View File
@@ -146,7 +146,7 @@ namespace DesktopMagic
Assembly dll = Assembly.Load(assemblyBytes); Assembly dll = Assembly.Load(assemblyBytes);
Type instanceType = dll.GetTypes().FirstOrDefault(type => type.GetTypeInfo().BaseType == typeof(Plugin)); 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(item.Name);
Debug.WriteLine(typeof(Plugin).Name); Debug.WriteLine(typeof(Plugin).Name);
@@ -249,6 +249,8 @@ namespace DesktopMagic
valueTimer.Stop(); valueTimer.Stop();
} }
if (result is not null)
{
//Update Image //Update Image
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -256,6 +258,7 @@ namespace DesktopMagic
}); });
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
stop = true; stop = true;
+1 -1
View File
@@ -48,7 +48,7 @@ namespace DesktopMagic
base.OnSourceInitialized(e); base.OnSourceInitialized(e);
//Set the window style to noactivate. //Set the window style to noactivate.
var helper = new WindowInteropHelper(this); WindowInteropHelper helper = new WindowInteropHelper(this);
WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE, WindowPos.SetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE,
WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE); WindowPos.GetWindowLong(helper.Handle, WindowPos.GWL_EXSTYLE) | WindowPos.WS_EX_NOACTIVATE);
} }