예제 #1
0
 void Agregar( object o, EventArgs args )
 {
     // crear dialogo
     Dialog dialog = new Dialog ("Agregar", window, Gtk.DialogFlags.DestroyWithParent);
     dialog.Modal = true;
     dialog.AddButton ("Aceptar", ResponseType.Ok);
     dialog.AddButton ("Cerrar", ResponseType.Close);
     Label lab = new Label("Información que desea agregar:");
     lab.Show();
     dialog.VBox.PackStart (lab , true, true, 5 );
     Table table = new Table (2, 2, false);
     Label labNombre = new Label("Nombre:");
     labNombre.Show();
     table.Attach(labNombre , 0, 1, 0, 1);
     entryNombre = new Entry();
     entryNombre.Show();
     table.Attach(entryNombre, 1, 2, 0, 1);
     Label labApe = new Label("Apellidos:");
     labApe.Show();
     table.Attach(labApe , 0, 1, 1, 2);
     entryApe = new Entry();
     entryApe.Show();
     table.Attach(entryApe , 1, 2, 1, 2);
     table.Show();
     dialog.VBox.PackStart (table, true, true, 5 );
     dialog.Response += new ResponseHandler (on_dialog_agregar);
     dialog.Run ();
     dialog.Destroy ();
 }
예제 #2
0
        private void create_with_file_chooser(string title, Gtk.Window parent, Action action)
        {
            int    a     = 0;
            string stock = Gtk.Stock.Open;

            /* FIXME: here we use the raw enum values from
             * GtkFileChooserAction, because I'm too lazy to do something
             * like this:
             *
             * GType t = gtk_file_chooser_action_get_type ();
             * GEnumClass *c = g_type_class_ref (t);
             * GEnumValue *v = g_enum_get_value_by_name (c, "GTK_FILE_CHOOSER_ACTION_FOO");
             * int intval = v->value;
             * g_type_class_unref (c);
             * ... use intval ...
             */
            switch (action)
            {
            case Action.Open:
                a     = 0;
                stock = Gtk.Stock.Open;
                break;

            case Action.Save:
                a     = 1;
                stock = Gtk.Stock.Save;
                break;

            case Action.SelectFolder:
                a     = 2;
                stock = Gtk.Stock.Open;
                break;
            }

#if false
            IntPtr ptr = gtk_file_chooser_dialog_new_with_backend(title,
                                                                  parent != null ? parent.Handle : IntPtr.Zero,
                                                                  a, "gtk+", IntPtr.Zero);
#else
            IntPtr ptr = gtk_file_chooser_dialog_new(title,
                                                     parent != null ? parent.Handle : IntPtr.Zero,
                                                     a, IntPtr.Zero);
#endif

            chooser = GLib.Object.GetObject(ptr, false) as Gtk.Dialog;

            chooser.AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);

            /* Note that we use Ok rather than the preferred Accept because
             * that's what GtkFileSelection uses.  Rather than have two
             * separate tests for each case (chooser/filesel), we'll rather
             * just test for a single response code, which is Ok.
             */
            chooser.AddButton(stock, Gtk.ResponseType.Ok);
            chooser.DefaultResponse = Gtk.ResponseType.Ok;
        }
예제 #3
0
        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 ();

            }
        }
예제 #4
0
 private void onClick(object Sender, EventArgs e)
 {
     Dialog d = new Dialog ("Test", this, DialogFlags.DestroyWithParent);
     d.Modal = true;
     d.AddButton ("Close", ResponseType.Close);
     d.Run ();
     d.Destroy ();
 }
예제 #5
0
        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 ();

            }
        }
예제 #6
0
 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 ();
 }
예제 #7
0
        public bool Execute(PhotoStore store, Photo photo, Gtk.Window parent_window)
        {
            // FIXME HIG-ify.
            Dialog dialog = new Dialog ();
            dialog.BorderWidth = 6;
            dialog.TransientFor = parent_window;
            dialog.HasSeparator = false;
            dialog.Title = Catalog.GetString ("Really Delete?");
            dialog.AddButton (Catalog.GetString ("Cancel"), (int) ResponseType.Cancel);
            dialog.AddButton (Catalog.GetString ("Delete"), (int) ResponseType.Ok);
            dialog.DefaultResponse = ResponseType.Ok;

            string version_name = photo.GetVersion (photo.DefaultVersionId).Name;
            Label label = new Label (String.Format (Catalog.GetString ("Really delete version \"{0}\"?"), version_name));
            label.Show ();
            dialog.VBox.PackStart (label, false, true, 6);;

            if (dialog.Run () == (int) ResponseType.Ok) {
                try {
                    photo.DeleteVersion (photo.DefaultVersionId);
                    store.Commit (photo);
                } catch (Exception e) {
                    Log.DebugException (e);
                    string msg = Catalog.GetString ("Could not delete a version");
                    string desc = String.Format (Catalog.GetString ("Received exception \"{0}\". Unable to delete version \"{1}\""),
                                     e.Message, photo.Name);

                    HigMessageDialog md = new HigMessageDialog (parent_window, DialogFlags.DestroyWithParent,
                                            Gtk.MessageType.Error, ButtonsType.Ok,
                                            msg,
                                            desc);
                    md.Run ();
                    md.Destroy ();
                    dialog.Destroy (); // Delete confirmation window.
                    return false;
                }

                dialog.Destroy ();
                return true;
            }

            dialog.Destroy ();
            return false;
        }
예제 #8
0
        public void OnAddPls()
        {
            Hyena.Log.Information("add playlist");
            Gtk.Dialog dlg = new Gtk.Dialog();
            dlg.Title = "Add Playlist";
            Gtk.Entry pls = new Gtk.Entry();
            pls.WidthChars = 40;
            Gtk.Label lbl = new Gtk.Label("Playlist name:");
            Gtk.HBox  hb  = new Gtk.HBox();
            hb.PackStart(lbl, false, false, 1);
            hb.PackEnd(pls);
            dlg.VBox.PackStart(hb);
            dlg.AddButton(Gtk.Stock.Cancel, 0);
            dlg.AddButton(Gtk.Stock.Ok, 1);
            dlg.VBox.ShowAll();
            string plsname = "";

            while (plsname == "")
            {
                int response = dlg.Run();
                if (response == 0)
                {
                    dlg.Hide();
                    dlg.Destroy();
                    return;
                }
                else
                {
                    plsname = pls.Text.Trim();
                }
            }
            dlg.Hide();
            dlg.Destroy();
            _pls = _col.NewPlayList(plsname);
            _model.Reload();
            _pls_model.SetPlayList(_pls);
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
 protected void TableButtonHandler(object o, EventArgs args)
 {
     if (LexemList.Instance.Lexems.Count > 0)
     {
         System.Diagnostics.Process.Start("/usr/bin/open", "-a Safari " + Constants.HTMLTablePath);
     }
     else
     {
         Gtk.Dialog dialog = new Gtk.Dialog("Ошибочка", this, Gtk.DialogFlags.Modal);
         Label      text   = new Label();
         text.Text = "Сначала скомпилируйте файл";
         dialog.VBox.Add(text);
         dialog.AddButton("Close", ResponseType.Close);
         dialog.ShowAll();
         dialog.Run();
         dialog.Destroy();
     }
 }
예제 #11
0
        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 ();
        }
