Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stone-Red-Code committed Sep 10, 2021
2 parents 69774b8 + 535062e commit 24ca987
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 87 deletions.
Binary file modified src/DesktopMagic.Installer/DesktopMagic-Installer.exe
Binary file not shown.
37 changes: 2 additions & 35 deletions src/DesktopMagic.Installer/Installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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]
Expand Down
3 changes: 0 additions & 3 deletions src/DesktopMagic.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 28 additions & 1 deletion src/DesktopMagic/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Windows;
using System;
using System.Threading;
using System.Windows;

namespace DesktopMagic
{
Expand All @@ -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();
}
}
}
12 changes: 11 additions & 1 deletion src/DesktopMagic/DesktopMagic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
3 changes: 2 additions & 1 deletion src/DesktopMagic/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public MainWindow()
notifyIcon.Visible = true;
notifyIcon.Text = AppName;
notifyIcon.Icon = new System.Drawing.Icon(iconStream);
notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip();

InitializeComponent();

Expand Down Expand Up @@ -772,7 +773,7 @@ private void LayoutsComboBox_SelectionChanged(object sender, SelectionChangedEve

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 = "";
Expand Down
5 changes: 1 addition & 4 deletions src/DesktopMagic/Plugin/PluginData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public PluginData(PluginWindow win)

public Point WindowPosition => new Point((int)window.Left, (int)window.Top);

public void UpdateWindow()
{
window.UpdatePluginWindow();
}
public void UpdateWindow() => window.UpdatePluginWindow();
}
}
52 changes: 37 additions & 15 deletions src/DesktopMagic/Plugin/PluginWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Timers;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace DesktopMagic
Expand Down Expand Up @@ -190,19 +191,13 @@ private void ExecuteSource(string sourceText)
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)
Expand Down Expand Up @@ -249,16 +244,35 @@ private void ValueTimer_Elapsed(object sender, ElapsedEventArgs e)
{
//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();
try
{
Bitmap result = pluginClassInstance.Main();

//Update Image
Dispatcher.Invoke(() =>
if (pluginClassInstance.UpdateInterval > 0)
{
valueTimer.Interval = pluginClassInstance.UpdateInterval;
}
else
{
valueTimer.Stop();
}

//Update Image
Dispatcher.Invoke(() =>
{
image.Source = BitmapToImageSource(result);
});
}
catch (Exception ex)
{
image.Source = BitmapToImageSource(result);
});
MainWindow.Logger.Log(ex.ToString(), "Plugin");
MessageBox.Show("File execution error:\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Exit();
return;
}

if (stop)
{
Expand Down Expand Up @@ -312,12 +326,20 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs

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
Expand Down
1 change: 1 addition & 0 deletions src/DesktopMagic/Resources/StringResources.de.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions src/DesktopMagic/Resources/StringResources.en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file modified src/DesktopMagic/icon.ico
Binary file not shown.
Binary file added src/DesktopMagic/icon_Dark.ico
Binary file not shown.
47 changes: 31 additions & 16 deletions src/DesktopMagicPlugin.Test/PluginScript.cs
Original file line number Diff line number Diff line change
@@ -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];
}
}
}
1 change: 1 addition & 0 deletions src/DesktopMagicPluginAPI/DesktopMagicPluginAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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'">
Expand Down
Loading

0 comments on commit 24ca987

Please sign in to comment.