private void BTN_Add_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; dlg.Filter = "Fichiers png (*.png)|*.png"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { WaitingForm form = new WaitingForm(); form.Show(); Application.DoEvents(); for (int i = 0; i < dlg.FileNames.Count(); i++) { using (XNAUtils utils = new XNAUtils()) { byte[] data = File.ReadAllBytes(dlg.FileNames[i]); Image image = byteArrayToImage(data); Battler battler = new Battler(dlg.SafeFileNames[i], utils.ConvertToTexture(image)); LIST_Battlers.Items.Add(battler); } } form.Close(); } }
/// <summary> /// 关闭画面 /// </summary> public static void CloseForm(WaitingForm window) { if (window != null) { window.Close(); Application.Current.MainWindow.Activate(); } }
private void CloseCallBack(WaitingForm form) { Application.Current.Dispatcher.Invoke((Action)(() => { form.Close(); Application.Current.MainWindow.Activate(); })); }
private void btnImport_Click(object sender, EventArgs e) { var waitingForm = new WaitingForm(); waitingForm.Show(); var worker = new BackgroundWorker(); worker.DoWork += (o, args) => this.LogRunningOperation(o, args); worker.OnWorkComplete += (o, args) => { waitingForm.Close(); worker.Dispose(); }; worker.RunWorkerAsync();
private void ShowThread() { WaitingForm waitingform = new WaitingForm(); waitingform.Text = this.formCaption; waitingform.Label = this.formText; if (this.parentCenter != null) { waitingform.StartPosition = FormStartPosition.Manual; waitingform.Location = new Point(parentCenter.X - waitingform.Width / 2, parentCenter.Y - waitingform.Height / 2); } ; waitingform.Show(); waitingform.Refresh(); while (showForm) { Application.DoEvents(); if (waitingform.Text != this.formCaption) { waitingform.Text = this.formCaption; } if (waitingform.Label != this.formText) { waitingform.Label = this.formText; } waitingform.Refresh(); if (isModal && ApplicationIsActive()) { waitingform.BringToFront(); waitingform.Activate(); waitingform.Focus(); waitingform.Refresh(); } ; System.Threading.Thread.Sleep(50); } ; waitingform.Close(); waitingform.Dispose(); waitingform = null; }
private void BTN_Add_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { WaitingForm form = new WaitingForm(); form.Show(); Application.DoEvents(); for (int i = 0; i < dlg.FileNames.Count(); i++) { byte[] data = File.ReadAllBytes(dlg.FileNames[i]); Sound sound = new Sound() { Data = data, Name = dlg.SafeFileNames[i] }; SoundBundle.Sounds.Add(sound); LIST_Sounds.Items.Add(sound); } form.Close(); } }
public static void closeWaitingForm(WaitingForm waitForm) { waitForm.Invoke((EventHandler)delegate { waitForm.Close(); }); waitForm = null; }
// The thread showing the waiting form private void THREADShowWaitingForm() { IsWaiting = true; WaitingForm waitingform = new WaitingForm(); waitingform.Show(); while (IsWaiting) { waitingform.Refresh(); Thread.Sleep(10); } waitingform.Close(); }
public void CompleteRecording() { if (recording) { WaitingForm wait = new WaitingForm(); //This should really be in its own thread to avoid hanging the gui. wait.Show(); wait.Refresh(); frame--; outputBlobWriter.Close(); outputBlobWriter = null; BinaryReader outputBlobReader = new BinaryReader(File.OpenRead(outputPath)); byte[] header = new byte[54]; BinaryWriter headerBuilder = new BinaryWriter(new MemoryStream(header)); int bmpSize = width * height * 3; headerBuilder.Write('B');//BMP Header headerBuilder.Write('M'); headerBuilder.Write((uint)(54 + bmpSize)); headerBuilder.Write((ushort)(0)); headerBuilder.Write((ushort)(0)); headerBuilder.Write((uint)(54)); headerBuilder.Write((uint)(40));//DIB Header headerBuilder.Write((int)(width)); headerBuilder.Write((int)(height)); headerBuilder.Write((ushort)(1)); headerBuilder.Write((ushort)(24)); headerBuilder.Write((int)(0)); headerBuilder.Write((uint)(bmpSize)); headerBuilder.Write((int)(2835));//Random values for pixels/meter that I stole from a sample, hopefully they are reasonable. headerBuilder.Write((int)(2835)); headerBuilder.Write((int)(0)); headerBuilder.Write((int)(0)); headerBuilder.Close(); string frameStringLength = frame.ToString().Length.ToString(); string framePath = Path.ChangeExtension(outputPath, null); for (int i = 0; i <= frame; i++) { FileStream frameFile = File.Create(framePath + "-" + i.ToString("D" + frameStringLength) + ".bmp"); BinaryWriter frameWriter = new BinaryWriter(frameFile); frameWriter.Write(header); frameWriter.Write(outputBlobReader.ReadBytes(bmpSize)); frameWriter.Close(); wait.ReportProgress((int)((i / (frame * 1.0)) * 100)); } outputBlobReader.Close(); File.Delete(outputPath); recording = false; wait.Close(); } }