예제 #12
0
파일: helpers.cs 프로젝트: kig/filezoo
    public static void TextPrompt(string title, string labelText, string entryText, string buttonText,
   int position, int selectStart, int selectEnd, TextPromptHandler onOk)
    {
        Dialog d = new Dialog();
        d.Modal = false;
        d.ActionArea.Layout = ButtonBoxStyle.Spread;
        d.HasSeparator = false;
        d.BorderWidth = 10;
        d.Title = title;
        Label label = new Label (labelText);
        label.UseUnderline = false;
        d.VBox.Add (label);
        Entry e = new Entry (entryText);
        e.WidthChars = Math.Min(100, e.Text.Length + 10);
        e.Activated += new EventHandler (delegate { d.Respond(ResponseType.Ok); });
        d.VBox.Add (e);
        d.AddButton (buttonText, ResponseType.Ok);

        d.Response += new ResponseHandler(delegate (object obj, ResponseArgs args) {
          if (args.ResponseId == ResponseType.Ok) {
        onOk(e.Text);
          } else {
        LogError (args.ResponseId);
          }
          d.Unrealize ();
          d.Destroy ();
        });

        d.ShowAll ();
        e.Position = position;
        e.SelectRegion(selectStart, selectEnd);
    }
        void ShowConnectingDialog(RemoteDebuggerStartInfo dsi)
        {
            string message = GetConnectingMessage (dsi);

            Gtk.Application.Invoke (delegate {
                if (VirtualMachine != null || Exited)
                    return;

                dialog = new Gtk.Dialog () {
                    Title = "Waiting for debugger"
                };

                var label = new Gtk.Alignment (0.5f, 0.5f, 1f, 1f) {
                    Child = new Gtk.Label (message),
                    BorderWidth = 12
                };
                dialog.VBox.PackStart (label);
                label.ShowAll ();

                dialog.AddButton ("Cancel", Gtk.ResponseType.Cancel);

                int response = MonoDevelop.Ide.MessageService.ShowCustomDialog (dialog);

                dialog = null;

                if (response != (int) Gtk.ResponseType.Ok) {
                    EndSession ();
                }
            });
        }
예제 #14
0
        /// <summary>
        /// Запуск простого диалога редактирования справочника
        /// </summary>
        /// <returns>Возвращает экземпляр сохраненного объекта, загруженного в сессии диалога. То есть не переданный объект.
        /// Если пользователь отказался от сохранения возвращаем null.
        /// </returns>
        /// <param name="editObject">Объект для редактирования. Если null создаем новый объект.</param>
        public static object RunSimpleDialog(Window parent, System.Type objectType, object editObject)
        {
            string actionTitle = null;
            string dialogTitle = null;

            if (editObject == null)
            {
                var names = DomainHelper.GetSubjectNames(objectType);
                if (names != null && names.Gender != GrammaticalGender.Unknown)
                {
                    switch (names.Gender)
                    {
                    case GrammaticalGender.Feminine:
                        actionTitle = $"Простое редактирование новой {names.Genitive}";
                        dialogTitle = $"Новая {names.Nominative}";
                        break;

                    case GrammaticalGender.Masculine:
                        actionTitle = $"Простое редактирование нового {names.Genitive}";
                        dialogTitle = $"Новый {names.Nominative}";
                        break;

                    case GrammaticalGender.Neuter:
                        actionTitle = $"Простое редактирование нового {names.Genitive}";
                        dialogTitle = $"Новое {names.Nominative}";
                        break;
                    }
                }
                else
                {
                    actionTitle = "Диалог простого редактирования";
                }
            }
            else
            {
                actionTitle = $"Простое редактирование '{DomainHelper.GetObjectTilte(editObject)}'";
                var names = DomainHelper.GetSubjectNames(objectType);
                if (names != null && names.Genitive != null)
                {
                    dialogTitle = $"Редактирование {names.Genitive}";
                }
            }
            using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot(actionTitle))
            {
                //Создаем объект редактирования
                object tempObject;
                if (editObject == null)
                {
                    tempObject = Activator.CreateInstance(objectType);
                }
                else
                {
                    if (editObject is IDomainObject)
                    {
                        tempObject = uow.GetById(objectType, (editObject as IDomainObject).Id);
                    }
                    else
                    {
                        throw new InvalidCastException("У объекта переданного для запуска простого диалога, нет интерфейса IDomainObject, объект не может быть открыт.");
                    }
                }

                //Создаем диалог
                Gtk.Dialog editDialog = new Gtk.Dialog(dialogTitle ?? "Редактирование", parent, Gtk.DialogFlags.Modal);
                editDialog.AddButton("Отмена", ResponseType.Cancel);
                editDialog.AddButton("Сохранить", ResponseType.Ok);
                Gtk.Table editDialogTable = new Table(1, 2, false);
                Label     LableName       = new Label("Название:");
                LableName.Justify = Justification.Right;
                editDialogTable.Attach(LableName, 0, 1, 0, 1);
                yEntry inputNameEntry = new yEntry();
                inputNameEntry.WidthRequest = 300;
                inputNameEntry.Binding.AddBinding(tempObject, "Name", w => w.Text).InitializeFromSource();
                editDialogTable.Attach(inputNameEntry, 1, 2, 0, 1);
                editDialog.VBox.Add(editDialogTable);

                //Запускаем диалог
                editDialog.ShowAll();
                int result = editDialog.Run();
                if (result == (int)ResponseType.Ok)
                {
                    string name = (string)tempObject.GetPropertyValue("Name");
                    if (String.IsNullOrWhiteSpace(name))
                    {
                        var    att         = DomainHelper.GetSubjectNames(tempObject);
                        string subjectName = att != null ? att.Accusative : null;
                        string msg         = String.Format("Название {0} пустое и не будет сохранено.",
                                                           string.IsNullOrEmpty(subjectName) ? "элемента справочника" : subjectName
                                                           );
                        MessageDialogHelper.RunWarningDialog(msg);
                        logger.Warn(msg);
                        editDialog.Destroy();
                        return(null);
                    }
                    var list = uow.Session.CreateCriteria(objectType)
                               .Add(Restrictions.Eq("Name", name))
                               .Add(Restrictions.Not(Restrictions.IdEq(DomainHelper.GetId(tempObject))))
                               .List();
                    if (list.Count > 0)
                    {
                        var    att         = DomainHelper.GetSubjectNames(tempObject);
                        string subjectName = att != null?att.Nominative.StringToTitleCase() : null;

                        string msg = String.Format("{0} с таким названием уже существует.",
                                                   string.IsNullOrEmpty(subjectName) ? "Элемент справочника" : subjectName
                                                   );
                        MessageDialogHelper.RunWarningDialog(msg);
                        logger.Warn(msg);
                        editDialog.Destroy();
                        return(list [0]);
                    }
                    uow.TrySave(tempObject);
                    uow.Commit();
                }
                else
                {
                    tempObject = null;
                }

                editDialog.Destroy();
                return(tempObject);
            }
        }
예제 #15
0
        protected void OnButtonPickDatePeriodClicked(object sender, EventArgs e)
        {
            #region Widget creation
            Window parentWin = (Window)Toplevel;
            var selectDate = new Dialog ("Укажите период", parentWin, DialogFlags.DestroyWithParent);
            selectDate.Modal = true;
            selectDate.AddButton ("Отмена", ResponseType.Cancel);
            selectDate.AddButton ("Ok", ResponseType.Ok);

            periodSummary = new Label();
            selectDate.VBox.Add(periodSummary);

            HBox hbox = new HBox (true, 6);

            StartDateCalendar = new Calendar ();
            StartDateCalendar.DisplayOptions = DisplayOptions;
            StartDateCalendar.Date = StartDateOrNull ?? DateTime.Today;
            StartDateCalendar.DaySelected += StartDateCalendar_DaySelected;

            EndDateCalendar = new Calendar ();
            EndDateCalendar.DisplayOptions = DisplayOptions;
            EndDateCalendar.Date = EndDateOrNull ?? DateTime.Today;
            EndDateCalendar.DaySelected += EndDateCalendar_DaySelected;

            hbox.Add (StartDateCalendar);
            hbox.Add (EndDateCalendar);

            selectDate.VBox.Add (hbox);
            selectDate.ShowAll ();
            #endregion

            int response = selectDate.Run ();
            if (response == (int)ResponseType.Ok) {
                startDate = StartDateCalendar.GetDate ();
                endDate = EndDateCalendar.GetDate ();
                OnPeriodChanged ();
            }

            #region Destroy
            EndDateCalendar.Destroy ();
            StartDateCalendar.Destroy ();
            hbox.Destroy ();
            selectDate.Destroy ();
            #endregion
        }
