Merge branch 'develop'

This commit is contained in:
Stone-Red-Code
2021-09-10 16:59:07 +02:00
19 changed files with 151 additions and 88 deletions
+2 -35
View File
@@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "DesktopMagic"
#define MyAppVersion "0.0.2.1"
#define MyAppVersion "0.0.2.2"
#define MyAppPublisher "Stone_Red"
#define MyAppExeName "DesktopMagic.exe"
@@ -36,40 +36,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
[Files]
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Stone_Red-C-Sharp-Utilities.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.deps.json"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.runtimeconfig.dev.json"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagic.runtimeconfig.json"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagicPluginAPI.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\DesktopMagicPluginAPI.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Google.Apis.Auth.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Google.Apis.Auth.PlatformServices.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Google.Apis.Calendar.v3.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Google.Apis.Core.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Google.Apis.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Hardcodet.NotifyIcon.Wpf.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\MaterialDesignColors.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\MaterialDesignThemes.Wpf.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.Asio.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.Core.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.Midi.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.Wasapi.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.WinForms.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\NAudio.WinMM.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Newtonsoft.Json.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\System.Drawing.Common.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\System.Management.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Xceed.Wpf.AvalonDock.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Xceed.Wpf.AvalonDock.Themes.Aero.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Xceed.Wpf.AvalonDock.Themes.Metro.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Xceed.Wpf.AvalonDock.Themes.VS2010.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\Xceed.Wpf.Toolkit.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\DesktopMagic\bin\Release\net5.0-windows\runtimes\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "..\DesktopMagic\bin\Release\net5.0-windows\publish\DesktopMagic.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
-3
View File
@@ -4,9 +4,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopMagic", "DesktopMagic\DesktopMagic.csproj", "{B56B4CCC-CF92-4C05-9DEA-57666D81889A}"
ProjectSection(ProjectDependencies) = postProject
{A06BD685-7F92-4799-846B-3EC38345108E} = {A06BD685-7F92-4799-846B-3EC38345108E}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesktopMagicPluginAPI", "DesktopMagicPluginAPI\DesktopMagicPluginAPI.csproj", "{9D193A10-3E8E-447F-89F1-4B316C2EE37D}"
EndProject
+28 -1
View File
@@ -1,4 +1,6 @@
using System.Windows;
using System;
using System.Threading;
using System.Windows;
namespace DesktopMagic
{
@@ -7,5 +9,30 @@ namespace DesktopMagic
/// </summary>
public partial class App : Application
{
private Mutex _mutex;
public App()
{
// Try to grab mutex
bool createdNew;
_mutex = new Mutex(true, $"Stone_Red{DesktopMagic.MainWindow.AppName}", out createdNew);
//check if creating new was succesfull
if (!createdNew)
{
//Shutdown Aplication
Current.Shutdown();
}
else
{
// Add Event handler to exit event.
Exit += CloseMutexHandler;
}
}
protected virtual void CloseMutexHandler(object sender, EventArgs e)
{
_mutex?.Close();
}
}
}
+11 -1
View File
@@ -7,11 +7,16 @@
<RootNamespace>DesktopMagic</RootNamespace>
<ApplicationIcon>icon.ico</ApplicationIcon>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<Authors>Stone_Red</Authors>
<Version>0.0.2.2</Version>
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<None Remove="icon.ico" />
<None Remove="icons8_volunteering_26_85L_icon.ico" />
<None Remove="icon_Dark.ico" />
</ItemGroup>
<ItemGroup>
@@ -29,6 +34,11 @@
</ItemGroup>
<ItemGroup>
<Resource Include="icon.ico" />
<Resource Include="icon_Dark.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project>
+2 -1
View File
@@ -72,6 +72,7 @@ namespace DesktopMagic
notifyIcon.Visible = true;
notifyIcon.Text = AppName;
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();
InitializeComponent();
@@ -772,7 +773,7 @@ namespace DesktopMagic
private void NewLayoutButton_Click(object sender, RoutedEventArgs e)
{
InputDialog inputDialog = new("Layoutnamen eingeben:");
InputDialog inputDialog = new((string)FindResource("enterLayoutName"));
if (inputDialog.ShowDialog() == true)
{
string content = "";
+1 -4
View File
@@ -20,9 +20,6 @@ namespace DesktopMagic
public Point WindowPosition => new Point((int)window.Left, (int)window.Top);
public void UpdateWindow()
{
window.UpdatePluginWindow();
}
public void UpdateWindow() => window.UpdatePluginWindow();
}
}
+38 -16
View File
@@ -13,6 +13,7 @@ using System.Threading;
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace DesktopMagic
@@ -190,19 +191,13 @@ namespace DesktopMagic
return;
}
if (instanceType.Namespace == nameof(DesktopMagic))
{
MessageBox.Show("NO!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Exit();
return;
}
LoadOptions(instance);
valueTimer = new System.Timers.Timer();
valueTimer.Interval = 1000;
valueTimer.Elapsed += ValueTimer_Elapsed;
pluginClassInstance.Start();
UpdatePluginWindow();
if (pluginClassInstance.UpdateInterval > 0)
@@ -249,16 +244,35 @@ namespace DesktopMagic
{
//Set Arguments
SolidBrush newBrush = (SolidBrush)MainWindow.GlobalSystemColor;
Color color = newBrush.Color;
System.Drawing.Color color = newBrush.Color;
string font = MainWindow.GlobalFont;
Bitmap result = pluginClassInstance.Main();
//Update Image
Dispatcher.Invoke(() =>
try
{
image.Source = BitmapToImageSource(result);
});
Bitmap result = pluginClassInstance.Main();
if (pluginClassInstance.UpdateInterval > 0)
{
valueTimer.Interval = pluginClassInstance.UpdateInterval;
}
else
{
valueTimer.Stop();
}
//Update Image
Dispatcher.Invoke(() =>
{
image.Source = BitmapToImageSource(result);
});
}
catch (Exception ex)
{
MainWindow.Logger.Log(ex.ToString(), "Plugin");
MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Exit();
return;
}
if (stop)
{
@@ -312,12 +326,20 @@ namespace DesktopMagic
private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Clicked(new System.Drawing.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y));
ImageSource imageSource = image.Source;
BitmapSource bitmapImage = (BitmapSource)imageSource;
double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight;
double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight;
Clicked(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY));
}
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
{
Moved(new System.Drawing.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y));
ImageSource imageSource = image.Source;
BitmapSource bitmapImage = (BitmapSource)imageSource;
double pixelMousePositionX = e.GetPosition(image).X * bitmapImage.PixelWidth / image.ActualHeight;
double pixelMousePositionY = e.GetPosition(image).Y * bitmapImage.PixelHeight / image.ActualHeight;
Moved(new System.Drawing.Point((int)pixelMousePositionX, (int)pixelMousePositionY));
}
#endregion Window Events
@@ -23,6 +23,7 @@
<system:String x:Key="deleteLayout">Layout Löschen</system:String>
<system:String x:Key="ok">Ok</system:String>
<system:String x:Key="cancel">Abbrechen</system:String>
<system:String x:Key="enterLayoutName">Layoutnamen eingeben:</system:String>
<col:ArrayList x:Key="musicVisualizerOptionsComboboxItems">
<system:String>Unten</system:String>
<system:String>Mitte</system:String>
@@ -23,6 +23,7 @@
<system:String x:Key="deleteLayout">Delete Layout</system:String>
<system:String x:Key="ok">Ok</system:String>
<system:String x:Key="cancel">Cancel</system:String>
<system:String x:Key="enterLayoutName">Enter layout name</system:String>
<col:ArrayList x:Key="musicVisualizerOptionsComboboxItems">
<system:String>Bottom</system:String>
<system:String>Middle</system:String>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

