Esempio n. 1
0
        /// <summary>
        /// Creates the runtime proxy for package.
        /// Provide runtime specific settings to package here.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <returns>Package.</returns>
        /// <remarks>...</remarks>
        public override Package Proxify(Package package)
        {
            // Stop old package.
            package.Save();

            // Find internal package type.
            if (package.SettingsStorage.Has(package, HtmlAppPackage.PackageTypeId))
            {
                var newPackage = new HtmlAppPackage(package.Location, package.SettingsStorage);
                return(newPackage);
            }
            if (package.SettingsStorage.Has(package, AppLinkPackage.PackageTypeId))
            {
                var newPackage = new AppLinkPackage(package.Location, package.SettingsStorage);
                return(newPackage);
            }
            if (package.SettingsStorage.Has(package, NewgenPackage.PackageTypeId))
            {
                // 1. Find the compiled assembly.
                var packageAssemblyPath = Path.Combine(package.Location, package.GetId() + ".dll");

                // 2. Load assembly into memory.
                var packageAssembly = Assembly.LoadFrom(packageAssemblyPath);

                // 3. Find, create, load package.
                var newPackage = Activator.CreateInstance(
                    packageAssembly.GetTypes().FirstOrDefault(f => typeof(Package).IsAssignableFrom(f)),
                    (object)package.Location,
                    package.SettingsStorage
                    ) as NewgenPackage;
                if (newPackage != null)
                {
                    newPackage.ProxyProvider = Package;
                    newPackage.Load();

                    return(newPackage);
                }
            }

            return(base.Proxify(package));
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the <see cref="E:PinWebItemClick" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        /// <remarks>...</remarks>
        private void OnPinWebItemClick(object sender, RoutedEventArgs e)
        {
            CloseToolbar();

            var bar = new AppLinkPackageAddressBarWindow();

            bar.ShowDialog();
            var uri = default(Uri);

            if (!Uri.TryCreate(bar.AddressBox.Text, UriKind.RelativeOrAbsolute, out uri) || string.IsNullOrWhiteSpace(uri.OriginalString))
            {
                return;
            }

            App.PM.LoadPackage(new AppLinkPackage(uri.OriginalString, Path.Combine(Api.PackagesRoot, AppLinkPackage.GetPackageId(uri.OriginalString)), App.PSS));
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the <see cref="E:PinAppItemClick" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        /// <remarks>...</remarks>
        private void OnPinAppItemClick(object sender, RoutedEventArgs e)
        {
            CloseToolbar();

            var dlg = new OpenFileDialog();

            dlg.Filter = Api.AnyFilter;
            if (!(bool)dlg.ShowDialog())
            {
                return;
            }

            App.PM.LoadPackage(new AppLinkPackage(dlg.FileName, Path.Combine(Api.PackagesRoot, AppLinkPackage.GetPackageId(dlg.FileName)), App.PSS));
        }
Esempio n. 4
0
        /// <summary>
        /// Handles the <see cref="E:PinDirItemClick" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        /// <remarks>...</remarks>
        private void OnPinDirItemClick(object sender, RoutedEventArgs e)
        {
            CloseToolbar();

            var dlg = new System.Windows.Forms.FolderBrowserDialog();

            if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            App.PM.LoadPackage(new AppLinkPackage(dlg.SelectedPath, Path.Combine(Api.PackagesRoot, AppLinkPackage.GetPackageId(dlg.SelectedPath)), App.PSS));
        }
Esempio n. 5
0
 /// <summary>
 /// Handles the <see cref="E:Drop" /> event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="DragEventArgs" /> instance containing the event data.</param>
 /// <remarks>...</remarks>
 private void OnDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop, true))
     {
         foreach (var path in e.Data.GetData(DataFormats.FileDrop, true) as string[])
         {
             if (File.Exists(path))
             {
                 App.PM.LoadPackage(new AppLinkPackage(path, Path.Combine(Api.PackagesRoot, AppLinkPackage.GetPackageId(path)), App.PSS));
             }
         }
     }
 }