예제 #16
0
        /* Private methods */

        private Gtk.Dialog BuildDialog()
        {
            Gtk.Dialog dialog = new Gtk.Dialog();
            dialog.Resizable = false;     //This way it automatically resizes according to its content in the 2 display modes: find / replace

            //Content area

            Grid grid = new Grid();

            grid.BorderWidth   = WidgetStyles.BorderWidthLarge;
            grid.ColumnSpacing = WidgetStyles.ColumnSpacingLarge;
            grid.RowSpacing    = WidgetStyles.RowSpacingLarge;

            Label findLabel = new Label(Catalog.GetString("F_ind"));

            findLabel.SetAlignment(1, 0.5f);
            grid.Attach(findLabel, 0, 0, 1, 1);

            findEntry                  = new Entry();
            findEntry.Changed         += OnFindTextChanged;
            findEntry.ActivatesDefault = true;
            grid.Attach(findEntry, 1, 0, 2, 1);

            replaceLabel = new Label(Catalog.GetString("Replace _with"));
            replaceLabel.SetAlignment(1, 0.5f);
            grid.Attach(replaceLabel, 0, 1, 1, 1);

            replaceEntry                  = new Entry();
            replaceEntry.Changed         += OnReplaceTextChanged;
            replaceEntry.ActivatesDefault = true;
            grid.Attach(replaceEntry, 1, 1, 2, 1);

            matchCaseCheckButton          = new CheckButton(Catalog.GetString("_Match case"));
            matchCaseCheckButton.Toggled += OnMatchCaseToggled;
            grid.Attach(matchCaseCheckButton, 1, 2, 1, 1);

            backwardsCheckButton          = new CheckButton(Catalog.GetString("Search _backwards"));
            backwardsCheckButton.Toggled += OnBackwardsToggled;
            grid.Attach(backwardsCheckButton, 2, 2, 1, 1);

            regexCheckButton          = new CheckButton(Catalog.GetString("Regular _expression"));
            regexCheckButton.Toggled += OnUseRegexToggled;
            grid.Attach(regexCheckButton, 1, 3, 1, 1);

            wrapCheckButton          = new CheckButton(Catalog.GetString("Wra_p around"));
            wrapCheckButton.Toggled += OnWrapToggled;
            grid.Attach(wrapCheckButton, 2, 3, 1, 1);

            dialog.ContentArea.Add(grid);
            dialog.ContentArea.ShowAll();

            //Action area

            buttonReplaceAll           = dialog.AddButton(Catalog.GetString("Replace _All"), (int)SearchDialogResponse.ReplaceAll) as Button;
            buttonReplaceAll.Sensitive = false;

            buttonReplace           = dialog.AddButton(Catalog.GetString("_Replace"), (int)SearchDialogResponse.Replace) as Button;
            buttonReplace.Sensitive = false;

            buttonFind           = dialog.AddButton(Util.GetStockLabel("gtk-find"), (int)SearchDialogResponse.Find) as Button;
            buttonFind.Sensitive = false;

            dialog.DefaultResponse = (ResponseType)SearchDialogResponse.Find;

            return(dialog);
        }
예제 #17
0
    private static void UpdateDialog(string format, params object[] args)
    {
        string text = String.Format (format, args);

        if (dialog == null)
        {
            dialog = new Dialog ();
            dialog.Title = "Loading data from assemblies...";
            dialog.AddButton (Stock.Cancel, 1);
            dialog.Response += new ResponseHandler (ResponseCB);
            dialog.SetDefaultSize (480, 100);

            VBox vbox = dialog.VBox;
            HBox hbox = new HBox (false, 4);
            vbox.PackStart (hbox, true, true, 0);

            Gtk.Image icon = new Gtk.Image (Stock.DialogInfo, IconSize.Dialog);
            hbox.PackStart (icon, false, false, 0);
            dialog_label = new Label (text);
            hbox.PackStart (dialog_label, false, false, 0);
            dialog.ShowAll ();
        } else {
            dialog_label.Text = text;
            while (Application.EventsPending ())
                Application.RunIteration ();
         		}
    }
예제 #18
0
        protected void OnBotonModificarClicked(object sender, EventArgs e)
        {
            ControladorBaseDatos db = new ControladorBaseDatos();

            try {
                string [] aux = db.ObtenerusuarioAntiguoBd(entryUsuarioEdit.Text.Trim());

                Usuario usuarioAntiguo = new Usuario(aux[0],aux[1],aux[2],aux[3],aux[4],aux[5],aux[6]);

                Usuario usuarioNuevo = new Usuario(entryUsuarioEdit.Text.Trim(),
                                                   entryContraseñaEdit.Text.Trim(),
                                                   entryNombreEdit.Text.Trim(),
                                                   entryApellidosEdit.Text.Trim(),
                                                   entryTelefonoEdit.Text.Trim(),
                                                   entryRutEdit.Text.Trim(),
                                                   comboboxTipoUsuarioMod.ActiveText);

                db.ActualizarUsuarioBd(usuarioAntiguo,usuarioNuevo);

                Dialog dialog = new Dialog("USUARIO ACTUALIZADO", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "Actualización correcta";
                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)
            {
                Console.WriteLine("Excepcion:"+ex);
            }
        }
예제 #19
0
        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 ();
                }
            }
        }
