// start the coroutine to load asynchronously and generate a progress bar prefab private void LoadLevelAsync(int levelIndex) { if (_loadProgressBarPrefab != null) { _loadProgressBar = Object.Instantiate(_loadProgressBarPrefab, Vector3.zero, Quaternion.identity); _loadProgressBar.InitSlider(); } StartCoroutine(LoadLevelAsyncRoutine(levelIndex)); }
void Awake() { _instance = this; bg = transform.Find("bg").gameObject; progressBar = transform.Find("bg/ProgressBar").GetComponent <UISlider> (); gameObject.SetActive(false); //Application.LoadLevelAsync (2); }
private void cmdLoadColumns_Click(object sender, EventArgs e) { //new set of parts will be loaded parts.Clear(); //get the selected index from each box. //this corresponds to the column in wich the data is stored in the csv for (int i = 0; i < NewColumnIndex.Length; i++) { NewColumnIndex[i] = SelectorBoxes[i].SelectedIndex; } if (NewColumnIndex.Contains <int>(-1)) { lblPartsCount.Text = "Not every field selected!"; return; } //actually add the Parts: //open File StreamReader sr = File.OpenText(openFile); //get first line with all the Descriptions of the columns String line = sr.ReadLine(); //this doesnt matter at all now. //line Counter to estimate the Progress-Bar int ProcessedLines = 0; while ((line = sr.ReadLine()) != null) { //skip any empty lines if (line != "") { //this will get the Columns, already sorted in the order stated above at the declaration of "NewColumnIndex". String[] Columns = GetColumnsfromLine(line); //get Part-Objects from column set and add them to the list parts.AddRange(ParseLine(Columns)); } ProcessedLines++; //set the text on the form lblPartsCount.Text = "Lines Processed: " + ProcessedLines.ToString() + "/" + NumLines.ToString(); //update the progress bar LoadProgressBar.Value = 100 * ProcessedLines / NumLines; //refresh the form for visual updates LoadProgressBar.Refresh(); lblPartsCount.Refresh(); } this.Close(); this.Dispose(); }
private void ShowFileList(string path) { FileListView.Items.Clear(); LoadProgressBar.Value = 0; try { FileExplorer fileExplorer = new FileExplorer(path); int maxFilesCount = fileExplorer.Files.Length + fileExplorer.Directories.Length; LoadProgressBar.Maximum = maxFilesCount; int currentFileCount = 0; string currentNum = ""; Graphics gr = LoadProgressBar.CreateGraphics(); foreach (var item in fileExplorer.Directories) { string[] details = { item.Name, "DIR", fileExplorer.FormatFileSize(fileExplorer.GetDirectorySize(item)), item.LastAccessTime.ToShortDateString(), item.Attributes.ToString() }; ListViewItem listViewItem = new ListViewItem(details); FileListView.Items.Add(listViewItem); listViewItem.ImageIndex = 0; currentFileCount += 1; currentNum = currentFileCount + " of " + maxFilesCount + " files loaded."; gr.Clear(LoadProgressBar.BackColor); gr.DrawString(currentNum, SystemFonts.DefaultFont, Brushes.Black, new PointF( (LoadProgressBar.Width / 2) - (gr.MeasureString(currentNum, SystemFonts.DefaultFont).Width / 2.0F), (LoadProgressBar.Height / 2) - gr.MeasureString(currentNum, SystemFonts.DefaultFont).Height / 2.0F)); LoadProgressBar.Increment(1); } foreach (var item in fileExplorer.Files) { string[] details = { item.Name, item.Extension, fileExplorer.FormatFileSize(item.Length), item.LastAccessTime.ToShortDateString(), item.Attributes.ToString() }; ListViewItem listViewItem = new ListViewItem(details); FileListView.Items.Add(listViewItem); listViewItem.ImageIndex = 1; currentFileCount += 1; currentNum = currentFileCount + " of " + maxFilesCount + " files loaded."; gr.Clear(LoadProgressBar.BackColor); gr.DrawString(currentNum, SystemFonts.DefaultFont, Brushes.Black, new PointF( (LoadProgressBar.Width / 2) - (gr.MeasureString(currentNum, SystemFonts.DefaultFont).Width / 2.0F), (LoadProgressBar.Height / 2) - gr.MeasureString(currentNum, SystemFonts.DefaultFont).Height / 2.0F)); LoadProgressBar.Increment(1); } } catch (UnauthorizedAccessException ex) { MessageBox.Show($"File or folder cannot be accessed.\n\nError message: {ex.Message}\n\n" + $"Details:\n\n{ex.StackTrace}"); } }
private void OnLoadSongList() { _paths = SongListOperator.Instance.LoadDirectorySongList(); var progressable = new LoadProgressBar(this, p => { if (!p.IsCanceled) { var text = $"共导入{MainViewModel.SongList.Count}首歌曲"; MessageBox.Show(text); } }); ProgressRunner.Run(progressable); }
public void IncrementLoadValue() { LoadProgressBar.PerformStep(); }