void UpdateButton(DialogButton btn, Gtk.Button b) { if (!string.IsNullOrEmpty(btn.Label) && btn.Image == null) { b.Label = btn.Label; } else if (string.IsNullOrEmpty(btn.Label) && btn.Image != null) { var pix = btn.Image.ToImageDescription(); b.Image = new ImageBox(ApplicationContext, pix); } else if (!string.IsNullOrEmpty(btn.Label)) { Gtk.Box box = new Gtk.HBox(false, 3); var pix = btn.Image.ToImageDescription(); box.PackStart(new ImageBox(ApplicationContext, pix), false, false, 0); box.PackStart(new Gtk.Label(btn.Label), true, true, 0); b.Image = box; } if (btn.Visible) { b.ShowAll(); } else { b.Hide(); } b.Sensitive = btn.Sensitive; UpdateActionAreaVisibility(); }
void UpdateButton(DialogButton btn, Gtk.Button b) { if (!string.IsNullOrEmpty(btn.Label) && btn.Image == null) { b.Label = btn.Label; } else if (string.IsNullOrEmpty(btn.Label) && btn.Image != null) { var pix = (Gdk.Pixbuf)WidgetRegistry.GetBackend(btn.Image); b.Image = new Gtk.Image(pix); } else if (!string.IsNullOrEmpty(btn.Label)) { Gtk.Box box = new Gtk.HBox(false, 3); var pix = (Gdk.Pixbuf)WidgetRegistry.GetBackend(btn.Image); box.PackStart(new Gtk.Image(pix), false, false, 0); box.PackStart(new Gtk.Label(btn.Label), true, true, 0); b.Image = box; } if (btn.Visible) { b.ShowAll(); } else { b.Hide(); } b.Sensitive = btn.Sensitive; }
private void CreateGui() { Gtk.FileChooserButton fc = new Gtk.FileChooserButton("Choose directory to put your splitted files", Gtk.FileChooserAction.SelectFolder); string fn = Banshee.Configuration.ConfigurationClient.Get <string>("cuesheets_todevice", ""); if (fn != "") { fc.SelectFilename(fn); } fc.FileSet += new EventHandler(delegate(Object sender, EventArgs args) { fn = fc.Filename; Banshee.Configuration.ConfigurationClient.Set <string>("cuesheets_todevice", fn); }); Gtk.Button btn = new Gtk.Button("Split CueSheet Audio File"); Gtk.Button csplit = new Gtk.Button("Cancel"); csplit.Clicked += delegate(object sender, EventArgs args) { _splt.CancelSplit(); }; Gtk.ProgressBar bar = new Gtk.ProgressBar(); Gtk.ProgressBar nr = new Gtk.ProgressBar(); Gtk.Button ok = (Gtk.Button)base.AddButton("OK", 1); Gtk.Label result = new Gtk.Label("-"); btn.Clicked += delegate(object sender, EventArgs args) { btn.Hide(); csplit.Show(); result.Markup = ""; ok.Sensitive = false; fc.Sensitive = false; btn.Sensitive = false; _splt.SplitWithPaths(); bool convert_to_latin1 = true; _splt.SplitToDir(fn, convert_to_latin1); GLib.Timeout.Add(50, delegate() { bar.Fraction = _splt.ProgressOfCurrentTrack; int n = _splt.ProgressNTracks; int i = _splt.ProgressCurrentTrack; double d = ((double)i) / ((double)n); nr.Fraction = d; if (_splt.SplitFinished) { ok.Sensitive = true; btn.Sensitive = true; fc.Sensitive = true; csplit.Hide(); btn.Show(); if (_splt.Cancelled) { result.Markup = "<b>Split Cancelled</b>"; } else { result.Markup = "<b>Finished</b>"; } } return(!_splt.SplitFinished); }); }; fc.Show(); nr.Show(); bar.Show(); btn.Show(); result.Show(); base.VBox.Add(fc); base.VBox.Add(hsep()); base.VBox.Add(nr); base.VBox.Add(bar); base.VBox.Add(hsep()); base.VBox.Add(result); base.VBox.Add(hsep()); base.VBox.Add(btn); base.VBox.Add(csplit); base.VBox.Show(); }
private static void DataListenLoop() { try { int cyclesCount = 0; System.Timers.Timer timer = new System.Timers.Timer(1000); timer.Elapsed += (sender, args) => { main.cycleSpeedReceive.Text = cyclesCount.ToString(); cyclesCount = 0; }; timer.Enabled = true; while (true) { Socket pipeListener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); pipeListener.Bind(new IPEndPoint(localIP, 4578)); pipeListener.Listen(10); pipe = pipeListener.Accept(); //int startTime = DateTime.Now.Millisecond; while (pipe.Connected) { cyclesCount++; //main.cycleSpeedReceive.Text = (DateTime.Now.Millisecond - startTime).ToString(); //startTime = DateTime.Now.Millisecond; //Thread.Sleep(10); int bytes = 0; byte[] data = new byte[30000]; do { bytes = pipe.Receive(data); } while (pipe.Available > 0); try { object imgData = Serializer.BytesToObj(data, bytes); if (!(imgData is ImageStreamPart)) { throw new Exception("Wrong data!"); } data = (imgData as ImageStreamPart).bitmap; //decompressing byte[] decompressedImage = new byte[(imgData as ImageStreamPart).originalSize]; LZ4Codec.Decode(data, decompressedImage); strWin.img.Pixbuf = new Gdk.Pixbuf(decompressedImage); if (disconnectRequest) { pipe.Disconnect(true); pipe.Dispose(); pipe = null; discBtn.Hide(); discBtn.Destroy(); discBtn.Dispose(); disconnectRequest = false; strWin.Hide(); strWin.Dispose(); strWin = null; break; //searchTask.Start(); } } catch (Exception e1) { ConsoleLogic.WriteConsole("Error at converting received data"); } } } } catch (Exception e) { ConsoleLogic.WriteConsole("error at DataListenLoop"); } }
private void CreateGui() { Gtk.FileChooserButton fc=new Gtk.FileChooserButton("Choose directory to put your splitted files",Gtk.FileChooserAction.SelectFolder); string fn=Banshee.Configuration.ConfigurationClient.Get<string>("cuesheets_todevice",""); if (fn!="") { fc.SelectFilename(fn); } fc.FileSet+=new EventHandler(delegate(Object sender,EventArgs args) { fn=fc.Filename; Banshee.Configuration.ConfigurationClient.Set<string>("cuesheets_todevice",fn); }); Gtk.Button btn=new Gtk.Button("Split CueSheet Audio File"); Gtk.Button csplit=new Gtk.Button("Cancel"); csplit.Clicked+=delegate(object sender,EventArgs args) { _splt.CancelSplit(); }; Gtk.ProgressBar bar=new Gtk.ProgressBar(); Gtk.ProgressBar nr=new Gtk.ProgressBar(); Gtk.Button ok=(Gtk.Button) base.AddButton ("OK",1); Gtk.Label result=new Gtk.Label("-"); btn.Clicked+=delegate(object sender,EventArgs args) { btn.Hide (); csplit.Show (); result.Markup=""; ok.Sensitive=false; fc.Sensitive=false; btn.Sensitive=false; _splt.SplitWithPaths (); bool convert_to_latin1=true; _splt.SplitToDir (fn,convert_to_latin1); GLib.Timeout.Add(50,delegate () { bar.Fraction=_splt.ProgressOfCurrentTrack; int n=_splt.ProgressNTracks; int i=_splt.ProgressCurrentTrack; double d=((double) i)/((double) n); nr.Fraction=d; if (_splt.SplitFinished) { ok.Sensitive=true; btn.Sensitive=true; fc.Sensitive=true; csplit.Hide (); btn.Show (); if (_splt.Cancelled) { result.Markup="<b>Split Cancelled</b>"; } else { result.Markup="<b>Finished</b>"; } } return !_splt.SplitFinished; }); }; fc.Show (); nr.Show (); bar.Show (); btn.Show (); result.Show (); base.VBox.Add (fc); base.VBox.Add (hsep()); base.VBox.Add (nr); base.VBox.Add (bar); base.VBox.Add (hsep ()); base.VBox.Add (result); base.VBox.Add (hsep ()); base.VBox.Add (btn); base.VBox.Add (csplit); base.VBox.Show(); }