-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deferred settings application system + new shortcut settings
this system took way too much effort to think of for some reason idk why
- Loading branch information
1 parent
f3110f4
commit 7e95fb4
Showing
13 changed files
with
354 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Bloxstrap.Models.SettingTasks | ||
{ | ||
public class BaseTask : ISettingTask | ||
{ | ||
private bool _originalState; | ||
|
||
private bool _newState; | ||
|
||
public string Name { get; set; } = ""; | ||
|
||
public bool OriginalState | ||
{ | ||
get | ||
{ | ||
return _originalState; | ||
} | ||
|
||
set | ||
{ | ||
_originalState = value; | ||
_newState = value; | ||
} | ||
} | ||
|
||
public bool NewState | ||
{ | ||
get | ||
{ | ||
return _newState; | ||
} | ||
|
||
set | ||
{ | ||
App.PendingSettingTasks[Name] = this; | ||
_newState = value; | ||
} | ||
} | ||
|
||
public virtual void Execute() => throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Bloxstrap.Models.SettingTasks | ||
{ | ||
public interface ISettingTask | ||
{ | ||
public bool OriginalState { get; set; } | ||
|
||
public bool NewState { get; set; } | ||
|
||
public void Execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Bloxstrap.Models.SettingTasks | ||
{ | ||
public class ShortcutTask : BaseTask, ISettingTask | ||
{ | ||
public string ExeFlags { get; set; } = ""; | ||
|
||
public string ShortcutPath { get; set; } | ||
|
||
public ShortcutTask(string shortcutPath) | ||
{ | ||
ShortcutPath = shortcutPath; | ||
|
||
OriginalState = File.Exists(ShortcutPath); | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
if (NewState == OriginalState) | ||
return; | ||
|
||
if (NewState) | ||
Shortcut.Create(Paths.Application, ExeFlags, ShortcutPath); | ||
else | ||
File.Delete(ShortcutPath); | ||
|
||
OriginalState = NewState; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.