Esempio n. 1
0
        protected async override void Run()
        {
            using (var monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(false))
            {
                monitor.BeginTask(1);
                var solution         = ProjectOperations.CurrentSelectedSolution;
                var solutionFullPath = solution.BaseDirectory.FullPath;
                try
                {
                    var isConfirmed = MessageDialog.Confirm(
                        $"Are you sure you want to delete '{solutionFullPath}'?",
                        "Please note that after performing this operation it might be impossible to restore the solution.",
                        Xwt.Command.Ok);
                    if (isConfirmed)
                    {
                        await IdeApp.Workspace.Close();

                        FileService.DeleteDirectory(solutionFullPath);
                        monitor.ReportSuccess($"Succesfully deleted: `{solutionFullPath}`.");
                    }
                }
                catch (Exception ex)
                {
                    monitor.ReportError($"Failed to delete '{solutionFullPath}' with: {ex}");
                }
                finally
                {
                    monitor.EndTask();
                }
            }
        }
Esempio n. 2
0
 void HandleCloseRequested(object sender, CloseRequestedEventArgs args)
 {
     args.AllowClose = MessageDialog.Confirm(Application.TranslationCatalog.GetString("The application will be closed"), Command.Ok);
     if (args.AllowClose)
     {
         Application.Exit();
     }
 }
Esempio n. 3
0
 private void MainWindow_CloseRequested(object sender, CloseRequestedEventArgs args)
 {
     args.AllowClose = MessageDialog.Confirm("Este programa se va a cerrar...\n¿Estas seguro?", Command.Ok);
     if (args.AllowClose)
     {
         Application.Exit();
     }
 }
Esempio n. 4
0
 void HandleCloseRequested(object sender, CloseRequestedEventArgs args)
 {
     args.AllowClose = MessageDialog.Confirm("Samples will be closed", Command.Ok);
     if (args.AllowClose)
     {
         Application.Exit();
     }
 }
        public void Execute()
        {
            if (!MessageDialog.Confirm(Properties.Resources.Action_DeleteEvidenceAll_Confirm))
            {
                return;
            }

            App.Context.GetActiveWorkbookContext().DeleteEvidenceAll();
        }
Esempio n. 6
0
 public static void CallBackEvents(this ICallBack callbackable, Widget widget)
 {
     if (callbackable != null)
     {
         callbackable.CallBack.Message      += (title, message) => MessageDialog.ShowMessage(widget.ParentWindow, title, message);
         callbackable.CallBack.Warning      += (title, message) => MessageDialog.ShowWarning(widget.ParentWindow, title, message);
         callbackable.CallBack.Error        += (title, message) => MessageDialog.ShowError(widget.ParentWindow, title, message);
         callbackable.CallBack.Confirmation += (title, message) => MessageDialog.Confirm(widget.ParentWindow, title, message, Command.Yes);
     }
 }
Esempio n. 7
0
        protected bool ShowRetryCancel(Exception e)
        {
            var msg = new ConfirmationMessage(e.Message, XwtMessager.Retry);

            msg.Buttons.Clear();
            msg.Buttons.Add(XwtMessager.Abort);
            msg.ConfirmButton = XwtMessager.Retry;
            msg.Icon          = StockIcons.Error;
            return(MessageDialog.Confirm(msg));
        }
Esempio n. 8
0
        protected override bool OnCloseRequested()
        {
            var allow_close = MessageDialog.Confirm("Hamekoz.PyME.UI will be closed", Command.Ok);

            if (allow_close)
            {
                Application.Exit();
            }
            return(allow_close);
        }
Esempio n. 9
0
 private void TestRunForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     switch (this.runner.Status)
     {
     case TaskStatus.Running:
     case TaskStatus.WaitingForActivation:
     case TaskStatus.WaitingForChildrenToComplete:
     case TaskStatus.WaitingToRun:
         this.runner.Pause();
         e.Cancel = !MessageDialog.Confirm(Properties.Resources.CancelTestRun);
         this.runner.Resume();
         break;
     }
 }
Esempio n. 10
0
        public DialogResult Show(string title, string text, MessageBoxButtons buttons)
        {
            try {
                Application.MainLoop.DispatchPendingEvents();

                if (buttons == MessageBoxButtons.None)
                {
                    MessageDialog.ShowMessage(title, text);
                    return(DialogResult.None);
                }

                if (buttons == MessageBoxButtons.Yes || buttons == MessageBoxButtons.Ok)
                {
                    MessageDialog.ShowMessage(title, text);
                    if (buttons == MessageBoxButtons.Yes)
                    {
                        return(DialogResult.Yes);
                    }
                    return(DialogResult.Ok);
                }

                if ((buttons & (MessageBoxButtons.No | MessageBoxButtons.Cancel | MessageBoxButtons.Retry)) != 0)
                {
                    var question = MessageDialog.AskQuestion(title, text, 0, ToXwt(buttons));
                    return(ToLim(question));
                }

                if (false)
                {
                    var confirm = MessageDialog.Confirm(text, title, ToXwt(buttons).First());
                    if (confirm)
                    {
                        return(DialogResult.Ok);
                    }
                    else
                    {
                        return(DialogResult.Cancel);
                    }
                }

                return(DialogResult.None);
            } catch (Exception ex) {
                Application.NotifyException(ex);
                return(DialogResult.None);
            }
            return(DialogResult.None);
        }
