mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-28 17:34:06 +02:00
Refactor code to avoid nulls (#206)
* Ensure potential nulls have a fallback value & add/remove null checks * Refactor update check code to avoid nulls * Refactor ProfileManager exception handling to avoid nulls * Refactor a few more various classes and fix nulls in ContextInfo * Force c#7 everywhere and revert usage of newer features from cherry-picked commits * Remove unused #pragma declaration
This commit is contained in:
parent
ed317a4e46
commit
f1f90a2ee3
Core
Plugins/Controls
Program.csTweetDuck.csprojUpdates
lib/TweetLib.Communication
subprocess
tests
video
@ -132,7 +132,7 @@ void ViewImage(string path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
string url = LastLink.GetMediaSource(parameters);
|
string url = LastLink.GetMediaSource(parameters);
|
||||||
string file = Path.Combine(BrowserCache.CacheFolder, TwitterUtils.GetImageFileName(url));
|
string file = Path.Combine(BrowserCache.CacheFolder, TwitterUtils.GetImageFileName(url) ?? Path.GetRandomFileName());
|
||||||
|
|
||||||
if (File.Exists(file)){
|
if (File.Exists(file)){
|
||||||
ViewImage(file);
|
ViewImage(file);
|
||||||
@ -187,7 +187,7 @@ protected void OpenBrowser(Control control, string url){
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void SetClipboardText(Control control, string text){
|
protected void SetClipboardText(Control control, string text){
|
||||||
control.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
|
control.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text ?? string.Empty, TextDataFormat.UnicodeText));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void AddDebugMenuItems(IMenuModel model){
|
protected static void AddDebugMenuItems(IMenuModel model){
|
||||||
|
@ -11,7 +11,12 @@ public ContextInfo(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void SetLink(string type, string url){
|
public void SetLink(string type, string url){
|
||||||
Link = new LinkInfo(string.IsNullOrEmpty(url) ? null : type, url);
|
if (string.IsNullOrEmpty(url)){
|
||||||
|
Link = new LinkInfo();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Link = new LinkInfo(type, url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
public void SetChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
||||||
|
@ -23,7 +23,6 @@ public enum Items{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRestarting { get; private set; }
|
public bool IsRestarting { get; private set; }
|
||||||
public Exception LastException { get; private set; }
|
|
||||||
|
|
||||||
private readonly string file;
|
private readonly string file;
|
||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
@ -67,7 +66,7 @@ public bool Export(Items items){
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
LastException = e;
|
Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting TweetDuck profile.", true, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,8 +99,7 @@ public Items FindImportItems(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception){
|
||||||
LastException = e;
|
|
||||||
items = Items.None;
|
items = Items.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,12 +162,12 @@ public bool Import(Items items){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (missingPlugins.Count > 0){
|
if (missingPlugins.Count > 0){
|
||||||
FormMessage.Information("Importing TweetDuck Profile", "Detected missing plugins when importing plugin data:\n"+string.Join("\n", missingPlugins), FormMessage.OK);
|
FormMessage.Information("Profile Import", "Detected missing plugins when importing plugin data:\n"+string.Join("\n", missingPlugins), FormMessage.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
LastException = e;
|
Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing TweetDuck profile.", true, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,15 +197,23 @@ public static void DeleteCookies(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<PathInfo> EnumerateFilesRelative(string root){
|
private static IEnumerable<PathInfo> EnumerateFilesRelative(string root){
|
||||||
return Directory.Exists(root) ? Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories).Select(fullPath => new PathInfo{
|
if (Directory.Exists(root)){
|
||||||
Full = fullPath,
|
int rootLength = root.Length;
|
||||||
Relative = fullPath.Substring(root.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) // strip leading separator character
|
return Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories).Select(fullPath => new PathInfo(fullPath, rootLength));
|
||||||
}) : Enumerable.Empty<PathInfo>();
|
}
|
||||||
|
else{
|
||||||
|
return Enumerable.Empty<PathInfo>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class PathInfo{
|
private sealed class PathInfo{
|
||||||
public string Full { get; set; }
|
public string Full { get; }
|
||||||
public string Relative { get; set; }
|
public string Relative { get; }
|
||||||
|
|
||||||
|
public PathInfo(string fullPath, int rootLength){
|
||||||
|
this.Full = fullPath;
|
||||||
|
this.Relative = fullPath.Substring(rootLength).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); // strip leading separator character
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ sealed class VideoPlayer : IDisposable{
|
|||||||
public event EventHandler ProcessExited;
|
public event EventHandler ProcessExited;
|
||||||
|
|
||||||
private readonly FormBrowser owner;
|
private readonly FormBrowser owner;
|
||||||
private string lastUrl;
|
|
||||||
private string lastUsername;
|
|
||||||
|
|
||||||
private Instance currentInstance;
|
private Instance currentInstance;
|
||||||
private bool isClosing;
|
private bool isClosing;
|
||||||
@ -30,9 +28,6 @@ public void Launch(string url, string username){
|
|||||||
Destroy();
|
Destroy();
|
||||||
isClosing = false;
|
isClosing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUrl = url;
|
|
||||||
lastUsername = username;
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
DuplexPipe.Server pipe = DuplexPipe.CreateServer();
|
DuplexPipe.Server pipe = DuplexPipe.CreateServer();
|
||||||
@ -46,7 +41,7 @@ public void Launch(string url, string username){
|
|||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true
|
RedirectStandardOutput = true
|
||||||
})) != null){
|
})) != null){
|
||||||
currentInstance = new Instance(process, pipe);
|
currentInstance = new Instance(process, pipe, url, username);
|
||||||
|
|
||||||
process.EnableRaisingEvents = true;
|
process.EnableRaisingEvents = true;
|
||||||
process.Exited += process_Exited;
|
process.Exited += process_Exited;
|
||||||
@ -81,9 +76,9 @@ private void pipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "download":
|
case "download":
|
||||||
if (!string.IsNullOrEmpty(lastUrl)){
|
if (currentInstance != null){
|
||||||
owner.AnalyticsFile.DownloadedVideos.Trigger();
|
owner.AnalyticsFile.DownloadedVideos.Trigger();
|
||||||
TwitterUtils.DownloadVideo(lastUrl, lastUsername);
|
TwitterUtils.DownloadVideo(currentInstance.Url, currentInstance.Username);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -147,6 +142,7 @@ private void process_Exited(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int exitCode = currentInstance.Process.ExitCode;
|
int exitCode = currentInstance.Process.ExitCode;
|
||||||
|
string url = currentInstance.Url;
|
||||||
|
|
||||||
currentInstance.Dispose();
|
currentInstance.Dispose();
|
||||||
currentInstance = null;
|
currentInstance = null;
|
||||||
@ -154,14 +150,14 @@ private void process_Exited(object sender, EventArgs e){
|
|||||||
switch(exitCode){
|
switch(exitCode){
|
||||||
case 3: // CODE_LAUNCH_FAIL
|
case 3: // CODE_LAUNCH_FAIL
|
||||||
if (FormMessage.Error("Video Playback Error", "Error launching video player, this may be caused by missing Windows Media Player. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){
|
if (FormMessage.Error("Video Playback Error", "Error launching video player, this may be caused by missing Windows Media Player. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){
|
||||||
BrowserUtils.OpenExternalBrowser(lastUrl);
|
BrowserUtils.OpenExternalBrowser(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // CODE_MEDIA_ERROR
|
case 4: // CODE_MEDIA_ERROR
|
||||||
if (FormMessage.Error("Video Playback Error", "The video could not be loaded, most likely due to unknown format. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){
|
if (FormMessage.Error("Video Playback Error", "The video could not be loaded, most likely due to unknown format. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){
|
||||||
BrowserUtils.OpenExternalBrowser(lastUrl);
|
BrowserUtils.OpenExternalBrowser(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -185,9 +181,14 @@ public bool Running{
|
|||||||
public Process Process { get; }
|
public Process Process { get; }
|
||||||
public DuplexPipe.Server Pipe { get; }
|
public DuplexPipe.Server Pipe { get; }
|
||||||
|
|
||||||
public Instance(Process process, DuplexPipe.Server pipe){
|
public string Url { get; }
|
||||||
|
public string Username { get; }
|
||||||
|
|
||||||
|
public Instance(Process process, DuplexPipe.Server pipe, string url, string username){
|
||||||
this.Process = process;
|
this.Process = process;
|
||||||
this.Pipe = pipe;
|
this.Pipe = pipe;
|
||||||
|
this.Url = url;
|
||||||
|
this.Username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KillAndDispose(){
|
public void KillAndDispose(){
|
||||||
|
@ -24,7 +24,7 @@ protected override FormBorderStyle NotificationBorderStyle{
|
|||||||
private readonly TweetNotification exampleNotification;
|
private readonly TweetNotification exampleNotification;
|
||||||
|
|
||||||
public FormNotificationExample(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, false){
|
public FormNotificationExample(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, false){
|
||||||
string exampleTweetHTML = ScriptLoader.LoadResource("pages/example.html", true).Replace("{avatar}", TweetNotification.AppLogo.Url);
|
string exampleTweetHTML = ScriptLoader.LoadResource("pages/example.html", true)?.Replace("{avatar}", TweetNotification.AppLogo.Url) ?? string.Empty;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
exampleTweetHTML = exampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:256px'>Scrollbar test padding...</div>");
|
exampleTweetHTML = exampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:256px'>Scrollbar test padding...</div>");
|
||||||
|
@ -217,7 +217,9 @@ protected virtual void UpdateTitle(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ShowTweetDetail(){
|
public void ShowTweetDetail(){
|
||||||
owner.ShowTweetDetail(currentNotification.ColumnId, currentNotification.ChirpId, currentNotification.TweetUrl);
|
if (currentNotification != null){
|
||||||
|
owner.ShowTweetDetail(currentNotification.ColumnId, currentNotification.ChirpId, currentNotification.TweetUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveToVisibleLocation(){
|
public void MoveToVisibleLocation(){
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace TweetDuck.Core.Notification{
|
namespace TweetDuck.Core.Notification{
|
||||||
sealed class TweetNotification{
|
sealed class TweetNotification{
|
||||||
private const string DefaultHeadLayout = @"<html id='tduck' class='os-windows txt-size--14' data-td-font='medium' data-td-theme='dark'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='chrome=1'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/font.5ef884f9f9.css'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/app-dark.5631e0dd42.css'><style type='text/css'>body{background:#222426}</style>";
|
private const string DefaultHeadLayout = @"<html id='tduck' class='os-windows txt-size--14' data-td-font='medium' data-td-theme='dark'><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='chrome=1'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/font.5ef884f9f9.css'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/app-dark.5631e0dd42.css'><style type='text/css'>body{background:#222426}</style>";
|
||||||
private static readonly string CustomCSS = ScriptLoader.LoadResource("styles/notification.css");
|
private static readonly string CustomCSS = ScriptLoader.LoadResource("styles/notification.css") ?? string.Empty;
|
||||||
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
|
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
|
||||||
|
|
||||||
public static TweetNotification Example(string html, int characters){
|
public static TweetNotification Example(string html, int characters){
|
||||||
|
@ -21,7 +21,7 @@ static AnalyticsFile(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly AnalyticsFile Dummy = new AnalyticsFile(null);
|
public static readonly AnalyticsFile Dummy = new AnalyticsFile();
|
||||||
|
|
||||||
// STATE PROPERTIES
|
// STATE PROPERTIES
|
||||||
|
|
||||||
@ -67,6 +67,10 @@ private AnalyticsFile(string file){
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AnalyticsFile(){
|
||||||
|
this.file = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void SetupProperties(){
|
private void SetupProperties(){
|
||||||
foreach(Counter counter in GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(prop => prop.PropertyType == typeof(Counter)).Select(prop => (Counter)prop.GetValue(this))){
|
foreach(Counter counter in GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(prop => prop.PropertyType == typeof(Counter)).Select(prop => (Counter)prop.GetValue(this))){
|
||||||
counter.SetOwner(this);
|
counter.SetOwner(this);
|
||||||
|
@ -58,11 +58,8 @@ private FormGuide(string url, FormBrowser owner){
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Guide";
|
Text = Program.BrandName+" Guide";
|
||||||
|
Size = new Size(owner.Size.Width*3/4, owner.Size.Height*3/4);
|
||||||
if (owner != null){
|
VisibleChanged += (sender, args) => this.MoveToCenter(owner);
|
||||||
Size = new Size(owner.Size.Width*3/4, owner.Size.Height*3/4);
|
|
||||||
VisibleChanged += (sender, args) => this.MoveToCenter(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.browser = new ChromiumWebBrowser(url){
|
this.browser = new ChromiumWebBrowser(url){
|
||||||
MenuHandler = new ContextMenuGuide(owner),
|
MenuHandler = new ContextMenuGuide(owner),
|
||||||
|
@ -164,9 +164,6 @@ private void btnContinue_Click(object sender, EventArgs e){
|
|||||||
ShouldReloadBrowser = true;
|
ShouldReloadBrowser = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
Program.Reporter.HandleException("Profile Import Error", "An exception happened while importing TweetDuck profile.", true, importManager.LastException);
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
@ -191,12 +188,8 @@ private void btnContinue_Click(object sender, EventArgs e){
|
|||||||
|
|
||||||
Program.UserConfig.Save();
|
Program.UserConfig.Save();
|
||||||
Program.SystemConfig.Save();
|
Program.SystemConfig.Save();
|
||||||
|
|
||||||
ProfileManager manager = new ProfileManager(file, plugins);
|
new ProfileManager(file, plugins).Export(SelectedItems);
|
||||||
|
|
||||||
if (!manager.Export(SelectedItems)){
|
|
||||||
Program.Reporter.HandleException("Profile Export Error", "An exception happened while exporting TweetDuck profile.", true, manager.LastException);
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
|
@ -170,7 +170,7 @@ private void btnCheckUpdates_Click(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updates_CheckFinished(object sender, UpdateEventArgs e){
|
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||||
this.InvokeAsyncSafe(() => {
|
this.InvokeAsyncSafe(() => {
|
||||||
if (e.EventId == updateCheckEventId){
|
if (e.EventId == updateCheckEventId){
|
||||||
btnCheckUpdates.Enabled = true;
|
btnCheckUpdates.Enabled = true;
|
||||||
|
@ -42,12 +42,12 @@ private void checkSpellCheck_CheckedChanged(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void comboBoxSpellCheckLanguage_SelectedValueChanged(object sender, EventArgs e){
|
private void comboBoxSpellCheckLanguage_SelectedValueChanged(object sender, EventArgs e){
|
||||||
Config.SpellCheckLanguage = (comboBoxSpellCheckLanguage.SelectedItem as LocaleUtils.Item)?.Code;
|
Config.SpellCheckLanguage = (comboBoxSpellCheckLanguage.SelectedItem as LocaleUtils.Item)?.Code ?? "en-US";
|
||||||
PromptRestart();
|
PromptRestart();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void comboBoxTranslationTarget_SelectedValueChanged(object sender, EventArgs e){
|
private void comboBoxTranslationTarget_SelectedValueChanged(object sender, EventArgs e){
|
||||||
Config.TranslationTarget = (comboBoxTranslationTarget.SelectedItem as LocaleUtils.Item)?.Code;
|
Config.TranslationTarget = (comboBoxTranslationTarget.SelectedItem as LocaleUtils.Item)?.Code ?? "en";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ public void UpdateProperties(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void InjectBrowserCSS(){
|
public void InjectBrowserCSS(){
|
||||||
browser.ExecuteScriptAsync("TDGF_injectBrowserCSS", ScriptLoader.LoadResource("styles/browser.css").TrimEnd());
|
browser.ExecuteScriptAsync("TDGF_injectBrowserCSS", ScriptLoader.LoadResource("styles/browser.css")?.TrimEnd() ?? string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReinjectCustomCSS(string css){
|
public void ReinjectCustomCSS(string css){
|
||||||
|
@ -36,7 +36,7 @@ public PluginControl(PluginManager pluginManager, Plugin plugin) : this(){
|
|||||||
labelDescription.Visible = false;
|
labelDescription.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
panelDescription_Resize(panelDescription, null);
|
panelDescription_Resize(panelDescription, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void panelDescription_Resize(object sender, EventArgs e){
|
private void panelDescription_Resize(object sender, EventArgs e){
|
||||||
|
@ -151,10 +151,9 @@ private static void Main(){
|
|||||||
|
|
||||||
Application.ApplicationExit += (sender, args) => ExitCleanup();
|
Application.ApplicationExit += (sender, args) => ExitCleanup();
|
||||||
|
|
||||||
UpdaterSettings updaterSettings = new UpdaterSettings{
|
UpdaterSettings updaterSettings = new UpdaterSettings(InstallerPath){
|
||||||
AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates),
|
AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates),
|
||||||
DismissedUpdate = UserConfig.DismissedUpdate,
|
DismissedUpdate = UserConfig.DismissedUpdate
|
||||||
InstallerDownloadFolder = InstallerPath
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FormBrowser mainForm = new FormBrowser(updaterSettings);
|
FormBrowser mainForm = new FormBrowser(updaterSettings);
|
||||||
|
@ -291,6 +291,7 @@
|
|||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Reporter.cs" />
|
<Compile Include="Reporter.cs" />
|
||||||
|
<Compile Include="Updates\Events\UpdateCheckEventArgs.cs" />
|
||||||
<Compile Include="Updates\FormUpdateDownload.cs">
|
<Compile Include="Updates\FormUpdateDownload.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -312,7 +313,7 @@
|
|||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Resources\ScriptLoader.cs" />
|
<Compile Include="Resources\ScriptLoader.cs" />
|
||||||
<Compile Include="Updates\UpdateEventArgs.cs" />
|
<Compile Include="Updates\Events\UpdateEventArgs.cs" />
|
||||||
<Compile Include="Updates\UpdaterSettings.cs" />
|
<Compile Include="Updates\UpdaterSettings.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
13
Updates/Events/UpdateCheckEventArgs.cs
Normal file
13
Updates/Events/UpdateCheckEventArgs.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TweetDuck.Updates{
|
||||||
|
sealed class UpdateCheckEventArgs : EventArgs{
|
||||||
|
public int EventId { get; }
|
||||||
|
public bool IsUpdateAvailable { get; }
|
||||||
|
|
||||||
|
public UpdateCheckEventArgs(int eventId, bool isUpdateAvailable){
|
||||||
|
this.EventId = eventId;
|
||||||
|
this.IsUpdateAvailable = isUpdateAvailable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Updates/Events/UpdateEventArgs.cs
Normal file
11
Updates/Events/UpdateEventArgs.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TweetDuck.Updates{
|
||||||
|
sealed class UpdateEventArgs : EventArgs{
|
||||||
|
public UpdateInfo UpdateInfo { get; }
|
||||||
|
|
||||||
|
public UpdateEventArgs(UpdateInfo updateInfo){
|
||||||
|
this.UpdateInfo = updateInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace TweetDuck.Updates{
|
|
||||||
sealed class UpdateEventArgs : EventArgs{
|
|
||||||
public int EventId { get; }
|
|
||||||
public UpdateInfo UpdateInfo { get; }
|
|
||||||
|
|
||||||
public bool IsUpdateAvailable => UpdateInfo != null;
|
|
||||||
|
|
||||||
public UpdateEventArgs(int eventId, UpdateInfo updateInfo){
|
|
||||||
this.EventId = eventId;
|
|
||||||
this.UpdateInfo = updateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateEventArgs(UpdateInfo updateInfo){
|
|
||||||
this.EventId = updateInfo.EventId;
|
|
||||||
this.UpdateInfo = updateInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,7 @@ sealed class UpdateHandler{
|
|||||||
|
|
||||||
public event EventHandler<UpdateEventArgs> UpdateAccepted;
|
public event EventHandler<UpdateEventArgs> UpdateAccepted;
|
||||||
public event EventHandler<UpdateEventArgs> UpdateDismissed;
|
public event EventHandler<UpdateEventArgs> UpdateDismissed;
|
||||||
public event EventHandler<UpdateEventArgs> CheckFinished;
|
public event EventHandler<UpdateCheckEventArgs> CheckFinished;
|
||||||
|
|
||||||
private ushort lastEventId;
|
private ushort lastEventId;
|
||||||
private UpdateInfo lastUpdateInfo;
|
private UpdateInfo lastUpdateInfo;
|
||||||
@ -93,7 +93,7 @@ private void TriggerUpdateDismissedEvent(UpdateEventArgs args){
|
|||||||
UpdateDismissed?.Invoke(this, args);
|
UpdateDismissed?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TriggerCheckFinishedEvent(UpdateEventArgs args){
|
private void TriggerCheckFinishedEvent(UpdateCheckEventArgs args){
|
||||||
CheckFinished?.Invoke(this, args);
|
CheckFinished?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ public void OnUpdateCheckFinished(int eventId, string versionTag, string downloa
|
|||||||
owner.lastUpdateInfo = new UpdateInfo(owner.settings, eventId, versionTag, downloadUrl);
|
owner.lastUpdateInfo = new UpdateInfo(owner.settings, eventId, versionTag, downloadUrl);
|
||||||
owner.lastUpdateInfo.BeginSilentDownload();
|
owner.lastUpdateInfo.BeginSilentDownload();
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.TriggerCheckFinishedEvent(new UpdateEventArgs(eventId, owner.lastUpdateInfo));
|
owner.TriggerCheckFinishedEvent(new UpdateCheckEventArgs(eventId, owner.lastUpdateInfo != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUpdateAccepted(){
|
public void OnUpdateAccepted(){
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
namespace TweetDuck.Updates{
|
namespace TweetDuck.Updates{
|
||||||
sealed class UpdaterSettings{
|
sealed class UpdaterSettings{
|
||||||
|
public string InstallerDownloadFolder { get; }
|
||||||
|
|
||||||
public bool AllowPreReleases { get; set; }
|
public bool AllowPreReleases { get; set; }
|
||||||
public string DismissedUpdate { get; set; }
|
public string DismissedUpdate { get; set; }
|
||||||
public string InstallerDownloadFolder { get; set; }
|
|
||||||
|
public UpdaterSettings(string installerDownloadFolder){
|
||||||
|
this.InstallerDownloadFolder = installerDownloadFolder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@ -20,6 +20,7 @@
|
|||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<LangVersion>7</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<OutputPath>bin\x86\Release\</OutputPath>
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<LangVersion>7</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@ -22,6 +22,7 @@
|
|||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
<LangVersion>7</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
@ -22,6 +22,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<LangVersion>7</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<OutputPath>bin\x86\Release\</OutputPath>
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
Loading…
Reference in New Issue
Block a user