public MoleculeProcessingProgress(LoadingProgress loadingProgress)
     : base("Molecule Processing", loadingProgress)
 {
 }
Ejemplo n.º 2
0
        async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            //viewModel.Items.Clear();
            var item = args.SelectedItem as Models.Character;

            if (item == null)
            {
                return;
            }
            BuilderContext Context = new BuilderContext(item.Player);
            PluginManager  manager = new PluginManager();

            manager.Add(new SpellPoints());
            manager.Add(new SingleLanguage());
            manager.Add(new CustomBackground());
            manager.Add(new NoFreeEquipment());
            Context.Plugins = manager;

            //Task.Run(async () =>
            //     {
            //         if (Context.Player.FilePath is IFile file)
            //         {
            //             string name = file.Name;
            //             IFile target = await (await App.Storage.CreateFolderAsync("Backups", CreationCollisionOption.OpenIfExists).ConfigureAwait(false)).CreateFileAsync(name, CreationCollisionOption.ReplaceExisting).ConfigureAwait(false);
            //             using (Stream fout = await target.OpenAsync(FileAccess.ReadAndWrite))
            //             {
            //                 using (Stream fin = await file.OpenAsync(FileAccess.Read))
            //                 {
            //                     await fin.CopyToAsync(fout);
            //                 }
            //             };
            //         }
            //     }).Forget();
            Context.UndoBuffer         = new LinkedList <Player>();
            Context.RedoBuffer         = new LinkedList <Player>();
            Context.UnsavedChanges     = 0;
            ItemsListView.SelectedItem = null;
            LoadingProgress loader = new LoadingProgress(Context);
            LoadingPage     l      = new LoadingPage(loader);
            await Navigation.PushModalAsync(l);

            var t = l.Cancel.Token;

            try
            {
                await loader.Load(t).ConfigureAwait(false);

                t.ThrowIfCancellationRequested();
                PlayerBuildModel model = new PlayerBuildModel(Context);
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await Navigation.PopModalAsync(false);
                    await Navigation.PushModalAsync(new NavigationPage(new FlexPage(model)));
                });
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                IsBusy = false;
                (sender as ListView).SelectedItem = null;
            }
            // Manually deselect item
        }
 public MoleculeLoadingProgress(string molName, LoadingProgress loadingProgress)
     : base("Molecule Loading", loadingProgress)
 {
     this.molName = molName;
 }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     Instance = this;
 }