Esempio n. 11
0
        public MainWindow()
        {
            StartPosition = WindowPosition.CenterScreen;
            Size          = new Size(600, 400);
            //Title = ApplicationName;

            /* Commands */

            /* New */
            var newCommand = StockCommand.New.GetGlobalInstance();

            newCommand.Activated += (sender, e) =>
            {
                MessageDialog.RootWindow = this;
                var result = MessageDialog.Confirm("NEW!", "Secondary");
                result = result;
            };

            /* Open File */
            var openFileCommandAccelerator = new Accelerator(Key.o, ModifierKeys.Command);
            var openFileCommand            = new Command("OpenFile", "Open _File\u2026", openFileCommandAccelerator);

            openFileCommand.Activated += (sender, e) =>
            {
                var openFileDialog = new OpenFileDialog();
                openFileDialog.Filters.Add(new FileDialogFilter("KeePass KDBX Files", "*.kdbx"));
                openFileDialog.Filters.Add(new FileDialogFilter("All Files", "*.*"));
                openFileDialog.CurrentFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
                openFileDialog.Run();
                // TODO: Handle actual file opening
            };

            /* Open Url */
            var openUrlCommandAccelerator = new Accelerator(Key.O, ModifierKeys.Command);
            var openUrlCommand            = new Command("OpenUrl", "Open _URL\u2026", openUrlCommandAccelerator);

            openUrlCommand.Activated += (sender, e) =>
            {
                // TODO: add OpenUrlDialog
            };

            /* Clear Recent List */
            var clearOpenRecentListCommand = new Command("OpenRecentClearList", "_Clear List");

            clearOpenRecentListCommand.Activated += (sender, e) =>
            {
                if (openRecentCommandList != null)
                {
                    openRecentCommandList.Clear();
                }
            };

            /* Close */
            var closeCommand = StockCommand.Close.GetGlobalInstance();

            /* Save */
            var saveCommand = StockCommand.Save.GetGlobalInstance();
            /* Save To File */
            var saveFileCommand = new Command("SaveToFile", "Save to _File\u2026");

            /* Save To URL */
            var saveUrlCommand = new Command("SaveToURL", "Save to _URL\u2026");

            /* Save Copy To File */
            var saveCopyFileCommand = new Command("SaveCopyToFile", "Save _Copy to File\u2026");

            /* Database Settings */
            var showDatabaseSettingsCommand = new Command("DatabaseSettings", "_Database Settings\u2026");

            /* Change Master Key */
            var changeMasterKeyCommand = new Command("ChangeMasterKey", "Change _Master Key\u2026");

            /* Print */
            var printCommand = StockCommand.Print.GetGlobalInstance();

            /* Import */
            var importcommand = StockCommand.Import.GetGlobalInstance();

            /* Export */
            var exportcommand = StockCommand.Export.GetGlobalInstance();

            /* Synchronize File */
            var synchronizeFileAccelerator = new Accelerator(Key.r, ModifierKeys.Command);
            var synchronizeFileCommand     = new Command("SynchronizeFile", "Synchronize with _File\u2026",
                                                         synchronizeFileAccelerator);

            /* Synchronize URL */
            var synchronizeUrlAccelerator = new Accelerator(Key.R, ModifierKeys.Command);
            var synchronizeUrlCommand     = new Command("SynchronizeURL", "Synchronize with _URL\u2026",
                                                        synchronizeUrlAccelerator);

            /* Clear Synchronize Recent List */
            var clearSynchronizeRecentListCommand = new Command("SynchronizeRecentClearList", "_Clear List");

            clearSynchronizeRecentListCommand.Activated += (sender, e) =>
            {
                if (synchronizeRecentCommandList != null)
                {
                    synchronizeRecentCommandList.Clear();
                }
            };

            /* Lock Workspace */
            var lockWorkspaceAccelerator = new Accelerator(Key.l, ModifierKeys.Command);
            var lockWorkspaceCommand     = new Command("LockWorkspace", "_Lock Workspace", lockWorkspaceAccelerator);

            /* Preferences/Options */
            var showPreferencesCommand = StockCommand.Preferences.GetGlobalInstance();

            /* Quit */
            var quitCommand = StockCommand.Quit.GetGlobalInstance();
            //quitCommand.Activated += (sender, e) => Application.Exit ();


            /* About */
            var aboutCommand = new Command("About", "_About");


            /* Main Menu */

            MainMenu = new Menu();

            var isOSXToolkit = Toolkit.CurrentEngine.Type == ToolkitType.Cocoa ||
                               Toolkit.CurrentEngine.Type == ToolkitType.XamMac;

            if (isOSXToolkit)
            {
                /* Application */
                var appMenu = new MenuItem();                  // title is automatic
                MainMenu.Items.Add(appMenu);
                appMenu.SubMenu = new Menu();

                /* Application > About */
                appMenu.SubMenu.Items.Add(aboutCommand.CreateMenuItem());

                /* Application > Preferences */
                var appPreferencesMenuItem = showPreferencesCommand.CreateMenuItem();
                appMenu.SubMenu.Items.Add(appPreferencesMenuItem);

                appMenu.SubMenu.Items.Add(new SeparatorMenuItem());

                /* Application > Quit */
                appMenu.SubMenu.Items.Add(quitCommand.CreateMenuItem());
            }

            /* File */
            var fileMenu = new MenuItem("_File");

            fileMenu.SubMenu = new Menu();
            MainMenu.Items.Add(fileMenu);
            var fileNewMenuItem = newCommand.CreateMenuItem();

            /* File > New... */
            fileMenu.SubMenu.Items.Add(fileNewMenuItem);

            /* File > Open */
            var fileOpenMenuItem = new MenuItem("_Open");

            fileOpenMenuItem.SubMenu = new Menu();
            fileMenu.SubMenu.Items.Add(fileOpenMenuItem);

            /* File > Open > Open File... */
            fileOpenMenuItem.SubMenu.Items.Add(openFileCommand.CreateMenuItem());

            /* File > Open > Open URL... */
            fileOpenMenuItem.SubMenu.Items.Add(openUrlCommand.CreateMenuItem());

            /* File > Open Recent */
            var fileOpenRecentMenuItem = new MenuItem("Open _Recent");

            fileOpenRecentMenuItem.SubMenu = new Menu();
            // SubMenu is dynamically generated
            fileOpenRecentMenuItem.Clicked += (sender, e) =>
            {
                fileOpenRecentMenuItem.SubMenu.Items.Clear();
                if (openRecentCommandList == null)
                {
                    openRecentCommandList = new List <Command> ();
                    // TODO: Populate from user settings
                }
                var hasItems = openRecentCommandList.Count > 0;
                if (hasItems)
                {
                    foreach (var command in openRecentCommandList)
                    {
                        fileOpenRecentMenuItem.SubMenu.Items.Add(command.CreateMenuItem());
                    }
                }
                else
                {
                    fileOpenRecentMenuItem.SubMenu.Items.Add
                        (new MenuItem("(No Recent Items)")
                    {
                        Sensitive = false
                    });
                }
                fileOpenRecentMenuItem.SubMenu.Items.Add(new SeparatorMenuItem());
                var fileOpenRecentClearListMenuItem = clearOpenRecentListCommand.CreateMenuItem();
                fileOpenRecentClearListMenuItem.Sensitive = hasItems;
                fileOpenRecentMenuItem.SubMenu.Items.Add(fileOpenRecentClearListMenuItem);
            };
            fileMenu.SubMenu.Items.Add(fileOpenRecentMenuItem);

            /* File > Close */
            fileMenu.SubMenu.Items.Add(closeCommand.CreateMenuItem());

            fileMenu.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Save */
            fileMenu.SubMenu.Items.Add(saveCommand.CreateMenuItem());

            /* File > Save As */
            var fileSaveAsMenuItem = new MenuItem("Save _As");

            fileSaveAsMenuItem.SubMenu = new Menu();
            fileMenu.SubMenu.Items.Add(fileSaveAsMenuItem);

            /* File > Save As > Save to File... */
            fileSaveAsMenuItem.SubMenu.Items.Add(saveFileCommand.CreateMenuItem());

            /* File > Save As > Save to URL... */
            fileSaveAsMenuItem.SubMenu.Items.Add(saveUrlCommand.CreateMenuItem());

            fileSaveAsMenuItem.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Save As > Save Copy to File... */
            fileSaveAsMenuItem.SubMenu.Items.Add(saveCopyFileCommand.CreateMenuItem());

            fileMenu.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Database Settings... */
            fileMenu.SubMenu.Items.Add(showDatabaseSettingsCommand.CreateMenuItem());

            /* File > Change Master Key... */
            fileMenu.SubMenu.Items.Add(changeMasterKeyCommand.CreateMenuItem());

            fileMenu.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Print... */
            fileMenu.SubMenu.Items.Add(printCommand.CreateMenuItem());

            fileMenu.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Import... */
            fileMenu.SubMenu.Items.Add(importcommand.CreateMenuItem());

            /* File > Export... */
            fileMenu.SubMenu.Items.Add(exportcommand.CreateMenuItem());

            fileMenu.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Synchronize */
            var fileSynchronizeMenuItem = new MenuItem("S_ynchronize");

            fileSynchronizeMenuItem.SubMenu = new Menu();
            fileMenu.SubMenu.Items.Add(fileSynchronizeMenuItem);

            /* File > Synchronize > Synchronize with File... */
            fileSynchronizeMenuItem.SubMenu.Items.Add(synchronizeFileCommand.CreateMenuItem());

            /* File > Synchronize > Synchronize with URL... */
            fileSynchronizeMenuItem.SubMenu.Items.Add(synchronizeUrlCommand.CreateMenuItem());

            fileSynchronizeMenuItem.SubMenu.Items.Add(new SeparatorMenuItem());

            /* File > Synchronize > Recent Files */
            var fileSynchronizeRecentMenuItem = new MenuItem("_Recent Files");

            fileSynchronizeRecentMenuItem.SubMenu = new Menu();
            // SubMenu is dynamically generated
            fileSynchronizeRecentMenuItem.Clicked += (sender, e) =>
            {
                fileSynchronizeRecentMenuItem.SubMenu.Items.Clear();
                if (openRecentCommandList == null)
                {
                    openRecentCommandList = new List <Command> ();
                    // TODO: Populate from user settings
                }
                var hasItems = openRecentCommandList.Count > 0;
                if (hasItems)
                {
                    foreach (var command in openRecentCommandList)
                    {
                        fileSynchronizeRecentMenuItem.SubMenu.Items.Add(command.CreateMenuItem());
                    }
                }
                else
                {
                    fileSynchronizeRecentMenuItem.SubMenu.Items.Add
                        (new MenuItem("(No Recent Items)")
                    {
                        Sensitive = false
                    });
                }
                fileSynchronizeRecentMenuItem.SubMenu.Items.Add(new SeparatorMenuItem());
                var fileSynchronizeRecentClearListMenuItem = clearSynchronizeRecentListCommand.CreateMenuItem();
                fileSynchronizeRecentClearListMenuItem.Sensitive = hasItems;
                fileSynchronizeRecentMenuItem.SubMenu.Items.Add(fileSynchronizeRecentClearListMenuItem);
            };
            fileSynchronizeMenuItem.SubMenu.Items.Add(fileSynchronizeRecentMenuItem);

            /* File > Lock Workspace */
            fileMenu.SubMenu.Items.Add(lockWorkspaceCommand.CreateMenuItem());

            if (!isOSXToolkit)
            {
                fileMenu.SubMenu.Items.Add(new SeparatorMenuItem());

                /* File > Quit */
                fileMenu.SubMenu.Items.Add(quitCommand.CreateMenuItem());
            }

            /* Edit */
            var editMenu = new MenuItem("_Edit");

            editMenu.SubMenu = new Menu();
            MainMenu.Items.Add(editMenu);

            if (!isOSXToolkit)
            {
                /* Edit > Preferences */
                var editPreferencesMenuItem = showPreferencesCommand.CreateMenuItem();
                editMenu.SubMenu.Items.Add(editPreferencesMenuItem);

                editMenu.SubMenu.Items.Add(new SeparatorMenuItem());
            }

            editMenu.SubMenu.Items.Add(StockCommand.Cut.GetGlobalInstance().CreateMenuItem());
            StockCommand.Cut.GetGlobalInstance().Activated += (sender, e) => MessageDialog.ShowMessage("Cut");
            editMenu.SubMenu.Items.Add(StockCommand.Copy.GetGlobalInstance().CreateMenuItem());
            editMenu.SubMenu.Items.Add(StockCommand.Paste.GetGlobalInstance().CreateMenuItem());

            /* View */

            var viewMenu = new MenuItem("_View");

            viewMenu.SubMenu = new Menu();
            MainMenu.Items.Add(viewMenu);


            /* Tools */

            var toolsMenu = new MenuItem("_Tools");

            toolsMenu.SubMenu = new Menu();
            MainMenu.Items.Add(toolsMenu);


            /* Help */

            var helpMenu = new MenuItem("_Help");

            helpMenu.SubMenu = new Menu();
            MainMenu.Items.Add(helpMenu);

            if (!isOSXToolkit)
            {
                /* Help > About */
                helpMenu.SubMenu.Items.Add(aboutCommand.CreateMenuItem());
            }

            /* Content */

            var content = new HBox();

            content.PackStart(new TextEntry());
            content.PackStart(new Button("test"));
            Content = content;


            /* Events */

            CloseRequested += (sender, args) => quitCommand.Activate();
        }
