本文整理汇总了C#中Dialog.Destroy方法的典型用法代码示例。如果您正苦于以下问题:C# Dialog.Destroy方法的具体用法?C# Dialog.Destroy怎么用?C# Dialog.Destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dialog
的用法示例。
在下文中一共展示了Dialog.Destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnButtonIngresarClicked
protected void OnButtonIngresarClicked(object sender, EventArgs e)
{
ControladorBaseDatos Bd = new ControladorBaseDatos();
string[] usuarioClave = new string[2];
usuarioClave = Bd.ObtenerUsuarioContraseñaBd(entryUsuario.Text);
if(usuarioClave[0].Equals(entryUsuario.Text) & usuarioClave[1].Equals(entryClave.Text))
{
//PrincipalWindow principal = new PrincipalWindow(entryUsuario.Text);
VenderProductosDialog principal = new VenderProductosDialog(entryUsuario.Text);
base.Destroy();
principal.Show();
}
else
{
Dialog dialog = new Dialog("Iniciar Sesion", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "Usuario/Clave incorrectos";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
}
示例2: OnButtonEditarNumBoletaClicked
protected void OnButtonEditarNumBoletaClicked(object sender, EventArgs e)
{
numBoleta = this.db.ObtenerBoleta ();
if (Int32.Parse (entryNumBoleta.Text.Trim ()) > numBoleta) {
try {
Venta nuevaVenta = new Venta (Int32.Parse (entryNumBoleta.Text.Trim ()), DateTime.Now.ToString ("yyyy-MM-dd"), "0", "inicioBoletaNueva", Int32.Parse ("0"), usuario_, "false");
db.AgregarVentaBd (nuevaVenta);
entryNumBoleta.Text = "";
Dialog dialog = new Dialog ("EDITAR BOLETA", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label ();
etiqueta.Markup = "La operación ha sido realizada con éxito";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart (etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll ();
dialog.Run ();
dialog.Destroy ();
} catch (Exception ex) {
Dialog dialog = new Dialog ("EDITAR BOLETA", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label ();
etiqueta.Markup = "Ha ocurrido un error al editar boleta";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart (etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll ();
dialog.Run ();
dialog.Destroy ();
Console.WriteLine ("error editar boleta: " + ex);
}
} else {
Dialog dialog = new Dialog ("EDITAR BOLETA", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label ();
etiqueta.Markup = "La boleta ingresada es menor a la del sistema";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart (etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll ();
dialog.Run ();
dialog.Destroy ();
}
}
示例3: OnButton1Clicked
protected void OnButton1Clicked(object sender, EventArgs e)
{
dialog = new Dialog ("Sample", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.AddButton ("Close", ResponseType.Close);
dialog.Response += (o, args) => Console.WriteLine(args.ResponseId);
dialog.Run ();
dialog.Destroy ();
}
示例4: compileButton_Clicked
private void compileButton_Clicked(object sender, EventArgs e)
{
try
{
softwareModel = new SoftwareModel (openTextBox.Text, softwareModelLoaded);
}
catch (Exception ex)
{
var dlg = new Dialog("Error", this, DialogFlags.Modal, ResponseType.Ok);
dlg.VBox.Add (new Label (ex.Message));
dlg.ShowAll ();
dlg.Run();
dlg.Destroy();
}
}
示例5: OnButtonIngresarDineroClicked
protected void OnButtonIngresarDineroClicked(object sender, EventArgs e)
{
ControladorBaseDatos baseDatos = new ControladorBaseDatos();
try {
int boleta = baseDatos.ObtenerBoleta();
Venta nVenta = new Venta(boleta,
DateTime.Now.ToString("yyyy-MM-dd"),
entryMontoDinero.Text.Trim(),
"IngresoDineroCaja",
Int32.Parse("0"),
usuario_,
"false");
baseDatos.AgregarVentaBd(nVenta);
entryMontoDinero.Text = "";
Dialog dialog = new Dialog("INGRESAR MONTO DINERO", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "La operación ha sido realizada con éxito";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
catch (Exception ex)
{
Dialog dialog = new Dialog("INGRESAR MONTO DINERO", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "Ha ocurrido un error al ingresar monto dinero";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
Console.WriteLine("error ingresar monto: "+ex);
}
}
示例6: ShowMessage
void ShowMessage (Window parent, string title, string message)
{
Dialog dialog = null;
try {
dialog = new Dialog (title, parent,
DialogFlags.DestroyWithParent | DialogFlags.Modal,
ResponseType.Ok);
dialog.VBox.Add (new Label (message));
dialog.ShowAll ();
dialog.Run ();
} finally {
if (dialog != null)
dialog.Destroy ();
}
}
示例7: EditarNumBoletaDialog
public EditarNumBoletaDialog(string usuario)
{
this.usuario_ = usuario;
this.Build ();
numBoleta = this.db.ObtenerBoleta () - 1;
Dialog dialog = new Dialog ("EDITAR BOLETA", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label ();
etiqueta.Markup = "Número de boleta actual: "+numBoleta.ToString();
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart (etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll ();
dialog.Run ();
dialog.Destroy ();
}
示例8: OnActualizarButtonClicked
protected virtual void OnActualizarButtonClicked(object sender, System.EventArgs e)
{
Gtk.TreeIter iter;
this.FamiliaProductosTreeview.Selection.GetSelected(out iter);
FamiliaProducto familia_vieja = new FamiliaProducto(this.familiaModel.GetValue(iter, 0).ToString());
FamiliaProducto familia_nueva = new FamiliaProducto(entryFamilia.Text.Trim());
if (!this.db.ExisteFamiliaBd(familia_vieja))
{
Dialog dialog = new Dialog("No se pudo actualizar la familia", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "No se pudo actualizar la familia porque no existe una en la base de datos.\nIntente recargar la lista de familias.";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
else
{
if (this.db.ActualizarFamilia(familia_vieja, familia_nueva))
{
this.familias.RemoveAt(this.familiaModel.GetPath(iter).Indices[0]);
this.familias.Insert(this.familiaModel.GetPath(iter).Indices[0], familia_nueva);
this.familiaModel.SetValue(iter, 0, familia_nueva.Nombre);
this.entryFamilia.Text = "";
this.quitar_button.Sensitive = false;
this.actualizar_button.Sensitive = false;
this.FamiliaProductosTreeview.Selection.UnselectAll();
//Console.WriteLine("Actualizado");
this.cambiado = true;
}
else
{
Dialog dialog = new Dialog("No se pudo actualizar la familia", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "No se pudo actualizar la familia, ha ocurrido un error al actualizar en la base de datos.";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
}
}
示例9: OnStartStreamButtonClicked
protected void OnStartStreamButtonClicked (object sender, EventArgs e)
{
bool vlcError = false;
if(rtspTunnel != null && rtspTunnel.Running){
SpawnThread(delegate()
{
vlcWindow.Kill();
});
return;
}
else{
SpawnThread(delegate()
{
int stepTimeOut = 10000;
bool hasError = false;
Gtk.ProgressBar progressBar = new Gtk.ProgressBar();
progressBar.WidthRequest = 170;
Label label = new Label("Opening RTSP Connection");
//label.HeightRequest = 10;
Dialog dialog = new Dialog ("Starting video stream", this, Gtk.DialogFlags.DestroyWithParent);
dialog.TypeHint = WindowTypeHint.Splashscreen;
dialog.Modal = true;
dialog.VBox.Add (label);
dialog.VBox.Add (progressBar);
dialog.HasSeparator = false;
System.Timers.Timer timer = new System.Timers.Timer(100);
timer.Elapsed += delegate {
Gtk.Application.Invoke (delegate {
progressBar.Pulse();
});
};
Gtk.Application.Invoke (delegate {
dialog.ShowAll();
});
timer.Start();
if(brickType == BrickType.NXT)
rtspTunnel = new RtspTunnel(rtspPort,imagePort,brick.Connection);
else
throw new NotImplementedException("What to do with EV3");
rtspTunnel.Start();
string errorMessage = "";
if(rtspTunnel.RTSPWaitHandle.WaitOne(stepTimeOut)){
Gtk.Application.Invoke (delegate {
label.Text = "Starting stream";
});
vlcWindow = new Process();
string argument = "rtsp://127.0.0.1:" + rtspPort + " --network-caching="+ networkCachingCombobox.GetActiveValue();
Console.WriteLine(argument);
vlcWindow.StartInfo = new ProcessStartInfo(settings.Path,
argument);
try{
vlcError = false;
vlcWindow = Process.Start(new ProcessStartInfo(settings.Path,argument));
/*if(vlcWindow.Start()){
vlcError = false;
}*/
}
catch{
vlcError = true;
}
if(!vlcError){
Gtk.Application.Invoke (delegate {
label.Text = "Waiting for image stream";
});
if(rtspTunnel.StreamWaitHandle.WaitOne(stepTimeOut)){
//Everything is ok
rtspTunnel.Stopped += OnRTSPTunnelStopped;
rtspTunnel.NewImageDataRate += OnUpdateStreamRate;
OnRTSPTunnelStarted();
}
else{
errorMessage = "Failed to receive image data";
hasError = true;
}
}
else{
errorMessage = "Failed to start vlc window";
hasError = true;
}
}
else{
errorMessage = "Failed to start remote RTSP-server";
hasError = true;
}
timer.Stop();
Gtk.Application.Invoke (delegate {
dialog.Destroy();
});
if(hasError && !vlcError){
if(rtspTunnel != null && rtspTunnel.Running){
rtspTunnel.Stop();
}
Gtk.Application.Invoke (delegate {
MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "\n" + errorMessage);
md.Icon = global::Gdk.Pixbuf.LoadFromResource (MessageDialogIconName);
md.WindowPosition = Gtk.WindowPosition.CenterOnParent;
md.Run ();
md.Destroy();
});
//.........这里部分代码省略.........
示例10: ExcepcionDesconocida
private void ExcepcionDesconocida(GLib.UnhandledExceptionArgs e)
{
#if DEBUG
Console.WriteLine(e.ToString());
#endif
Dialog dialog = new Dialog("Excepcion", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "Ha ocurrido un error.";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
示例11: OnQuitarFamiliaDialogResponse
private void OnQuitarFamiliaDialogResponse(object sender, ResponseArgs args)
{
switch (args.ResponseId)
{
case ResponseType.Accept:
Gtk.TreeIter iter;
this.FamiliaProductosTreeview.Selection.GetSelected(out iter);
FamiliaProducto bod = new FamiliaProducto(this.familiaModel.GetValue(iter, 0).ToString());
if (!this.db.ExisteFamiliaBd(bod))
{
Dialog dialog = new Dialog("No se pudo quitar la familia", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "No se pudo quitar la familia porque no existe en la base de datos.\nIntente recargar la lista de familias.";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
else
{
if (this.db.QuitarFamilia(bod))
{
Console.WriteLine(this.familias.Count);
this.familias.RemoveAt(this.familiaModel.GetPath(iter).Indices[0]);
Console.WriteLine(this.familias.Count);
this.familiaModel.Remove(ref iter);
this.actualizar_button.Sensitive = false;
this.FamiliaProductosTreeview.Selection.UnselectAll();
this.cambiado = true;
}
else
{
Dialog dialog = new Dialog("No se pudo quitar la familia", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "No se pudo quitar la familia, ha ocurrido un error al quitarla de la base de datos.";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
}
break;
default:
break;
}
}
示例12: RunInputTextDialog
private bool RunInputTextDialog(string title, string button1,
string originalcomment, out string comment)
{
Dialog d = new Dialog();
d.SetIconFromFile(DeskFlickrUI.ICON_PATH);
d.Title = title;
d.AddButton(button1, Gtk.ResponseType.Ok);
d.AddButton(Stock.Cancel, Gtk.ResponseType.Cancel);
ScrolledWindow swin = new ScrolledWindow();
swin.HscrollbarPolicy = Gtk.PolicyType.Never;
swin.VscrollbarPolicy = Gtk.PolicyType.Automatic;
swin.ShadowType = Gtk.ShadowType.EtchedIn;
TextView tv = new TextView();
tv.WrapMode = Gtk.WrapMode.WordChar;
tv.BorderWidth = 2;
tv.Buffer.Text = originalcomment;
swin.Add(tv);
d.VBox.Add(swin);
d.WidthRequest = 400;
d.HeightRequest = 200;
d.ShowAll();
Gtk.ResponseType response = (Gtk.ResponseType) d.Run();
comment = tv.Buffer.Text;
d.Destroy();
if (response == Gtk.ResponseType.Cancel) return false;
else if (comment.Trim() == "") return false;
else return true;
}
示例13: OnQuitarButtonClicked
protected void OnQuitarButtonClicked(object sender, EventArgs e)
{
Gtk.TreeIter iter;
if (this.FamiliaProductosTreeview.Selection.GetSelected(out iter))
{
Dialog dialog = new Dialog("Quitar familia", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "Está intentando quitar la familia seleccionada de la lista.\n\n<b>¿Desea continuar con la eliminación de la familia?</b>\n";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Si", ResponseType.Accept);
dialog.AddButton ("No", ResponseType.Cancel);
dialog.Response += new ResponseHandler (OnQuitarFamiliaDialogResponse);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
else
{
this.actualizar_button.Sensitive = false;
}
}
示例14: ControladorBaseDatos
/* public void CargarFechaInicial()
{
ControladorBaseDatos db = new ControladorBaseDatos();
try {
//db.ordenarFecha();
List<string> fechaInicial = db.ObtenerFechaBd();
comboboxFechasInicial.Clear();
CellRendererText cell = new CellRendererText();
comboboxFechasInicial.PackStart(cell, false);
comboboxFechasInicial.AddAttribute(cell, "text", 0);
this.fechaInicialModel = new Gtk.ListStore(typeof (string));
comboboxFechasInicial.Model = fechaInicialModel;
foreach (string i in fechaInicial)
{
this.fechaInicialModel.AppendValues(i);
}
if (fechaInicial.Count != 0)
{
this.comboboxFechasInicial.Active = 0;
}
}
catch (Exception ex)
{
Console.WriteLine("Excepcion:"+ex);
}
}
public void CargarFechaFinal()
{
ControladorBaseDatos db = new ControladorBaseDatos();
//db.ordenarFecha();
try {
List<string> fechaFinal = db.ObtenerFechaBd();
comboboxFechasFinal.Clear();
CellRendererText cell2 = new CellRendererText();
comboboxFechasFinal.PackStart(cell2, false);
comboboxFechasFinal.AddAttribute(cell2, "text", 0);
this.fechaFinalModel = new Gtk.ListStore(typeof (string));
comboboxFechasFinal.Model = fechaFinalModel;
foreach (string j in fechaFinal)
{
this.fechaFinalModel.AppendValues(j);
}
if (fechaFinal.Count != 0)
{
this.comboboxFechasFinal.Active = 0;
}
}
catch (Exception ex)
{
Console.WriteLine("Excepcion:"+ex);
}
}
*/
protected void OnButtonGuardarReporteClicked(object sender, EventArgs e)
{
string fechaInicial = calendarFInicial.GetDate ().ToString ("yyyy-MM-dd").Trim ();
string fechaFinal = calendarFFinal.GetDate ().ToString ("yyyy-MM-dd").Trim ();
this.OnCalendarFInicialDaySelected(sender,e);
this.OnCalendarFFinalDaySelected(sender,e);
if(fechaInicial.CompareTo(fechaFinal)==1){
Dialog dialog = new Dialog("ADVERTENCIA", this, Gtk.DialogFlags.DestroyWithParent);
dialog.Modal = true;
dialog.Resizable = false;
Gtk.Label etiqueta = new Gtk.Label();
etiqueta.Markup = "fecha final no puede ser anterior a fecha inicial";
dialog.BorderWidth = 8;
dialog.VBox.BorderWidth = 8;
dialog.VBox.PackStart(etiqueta, false, false, 0);
dialog.AddButton ("Cerrar", ResponseType.Close);
dialog.ShowAll();
dialog.Run ();
dialog.Destroy ();
}
else{
// string fechaInicial = comboboxFechasInicial.ActiveText;
// string fechaFinal = comboboxFechasFinal.ActiveText;
Document myDocument;
SeleccionarRuta();
// for(int aux=0; aux<listaVentas.Count; aux++){
// Console.WriteLine("Numero Boleta: "+Convert.ToString(listaVentas[aux].Idventa));
//myDocument.Add(new Paragraph("Numero Boleta: "+listaVentas[aux].Idventa));
// }
if(this.ruta_destino!=null){
Console.WriteLine("iText Demo");
//.........这里部分代码省略.........
示例15: OnDownloadFileButtonPressed
protected void OnDownloadFileButtonPressed(object sender, System.EventArgs e){
FileNode selectedFileNode = (FileNode)FileNodeView.NodeSelection.SelectedNode;
if(selectedFileNode == null){
Gtk.Application.Invoke (delegate {
MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "\nPlease select a file to download");
md.Icon = global::Gdk.Pixbuf.LoadFromResource (MessageDialogIconName);
md.WindowPosition = Gtk.WindowPosition.CenterOnParent;
md.Run ();
md.Destroy();
});
return;
}
if(downloadFolder == ""){
Gtk.Application.Invoke (delegate {
MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "\nPlease select a folder");
md.Icon = global::Gdk.Pixbuf.LoadFromResource (MessageDialogIconName);
md.WindowPosition = Gtk.WindowPosition.CenterOnParent;
md.Run ();
md.Destroy();
});
return;
}
SpawnThread(delegate()
{
Gtk.ProgressBar progressBar = new Gtk.ProgressBar();
progressBar.WidthRequest = 170;
progressBar.PulseStep = 0.1;
progressBar.Fraction = 0;
progressBar.Text = (0).ToString() + "%";
Label label = new Label("Downloading file...");
//label.HeightRequest = 10;
Dialog dialog = new Dialog ("Progress", this, Gtk.DialogFlags.DestroyWithParent);
dialog.TypeHint = WindowTypeHint.Splashscreen;
dialog.Modal = true;
dialog.VBox.Add (label);
dialog.VBox.Add (progressBar);
dialog.HasSeparator = false;
//dialog.AddButton ("Cancel", ResponseType.Close);
//dialog.Response += delegate(object obj, ResponseArgs args){ dialog.Destroy();};
Gtk.Application.Invoke (delegate {
dialog.ShowAll();
});
int totalBytes = 0;
double target = (double) selectedFileNode.Size;
System.Action<int> onBytesRead = delegate(int bytesRead){
Gtk.Application.Invoke (delegate {
totalBytes += bytesRead;
//label.Text = "Downloading file...\n" + totalBytes + " of " + selectedFileNode.Size.ToString() + " bytes";
progressBar.Fraction = ((double)totalBytes/target);
progressBar.Text = ((int) (progressBar.Fraction*100)).ToString() + "%";
});
};
brick.FileSystem.OnBytesRead += onBytesRead;
try{
brick.FileSystem.DownloadFile(downloadFolder+"\\"+selectedFileNode.FileName,selectedFileNode.FileName);
Gtk.Application.Invoke (delegate {
dialog.Destroy();
});
}
catch(Exception exception){
Gtk.Application.Invoke (delegate {
dialog.Destroy();
MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "\nFailed to download file\nError: " + exception.Message);
md.Icon = global::Gdk.Pixbuf.LoadFromResource (MessageDialogIconName);
md.WindowPosition = Gtk.WindowPosition.CenterOnParent;
md.Run ();
md.Destroy();
});
if(brick != null)
brick.FileSystem.OnBytesRead -= onBytesRead;
if(exception is MonoBrickException)
throw(exception);
return;
}
brick.FileSystem.OnBytesRead -= onBytesRead;
Gtk.Application.Invoke (delegate {
MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "\nFile downloaded successfully");
md.Icon = global::Gdk.Pixbuf.LoadFromResource (MessageDialogIconName);
md.WindowPosition = Gtk.WindowPosition.CenterOnParent;
md.Run ();
md.Destroy();
});
});
}