Ejemplo n.º 5
0
        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            Task.Run(async() =>
            {
                if ("Inbox".Equals(Path.GetFileName(Path.GetDirectoryName(url.Path))))
                {
                    IFolder incoming = await App.Storage.CreateFolderAsync("Incoming", CreationCollisionOption.OpenIfExists);
                    IFile f          = await FileSystem.Current.GetFileFromPathAsync(url.Path);
                    await f.MoveAsync(Path.Combine(incoming.Path, f.Name), NameCollisionOption.GenerateUniqueName);
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                    {
                        App.MainTab.SelectedItem = App.MainTab.Children[3];
                        await App.MainTab.Children[3].Navigation.PopToRootAsync();
                        await App.MainTab.Children[3].Navigation.PushAsync(new FileBrowser(incoming));
                    });
                }
                else if (url.Path?.EndsWith(".cb5") ?? false)
                {
                    url.StartAccessingSecurityScopedResource();
                    try {
                        //using (MemoryStream s = new MemoryStream()) {
                        //    NSInputStream stream = NSInputStream.FromUrl(url);
                        //    byte[] buffer = new byte[1024];
                        //    while (stream.HasBytesAvailable()) {
                        //        int read = (int)stream.Read(buffer, 1024);
                        //        s.Write(buffer, 0, read);
                        //    }
                        //    s.Seek(0, SeekOrigin.Begin);
                        //NSFileHandle fs = NSFileHandle.OpenReadUrl(url, out NSError err);
                        //NSData data = fs.ReadDataToEndOfFile();
                        //fs.CloseFile();
                        //using (Stream f = data.AsStream()) {AsStream
                        //new MyInputStream(NSInputStream.FromUrl(url))) {
                        //NSData d = await url.LoadDataAsync("text/xml");
                        //File.OpenRead(url.Path)
                        using (Stream s = File.OpenRead(url.Path)) {
                            Player player          = Player.Serializer.Deserialize(s) as Player;
                            BuilderContext Context = new BuilderContext(player);
                            PluginManager manager  = new PluginManager();
                            manager.Add(new SpellPoints());
                            manager.Add(new SingleLanguage());
                            manager.Add(new CustomBackground());
                            manager.Add(new NoFreeEquipment());
                            Context.Plugins = manager;


                            Context.UndoBuffer     = new LinkedList <Player>();
                            Context.RedoBuffer     = new LinkedList <Player>();
                            Context.UnsavedChanges = 0;

                            Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                            {
                                LoadingProgress loader   = new LoadingProgress(Context);
                                LoadingPage l            = new LoadingPage(loader, false);
                                App.MainTab.SelectedItem = App.MainTab.Children[1];
                                await App.MainTab.Children[2].Navigation.PushModalAsync(l);
                                var t = l.Cancel.Token;
                                try
                                {
                                    await loader.Load(t).ConfigureAwait(false);
                                    t.ThrowIfCancellationRequested();
                                    PlayerBuildModel model = new PlayerBuildModel(Context);
                                    Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                                    {
                                        await App.MainTab.Children[1].Navigation.PopModalAsync(false);
                                        await App.MainTab.Children[1].Navigation.PushModalAsync(new NavigationPage(new FlexPage(model)));
                                    });
                                } catch (Exception e) {
                                    ConfigManager.LogError(e);
                                }
                            });
                        }
                        url.StopAccessingSecurityScopedResource();
                    }
                    catch (Exception e)
                    {
                        ConfigManager.LogError(e);
                    }
                }
                else if (url.Path.StartsWith(App.Storage.Path, System.StringComparison.Ordinal))
                {
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                    {
                        App.MainTab.SelectedItem = App.MainTab.Children[3];
                        await App.MainTab.Children[3].Navigation.PopToRootAsync();
                        await App.MainTab.Children[3].Navigation.PushAsync(new FileBrowser(await FileSystem.Current.GetFolderFromPathAsync(Path.GetDirectoryName(url.Path))));
                    });
                }
                else
                {
                    url.StartAccessingSecurityScopedResource();
                    IFolder incoming = await App.Storage.CreateFolderAsync("Incoming", CreationCollisionOption.OpenIfExists);
                    IFile target     = await incoming.CreateFileAsync(url.LastPathComponent, CreationCollisionOption.GenerateUniqueName);
                    using (Stream f = File.OpenRead(url.Path))
                    {
                        using (Stream o = await target.OpenAsync(PCLStorage.FileAccess.ReadAndWrite))
                        {
                            await f.CopyToAsync(o);
                        }
                    }
                    url.StopAccessingSecurityScopedResource();
                    Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
                    {
                        App.MainTab.SelectedItem = App.MainTab.Children[3];
                        await App.MainTab.Children[3].Navigation.PopToRootAsync();
                        await App.MainTab.Children[3].Navigation.PushAsync(new FileBrowser(incoming));
                    });
                }
            }).Forget();
            return(true);
        }
Ejemplo n.º 6
0
 public virtual void GotoScene()
 {
     LoadingProgress.LoadScene((int)wantToGoSceneName);
 }
Ejemplo n.º 7
0
 public ObstacleFactory(LunchHourGames lhg, LoadingProgress progress)
 {
     this.lhg      = lhg;
     this.progress = progress;
 }
 public LoadingPage(LoadingProgress loader)
 {
     InitializeComponent();
     BindingContext = loader;
 }
Ejemplo n.º 9
0
 private async void Browser_Navigating(object sender, WebNavigatingEventArgs e)
 {
     LoadingProgress.IsVisible = true;
     await LoadingProgress.ProgressTo(.9, 900, Easing.SpringIn);
 }
Ejemplo n.º 10
0
 protected async override void OnAppearing()
 {
     base.OnAppearing();
     await LoadingProgress.ProgressTo(.9, 900, Easing.SpringIn);
 }