Skip to content

Commit

Permalink
Version 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmayer-dev committed Jan 16, 2022
1 parent b42afe9 commit bb1de1b
Show file tree
Hide file tree
Showing 40 changed files with 1,411 additions and 308 deletions.
1 change: 0 additions & 1 deletion ActionButton/ButtonLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class ButtonLabel
private string _labelBase64 = "";
private string _labelHex128_64Base64 = "";

[JsonIgnore]
public string LabelBase64
{
get { return _labelBase64; }
Expand Down
34 changes: 23 additions & 11 deletions Backup/BackupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,20 @@ public static void RestoreBackup(string backupFileName, RestoreBackupInfo restor
serializer.Serialize(writer, restoreBackupInfo);
}

Process.Start(Path.Combine(MacroDeck.MainDirectoryPath, AppDomain.CurrentDomain.FriendlyName), "--show");
Environment.Exit(0);
} catch { }
MacroDeck.RestartMacroDeck("--show");
} catch (Exception ex) {

MacroDeckLogger.Error("Backup restoration failed: " + ex.Message + Environment.NewLine + ex.StackTrace);
}
}


public static void CreateBackup()
{
if (BackupInProgress) return;
BackupInProgress = true;
string backupFileName = "backup_" + DateTime.Now.ToString("ddmmyyhhmmss") + ".zip";
string backupFileName = string.Format("backup_{0}.zip", DateTime.Now.ToString("yy-MM-dd_HH-mm-ss"));
MacroDeckLogger.Info("Sarting creation of backup: " + backupFileName);

try
{
Expand All @@ -230,37 +233,42 @@ public static void CreateBackup()
DirectoryInfo pluginDirectoryInfo = new DirectoryInfo(directory);
foreach (FileInfo file in pluginDirectoryInfo.GetFiles("*"))
{
archive.CreateEntryFromFile(Path.Combine(MacroDeck.PluginsDirectoryPath, pluginDirectoryInfo.Name, file.Name), new DirectoryInfo(MacroDeck.PluginsDirectoryPath).Name + "/" + pluginDirectoryInfo.Name + "/" + file.Name);
archive.CreateEntryFromFile(Path.Combine(MacroDeck.PluginsDirectoryPath, pluginDirectoryInfo.Name, file.Name), Path.Combine(new DirectoryInfo(MacroDeck.PluginsDirectoryPath).Name, pluginDirectoryInfo.Name, file.Name));
}
}
DirectoryInfo pluginConfigDirectoryInfo = new DirectoryInfo(MacroDeck.PluginConfigPath);
foreach (FileInfo file in pluginConfigDirectoryInfo.GetFiles("*"))
{
archive.CreateEntryFromFile(Path.Combine(MacroDeck.PluginConfigPath, file.Name), pluginConfigDirectoryInfo.Name + "/" + file.Name);
archive.CreateEntryFromFile(Path.Combine(MacroDeck.PluginConfigPath, file.Name), Path.Combine(pluginConfigDirectoryInfo.Name, file.Name));
}
DirectoryInfo pluginCredentialsDirectoryInfo = new DirectoryInfo(MacroDeck.PluginCredentialsPath);
foreach (FileInfo file in pluginCredentialsDirectoryInfo.GetFiles("*"))
{
archive.CreateEntryFromFile(Path.Combine(MacroDeck.PluginCredentialsPath, file.Name), pluginCredentialsDirectoryInfo.Name + "/" + file.Name);
archive.CreateEntryFromFile(Path.Combine(MacroDeck.PluginCredentialsPath, file.Name), Path.Combine(pluginCredentialsDirectoryInfo.Name, file.Name));
}
DirectoryInfo iconPackDirectoryInfo = new DirectoryInfo(MacroDeck.IconPackDirectoryPath);
foreach (FileInfo file in iconPackDirectoryInfo.GetFiles("*"))
{
archive.CreateEntryFromFile(Path.Combine(MacroDeck.IconPackDirectoryPath, file.Name), iconPackDirectoryInfo.Name + "/" + file.Name);
archive.CreateEntryFromFile(Path.Combine(MacroDeck.IconPackDirectoryPath, file.Name), Path.Combine(iconPackDirectoryInfo.Name, file.Name));
}

MacroDeckLogger.Info("Backup successfully created: " + backupFileName);
if (BackupSaved != null)
{
BackupSaved(null, EventArgs.Empty);
}
}
} catch (Exception ex) {
} catch (Exception ex)
{
MacroDeckLogger.Error("Backup creation failed: " + ex.Message + Environment.NewLine + ex.StackTrace);
if (BackupFailed != null)
{
BackupFailed(null, new BackupFailedEventArgs() { Message = ex.Message });
}
} finally
{
BackupInProgress = false;
}
BackupInProgress = false;
}

public static void DeleteBackup(string fileName)
Expand All @@ -270,11 +278,15 @@ public static void DeleteBackup(string fileName)
try
{
File.Delete(fileName);
MacroDeckLogger.Info("Backup successfully deleted: " + fileName);
if (DeleteSuccess != null)
{
DeleteSuccess(null, EventArgs.Empty);
}
} catch { }
} catch (Exception ex)
{
MacroDeckLogger.Error("Backup deletion failed: " + ex.Message + Environment.NewLine + ex.StackTrace);
}
}
}