Esempio n. 12
0
        protected Same()
        {
            buscar.Clicked += delegate {
                Dialogo.Refresh();
                var r = Dialogo.Run(ParentWindow);
                if (r == Command.Ok)
                {
                    if (Dialogo.SelectedItem == null)
                    {
                        return;
                    }
                    var item = Dialogo.SelectedItem;
                    Controller.Load(item);
                    Widget.Item = item;
                    Widget.ValuesRefresh();
                    Editable(false);
                    isNew = false;
                }
                Dialogo.Hide();
            };

            agregar.Clicked += delegate {
                var item = Controller.Create();
                Widget.ValuesClean();
                Widget.Item = item;
                OnBeforeAdd();
                Widget.ValuesRefresh();
                Editable(true);
                isNew = true;
            };

            modificar.Clicked += delegate {
                Editable(Widget.HasItem());
            };

            eliminar.Clicked += delegate {
                if (Widget.HasItem() && MessageDialog.Confirm(string.Format(Application.TranslationCatalog.GetString("Are you sure to erase this {0}?"), typeof(T).Name.Humanize()), Command.Yes))
                {
                    Controller.Remove(Widget.Item);
                    Widget.ValuesClean();
                    Editable(false);
                }
            };

            grabar.Clicked += delegate {
                try {
                    Widget.ValuesTake();
                    OnBeforeSave();
                    Controller.Save(Widget.Item);
                    Editable(false);
                    Widget.ValuesRefresh();
                    OnAfterSave();
                } catch (ValidationDataException ex) {
                    MessageDialog.ShowWarning(Application.TranslationCatalog.GetString("Data is not valid"), ex.Message);
                }
            };

            cancelar.Clicked += delegate {
                if (isNew)
                {
                    Widget.ValuesClean();
                }
                else
                {
                    //FIX no deberia tener que recargar el objeto si no se persisten los cambios
                    Controller.Load(Widget.Item);
                    Widget.ValuesRefresh();
                }
                Editable(false);
            };

            imprimir.Clicked += (sender, e) => OnPrint();

            actionBox.PackStart(buscar, true, true);
            actionBox.PackStart(agregar, true, true);
            actionBox.PackStart(modificar, true, true);
            actionBox.PackStart(eliminar, true, true);
            actionBox.PackStart(grabar, true, true);
            actionBox.PackStart(cancelar, true, true);
            actionBox.PackStart(imprimir, true, true);

            PackStart(scroller, true, true);
            PackEnd(actionBox, false, true);
        }