예제 #20
0
        protected void OnBotonAgregarClicked(object sender, EventArgs e)
        {
            ControladorBaseDatos db = new ControladorBaseDatos();

            bool existe = db.ExisteUsuarioBd(entryNombreUsuario.Text.Trim());

            if (existe)	{
                Dialog dialog = new Dialog("USUARIO YA EXISTE", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "El Usuario que intenta agregar ya existe 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 ();
            }
            else
            {
                Usuario NuevoUsuario = new Usuario(entryNombreUsuario.Text.Trim(),
                                                   entryContraseña.Text.Trim(),
                                                   entryNombre.Text.Trim(),
                                                   entryApellidos.Text.Trim(),
                                                   entryTelefono.Text.Trim(),
                                                   entryRut.Text.Trim(),
                                                   comboboxTipoUsuario.ActiveText);

                db.AgregarUsuarioBd(NuevoUsuario);

                Dialog dialog = new Dialog("USUARIO AGREGADO", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "El Usuario se ha agregado correctamente";
                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 ();

                this.CargarUsuariosModificarCombobox();
            }
        }
예제 #21
0
        protected void OnCalendarFInicialDaySelected(object sender, EventArgs e)
        {
            ControladorBaseDatos db = new ControladorBaseDatos ();
            string fechaI="";

            //DateTime.Now.ToString("yyyy-MM-dd")
            fechaI = calendarFInicial.GetDate ().ToString ("yyyy-MM-dd").Trim ();
            Console.WriteLine("fecha seleccionada I: "+fechaI);

            if (!db.ExisteFechaBd (fechaI)) {
                Console.WriteLine ("NO existe venta");

                Dialog dialog = new Dialog("Advertencia", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "No existen ventas en el día seleccionado";
                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 {
                Console.WriteLine ("existe venta");

            }
        }
예제 #22
0
        /// <summary>
        /// Запуск простого диалога редактирования справочника
        /// </summary>
        /// <returns>Возвращает экземпляр сохраненного объекта, загруженного в сессии диалога. То есть не переданный объект.
        /// Если пользователь отказался от сохранения возвращаем null.
        /// </returns>
        /// <param name="editObject">Объект для редактирования. Если null создаем новый объект.</param>
        public static object RunSimpleDialog(Window parent, System.Type objectType, object editObject)
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot ())
            {
                //Создаем объект редактирования
                object tempObject;
                if(editObject == null)
                {
                    tempObject = Activator.CreateInstance (objectType);
                }
                else
                {
                    if(editObject is IDomainObject)
                    {
                        tempObject = uow.GetById(objectType, (editObject as IDomainObject).Id);
                    }
                    else
                    {
                        throw new InvalidCastException ("У объекта переданного для запуска простого диалога, нет интерфейса IDomainObject, объект не может быть открыт.");
                    }
                }

                //Создаем диалог
                Dialog editDialog = new Dialog("Редактирование", parent, Gtk.DialogFlags.Modal);
                editDialog.AddButton("Отмена", ResponseType.Cancel);
                editDialog.AddButton("Сохранить", ResponseType.Ok);
                Gtk.Table editDialogTable = new Table(1, 2, false);
                Label LableName = new Label("Название:");
                LableName.Justify = Justification.Right;
                editDialogTable.Attach(LableName, 0, 1, 0, 1);
                yEntry inputNameEntry = new yEntry();
                inputNameEntry.WidthRequest = 300;
                inputNameEntry.Binding.AddBinding(tempObject, "Name", w => w.Text).InitializeFromSource ();
                editDialogTable.Attach(inputNameEntry, 1, 2, 0, 1);
                editDialog.VBox.Add(editDialogTable);

                //Запускаем диалог
                editDialog.ShowAll();
                int result = editDialog.Run();
                if (result == (int)ResponseType.Ok) {
                    string name = (string)tempObject.GetPropertyValue ("Name");
                    if (String.IsNullOrWhiteSpace (name)) {
                        var att = DomainHelper.GetSubjectNames (tempObject);
                        string subjectName = att != null ? att.Accusative : null;
                        string msg = String.Format ("Название {0} пустое и не будет сохранено.",
                                         string.IsNullOrEmpty (subjectName) ? "элемента справочника" : subjectName
                                     );
                        MessageDialogWorks.RunWarningDialog (msg);
                        logger.Warn (msg);
                        editDialog.Destroy ();
                        return null;
                    }
                    var list = uow.Session.CreateCriteria (objectType)
                        .Add (Restrictions.Eq ("Name", name))
                        .Add (Restrictions.Not (Restrictions.IdEq (DomainHelper.GetId (tempObject))))
                        .List ();
                    if (list.Count > 0) {
                        var att = DomainHelper.GetSubjectNames (tempObject);
                        string subjectName = att != null ? StringWorks.StringToTitleCase (att.Nominative) : null;
                        string msg = String.Format ("{0} с таким названием уже существует.",
                                         string.IsNullOrEmpty (subjectName) ? "Элемент справочника" : subjectName
                                     );
                        MessageDialogWorks.RunWarningDialog (msg);
                        logger.Warn (msg);
                        editDialog.Destroy ();
                        return list [0];
                    }
                    uow.TrySave (tempObject);
                    uow.Commit ();
                    OrmMain.NotifyObjectUpdated (tempObject);
                }
                else
                    tempObject = null;

                editDialog.Destroy();
                return tempObject;
            }
        }
예제 #23
0
        protected void OnEntryCodigoBarraKeyPressEvent(object o, Gtk.KeyPressEventArgs args)
        {
            string codigoBarra = "";
            string asterisco = "";
            string recoPesa = "";
            string tipoProd = "";
            string cant = "";
            string precioprod = "";
            string codigobarracorto = "";
            Console.WriteLine ("entra al OnEntry1KeyPressEvent1 de OnEntryCodigoBarraKeyPressEvent ");
            Console.WriteLine ("DEBUG: KeyValue: " + args.Event.KeyValue);

            if (args.Event.Key == Gdk.Key.Return) {

                // caso 1: se ingresa la cantidad de productos
                // luego un * y seguido el codigo de barra
                // del producto, la cantidad sera el numero
                // que antecede al signo *

                try {
                    int posAsterisco = 0;
                    if (Int32.Parse (entryCodigoBarra.Text.Trim ().Substring (0, 1)) == 2 &&
                        entryCodigoBarra.Text.Trim ().Substring (0, 2) != "2*") {

                        codigoBarra = entryCodigoBarra.Text.Trim ();

                        recoPesa = codigoBarra.Substring (0, 2);
                        Console.WriteLine ("codigoPesa: " + recoPesa);
                        codigobarracorto = codigoBarra.Substring (0, 7);
                        Console.WriteLine ("codigobarracorto: " + codigobarracorto);
                        precioprod = Int32.Parse (codigoBarra.Substring (7, 5)) + "";
                        //	Console.WriteLine("precioEntero: "+precioEntero);

                        // caso2: se listan los productos con cantidad 1
                        Produc n_prod = this.db.ObtenerProductosVenta (codigobarracorto);

                        n_prod.setCantidad (1);
                        productoventa.Add (n_prod);
                        Console.WriteLine ("lista:" + productoventa.Count);
                        foreach (Produc i in productoventa) {/*se recorre esta lista con un foreach*/
                            int contador = 0;
                            String x = i.getCodigo ();
                            String nom = i.getNombre ();/*se guarda un registro para luego hacer la comparacion*/
                            String prec = precioprod;
                            listapago.Add (new Produc (x, nom, precioprod, contador)); /*se agrega a otra lista el codigo de barra,nombre,precio,cantidad de productos*/

                        }

                        treeviewListaProductos.Model = this.ventamodel;
                        int valor = 1;
                        String nombre = "";
                        String precio = "";
                        foreach (Produc k in listapago) {
                            valor = 1;
                            nombre = k.getNombre ();
                            precio = precioprod;

                        }

                        Produc prod = this.productoventa.ToArray () [productoventa.Count - 1];
                        TreeIter tmpIter = new TreeIter ();
                        ventamodel.GetIterFirst (out tmpIter);

                        string item = (string)ventamodel.GetValue (tmpIter, 1);

                        preciototal = preciototal + Int32.Parse (precioprod);
                        labelTotalVenta.Text = preciototal.ToString ();

                        ventamodel.AppendValues (prod.getCantidad (), prod.getNombre (), precioprod);
                        entryCodigoBarra.DeleteText (0, entryCodigoBarra.Text.Length);

                    } else {
                        if ((entryCodigoBarra.Text.Trim ().Length > 13 ||
                            entryCodigoBarra.Text.Trim ().Length == 10 ||
                            entryCodigoBarra.Text.Trim ().Length == 11)) {
                            //y falta para que si se ingresa
                            codigoBarra = entryCodigoBarra.Text.Trim ();

                            posAsterisco = codigoBarra.IndexOf ('*');
                            asterisco = codigoBarra.Substring (posAsterisco, posAsterisco);
                            cant = codigoBarra.Substring (0, posAsterisco);
                            if (cant.Length < 1) {
                                cant = "1";
                            }
                            Console.WriteLine ("Cantidad: " + cant);
                            Console.WriteLine ("posAsterisco: " + posAsterisco);
                            Console.WriteLine ("asterisco: " + asterisco);
                            Console.WriteLine ("Largo codigo barra: " + codigoBarra.Length);
                            Console.WriteLine ("Codigo Barra: " + codigoBarra.Substring (posAsterisco + 1, (entryCodigoBarra.Text.Trim ().Length - (cant.Length + 1))));
                            Console.WriteLine ("largo desconocido" + posAsterisco + codigoBarra.Length);
                            Console.WriteLine ("resultado" + (entryCodigoBarra.Text.Trim ().Length - (cant.Length + 1)));

                            Produc n_prod = this.db.ObtenerProductosVenta ((codigoBarra.Substring (posAsterisco + 1, (entryCodigoBarra.Text.Trim ().Length - (cant.Length + 1)))));
                            n_prod.setCantidad (Int32.Parse (cant));
                            productoventa.Add (n_prod);

                            //**************

                            Console.WriteLine ("lista:" + productoventa.Count);
                            foreach (Produc i in productoventa) {/*se recorre esta lista con un foreach*/
                                int contador = 0;
                                String x = i.getCodigo ();
                                String nom = i.getNombre ();/*se guarda un registro para luego hacer la comparacion*/
                                String prec = i.getPrecio ();

                                listapago.Add (new Produc (x, nom, prec, contador)); /*se agrega a otra lista el codigo de barra,nombre,precio,cantidad de productos*/
                            }

                            treeviewListaProductos.Model = this.ventamodel;
                            // valor es la cantidad de producto que lleva el cliente
                            int valor = 0;
                            String nombre = "";
                            String precio = "";
                            valor = Int32.Parse (cant);
                            foreach (Produc k in listapago) {
                                //= Int32.Parse(cant);
                                nombre = k.getNombre ();
                                precio = k.getPrecio ();

                            }
                            Console.WriteLine (valor);

                            Produc prod = this.productoventa.ToArray () [productoventa.Count - 1];
                            TreeIter tmpIter = new TreeIter ();
                            ventamodel.GetIterFirst (out tmpIter);

                            string item = (string)ventamodel.GetValue (tmpIter, 1);

                            preciototal = preciototal + (Int32.Parse (prod.Precio) * prod.getCantidad ());
                            labelTotalVenta.Text = preciototal.ToString ();
                            ventamodel.AppendValues (prod.getCantidad (), prod.getNombre (), prod.getPrecio ());
                            entryCodigoBarra.DeleteText (0, entryCodigoBarra.Text.Length);

                            //**************

                        } else {

                            // caso2: se listan los productos con cantidad 1
                            Produc n_prod = this.db.ObtenerProductosVenta (entryCodigoBarra.Text.Trim ());
                            n_prod.setCantidad (1);
                            productoventa.Add (n_prod);
                            Console.WriteLine ("lista:" + productoventa.Count);
                            foreach (Produc i in productoventa) {/*se recorre esta lista con un foreach*/
                                int contador = 0;
                                String x = i.getCodigo ();
                                String nom = i.getNombre ();/*se guarda un registro para luego hacer la comparacion*/
                                String prec = i.getPrecio ();
                                listapago.Add (new Produc (x, nom, prec, contador)); /*se agrega a otra lista el codigo de barra,nombre,precio,cantidad de productos*/

                            }

                            treeviewListaProductos.Model = this.ventamodel;
                            int valor = 1;
                            String nombre = "";
                            String precio = "";
                            foreach (Produc k in listapago) {
                                valor = 1;
                                nombre = k.getNombre ();
                                precio = k.getPrecio ();

                            }

                            Produc prod = this.productoventa.ToArray () [productoventa.Count - 1];
                            TreeIter tmpIter = new TreeIter ();
                            ventamodel.GetIterFirst (out tmpIter);

                            string item = (string)ventamodel.GetValue (tmpIter, 1);

                            preciototal = preciototal + Int32.Parse (prod.Precio);
                            labelTotalVenta.Text = preciototal.ToString ();

                            ventamodel.AppendValues (prod.getCantidad (), prod.getNombre (), prod.getPrecio ());
                            entryCodigoBarra.DeleteText (0, entryCodigoBarra.Text.Length);

                        }

                    }

                } catch (Exception ee) {

                    Dialog dialog2 = new Dialog("MENSAJE", this, Gtk.DialogFlags.DestroyWithParent);
                    dialog2.Modal = true;
                    dialog2.Resizable = false;
                    Gtk.Label etiqueta2 = new Gtk.Label();
                    etiqueta2.Markup = "No existe producto";
                    dialog2.BorderWidth = 8;
                    dialog2.VBox.BorderWidth = 8;
                    dialog2.VBox.PackStart(etiqueta2, false, false, 0);
                    dialog2.AddButton ("Cerrar", ResponseType.Close);
                    dialog2.ShowAll();
                    dialog2.Run ();
                    dialog2.Destroy ();

                }
            }
        }
예제 #24
0
        protected void OnTreeviewListaProductosKeyPressEvent(object o, KeyPressEventArgs args)
        {
            if (args.Event.Key == Gdk.Key.F12) {
                Gtk.TreeIter iter;
                if (this.treeviewListaProductos.Selection.GetSelected (out iter)) {
                    Dialog dialog = new Dialog ("Quitar Producto De la lista", this, Gtk.DialogFlags.DestroyWithParent);
                    dialog.Modal = true;
                    dialog.Resizable = false;
                    Gtk.Label etiqueta = new Gtk.Label ();
                    etiqueta.Markup = "Está intentando quitar el producto seleccionado de la lista.\n\n<b>¿Desea continuar con la eliminación del producto?</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 (OnQuitarProductoDialogResponse);
                    dialog.ShowAll ();
                    dialog.Run ();
                    dialog.Destroy ();
                }

            }
        }
예제 #25
0
        /// <summary>
        /// Handles the click on the datetag:
        /// Opens up a calendar dialog
        /// </summary>
        /// <param name="editor">
        /// A <see cref="NoteEditor"/>
        /// </param>
        /// <param name="start">
        /// A <see cref="Gtk.TextIter"/>
        /// </param>
        /// <param name="end">
        /// A <see cref="Gtk.TextIter"/>
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        protected override bool OnActivate(NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end)
        {
            calendar = new Calendar ();
            range = new TextRange (start, end);
            this.editor = editor;

            Dialog dialog = new Dialog ();
            dialog.Modal = true;
            dialog.VBox.Add (calendar);
            dialog.VBox.ShowAll ();
            dialog.AddButton ("OK", ResponseType.Ok);
            dialog.AddButton ("Cancel", ResponseType.Cancel);

            dialog.Response += new ResponseHandler (OnDialogResponse);
            dialog.Run ();
            dialog.Destroy ();

            return true;
        }
예제 #26
0
 void DeadlineButton_Clicked(object sender, EventArgs e)
 {
     var dialog = new Dialog ("Sample", null, DialogFlags.DestroyWithParent);
     dialog.Modal = true;
     dialog.AddButton ("Cancel", ResponseType.Cancel);
     dialog.AddButton ("OK", ResponseType.Ok);
     dialog.ContentArea.Add (calendar);
     calendar.Show ();
     if (dialog.Run () == (int)ResponseType.Ok) {
         deadlineButton.Label = calendar.Date.ToShortDateString ();
     }
     dialog.Destroy ();
 }
예제 #27
0
    private bool AskUserForRepositoryCreation(string path)
    {
        var dialog = new Dialog (Catalog.GetString ("Please decide"), this, DialogFlags.Modal);
        dialog.VBox.PackStart (new Label (string.Format (Catalog.GetString ("ID_AskUserForCreationOfARepository"), path)));
        dialog.AddButton (Catalog.GetString ("Yes"), ResponseType.Yes);
        dialog.AddButton (Catalog.GetString ("No"), ResponseType.No);

        bool yesNo = false;
        dialog.ShowAll ();
        if (dialog.Run () == (int)ResponseType.Yes) {
            yesNo = true;
        }
        dialog.Destroy ();
        return yesNo;
    }
예제 #28
0
        protected virtual void OnAgregarButtonClicked(object sender, System.EventArgs e)
        {
            FamiliaProducto prod = new FamiliaProducto(this.entryFamilia.Text.Trim());

            if (this.db.ExisteFamiliaBd(prod))
            {
                Dialog dialog = new Dialog("FAMILIA YA EXISTE", this, Gtk.DialogFlags.DestroyWithParent);
                dialog.Modal = true;
                dialog.Resizable = false;
                Gtk.Label etiqueta = new Gtk.Label();
                etiqueta.Markup = "La Familia que intenta agregar ya existe 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 ();
            }
            else
            {
                if (this.db.AgregarFamiliaBd(prod))
                {
                    this.familias.Add(prod);
                    this.familiaModel.AppendValues(prod.Nombre);

                    this.entryFamilia.Text = "";
                    this.FamiliaProductosTreeview.Selection.UnselectAll();
                    this.añadir_button.Sensitive = false;

                    añadir_button.Sensitive = true;

                    this.cambiado = true;
                }
                else
                {
                    Dialog dialog = new Dialog("ERROR AL AGREGAR FAMILIA", this, Gtk.DialogFlags.DestroyWithParent);
                    dialog.Modal = true;
                    dialog.Resizable = false;
                    Gtk.Label etiqueta = new Gtk.Label();
                    etiqueta.Markup = "Ha ocurrido un error al agregar la Familia a 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 ();
                    añadir_button.Sensitive = true;

                }
            }
        }
	protected void OnConnectButtonClicked (object sender, System.EventArgs e)
	{
			SpawnThread(delegate()
            {
            	if(USBRadiobutton.Active){
					brick = new MonoBrick.NXT.Brick<MonoBrick.NXT.Sensor,MonoBrick.NXT.Sensor,MonoBrick.NXT.Sensor,MonoBrick.NXT.Sensor>(new USB<MonoBrick.NXT.Command,MonoBrick.NXT.Reply>());
				}
				if(bluetoothRadiobutton.Active){
				brick = new MonoBrick.NXT.Brick<MonoBrick.NXT.Sensor,Sensor,Sensor,Sensor>(new Bluetooth<MonoBrick.NXT.Command,MonoBrick.NXT.Reply>(comportCombobox.ActiveText));
				}
				if(networkRadiobutton.Active){
					if(waitForConnectioncheckbutton.Active){
						brick = new MonoBrick.NXT.Brick<Sensor,Sensor,Sensor,Sensor>(new TunnelConnection<MonoBrick.NXT.Command,MonoBrick.NXT.Reply>(ushort.Parse(portSpinbutton.Text)));
						Label networkLabel = new Label();
						//label.HeightRequest = 160;
						networkLabel.WidthRequest = 300;
						string[] addresses = NetworkHelper.GetLocalIPAddress();
							for(int i = 0; i < addresses.Length; i++){
							networkLabel.Text = networkLabel.Text + "Local IP address: " + addresses[i].PadRight(80)+"\n";
						}
						networkLabel.Text = networkLabel.Text+ "External IP Address: ";
						Dialog networkDialog = new Dialog ("Wait for connection", this, Gtk.DialogFlags.DestroyWithParent);
						networkDialog.TypeHint =  WindowTypeHint.Splashscreen;
						networkDialog.BorderWidth = 4;
						networkDialog.Modal = true;
				        networkDialog.VBox.Add (networkLabel);
						//dialog.VBox.Add (progressBar);
						networkDialog.HasSeparator = false;
						networkDialog.AddButton ("Cancel", ResponseType.Close);
						networkDialog.Response += delegate(object obj, ResponseArgs args){ 
							brick.Connection.Close();
						};
						Gtk.Application.Invoke (delegate {
							networkDialog.ShowAll();
						});
						networkLabel.Text = networkLabel.Text + Utilities.NetworkHelper.GetExternalIP();
						//MonoBrick.ConnectionDelegate onNetworkConnection = delegate(){};
						//brick.Connection.Connected += onNetworkConnection;
						try{
							brick.Connection.Open();//This will block and wait for a network connection
						}
						catch(Exception exception){
							//brick.Connection.Connected -= onNetworkConnection;
							Gtk.Application.Invoke (delegate {
								networkDialog.Destroy();
							});
							throw(exception);
						}
						//brick.Connection.Connected -= onNetworkConnection;
						Gtk.Application.Invoke (delegate {
							networkDialog.Destroy();
						});	
						
					}
					else{
						brick = new MonoBrick.NXT.Brick<Sensor,Sensor,Sensor,Sensor>(new TunnelConnection<Command,Reply>(ipEntry.Text, ushort.Parse(portSpinbutton.Text)));
					}
				}
				System.Timers.Timer timer = new System.Timers.Timer(100);
				ProgressBar progress = new ProgressBar();
				//progress.Fraction = 0.0;
				progress.Orientation = ProgressBarOrientation.LeftToRight;
				timer.Elapsed += (obj1,obj2) => {
					progress.Pulse();
				};
				Label connectLabel = new Label("Opening connection...");
				//label.HeightRequest = 160;
				connectLabel.WidthRequest = 200;
				Dialog connectDialog = new Dialog ("Connecting to the NXT", this, Gtk.DialogFlags.DestroyWithParent);
				connectDialog.TypeHint =  WindowTypeHint.Splashscreen;
				connectDialog.Modal = true;
				connectDialog.VBox.Add (connectLabel);
				connectDialog.HasSeparator = false;
				connectDialog.VBox.Add (progress);
				Gtk.Application.Invoke (delegate {
						connectDialog.ShowAll();
						timer.Start();
				});
				if(!brick.Connection.IsConnected){
					try{
						brick.Connection.Open();
					}
					catch(Exception ex){
						Gtk.Application.Invoke (delegate {
							connectDialog.Destroy();
							timer.Stop();
						});
						throw ex;
					}
				}
				brick.Connection.CommandSend += OnCommandSend;
				brick.Connection.ReplyReceived += OnReplyRecieved;
				//brick.ConnectionOpened += OnConnected;
				brick.Connection.Disconnected += Disconnected;
				try{
					Gtk.Application.Invoke (delegate {
						connectLabel.Text = "Retrieving brick information...";
					});
					
					DeviceInfo info = brick.GetDeviceInfo();
					DeviceFirmware firmware = brick.GetDeviceFirmware();
					ushort batteryLevel = brick.GetBatteryLevel();
					SetSensor[] setSensor = new SetSensor[]{
						delegate(Sensor sensor){brick.Sensor1 = sensor; brick.Sensor1.Initialize();},
						delegate(Sensor sensor){brick.Sensor2 = sensor; brick.Sensor2.Initialize();},
						delegate(Sensor sensor){brick.Sensor3 = sensor; brick.Sensor3.Initialize();},
						delegate(Sensor sensor){brick.Sensor4 = sensor; brick.Sensor4.Initialize();},
					};
					ComboBox[] comboArray = new ComboBox[]{sensor1Combobox, sensor2Combobox,sensor3Combobox, sensor4Combobox};
					//Check if sensors should be initialized with something other than none
					for(int i = 0; i < 4; i++){ 
						Console.WriteLine(i);
						Gtk.Application.Invoke (delegate {
							connectLabel.Text = "Setting up sensor " + (i+1);
						});
						if(comboArray[i].Active != 0){
							try{
								setSensor[i]((Sensor) comboArray[i].GetActiveValue());						
							}
							catch(MonoBrickException nxtEx){
								if(nxtEx is MonoBrickException){
									comboArray[i].Active = 0;//unable to set the sensor value set the comboBox to none
									setSensor[i](new Sensor(SensorType.NoSensor,SensorMode.Raw));
								}
								else
									throw nxtEx;
							}
						}
					}
					Gtk.Application.Invoke (delegate {
						UpdateDeviceInfo(info);
						UpdateFirmwareInfo(firmware);
						UpdateBatteryInfo(batteryLevel);
					});
					Connected();
					DisableAllTunnelInput();
					if(isConnectedViaNetwork()){
						Gtk.Application.Invoke (delegate {
							connectLabel.Text = "Checking tunnel settings...";
						});
						if(brickType == BrickType.NXT){
						var reply = brick.Connection.SendAndReceive(new Command(CommandType.TunnelCommand,CommandByte.GetTunnelCommands,true));
							if(!reply.HasError){
								for(int i = 0; i < reply.Data.Length-3; i++){
									switch(reply.Data[i+3]){
										case (byte)CommandByte.GetTunnelRTSPSettings:
											EnableVideoStreamInput();
											break;
										case (byte)CommandByte.GetTunnelGPSPosition:
											EnableGPSInput();
											break;
										case (byte)CommandByte.TunnelSpeak:
											EnableSpeakInput();
											break;
										}
									}
							}
							else{
								//The tunnel does not support any commands
							}
						}
					}
				}
				catch(MonoBrickException ex){
					Gtk.Application.Invoke (delegate {
						connectDialog.Destroy();
						timer.Stop();
					});
					brick.Connection.Close();
					throw ex;
				}
				Gtk.Application.Invoke (delegate {
					connectDialog.Destroy();
					timer.Stop();
				});
				
				
			});
	}
예제 #30
0
        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;
            }
        }