Expand Down
61 changes: 54 additions & 7 deletions Folders/Plugin/FolderPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using SuchByte.MacroDeck.GUI;
using SuchByte.MacroDeck.GUI.CustomControls;
using SuchByte.MacroDeck.Language;
using SuchByte.MacroDeck.Logging;
using SuchByte.MacroDeck.Plugins;
using SuchByte.MacroDeck.Profiles;
using SuchByte.MacroDeck.Server;
Expand Down Expand Up @@ -35,7 +36,22 @@ public class FolderSwitcher : PluginAction

public override void Trigger(string clientId, ActionButton.ActionButton actionButton)
{
MacroDeckServer.SetFolder(MacroDeckServer.GetMacroDeckClient(clientId), ProfileManager.FindFolderById(this.Configuration, MacroDeckServer.GetMacroDeckClient(clientId).Profile));
MacroDeckLogger.Trace("Switch folder triggered by " + clientId);
switch (clientId)
{
// ClientID -1 or "" = Macro Deck software itself
case "":
case "-1":
if (MacroDeck.MainWindow != null && MacroDeck.MainWindow.DeckView != null)
{
MacroDeck.MainWindow.DeckView.SetFolder(ProfileManager.FindFolderById(this.Configuration, ProfileManager.CurrentProfile));
}
break;
// ClientId != -1 = Connected device
default:
MacroDeckServer.SetFolder(MacroDeckServer.GetMacroDeckClient(clientId), ProfileManager.FindFolderById(this.Configuration, MacroDeckServer.GetMacroDeckClient(clientId).Profile));
break;
}
}
public override ActionConfigControl GetActionConfigControl(ActionConfigurator actionConfigurator)
{
Expand All @@ -51,9 +67,24 @@ public override void Trigger(string clientId, ActionButton.ActionButton actionBu
{
try
{
MacroDeckClient macroDeckClient = MacroDeckServer.GetMacroDeckClient(clientId);
MacroDeckFolder parentFolder = ProfileManager.FindParentFolder(macroDeckClient.Folder, macroDeckClient.Profile);
MacroDeckServer.SetFolder(macroDeckClient, parentFolder);
MacroDeckLogger.Trace("Go to parent folder triggered by " + clientId);
switch (clientId)
{
// ClientID -1 or "" = Macro Deck software itself
case "":
case "-1":
if (MacroDeck.MainWindow != null && MacroDeck.MainWindow.DeckView != null)
{
MacroDeck.MainWindow.DeckView.SetFolder(ProfileManager.FindParentFolder(MacroDeck.MainWindow.DeckView.CurrentFolder, ProfileManager.CurrentProfile));
}
break;
// ClientId != -1 = Connected device
default:
MacroDeckClient macroDeckClient = MacroDeckServer.GetMacroDeckClient(clientId);
MacroDeckFolder parentFolder = ProfileManager.FindParentFolder(macroDeckClient.Folder, macroDeckClient.Profile);
MacroDeckServer.SetFolder(macroDeckClient, parentFolder);
break;
}
} catch { }
}
public override ActionConfigControl GetActionConfigControl(ActionConfigurator actionConfigurator)
Expand All @@ -70,9 +101,25 @@ public override void Trigger(string clientId, ActionButton.ActionButton actionBu
{
try
{
MacroDeckClient macroDeckClient = MacroDeckServer.GetMacroDeckClient(clientId);
MacroDeckFolder rootFolder = macroDeckClient.Profile.Folders.Find(folder => folder.IsRootFolder);
MacroDeckServer.SetFolder(macroDeckClient, rootFolder);
MacroDeckLogger.Trace("Go to root folder triggered by " + clientId);
switch (clientId)
{
// ClientID -1 or "" = Macro Deck software itself
case "":
case "-1":
if (MacroDeck.MainWindow != null && MacroDeck.MainWindow.DeckView != null)
{
MacroDeck.MainWindow.DeckView.SetFolder(ProfileManager.CurrentProfile.Folders.Find(folder => folder.IsRootFolder));
}
break;
// ClientId != -1 = Connected device
default:
MacroDeckClient macroDeckClient = MacroDeckServer.GetMacroDeckClient(clientId);
MacroDeckFolder rootFolder = macroDeckClient.Profile.Folders.Find(folder => folder.IsRootFolder);
MacroDeckServer.SetFolder(macroDeckClient, rootFolder);
break;
}

}
catch { }
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace SuchByte.MacroDeck.GUI.CustomControls
{
public partial class InitialSetupIconPackItem : UserControl
public partial class InitialSetupIconPackItem : RoundedUserControl
{
private JObject _jsonObject;

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion GUI/CustomControls/InitialSetup/InitialSetupPluginItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace SuchByte.MacroDeck.GUI.CustomControls
{
public partial class InitialSetupPluginItem : UserControl
public partial class InitialSetupPluginItem : RoundedUserControl
{
private JObject _jsonObject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ public void Uninstall()

if (msgBox.ShowDialog("", String.Format(Language.LanguageManager.Strings.XSuccessfullyUninstalled, this._jsonObject["name"].ToString()), MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Process.Start(MacroDeck.MainDirectoryPath + AppDomain.CurrentDomain.FriendlyName, "--show");
Environment.Exit(0);
MacroDeck.RestartMacroDeck("--show");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions GUI/Dialogs/AddFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public AddFolder(MacroDeckFolder folder, bool rename)
InitializeComponent();
this.UpdateTranslation();
this.btnCreateFolder.Text = Language.LanguageManager.Strings.Save;
this.folderName.Enabled = !folder.IsRootFolder;
}

private void UpdateTranslation()
Expand Down
Loading

0 comments on commit bb1de1b

Please sign in to comment.