Esempio n. 13
0
 void HandleCloseRequested(object sender, CloseRequestedEventArgs args)
 {
     args.Handled = !MessageDialog.Confirm("Samples will be closed", Command.Ok);
 }
Esempio n. 14
0
        public MessageDialogs()
        {
            Table table = new Table();

            TextEntry txtPrimay    = new TextEntry();
            TextEntry txtSecondary = new TextEntry();

            txtSecondary.MultiLine = true;
            ComboBox cmbType = new ComboBox();

            cmbType.Items.Add("Message");
            cmbType.Items.Add("Question");
            cmbType.Items.Add("Confirmation");
            cmbType.Items.Add("Warning");
            cmbType.Items.Add("Error");
            cmbType.SelectedIndex = 0;

            Button btnShowMessage = new Button("Show Message");

            Label lblResult = new Label();

            table.Add(new Label("Primary Text:"), 0, 0);
            table.Add(txtPrimay, 1, 0, hexpand: true);
            table.Add(new Label("Secondary Text:"), 0, 1);
            table.Add(txtSecondary, 1, 1, hexpand: true);
            table.Add(new Label("Message Type:"), 0, 2);
            table.Add(cmbType, 1, 2, hexpand: true);

            table.Add(btnShowMessage, 1, 3, hexpand: true);
            table.Add(lblResult, 1, 4, hexpand: true);

            btnShowMessage.Clicked += (sender, e) => {
                switch (cmbType.SelectedText)
                {
                case "Message":
                    MessageDialog.ShowMessage(this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
                    lblResult.Text = "Result: dialog closed";
                    break;

                case "Question":
                    var question = new QuestionMessage(txtPrimay.Text, txtSecondary.Text);
                    question.Buttons.Add(new Command("Answer 1"));
                    question.Buttons.Add(new Command("Answer 2"));
                    question.DefaultButton = 1;
                    question.AddOption("option1", "Option 1", false);
                    question.AddOption("option2", "Option 2", true);
                    var result = MessageDialog.AskQuestion(question);
                    lblResult.Text = "Result: " + result.Id;
                    if (question.GetOptionValue("option1"))
                    {
                        lblResult.Text += " + Option 1";
                    }
                    if (question.GetOptionValue("option2"))
                    {
                        lblResult.Text += " + Option 2";
                    }
                    break;

                case "Confirmation":
                    var confirmation = new ConfirmationMessage(txtPrimay.Text, txtSecondary.Text, Command.Apply);
                    confirmation.AddOption("option1", "Option 1", false);
                    confirmation.AddOption("option2", "Option 2", true);
                    confirmation.AllowApplyToAll = true;

                    var success = MessageDialog.Confirm(confirmation);
                    lblResult.Text = "Result: " + success;
                    if (confirmation.GetOptionValue("option1"))
                    {
                        lblResult.Text += " + Option 1";
                    }
                    if (confirmation.GetOptionValue("option2"))
                    {
                        lblResult.Text += " + Option 2";
                    }

                    lblResult.Text += " + All: " + confirmation.AllowApplyToAll;
                    break;

                case "Warning":
                    MessageDialog.ShowWarning(this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
                    lblResult.Text = "Result: dialog closed";
                    break;

                case "Error":
                    MessageDialog.ShowError(this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
                    lblResult.Text = "Result: dialog closed";
                    break;
                }
            };

            PackStart(table, true);
        }
Esempio n. 15
0
        protected Lame()
        {
            SelectedItemChanged += delegate {
                var item = List.SelectedItem;
                if (item != null)
                {
                    Controller.Load(item);
                    Widget.Item = item;
                    Widget.ValuesRefresh();
                    Editable(false);
                    isNew = false;
                }
            };

            agregar.Clicked += delegate {
                var item = Controller.Create();
                Widget.Item = item;
                Widget.ValuesRefresh();
                List.UnselectAll();
                Editable(true);
                isNew = true;
            };

            modificar.Clicked += delegate {
                Editable(Widget.HasItem());
            };

            eliminar.Clicked += delegate {
                if (Widget.HasItem() && MessageDialog.Confirm(string.Format(Application.TranslationCatalog.GetString("Are you sure to erase this {0}?"), typeof(T).Name.Humanize()), Command.Yes))
                {
                    Controller.Remove(Widget.Item);
                    List.List.Remove(Widget.Item);
                    List.Refresh();
                    Widget.ValuesClean();
                    Editable(false);
                }
            };

            grabar.Clicked += delegate {
                try {
                    Widget.ValuesTake();
                    OnBeforeSave();
                    Controller.Save(Widget.Item);
                    List.List = Controller.List;
                    List.Refresh();
                    List.SelectedItem = Widget.Item;
                    Editable(false);
                } catch (ValidationDataException ex) {
                    MessageDialog.ShowWarning(Application.TranslationCatalog.GetString("Data is not valid"), ex.Message);
                }
            };

            cancelar.Clicked += delegate {
                if (isNew)
                {
                    Widget.ValuesClean();
                }
                else
                {
                    //FIX no deberia tener que recargar el objeto si no se persisten los cambios
                    Controller.Load(Widget.Item);
                    Widget.ValuesRefresh();
                }
                Editable(false);
            };

            imprimir.Clicked += (sender, e) => OnPrint();

            AddAction(agregar);
            AddAction(modificar);
            AddAction(eliminar);
            AddAction(grabar);
            AddAction(cancelar);
            AddAction(imprimir);
        }
Esempio n. 16
0
        public bool Initialize(ToolkitType type)
        {
            _log.Open(Path.Combine(AppData.Path, "ParkitectNexusLauncher.log"));
            _log.MinimumLogLevel = LogLevel.Debug;

            Application.Initialize(type);

            _window = _presenterFactory.InstantiatePresenter <MainWindow>();
            _window.Show();

            var update = _updateManager.CheckForUpdates <App>();

            if (update != null)
            {
                if (
                    MessageDialog.AskQuestion("ParkitectNexus Client Update",
                                              "A required update for the ParkitectNexus Client needs to be installed.\n" +
                                              "Without this update you won't be able to install blueprints, savegames or mods trough this application. The update should take less than a minute.\n" +
                                              $"Would you like to install it now?\n\nYou are currently running v{typeof (App).Assembly.GetName().Version}. The newest version is v{update.Version}",
                                              Command.Yes, Command.No) !=
                    Command.Yes)
                {
                    return(false);
                }

                if (!_updateManager.InstallUpdate(update))
                {
                    MessageDialog.ShowError(_window, "ParkitectNexus Client Update", "Failed installing the update! Please try again later.");
                }

                return(false);
            }

            if (!_parkitect.DetectInstallationPath())
            {
                if (
                    !MessageDialog.Confirm(
                        "We couldn't automatically detect Parkitect on your machine!\nPlease press OK and manually select the installation folder of Parkitect.",
                        Command.Ok))
                {
                    _window.Dispose();
                    Application.Dispose();
                    return(false);
                }

                do
                {
                    var dlg = new SelectFolderDialog("Select your Parkitect installation folder.")
                    {
                        CanCreateFolders = false,
                        Multiselect      = false
                    };


                    if (dlg.Run(_window))
                    {
                        if (_parkitect.SetInstallationPathIfValid(dlg.Folder))
                        {
                            break;
                        }
                    }
                    else
                    {
                        _window.Dispose();
                        Application.Dispose();
                        return(false);
                    }
                } while (!_parkitect.IsInstalled);
            }

            _migrator.Migrate();
            ModLoaderUtil.InstallModLoader(_parkitect, _log);
            _taskManager.Add <CheckForUpdatesTask>();
            return(true);
        }
Esempio n. 17
0
        public Windows()
        {
            Button bp = new Button("Show borderless window");

            PackStart(bp);
            bp.Clicked += delegate {
                Window w = new Window();
                w.Decorated = false;
                Button c = new Button("This is a window");
//				c.Margin.SetAll (10);
                w.Content  = c;
                c.Clicked += delegate {
                    w.Dispose();
                };
                var bpos = bp.ScreenBounds;
                w.ScreenBounds = new Rectangle(bpos.X, bpos.Y + bp.Size.Height, w.Width, w.Height);
                w.Show();
            };
            Button b = new Button("Show message dialog");

            PackStart(b);
            b.Clicked += delegate {
                MessageDialog.ShowMessage(ParentWindow, "Hi there!");
            };

            Button db = new Button("Show custom dialog");

            PackStart(db);
            db.Clicked += delegate {
                Dialog d = new Dialog();
                d.Title = "This is a dialog";
                Table t = new Table();
                t.Add(new Label("Some field:"), 0, 0);
                t.Add(new TextEntry(), 1, 0);
                t.Add(new Label("Another field:"), 0, 1);
                t.Add(new TextEntry(), 1, 1);
                d.Content         = t;
                d.CloseRequested += delegate(object sender, CloseRequestedEventArgs args) {
                    args.AllowClose = MessageDialog.Confirm("Really close?", Command.Close);
                };

                Command custom = new Command("Custom");
                d.Buttons.Add(new DialogButton(custom));
                d.Buttons.Add(new DialogButton("Custom OK", Command.Ok));
                d.Buttons.Add(new DialogButton(Command.Cancel));
                d.Buttons.Add(new DialogButton(Command.Ok));

                d.DefaultCommand = custom;

                d.CommandActivated += (sender, e) => {
                    if (e.Command == custom)
                    {
                        e.Handled = !MessageDialog.Confirm("Really close?", Command.Close);
                    }
                };

                var r = d.Run(this.ParentWindow);
                db.Label = "Result: " + (r != null ? r.Label : "(Closed)");
                d.Dispose();
            };

            b = new Button("Show Open File dialog");
            PackStart(b);
            b.Clicked += delegate {
                OpenFileDialog dlg = new OpenFileDialog("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect     = true;
                dlg.Filters.Add(new FileDialogFilter("Xwt files", "*.xwt"));
                dlg.Filters.Add(new FileDialogFilter("All files", "*.*"));
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Files have been selected!", string.Join("\n", dlg.FileNames));
                }
            };

            b = new Button("Show Save File dialog");
            PackStart(b);
            b.Clicked += delegate {
                SaveFileDialog dlg = new SaveFileDialog("Select a file");
                dlg.InitialFileName = "Some file";
                dlg.Multiselect     = true;
                dlg.Filters.Add(new FileDialogFilter("Xwt files", "*.xwt"));
                dlg.Filters.Add(new FileDialogFilter("All files", "*.*"));
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Files have been selected!", string.Join("\n", dlg.FileNames));
                }
            };

            b = new Button("Show Select Folder dialog (Multi select)");
            PackStart(b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog("Select some folder");
                dlg.Multiselect = true;
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Folders have been selected!", string.Join("\n", dlg.Folders));
                }
            };

            b = new Button("Show Select Folder dialog (Single select)");
            PackStart(b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog("Select a folder");
                dlg.Multiselect = false;
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Folders have been selected!", string.Join("\n", dlg.Folders));
                }
            };

            b = new Button("Show Select Folder dialog (Single select, allow creation)");
            PackStart(b);
            b.Clicked += delegate {
                SelectFolderDialog dlg = new SelectFolderDialog("Select or create a folder");
                dlg.Multiselect      = false;
                dlg.CanCreateFolders = true;
                if (dlg.Run())
                {
                    MessageDialog.ShowMessage("Folders have been selected/created!", string.Join("\n", dlg.Folders));
                }
            };

            b = new Button("Show Select Color dialog");
            PackStart(b);
            b.Clicked += delegate {
                SelectColorDialog dlg = new SelectColorDialog("Select a color");
                dlg.SupportsAlpha = true;
                dlg.Color         = Xwt.Drawing.Colors.AliceBlue;
                if (dlg.Run(ParentWindow))
                {
                    MessageDialog.ShowMessage("A color has been selected!", dlg.Color.ToString());
                }
            };

            b = new Button("Show Select Font dialog");
            PackStart(b);
            b.Clicked += delegate {
                SelectFontDialog dlg = new SelectFontDialog();
                if (dlg.Run(ParentWindow))
                {
                    Dialog d = new Dialog();
                    d.Title        = "A font has been selected!";
                    d.Content      = new Label(dlg.SelectedFont.ToString());
                    d.Content.Font = dlg.SelectedFont;
                    d.Buttons.Add(new DialogButton(Command.Ok));
                    d.Run(this.ParentWindow);
                    d.Dispose();
                }
            };

            b = new Button("Show window shown event");
            PackStart(b);
            b.Clicked += delegate
            {
                Window w = new Window();
                w.Decorated = false;
                Button c = new Button("This is a window with events on");
                w.Content  = c;
                c.Clicked += delegate
                {
                    w.Dispose();
                };
                w.Shown  += (sender, args) => MessageDialog.ShowMessage("My Parent has been shown");
                w.Hidden += (sender, args) => MessageDialog.ShowMessage("My Parent has been hidden");

                w.Show();
            };

            b = new Button("Show dialog with dynamically updating content");
            PackStart(b);
            b.Clicked += delegate
            {
                var dialog = new Dialog();
                dialog.Content = new Label("Hello World");
                Xwt.Application.TimeoutInvoke(TimeSpan.FromSeconds(2), () => {
                    dialog.Content = new Label("Goodbye World");
                    return(false);
                });
                dialog.Run();
            };

            b = new Button("Show dialog and make this window not sensitive");
            PackStart(b);
            b.Clicked += delegate
            {
                var dialog = new Dialog();
                dialog.Content = new Label("Hello World");
                dialog.Run();
                dialog.Shown  += (sender, args) => this.ParentWindow.Sensitive = false;
                dialog.Closed += (sender, args) => this.ParentWindow.Sensitive = true;
            };
        }