+31 -16
View File
@@ -1,39 +1,54 @@
using DesktopMagicPluginAPI;
using DesktopMagicPluginAPI.Inputs;
using DesktopMagicPluginAPI.Drawing;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
using System.Collections.Generic;
namespace DesktopMagicPlugin.Test
{
public class InputExamplePlugin : Plugin
public class GifPlugin : Plugin
{
public override int UpdateInterval { get; set; } = 0;
[Element("Gif path:")]
private TextBox input = new TextBox("");
[Element("Text:")] //Mark the property as element with the specified description
private TextBox textBox = new TextBox("abc"); //Create a text box with the specified default value.
private List<Bitmap> bitmaps = new List<Bitmap>();
public InputExamplePlugin()
public override int UpdateInterval { get; set; } = 100;
private int frameCount = -1;
public GifPlugin()
{
textBox.OnValueChanged += TextBox_OnValueChanged; //Add an event handler to the "OnValueChanged" event.
input.OnValueChanged += Input_OnValueChanged;
}
private void TextBox_OnValueChanged()
private void Input_OnValueChanged()
{
Application.UpdateWindow(); //Update the pugin window. (Calls the "Main" method.)
if (File.Exists(input.Value))
{
Image gif = Image.FromFile(input.Value);
bitmaps.Clear();
for (int i = 0; i < gif.GetFrameCount(FrameDimension.Time); i++)
{
gif.SelectActiveFrame(FrameDimension.Time, i);
bitmaps.Add(new Bitmap(gif));
}
}
}
public override Bitmap Main()
{
Bitmap bmp = new Bitmap(1000, 1000);
if (bitmaps.Count == 0)
return new Bitmap(1, 1);
using (Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Application.Color); //Set the background color to the color specified in the Desktop Magic application.
frameCount++;
g.DrawStringFixedWidth(textBox.Value, new Font(Application.Font, 100), Brushes.Black, new PointF(0, 0), 120); //Draw the value of the text box to the image.
}
if (frameCount >= bitmaps.Count)
frameCount = 0;
return bmp; //Return the image.
return bitmaps[frameCount];
}
}
}
@@ -10,6 +10,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>0.0.0.2</AssemblyVersion>
<PackageProjectUrl></PackageProjectUrl>
<FileVersion>0.0.0.2</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -44,6 +44,7 @@
- [Main()](#M-DesktopMagicPluginAPI-Plugin-Main 'DesktopMagicPluginAPI.Plugin.Main')
- [OnMouseClick(position)](#M-DesktopMagicPluginAPI-Plugin-OnMouseClick-System-Drawing-Point- 'DesktopMagicPluginAPI.Plugin.OnMouseClick(System.Drawing.Point)')
- [OnMouseMove(position)](#M-DesktopMagicPluginAPI-Plugin-OnMouseMove-System-Drawing-Point- 'DesktopMagicPluginAPI.Plugin.OnMouseMove(System.Drawing.Point)')
- [Start()](#M-DesktopMagicPluginAPI-Plugin-Start 'DesktopMagicPluginAPI.Plugin.Start')
- [Slider](#T-DesktopMagicPluginAPI-Inputs-Slider 'DesktopMagicPluginAPI.Inputs.Slider')
- [#ctor(min,max,value)](#M-DesktopMagicPluginAPI-Inputs-Slider-#ctor-System-Double,System-Double,System-Double- 'DesktopMagicPluginAPI.Inputs.Slider.#ctor(System.Double,System.Double,System.Double)')
- [Maximum](#P-DesktopMagicPluginAPI-Inputs-Slider-Maximum 'DesktopMagicPluginAPI.Inputs.Slider.Maximum')
@@ -338,7 +339,7 @@ Gets the window size of the main application.
##### Summary
Updates the plugin window
Updates the plugin window.
##### Parameters
@@ -445,14 +446,14 @@ DesktopMagicPluginAPI
##### Summary
The plugin class
The plugin class.
<a name='P-DesktopMagicPluginAPI-Plugin-Application'></a>
### Application `property`
##### Summary
Informations about the main application
Informations about the main application.
<a name='P-DesktopMagicPluginAPI-Plugin-UpdateInterval'></a>
### UpdateInterval `property`
@@ -502,6 +503,17 @@ Occurs when the mouse pointer is moved over the control.
| ---- | ---- | ----------- |
| position | [System.Drawing.Point](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Drawing.Point 'System.Drawing.Point') | |
<a name='M-DesktopMagicPluginAPI-Plugin-Start'></a>
### Start() `method`
##### Summary
Occurs once when the pugin gets activated.
##### Parameters
This method has no parameters.
<a name='T-DesktopMagicPluginAPI-Inputs-Slider'></a>
## Slider `type`
@@ -60,7 +60,7 @@
</member>
<member name="E:DesktopMagicPluginAPI.Inputs.Button.OnClick">
<summary>
Occurs when the button is clicked.
Occurs when the button gets clicked.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Inputs.Button.Value">
@@ -263,17 +263,17 @@
</member>
<member name="M:DesktopMagicPluginAPI.IPluginData.UpdateWindow">
<summary>
Updates the plugin window
Updates the plugin window.
</summary>
</member>
<member name="T:DesktopMagicPluginAPI.Plugin">
<summary>
The plugin class
The plugin class.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Plugin.Application">
<summary>
Informations about the main application
Informations about the main application.
</summary>
</member>
<member name="P:DesktopMagicPluginAPI.Plugin.UpdateInterval">
@@ -281,6 +281,11 @@
Gets or sets the interval, expressed in milliseconds, at which to call the <see cref="M:DesktopMagicPluginAPI.Plugin.Main"/> method.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.Start">
<summary>
Occurs once when the pugin gets activated.
</summary>
</member>
<member name="M:DesktopMagicPluginAPI.Plugin.Main">
<summary>
Occurs when the <see cref="P:DesktopMagicPluginAPI.Plugin.UpdateInterval"/> elapses.
+1 -1
View File
@@ -28,7 +28,7 @@ namespace DesktopMagicPluginAPI
Point WindowPosition { get; }
/// <summary>
/// Updates the plugin window
/// Updates the plugin window.
/// </summary>
void UpdateWindow();
}
+1 -1
View File
@@ -12,7 +12,7 @@ namespace DesktopMagicPluginAPI.Inputs
public class Button : Element
{
/// <summary>
/// Occurs when the button is clicked.
/// Occurs when the button gets clicked.
/// </summary>
public event Action OnClick;
+9 -2
View File
@@ -4,14 +4,14 @@ using System.Drawing;
namespace DesktopMagicPluginAPI
{
/// <summary>
/// The plugin class
/// The plugin class.
/// </summary>
public abstract class Plugin
{
private IPluginData application = null;
/// <summary>
/// Informations about the main application
/// Informations about the main application.
/// </summary>
public IPluginData Application
{
@@ -34,6 +34,13 @@ namespace DesktopMagicPluginAPI
/// </summary>
public virtual int UpdateInterval { get; set; } = 1000;
/// <summary>
/// Occurs once when the pugin gets activated.
/// </summary>
public virtual void Start()
{
}
/// <summary>
/// Occurs when the <see cref="UpdateInterval"/> elapses.
/// </summary>