예제 #31
0
		public static void ShowSimOnlyDialog ()
		{
			if (!SimOnly)
				return;
			
			var dialog = new Dialog ();
			dialog.Title =  GettextCatalog.GetString ("Evaluation Version");
			
			dialog.VBox.PackStart (
			 	new Label ("<b><big>Feature Not Available In Evaluation Version</big></b>") {
					Xalign = 0.5f,
					UseMarkup = true
				}, true, false, 12);
			
			var align = new Gtk.Alignment (0.5f, 0.5f, 1.0f, 1.0f) { LeftPadding = 12, RightPadding = 12 };
			dialog.VBox.PackStart (align, true, false, 12);
			align.Add (new Label (
				"You should upgrade to the full version of MonoTouch to target and deploy\n" +
				" to the device, and to enable your applications to be distributed.") {
					Xalign = 0.5f,
					Justify = Justification.Center
				});
			
			align = new Gtk.Alignment (0.5f, 0.5f, 1.0f, 1.0f) { LeftPadding = 12, RightPadding = 12 };
			dialog.VBox.PackStart (align, true, false, 12);
			var buyButton = new Button (
				new Label (GettextCatalog.GetString ("<big>Buy MonoTouch</big>")) { UseMarkup = true } );
			buyButton.Clicked += delegate {
				System.Diagnostics.Process.Start ("http://monotouch.net");
				dialog.Respond (ResponseType.Accept);
			};
			align.Add (buyButton);
			
			dialog.AddButton (GettextCatalog.GetString ("Continue evaluation"), ResponseType.Close);
			dialog.ShowAll ();
			
			MessageService.ShowCustomDialog (dialog);
		}
