private void Button1_Click(object sender, EventArgs e) { if (!animator) { textBox1.Text = "animator not found"; } else if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { string file = openFileDialog1.FileName; an = AnimationLoader.Load(file); button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; button1.Text = file.Substring(file.LastIndexOf('\\') + 1); } catch (Exception exc) { button1.Text = "Choose animation file"; textBox1.Text = exc.Message + "\n" + exc.StackTrace; button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; } } }
protected void LoadAnimations(string filename) { animation = AnimationLoader.Load(filename); }
void AnimatorWindow(Animator animator) { var timer = new Time(); ClearChildrens(fixed4); fileChooser = new FileChooserButton("Select a File", FileChooserAction.Open); fileChooser.WidthRequest = 124; fileChooser.Name = "filechooserbutton2"; fixed4.Put(fileChooser, 0, 19); fileChooser.Show(); // Container child fixed1.Gtk.Fixed+FixedChild var btnStart = new Button(); btnStart.WidthRequest = 109; btnStart.Name = "button2"; btnStart.Label = "Play"; fixed4.Put(btnStart, 0, 63); btnStart.Show(); // Container child fixed1.Gtk.Fixed+FixedChild var btn = new Button(); btn.WidthRequest = 110; btn.CanFocus = true; btn.Name = "button3"; btn.Label = "Stop"; fixed4.Put(btn, 0, 108); btn.Show(); // Container child fixed1.Gtk.Fixed+FixedChild var btnPR = new Button(); btnPR.WidthRequest = 110; btnPR.CanFocus = true; btnPR.Name = "button4"; btnPR.Label = "Pause"; fixed4.Put(btnPR, 0, 153); btnPR.Show(); fileChooser.FileSet += (sender, e) => { try { var an = AnimationLoader.Load(fileChooser.Filename); if (an != null) { animator.AnimationData = an; } } catch (Exception ex) { Console.WriteLine("cant load animation\n{0}\n{1}", ex.Message, ex.StackTrace); } }; //Play bool play = false; bool pause = false; btnStart.Clicked += (sender, e) => { animator.Play(); play = true; }; btn.Clicked += (sender, e) => { play = false; animator.Stop(); }; btnPR.Clicked += (sender, e) => { if (play && !pause) { animator.Pause(); btnPR.Label = "Resume"; pause = !pause; } else if (play) { animator.Resume(); btnPR.Label = "Pause"; pause = !pause; } }; }