/// <summary>
		/// Initialization override for update management
		/// </summary>
		/// <param name="pluginOptions"></param>
		public override void Initialize(IProperties pluginOptions)
		{
			// Base
			base.Initialize(pluginOptions);

			// Initiate update management
			bool checkAtStartup = pluginOptions.GetBoolean(Updater.CheckUpdatesOnStartupOptionName, true);
			if (checkAtStartup)
			{
				Updater.Check(pluginOptions);
			}
		}
Exemplo n.º 2
0
 public static MarginStyle GetImageMargin(IProperties props)
 {
     if (props.GetBoolean(CUSTOM_MARGIN, false))
     {
         int top    = props.GetInt(MARGIN_TOP, WriterDefaultMargin.Top);
         int right  = props.GetInt(MARGIN_RIGHT, WriterDefaultMargin.Right);
         int bottom = props.GetInt(MARGIN_BOTTOM, WriterDefaultMargin.Bottom);
         int left   = props.GetInt(MARGIN_LEFT, WriterDefaultMargin.Left);
         return(new MarginStyle(top, right, bottom, left, StyleSizeUnit.PX));
     }
     else
     {
         return(WriterDefaultMargin);
     }
 }
Exemplo n.º 3
0
        public static Options ToOptions(this IProperties source)
        {
            var options = new Options();

            if (source == null)
            {
                return(options);
            }
            options.InLineStyles    = source.GetBoolean(nameof(Options.InLineStyles), defaultOptions.InLineStyles);
            options.MaxHeight       = source.GetInt(nameof(Options.MaxHeight), defaultOptions.MaxHeight);
            options.BackgroundColor = source.GetString(nameof(Options.BackgroundColor), defaultOptions.BackgroundColor);
            options.FontSize        = source.GetInt(nameof(Options.FontSize), defaultOptions.FontSize);
            options.FontFamiles     = (source.GetString(nameof(Options.FontFamiles), string.Join(", ", defaultOptions.FontFamiles)) ?? "")
                                      .Split(',').Select(x => x.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
            options.TabSpaces = source.GetInt(nameof(Options.TabSpaces), defaultOptions.TabSpaces);
            return(options);
        }
		/// <summary>
		/// Check on startup
		/// </summary>
		/// <param name="properties">Plugin properties</param>
		/// <param name="ownerWindow">Owner window if any</param>
		public static void Check(IProperties properties, IWin32Window ownerWindow = null)
		{
			bool includePreReleaseVersions = properties.GetBoolean(IncludePreReleaseVersionsOptionName, false);
			VersionInfo latestVersion = GetLatestVersion(includePreReleaseVersions);
			string currentDateTime = DateTime.UtcNow.ToLocalTime().ToString("F", CultureInfo.CurrentCulture);
			properties.SetString(LastUpdateCheckDateOptionName, currentDateTime);

			// Check if latest version is more than installed version
			if (latestVersion == null)
			{
				if (ownerWindow != null)
				{
					MessageBox.Show(ownerWindow, Resources.Error_UpdateCheckFailure, Resources.Label_Warning);
				}
			}
			else if (latestVersion.Version > InstalledVersion.Version)
			{
				if (DialogResult.OK == MessageBox.Show(ownerWindow, string.Format(CultureInfo.CurrentCulture, Resources.Text_LatestVersionAvailableDownloadPrompt_Version,
								latestVersion.Version),
							Resources.Label_Information, MessageBoxButtons.OKCancel, MessageBoxIcon.Question,
							MessageBoxDefaultButton.Button1))
				{
					using (var updateForm = new DownloadUpdateForm(latestVersion))
					{
						DialogResult result = updateForm.ShowDialog(ownerWindow);
						if ((result == DialogResult.OK)
							&& updateForm.Downloaded)
						{
							Process.Start(new ProcessStartInfo(updateForm.DownloadedSetupFile));
						}
					}
				}
			}
			else
			{
				if (ownerWindow != null)
				{
					MessageBox.Show(ownerWindow, string.Format(CultureInfo.CurrentCulture, Resources.Text_InstalledVersionUpToDate_Version, InstalledVersion.Version), Resources.Label_Information);
				}
			}
		}
 public static MarginStyle GetImageMargin(IProperties props)
 {
     if (props.GetBoolean(CUSTOM_MARGIN, false))
     {
         int top = props.GetInt(MARGIN_TOP, WriterDefaultMargin.Top);
         int right = props.GetInt(MARGIN_RIGHT, WriterDefaultMargin.Right);
         int bottom = props.GetInt(MARGIN_BOTTOM, WriterDefaultMargin.Bottom);
         int left = props.GetInt(MARGIN_LEFT, WriterDefaultMargin.Left);
         return new MarginStyle(top, right, bottom, left, StyleSizeUnit.PX);
     }
     else
     {
         return WriterDefaultMargin;
     }
 }
Exemplo n.º 6
0
 public bool GetBoolean(string name, bool defaultValue)
 {
     return(CurrProperties.GetBoolean(name, defaultValue));
 }