예제 #32
0
        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 ();
        }
예제 #33
0
        /*	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");

                    // step 1: creation of a document-object
                    myDocument = new Document(PageSize.LETTER);

                    Console.WriteLine("hora: "+DateTime.Now.ToShortTimeString());

                    Console.WriteLine("Fecha: "+DateTime.Now.ToShortDateString());

                    // step 2:
                    // Now create a writer that listens to this doucment and writes the document to desired Stream.

                    PdfWriter.GetInstance(myDocument, new FileStream(this.ruta_destino, FileMode.Create));

                    // step 3:  Open the document now using
                    myDocument.Open();

                    PdfPTable tabla = new PdfPTable(4);

                    tabla.AddCell("N° Boleta ");
                    tabla.AddCell("Fecha " );
                    tabla.AddCell("Total Venta " );
                    tabla.AddCell("Cajero ");

                    foreach (PdfPCell celda in tabla.Rows[0].GetCells())
                    {
                        celda.BackgroundColor = BaseColor.LIGHT_GRAY;
                        celda.HorizontalAlignment = 1;
                        celda.Padding = 3;
                    }

                    try {
                        ControladorBaseDatos objeto = new ControladorBaseDatos();
                        //List<string> listaVentas = objeto.ObtenerIntervaloFechasBd(fechaInicial,fechaFinal);
                        List<Venta> listaVentas = objeto.ObtenerIntervaloFechasBd(fechaInicial,fechaFinal);
                        Console.WriteLine("tamaño listaVentas"+listaVentas.Count);

                        myDocument.Add(new Paragraph("                                                                                                                                                                                                                                                                                                                                                                                                                 Emitido el: "+DateTime.Now.ToShortDateString()+ " a las: "+DateTime.Now.ToShortTimeString()+" Horas",
                                                     FontFactory.GetFont("arial",   // fuente
                                            8,                            // tamaño
                                            Font.NORMAL,                   // estilo
                                            BaseColor.BLACK)));
                        myDocument.Add(new Paragraph(" "));
                        myDocument.Add(new Paragraph("                            Reporte Ventas Minimarket El Coke",
                                                     FontFactory.GetFont("arial",   // fuente
                                            18,                            // tamaño
                                            Font.NORMAL,                   // estilo
                                            BaseColor.BLACK)));

                        // AQUI VA EL LOGO DEL MINIMARKET

                        iTextSharp.text.Image imgP = iTextSharp.text.Image.GetInstance("/Users/Esteban/Projects/Git43Felo/punto.gui/iconos/imagen.png");
                        imgP.ScalePercent(40, 40);
                        imgP.Alignment = Element.ALIGN_CENTER;
                        myDocument.Add(imgP);

                        myDocument.Add(new Paragraph(" "));
                        myDocument.Add(new Paragraph("                                              Ventas realizadas entre "+fechaInicial+" y "+fechaFinal,
                                                     FontFactory.GetFont("arial",   // fuente
                                            10,                            // tamaño
                                            Font.NORMAL,                   // estilo
                                            BaseColor.BLACK)));
                        int tamanio = listaVentas.Count;

                        string[,] arreglo = new string[tamanio,4];

                        for(int i=0; i<tamanio; i++){
                            for(int j=0; j<4; j++){
                                switch(j)
                                {
                                case 0:
                                    arreglo[i,j] =Convert.ToString(listaVentas[i].Idventa);
                                    break;
                                case 1:
                                    arreglo[i,j] =listaVentas[i].Var_fecha;
                                    break;
                                case 2:
                                    arreglo[i,j] =listaVentas[i].Total;
                                    break;
                                case 3:
                                    arreglo[i,j] =listaVentas[i].Usuarios_userlogin;
                                    break;
                                default:
                                    Console.WriteLine("Default case");
                                    break;

                                }

                            }
                        }
                        List<string> lista2 = new List<string>();
                        for(int i=0; i<tamanio; i++){
                            for(int j=0; j<4; j++){
                                Console.WriteLine("["+i+"]["+j+"]: "+arreglo[i,j]+" ");
                                lista2.Add(arreglo[i,j]);
                            }
                            Console.WriteLine("\n");
                        }

                        for (int i = 0; i < (tamanio*4); i++){
                            tabla.AddCell(lista2[i]);
                        }

                        int total = 0;
                        for(int aux=0; aux<listaVentas.Count; aux++){

                            total+=Int32.Parse(listaVentas[aux].Total);
                        }
                        Console.WriteLine("Total: "+total);

                        myDocument.Add(new Paragraph(" "));
                        myDocument.Add(tabla);
                        myDocument.Add(new Paragraph(" "));
                        myDocument.Add(new Paragraph("                                                                                                                                                                                                                               Total______$"+total+".-",
                                                     FontFactory.GetFont("arial",   // fuente
                                            22,                            // tamaño
                                            Font.NORMAL,                   // estilo
                                            BaseColor.RED)));
                        /*	for(int aux=0; aux<listaVentas.Count; aux++){
                            Console.WriteLine("Numero Boleta: "+listaVentas[aux].Tipo_pago);
                            myDocument.Add(new Paragraph("Numero Boleta: "+Convert.ToString(listaVentas[aux].Idventa)));
                            myDocument.Add(new Paragraph("Fecha: "+listaVentas[aux].Var_fecha));
                            myDocument.Add(new Paragraph("Total: "+listaVentas[aux].Total));
                            myDocument.Add(new Paragraph("Cajero: "+listaVentas[aux].Usuarios_userlogin));
                            myDocument.Add(new Paragraph("***********************"));
                        }*/
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Excepcion:"+ex);
                    }
                    // step 4: Now add some contents to the document
                    //				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));
                    //				}

                    // step 5: Remember to close the documnet

                    myDocument.Close();

                    Dialog dialog2 = new Dialog("MENSAJE", this, Gtk.DialogFlags.DestroyWithParent);
                    dialog2.Modal = true;
                    dialog2.Resizable = false;
                    Gtk.Label etiqueta2 = new Gtk.Label();
                    etiqueta2.Markup = "Documento PDF creado correctamente";
                    dialog2.BorderWidth = 8;
                    dialog2.VBox.BorderWidth = 8;
                    dialog2.VBox.PackStart(etiqueta2, false, false, 0);
                    dialog2.AddButton ("Cerrar", ResponseType.Close);
                    dialog2.ShowAll();
                    dialog2.Run ();
                    dialog2.Destroy ();

                }
            }
        }