Esempio n. 18
0
        void HandleCloseRequested(object sender, CloseRequestedEventArgs args)
        {
            bool allowClose = MessageDialog.Confirm("Samples will be closed", Command.Ok);

            args.AllowClose = allowClose;
        }
Esempio n. 19
0
        public PrototypeWindow Composed()
        {
            Title = "Limada Xwt Prototype";
            var width = 500;

            Width  = width;
            Height = 400;

            try {
                statusIcon      = Application.CreateStatusIcon();
                statusIcon.Menu = new Menu();
                statusIcon.Menu.Items.Add(new MenuItem("Test"));
            } catch {
                Trace.WriteLine("Status icon could not be shown");
            }

            var data = new PrototypeData();

            var imageDisplay = new ImageDisplay {
                Data      = data.Image(ctx => data.FontTest(ctx)),
                BackColor = Colors.White,
                ZoomState = ZoomState.FitToScreen,
            };

            var visualsDisplay = new VisualsDisplay {
                BackColor = Colors.White,
            };

            visualsDisplay.Layout.Dimension = Dimension.Y;
            visualsDisplay.Layout.Distance  = new Xwt.Size(60, 60);
            visualsDisplay.StyleSheet.EdgeStyle.DefaultStyle.PaintData = true;
            visualsDisplay.Data = data.Scene;

            var box = new HPaned();

            box.Panel1.Content = visualsDisplay.WithScrollView();
            box.Panel2.Content = imageDisplay.WithScrollView();
            //box.Panel2.Content = new Label();
            box.Panel2.Resize = true;
            box.Position      = width / 2;
            BoundsChanged    += (s, e) => {
                box.Position = this.Width / 2;
            };

            Content = box;

            CloseRequested += (s, e) => {
                e.AllowClose = MessageDialog.Confirm("Samples will be closed", Command.Ok);
                if (e.AllowClose)
                {
                    Application.Exit();
                }
            };

            Action popover = () => {
                var popV = new Popover(new Label {
                    Text = "hy"
                });
                popV.Show(Popover.Position.Bottom, box.Panel1.Content);
            };
            Action edit = () => {
                var edite = new TextEntry();
                (visualsDisplay.Backend as Canvas).AddChild(edite, new Rectangle(40, 40, 100, 20));
            };
            Action changeView = () => {
                var one = box.Panel1.Content;
                var two = box.Panel2.Content;
                box.Panel1.Content = null;
                box.Panel2.Content = null;
                box.Panel1.Content = two;
                box.Panel2.Content = one;
            };
            Action newImageDisplay = () => {
                imageDisplay = new ImageDisplay {
                    Data      = data.Image(ctx => data.FontTest(ctx)),
                    BackColor = Colors.White
                };
                box.Panel2.Content = imageDisplay.Backend as Widget;
            };
            Action nextImage = () => {
                imageDisplay.Data = data.Image(ctx => data.FontTest(ctx));
            };

            visualsDisplay.SceneFocusChanged += (s, e) => nextImage();
            //(visualsDisplay.Backend as Widget).ButtonPressed += (s, e) => nextImage();

            MainMenu = new Menu(
                new MenuItem("_File", null, null,
                             new MenuItem("_Open"),
                             new MenuItem("_New"),
                             new MenuItem("_Close", null, (s, e) => this.Close())
                             ),
                new MenuItem("_Edit", null, null,
                             new MenuItem("Change View", null, (s, e) => changeView()),
                             new MenuItem("Edit", null, (s, e) => edit())
                             )
                );

            return(this);
        }