2018-10-13 17:58:54 -07:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2018, Lars Brubaker, John Lewin, Greg Diaz
|
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2015-07-14 17:59:41 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
|
|
|
|
|
|
2018-03-10 23:01:28 -08:00
|
|
|
|
namespace MatterHackers.MatterControl
|
2015-07-14 17:59:41 -07:00
|
|
|
|
{
|
2017-11-08 15:56:37 -08:00
|
|
|
|
public class CheckForUpdatesPage : DialogPage
|
2017-06-20 05:33:49 -07:00
|
|
|
|
{
|
2017-08-06 10:45:24 -07:00
|
|
|
|
public CheckForUpdatesPage()
|
2017-12-27 07:46:40 -08:00
|
|
|
|
: base("Close".Localize())
|
2017-06-20 05:33:49 -07:00
|
|
|
|
{
|
2018-01-11 22:11:43 -08:00
|
|
|
|
this.WindowTitle = this.HeaderText = "Check for Update".Localize();
|
|
|
|
|
|
this.Padding = 0;
|
|
|
|
|
|
this.AnchorAll();
|
2017-06-20 05:33:49 -07:00
|
|
|
|
|
2018-07-11 09:26:54 -07:00
|
|
|
|
// Clear padding so UpdateControlView toolbar appears like toolbar
|
2018-11-03 10:12:27 -07:00
|
|
|
|
contentRow.Padding = 0;
|
2017-06-20 05:33:49 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
// Update Status Widget
|
2018-11-03 10:12:27 -07:00
|
|
|
|
contentRow.AddChild(
|
2018-04-07 22:51:10 -07:00
|
|
|
|
new UpdateControlView(theme));
|
2015-07-15 18:11:11 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
var contentPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
VAnchor = VAnchor.Stretch,
|
|
|
|
|
|
Padding = 8
|
|
|
|
|
|
};
|
2018-11-03 10:12:27 -07:00
|
|
|
|
contentRow.AddChild(contentPanel);
|
2015-07-15 18:11:11 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
var currentBuildInfo = new TextWidget("Current Build".Localize() + $" : {VersionInfo.Instance.BuildVersion}")
|
2017-06-20 05:33:49 -07:00
|
|
|
|
{
|
2018-01-11 22:11:43 -08:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
Margin = new BorderDouble(left: 5, bottom: 15, top: 20),
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor
|
2018-01-11 22:11:43 -08:00
|
|
|
|
};
|
|
|
|
|
|
contentPanel.AddChild(currentBuildInfo);
|
2015-07-15 18:11:11 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
var currentFeedAndDropDownContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
|
2017-06-20 05:46:22 -07:00
|
|
|
|
{
|
2018-01-11 22:11:43 -08:00
|
|
|
|
VAnchor = VAnchor.Fit,
|
|
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
};
|
|
|
|
|
|
contentPanel.AddChild(currentFeedAndDropDownContainer);
|
2017-06-20 05:46:22 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
var feedLabel = new TextWidget("Update Channel".Localize(), pointSize: 12)
|
|
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
Margin = new BorderDouble(left: 5)
|
2017-06-20 05:46:22 -07:00
|
|
|
|
};
|
2018-01-11 22:11:43 -08:00
|
|
|
|
currentFeedAndDropDownContainer.AddChild(feedLabel);
|
2015-07-15 18:11:11 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
FlowLayoutWidget additionalInfoContainer = null;
|
2017-06-20 05:33:49 -07:00
|
|
|
|
|
2018-07-11 09:26:54 -07:00
|
|
|
|
var whatsThisLink = new LinkLabel("What's this?".Localize(), theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
|
|
|
|
|
Margin = new BorderDouble(left: 6),
|
|
|
|
|
|
};
|
2017-06-20 05:33:49 -07:00
|
|
|
|
whatsThisLink.Click += (sender, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!additionalInfoContainer.Visible)
|
|
|
|
|
|
{
|
|
|
|
|
|
additionalInfoContainer.Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
additionalInfoContainer.Visible = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
currentFeedAndDropDownContainer.AddChild(whatsThisLink);
|
2018-01-11 22:11:43 -08:00
|
|
|
|
|
2017-06-20 05:33:49 -07:00
|
|
|
|
currentFeedAndDropDownContainer.AddChild(new HorizontalSpacer());
|
2018-01-11 22:11:43 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var acceptableUpdateFeedTypeValues = new List<string>() { "release", "pre-release", "development" };
|
|
|
|
|
|
|
|
|
|
|
|
string currentUpdateFeedType = UserSettings.Instance.get(UserSettingsKey.UpdateFeedType);
|
|
|
|
|
|
if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, "release");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-14 21:56:39 -07:00
|
|
|
|
var releaseOptionsDropList = new MHDropDownList("Development", theme, maxHeight: 200 * GuiWidget.DeviceScale)
|
2018-01-11 22:11:43 -08:00
|
|
|
|
{
|
2018-04-01 14:23:27 -07:00
|
|
|
|
HAnchor = HAnchor.Fit,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
};
|
|
|
|
|
|
releaseOptionsDropList.AddItem("Stable".Localize(), "release");
|
|
|
|
|
|
releaseOptionsDropList.AddItem("Beta".Localize(), "pre-release");
|
|
|
|
|
|
releaseOptionsDropList.AddItem("Alpha".Localize(), "development");
|
|
|
|
|
|
releaseOptionsDropList.SelectedValue = currentUpdateFeedType;
|
|
|
|
|
|
releaseOptionsDropList.SelectionChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string releaseCode = releaseOptionsDropList.SelectedValue;
|
|
|
|
|
|
if (releaseCode != UserSettings.Instance.get(UserSettingsKey.UpdateFeedType))
|
|
|
|
|
|
{
|
|
|
|
|
|
UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, releaseCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-13 13:27:34 -08:00
|
|
|
|
UpdateControlData.Instance.CheckForUpdate();
|
2018-01-11 22:11:43 -08:00
|
|
|
|
};
|
2017-06-20 05:33:49 -07:00
|
|
|
|
currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList);
|
|
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
2018-10-13 17:58:54 -07:00
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
Padding = new BorderDouble(left: 6, top: 6),
|
|
|
|
|
|
Visible = false
|
|
|
|
|
|
};
|
|
|
|
|
|
additionalInfoContainer.AddChild(
|
|
|
|
|
|
new WrappedTextWidget("Changing your update channel will change the version of MatterControl that you receive when updating".Localize() + ":")
|
|
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
Margin = new BorderDouble(bottom: 20)
|
|
|
|
|
|
});
|
2017-08-06 10:45:24 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
additionalInfoContainer.AddChild(
|
|
|
|
|
|
new WrappedTextWidget("Stable: The current release version of MatterControl (recommended)".Localize())
|
|
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
Margin = new BorderDouble(bottom: 10)
|
|
|
|
|
|
});
|
2017-06-20 05:33:49 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
additionalInfoContainer.AddChild(
|
|
|
|
|
|
new WrappedTextWidget("Beta: The release candidate version of MatterControl".Localize())
|
|
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
Margin = new BorderDouble(bottom: 10)
|
|
|
|
|
|
});
|
2017-06-20 05:46:22 -07:00
|
|
|
|
|
2018-01-11 22:11:43 -08:00
|
|
|
|
additionalInfoContainer.AddChild(
|
|
|
|
|
|
new WrappedTextWidget("Alpha: The in development version of MatterControl".Localize())
|
|
|
|
|
|
{
|
2018-11-03 09:13:07 -07:00
|
|
|
|
TextColor = theme.TextColor,
|
2018-01-11 22:11:43 -08:00
|
|
|
|
Margin = new BorderDouble(bottom: 10)
|
|
|
|
|
|
});
|
|
|
|
|
|
contentPanel.AddChild(additionalInfoContainer);
|
2017-06-20 05:33:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-07-14 17:59:41 -07:00
|
|
|
|
}
|