예제 #34
0
        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;
            }
        }
예제 #35
0
		private void create_with_file_chooser (string title, Gtk.Window parent, Action action) {
			int a = 0;
			string stock = Gtk.Stock.Open;
			
			/* FIXME: here we use the raw enum values from
			 * GtkFileChooserAction, because I'm too lazy to do something
			 * like this:
			 *
			 * GType t = gtk_file_chooser_action_get_type ();
			 * GEnumClass *c = g_type_class_ref (t);
			 * GEnumValue *v = g_enum_get_value_by_name (c, "GTK_FILE_CHOOSER_ACTION_FOO");
			 * int intval = v->value;
			 * g_type_class_unref (c);
			 * ... use intval ...
			 */
			switch (action) {
			case Action.Open:
				a = 0;
				stock = Gtk.Stock.Open;
				break;
				
			case Action.Save:
				a = 1;
				stock = Gtk.Stock.Save;
				break;
				
			case Action.SelectFolder:
				a = 2;
				stock = Gtk.Stock.Open;
				break;
			}
			
#if false
			IntPtr ptr = gtk_file_chooser_dialog_new_with_backend (title,
									       parent != null ? parent.Handle : IntPtr.Zero,
									       a, "gtk+", IntPtr.Zero);
#else
			IntPtr ptr = gtk_file_chooser_dialog_new (title,
								  parent != null ? parent.Handle : IntPtr.Zero,
								  a, IntPtr.Zero);
#endif
			
			chooser = GLib.Object.GetObject (ptr, false) as Gtk.Dialog;
			
			chooser.AddButton (Gtk.Stock.Cancel, Gtk.ResponseType.Cancel);
			
			/* Note that we use Ok rather than the preferred Accept because
			 * that's what GtkFileSelection uses.  Rather than have two
			 * separate tests for each case (chooser/filesel), we'll rather
			 * just test for a single response code, which is Ok.
			 */
			chooser.AddButton (stock, Gtk.ResponseType.Ok);
			chooser.DefaultResponse = Gtk.ResponseType.Ok;
		}
