Exemple #1
0
        public async void LoadCode(Package package, Controls.OptionalPackageControl control)
        {
            try
            {
                IntPtr handle = LoadPackagedLibrary(OPT_PKG_LIB_FILE);

                if (handle == IntPtr.Zero)
                {
                    await new MessageDialog("Unable to load code file from Optional Package - Restart Main Package").ShowAsync();
                }
                else
                {
                    IntPtr factorialFuncPTR = GetProcAddress(handle, OPT_PKG_LIB_FACTORIAL_EXPORT);
                    if (factorialFuncPTR != IntPtr.Zero)
                    {
                        CodeDelegate function       = Marshal.GetDelegateForFunctionPointer <CodeDelegate>(factorialFuncPTR);
                        UInt32       inputValue     = control.CodeInputValue;
                        UInt32       functionReturn = function(inputValue);
                        control.CodeOutputValue = functionReturn;
                    }
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog("Unable to load code from Optional Package. {" + err(ex) + "}").ShowAsync();
            }
        }
Exemple #2
0
 private async void LoadPackageToUI(Package package)
 {
     await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         Controls.OptionalPackageControl opc = new Controls.OptionalPackageControl(this, package);
         optionalPackagesList.Add(opc);
     });
 }
Exemple #3
0
 public async void LoadCodeWinRT(Package package, Controls.OptionalPackageControl control)
 {
     try
     {
         //var optionalPackageWinRTClass = new OptWinRT.Class1();
         //UInt32 inputValue = control.WinRTInputValue;
         //UInt32 squareReturn = optionalPackageWinRTClass.Square(inputValue);
         //control.WinRTOutputValue = squareReturn;
     }
     catch (Exception ex)
     {
         await new MessageDialog("Unable to execute WinRT Function. {" + err(ex) + "}").ShowAsync();
     }
 }
Exemple #4
0
        public async void LoadText(Package package, Controls.OptionalPackageControl control)
        {
            try
            {
                StorageFolder installedLocation = package.InstalledLocation;
                StorageFile   textFile          = await installedLocation.GetFileAsync(OPT_PKG_TEXT_FILE);

                string textContent = await FileIO.ReadTextAsync(textFile);

                control.TextOutputValue = textContent;
            }
            catch (Exception ex)
            {
                await new MessageDialog("Unable to load text from Optional Package. {" + err(ex) + "}").ShowAsync();
            }
        }
Exemple #5
0
        public async void LoadTextLoc(Package package, Controls.OptionalPackageControl control)
        {
            try
            {
                var resourceManager = ResourceManager.Current;
                var resourceMap     = resourceManager.AllResourceMaps[package.Id.Name];
                var fileMap         = resourceMap.GetSubtree("Files");
                var textFile        = await fileMap.GetValue("Assets/Languages/textfile1.txt").GetValueAsFileAsync();

                string textContent = await FileIO.ReadTextAsync(textFile);

                control.TextOutputValueLoc = textContent;
            }
            catch (Exception ex)
            {
                await new MessageDialog("Unable to load localized text from Optional Package. {" + err(ex) + "}").ShowAsync();
            }
        }
Exemple #6
0
        public async void LoadImage(Package package, Controls.OptionalPackageControl control)
        {
            try
            {
                var resourceManager = ResourceManager.Current;
                var resourceMap     = resourceManager.AllResourceMaps[package.Id.Name];
                var fileMap         = resourceMap.GetSubtree("Files");
                var imageFile       = await fileMap.GetValue("Assets/Scales/scale-image.jpg").GetValueAsFileAsync();

                var filestream = await imageFile.OpenReadAsync();

                var logo = new BitmapImage();
                await logo.SetSourceAsync(filestream);

                control.ScaleImage.Source = logo;
            }
            catch (Exception ex)
            {
                await new MessageDialog("Unable to load scale image from Optional Package. {" + err(ex) + "}").ShowAsync();
            }
        }