Put in a check for updates menu

This commit is contained in:
Lars Brubaker 2015-05-22 12:33:59 -07:00
parent 1f1ec9f701
commit 108dbee140
3 changed files with 76 additions and 27 deletions

View file

@ -38,9 +38,10 @@ namespace MatterHackers.MatterControl
public class ApplicationMenuRow : FlowLayoutWidget
{
private static FlowLayoutWidget rightElement;
private event EventHandler unregisterEvents;
LinkButtonFactory linkButtonFactory = new LinkButtonFactory();
public static bool AlwaysShowUpdateStatus { get; set; }
GuiWidget popUpAboutPage;
public ApplicationMenuRow()
@ -60,11 +61,6 @@ namespace MatterHackers.MatterControl
MenuOptionFile menuOptionFile = new MenuOptionFile();
this.AddChild(menuOptionFile);
#if false
// put in the view menu
MenuOptionView menuOptionView = new MenuOptionView();
this.AddChild(menuOptionView);
#endif
MenuOptionSettings menuOptionSettings = new MenuOptionSettings();
this.AddChild(menuOptionSettings);
@ -109,6 +105,26 @@ namespace MatterHackers.MatterControl
}
}
public delegate void AddRightElementDelegate(GuiWidget iconContainer);
public static event AddRightElementDelegate AddRightElement
{
add
{
privateAddRightElement += value;
// and call it right away
value(rightElement);
}
remove
{
privateAddRightElement -= value;
}
}
private static event AddRightElementDelegate privateAddRightElement;
private event EventHandler unregisterEvents;
public override void OnClosed(EventArgs e)
{
if (unregisterEvents != null)
@ -158,32 +174,41 @@ namespace MatterHackers.MatterControl
break;
case UpdateControlData.UpdateStatusStates.UpToDate:
if (AlwaysShowUpdateStatus)
{
popUpAboutPage.RemoveAllChildren();
TextWidget updateStatusMessage = new TextWidget("Up to Date".Localize(), textColor: ActiveTheme.Instance.PrimaryAccentColor, pointSize: linkButtonFactory.fontSize);
updateStatusMessage.VAnchor = VAnchor.ParentCenter;
popUpAboutPage.AddChild(updateStatusMessage);
popUpAboutPage.Visible = true;
UiThread.RunOnIdle((state) => popUpAboutPage.Visible = false, 3);
AlwaysShowUpdateStatus = false;
}
else
{
popUpAboutPage.Visible = false;
}
break;
case UpdateControlData.UpdateStatusStates.CheckingForUpdate:
popUpAboutPage.Visible = false;
if (AlwaysShowUpdateStatus)
{
popUpAboutPage.RemoveAllChildren();
TextWidget updateStatusMessage = new TextWidget("Checking For Update".Localize(), textColor: ActiveTheme.Instance.PrimaryAccentColor, pointSize: linkButtonFactory.fontSize);
updateStatusMessage.VAnchor = VAnchor.ParentCenter;
popUpAboutPage.AddChild(updateStatusMessage);
popUpAboutPage.Visible = true;
}
else
{
popUpAboutPage.Visible = false;
}
break;
default:
throw new NotImplementedException();
}
}
public delegate void AddRightElementDelegate(GuiWidget iconContainer);
private static event AddRightElementDelegate privateAddRightElement;
public static event AddRightElementDelegate AddRightElement
{
add
{
privateAddRightElement += value;
// and call it right away
value(rightElement);
}
remove
{
privateAddRightElement -= value;
}
}
}
}

View file

@ -20,8 +20,11 @@ namespace MatterHackers.MatterControl
{
{LocalizedString.Get("Getting Started"), gettingStarted_Click},
{LocalizedString.Get("View Help"), help_Click},
{LocalizedString.Get("Report a Bug"), bug_Click},
{LocalizedString.Get("Release Notes"), notes_Click},
{LocalizedString.Get("------------------------"), nothing_Click},
{LocalizedString.Get("Report a Bug"), bug_Click},
{LocalizedString.Get("Check For Update"), checkForUpdate_Click},
{LocalizedString.Get("------------------------"), nothing_Click},
{LocalizedString.Get("About MatterControl"), about_Click},
};
}
@ -44,6 +47,16 @@ namespace MatterHackers.MatterControl
return true;
}
private bool checkForUpdate_Click()
{
UiThread.RunOnIdle((state) =>
{
ApplicationMenuRow.AlwaysShowUpdateStatus = true;
UpdateControlData.Instance.CheckForUpdateUserRequested();
});
return true;
}
private bool about_Click()
{
UiThread.RunOnIdle((state) =>
@ -53,6 +66,11 @@ namespace MatterHackers.MatterControl
return true;
}
private bool nothing_Click()
{
return true;
}
private bool notes_Click()
{
UiThread.RunOnIdle((state) =>

View file

@ -3259,3 +3259,9 @@ Translated:solid_shell
English:GCode file too big to preview ({0}).
Translated:GCode file too big to preview ({0}).
English:Up to Date
Translated:Up to Date
English:Checking For Update
Translated:Checking For Update