예제 #36
0
        protected void OnButtonPickDatePeriodClicked(object sender, EventArgs e)
        {
            #region Widget creation
            Window parentWin  = (Window)Toplevel;
            var    selectDate = new Gtk.Dialog("Укажите период", parentWin, DialogFlags.DestroyWithParent);
            selectDate.Modal = true;
            selectDate.AddButton("Отмена", ResponseType.Cancel);
            selectDate.AddButton("Ok", ResponseType.Ok);

            periodSummary = new Label();
            selectDate.VBox.Add(periodSummary);

            HBox hbox      = new HBox(true, 6);
            var  startVbox = new VBox(false, 3);
            var  endVbox   = new VBox(false, 3);

            StartDateCalendar = new Calendar();
            StartDateCalendar.DisplayOptions = DisplayOptions;
            StartDateCalendar.DaySelected   += StartDateCalendar_DaySelected;
            StartDateCalendar.MonthChanged  += StartDateCalendar_MonthChanged;
            StartDateCalendar.Day            = 0;
            StartDateCalendar_MonthChanged(null, null);

            EndDateCalendar = new Calendar();
            EndDateCalendar.DisplayOptions = DisplayOptions;
            EndDateCalendar.DaySelected   += EndDateCalendar_DaySelected;
            EndDateCalendar.MonthChanged  += EndDateCalendar_MonthChanged;
            EndDateCalendar.Day            = 0;
            EndDateCalendar_MonthChanged(null, null);

            if (CalendarFontSize.HasValue)
            {
                var desc = new FontDescription {
                    AbsoluteSize = CalendarFontSize.Value * 1000
                };
                StartDateCalendar.ModifyFont(desc);
                EndDateCalendar.ModifyFont(desc);
            }

            StartDateEntry              = new DatePicker();
            StartDateEntry.DateChanged += StartDateEntry_DateChanged;

            EndDateEntry              = new DatePicker();
            EndDateEntry.DateChanged += EndDateEntry_DateChanged;

            startVbox.Add(StartDateCalendar);
            startVbox.Add(StartDateEntry);
            endVbox.Add(EndDateCalendar);
            endVbox.Add(EndDateEntry);

            hbox.Add(startVbox);
            hbox.Add(endVbox);

            selectDate.VBox.Add(hbox);
            selectDate.ShowAll();

            StartDateEntry.HideCalendarButton = true;
            EndDateEntry.HideCalendarButton   = true;

            if (SetCurrentDateByDefault && !StartDateOrNull.HasValue && !EndDateOrNull.HasValue)
            {
                StartDateEntry.DateOrNull = DateTime.Today.Date;
                EndDateEntry.DateOrNull   = DateTime.Today.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            else
            {
                StartDateEntry.DateOrNull = StartDateOrNull;
                EndDateEntry.DateOrNull   = EndDateOrNull;
            }
            #endregion

            int response = selectDate.Run();
            if (response == (int)ResponseType.Ok)
            {
                startDate = StartDateEntry.DateOrNull;
                endDate   = EndDateEntry.DateOrNull;
                OnStartDateChanged();
                OnEndDateChanged();
                OnPeriodChanged();
                OnPeriodChangedByUser();
            }

            #region Destroy
            EndDateCalendar.Destroy();
            StartDateCalendar.Destroy();
            StartDateEntry.Destroy();
            EndDateEntry.Destroy();
            startVbox.Destroy();
            endVbox.Destroy();
            hbox.Destroy();
            selectDate.Destroy();
            #endregion
        }