Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NewgenPackage" /> class.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="settingsStorage">The settings storage.</param>
        /// <remarks>...</remarks>
        public HtmlAppPackage(string location, IPackageSettingsStorage settingsStorage)
            : base(location, settingsStorage)
        {
            // Package type marker.
            SettingsStorage.Put(this, PackageTypeId, PackageTypeId);

            // Pre-load settings for html apps.
            // This prevent abnormal behavious as Row/Column span for html apps are included in settings file
            // while app expects them as compiled defaults.
            Load();

            // Update html app settings.
            customizedSettings = GetSettings().Customize <HtmlAppPackageCustomizedSettings>(s => {
            });

            if (
                !File.Exists(Path.Combine(Location, customizedSettings.TilePage))
                &&
                !File.Exists(Path.Combine(Location, customizedSettings.TilePageImage))
                )
            {
                throw new Exception("Not a valid html app package !");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewgenPackage" /> class.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <param name="settingsStorage">The settings storage.</param>
 /// <remarks>...</remarks>
 public NewgenPackage(string location, IPackageSettingsStorage settingsStorage)
     : base(location, settingsStorage)
 {
     // Package type marker.
     SettingsStorage.Put(this, PackageTypeId, PackageTypeId);
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppLinkPackage" /> class.
        /// </summary>
        /// <param name="linkPath">The link path.</param>
        /// <param name="location">The location.</param>
        /// <param name="settingsStorage">The settings storage.</param>
        /// <remarks>...</remarks>
        public AppLinkPackage(string linkPath, string location, IPackageSettingsStorage settingsStorage)
            : base(location, settingsStorage) {
            if (!Directory.Exists(location))
                Directory.CreateDirectory(location);

            // Package type marker.
            SettingsStorage.Put(this, PackageTypeId, PackageTypeId);

            // Pre-load settings for app link apps.
            // This prevent abnormal behavious as Row/Column span for html apps are included in settings file
            // while app expects them as compiled defaults.
            Load();

            // Create settings
            customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                s.LinkPath = linkPath;
                s.IconPath = Path.Combine(Location, "Icon.png");
                s.ScreenshotPath = Path.Combine(Location, "Screenshot.png");
            });

            // Create icons and texts
            Uri uri;
            if (Uri.TryCreate(customizedSettings.LinkPath, UriKind.RelativeOrAbsolute, out uri)
                &&
                (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
                ) {
                // For url
                customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                    s.IsUrl = true;
                });

                browser = new System.Windows.Forms.WebBrowser();
                browser.ScrollBarsEnabled = false;
                browser.ScriptErrorsSuppressed = true;
                browser.DocumentCompleted += OnbrowserDocumentCompleted;
                browser.Width = (int)SystemParameters.WorkArea.Width;
                browser.Height = (int)SystemParameters.WorkArea.Height;
                browser.Navigate(customizedSettings.LinkPath);
            }
            else {
                // For file / folder

                // Check shell
                if (!File.Exists(customizedSettings.LinkPath) & !Directory.Exists(customizedSettings.LinkPath))
                    return;

                // Check Directory
                if (Directory.Exists(customizedSettings.LinkPath))
                    customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                        s.IsFolder = true;
                    });

                // Create texts
                customizedSettings = GetSettings().Customize<AppLinkPackageCustomizedSettings>(s => {
                    if (customizedSettings.IsFolder)
                        s.Title = new DirectoryInfo(s.LinkPath).Name;
                    else
                        s.Title = FileVersionInfo.GetVersionInfo(s.LinkPath).FileDescription ?? new FileInfo(s.LinkPath).Name;
                });

                // Create images
                var icon = InternalHelper.GetThumbnail(customizedSettings.LinkPath) as BitmapSource;
                icon.ToFile(new PngBitmapEncoder(), Path.Combine(Location, customizedSettings.IconPath));

                // Create tile color
                GetSettings().ObjectData[TileControl.TileBgColorKey] = icon.CalculateAverageColor(0xFF).ToString();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewgenPackage" /> class.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <param name="settingsStorage">The settings storage.</param>
 /// <remarks>...</remarks>
 public AppLinkPackage(string location, IPackageSettingsStorage settingsStorage)
     : base(location, settingsStorage) {
 }