Exemplo n.º 1
0
        public object ChooseOption(Dictionary <string, object> options, object parent = null)
        {
            object             res = null;
            Window             parentWindow;
            ChooseOptionDialog dialog;

            if (parent != null)
            {
                parentWindow = (parent as Widget).Toplevel as Gtk.Window;
            }
            else
            {
                parentWindow = mainWindow as Gtk.Window;
            }

            dialog         = new ChooseOptionDialog(parentWindow);
            dialog.Options = options;

            if (dialog.Run() == (int)ResponseType.Ok)
            {
                res = dialog.SelectedOption;
            }
            dialog.Destroy();
            return(res);
        }
Exemplo n.º 2
0
        public Task <object> ChooseOption(Dictionary <string, object> options, string title = null, object parent = null)
        {
            object             res = null;
            Window             parentWindow;
            ChooseOptionDialog dialog;

            if (title == null)
            {
                title = Catalog.GetString("Choose option");
            }

            if (parent != null)
            {
                parentWindow = (parent as Widget).Toplevel as Gtk.Window;
            }
            else
            {
                parentWindow = MainWindow;
            }

            dialog         = new ChooseOptionDialog(parentWindow);
            dialog.Options = options;
            dialog.Title   = title;

            if (dialog.Run() == (int)ResponseType.Ok)
            {
                res = dialog.SelectedOption;
            }
            dialog.Destroy();
            var task = Task.Factory.StartNew(() => res);

            return(task);
        }