Esempio n. 1
0
        void HandleAddButtonClicked(object sender, EventArgs e)
        {
            if (service.Status == Status.NotAdded)
            {
                var addProjects = new Dictionary <string, DotNetProject> ();

                foreach (DotNetProject project in service.Project.ParentSolution.GetAllProjects().Where(p => p is DotNetProject && p != service.Project))
                {
                    var svc = project.GetConnectedServicesBinding()?.SupportedServices.FirstOrDefault(s => s.Id == service.Id);
                    if (svc != null && svc.Status == Status.NotAdded)
                    {
                        addProjects [project.ItemId] = project;
                    }
                }

                var servicesToAdd = new List <IConnectedService> ();

                if (addProjects.Count > 0)
                {
                    var question = new Xwt.QuestionMessage(GettextCatalog.GetString("Add {0} to {1}", this.Service.DisplayName, this.Service.Project.Name));
                    question.SecondaryText = GettextCatalog.GetString("Also add '{0}' to other projects in the solution?", this.Service.DisplayName);

                    foreach (var project in addProjects)
                    {
                        question.AddOption(project.Key, project.Value.Name, true);
                    }

                    var cmdContinue    = new Command(GettextCatalog.GetString("Continue"));
                    var cmdProjectOnly = new Command(GettextCatalog.GetString("Skip"));
                    var cmdCancel      = new Command(GettextCatalog.GetString("Cancel"));
                    question.Buttons.Add(cmdContinue);
                    question.Buttons.Add(cmdProjectOnly);
                    question.Buttons.Add(cmdCancel);
                    question.DefaultButton = 0;

                    Xwt.Toolkit.NativeEngine.Invoke(delegate {
                        var result = MessageDialog.AskQuestion(question);
                        if (result != cmdCancel)
                        {
                            if (result == cmdContinue)
                            {
                                foreach (var project in addProjects)
                                {
                                    if (question.GetOptionValue(project.Key))
                                    {
                                        servicesToAdd.Add(project.Value.GetConnectedServicesBinding()?.SupportedServices.FirstOrDefault(s => s.Id == service.Id));
                                    }
                                }
                            }
                            AddSelectedServices(service, servicesToAdd);
                        }
                    });
                }
                else
                {
                    AddSelectedServices(service, servicesToAdd);
                }
            }
        }
Esempio n. 2
0
        public List <Document> CreateDocuments(Template template, Document parent)
        {
            var documents = new List <Document>();
            var fileNames = new List <string>();
            var question  = new QuestionMessage();

            question.Buttons.Add(Command.No);
            question.Buttons.Add(Command.Yes);
            question.Text = "New Document";
            if (template.IsFile.Value)
            {
                ofDialog.Title = "New " + template.Name;
                if (parent != null)
                {
                    ofDialog.Title += $" ({parent})";
                }
                if (ofDialog.Run(ParentWindow))
                {
                    var dr = Command.Save;
                    foreach (string fileName in ofDialog.FileNames)
                    {
                        string name = System.IO.Path.GetFileName(fileName);
                        var    drow = DocumentData.DBTable.LoadByCode(name, DocumentData.DBTable.ParseProperty(nameof(DocumentData.FileName)), DBLoadParam.Load);
                        if (drow != null)
                        {
                            if (dr == Command.Save)
                            {
                                question.SecondaryText = "Document whith number '" + name + "' exist\nCreate new?";
                                dr = MessageDialog.AskQuestion(ParentWindow, question);
                            }
                            if (dr == Command.Yes)
                            {
                                fileNames.Add(fileName);
                            }
                            else if (dr == Command.Cancel)
                            {
                                return(documents);
                            }
                        }
                        else
                        {
                            fileNames.Add(fileName);
                        }
                    }
                }
            }

            documents.Add(template.CreateDocument(parent, fileNames.ToArray()));
            return(documents);
        }
Esempio n. 3
0
        public List <Document> CreateDocuments(Template template, Document parent, List <Document> references)
        {
            var documents            = new List <Document>();
            var commandCreateSeveral = new Command("Several", $"Create {references.Count}");
            var commandCreateOne     = new Command("One", $"Create One");
            var command = commandCreateOne;

            if (references.Count > 1)
            {
                var question = new QuestionMessage("New Document", $"Create one {template} or several?");
                question.Buttons.Add(commandCreateOne);
                question.Buttons.Add(commandCreateSeveral);
                question.Buttons.Add(Command.Cancel);
                command = MessageDialog.AskQuestion(ParentWindow, question);
            }
            if (command == Command.Cancel)
            {
                return(documents);
            }
            else if (command == commandCreateSeveral)
            {
                foreach (var reference in references)
                {
                    var buffer = CreateDocuments(template, parent ?? reference);
                    if (parent != null)
                    {
                        foreach (var document in buffer)
                        {
                            document.CreateReference(reference, null);
                        }
                    }
                    documents.AddRange(buffer);
                }
            }
            else
            {
                documents = CreateDocuments(template, parent);
                foreach (var reference in references)
                {
                    foreach (var document in documents)
                    {
                        if (!document.ContainsReference(reference))
                        {
                            document.CreateReference(reference, null);
                        }
                    }
                }
            }
            return(documents);
        }
Esempio n. 4
0
        void OfficialAssetsButton_Clicked(object sender, EventArgs e)
        {
            var result = MessageDialog.AskQuestion("Download Mojang assets",
                                                   "This will download the official Minecraft assets from Mojang.\n\n" +
                                                   "By proceeding you agree to the Mojang asset guidelines:\n\n" +
                                                   "https://account.mojang.com/terms#brand\n\n" +
                                                   "Proceed?",
                                                   Command.Yes, Command.No);

            if (result == Command.Yes)
            {
                OfficialAssetsButton.Visible   = false;
                OfficialAssetsProgress.Visible = true;
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var stream = new WebClient().OpenRead("http://s3.amazonaws.com/Minecraft.Download/versions/b1.7.3/b1.7.3.jar");
                        var ms     = new MemoryStream();
                        CopyStream(stream, ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        stream.Dispose();
                        var jar = ZipFile.Read(ms);
                        var zip = new ZipFile();
                        zip.AddEntry("pack.txt", "Minecraft textures");
                        CopyBetweenZips("pack.png", jar, zip);
                        CopyBetweenZips("terrain.png", jar, zip);
                        // TODO: Items, windows, etc
                        zip.Save(Path.Combine(TexturePack.TexturePackPath, "Minecraft.zip"));
                        Application.Invoke(() =>
                        {
                            OfficialAssetsProgress.Visible = false;
                            var texturePack = TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, "Minecraft.zip"));
                            _texturePacks.Add(texturePack);
                            AddTexturePackRow(texturePack);
                        });
                        ms.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Application.Invoke(() =>
                        {
                            MessageDialog.ShowError("Error retrieving assets", ex.ToString());
                            OfficialAssetsProgress.Visible = false;
                            OfficialAssetsButton.Visible   = true;
                        });
                    }
                });
            }
        }
Esempio n. 5
0
        public AskResult AskSaveOrCancel()
        {
            var result = MessageDialog.AskQuestion("Do you want to save the project first?", Command.Yes, Command.No, Command.Cancel);

            if (result == Command.Yes)
            {
                return(AskResult.Yes);
            }

            if (result == Command.No)
            {
                return(AskResult.No);
            }

            return(AskResult.Cancel);
        }
Esempio n. 6
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. 7
0
        private bool SaveB()
        {
            var chars = new List <CharacterRegion>();

            for (int i = 0; i < listStore.RowCount; i++)
            {
                int start = GetListValue(listStore.GetValue(i, startCol));
                int end   = GetListValue(listStore.GetValue(i, endCol));

                chars.Add(new CharacterRegion(start, end));
            }

            if (!CharRegionsUtil.CheckConflict(chars))
            {
                int tmptab = notebook1.CurrentTabIndex;

                skip = true;
                notebook1.CurrentTabIndex = 1;

                var c = MessageDialog.AskQuestion("Character Region Conflict Detected", "How would you like to resolve it?", new[]
                {
                    new Command(Command.Yes.Id, "Auto-Resolve"),
                    new Command(Command.Cancel.Id, "Manually Resolve"),
                    new Command(Command.No.Id, "Don't Resolve")
                });

                skip = false;
                if (c.ToString() == Command.Yes.ToString())
                {
                    chars = CharRegionsUtil.ResolveConflicts(chars);
                }
                else if (c.ToString() == Command.No.ToString())
                {
                    skip = true;
                    notebook1.CurrentTabIndex = tmptab;
                    Reload();
                }
                else
                {
                    return(false);
                }
            }

            _core.CharacterRegions = chars;
            return(true);
        }
Esempio n. 8
0
 protected override void OnToolRefreshClick(object sender, EventArgs e)
 {
     if (Table.IsEdited)
     {
         var question = new QuestionMessage(Locale.Get("TableEditor", "Continue Rejecting?"), "Check");
         question.Buttons.Add(Command.No);
         question.Buttons.Add(Command.Yes);
         if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
         {
             Table.RejectChanges(GuiEnvironment.User);
         }
     }
     else if (Table.IsSynchronized)
     {
         Table.IsSynchronized = false;
     }
 }
Esempio n. 9
0
        public static void RowReject(DBItem row, ref Command dr, Window form)
        {
            DBLogItem changes = new DBLogItem(row);

            if (changes.BaseItem.Status == DBStatus.New)
            {
                if (dr == Command.Save)
                {
                    question.Text          = "Accept Deleting!";
                    question.SecondaryText = "Reject will delete item completly! Continue?";

                    dr = MessageDialog.AskQuestion(form, question);
                    if (dr == Command.Cancel)
                    {
                        return;
                    }
                }
            }
            changes.Reject(GuiEnvironment.User);
        }
Esempio n. 10
0
 public bool Closing()
 {
     if (Document != null && (Document.UpdateState & DBUpdateState.Delete) != DBUpdateState.Delete && EditorState != DocumentEditorState.Readonly && Document.IsChanged)
     {
         var question = new QuestionMessage(Locale.Get(nameof(DocumentEditor), "On Close"), Locale.Get(nameof(DocumentEditor), "Save changes?"));
         question.Buttons.Add(Command.No);
         question.Buttons.Add(Command.Yes);
         question.Buttons.Add(Command.Cancel);
         var dr = MessageDialog.AskQuestion(ParentWindow, question);
         if (dr == Command.Cancel)
         {
             return(false);
         }
         else if (dr == Command.Yes)
         {
             Document.Save();
         }
     }
     return(true);
 }
Esempio n. 11
0
        public override bool Closing()
        {
            loader.Cancel();

            if (Table != null && Table.IsEdited)
            {
                question.SecondaryText = Locale.Get("TableEditor", "Save changes?");
                var result = MessageDialog.AskQuestion(ParentWindow, question);
                if (result == Command.Yes)
                {
                    Table.Save().GetAwaiter().GetResult();
                    return(true);
                }
                else if (result == Command.Cancel)
                {
                    return(false);
                }
            }
            return(true);
        }
        internal static void Show(bool isOld, Action action)
        {
            Action del = delegate {
                string    primary;
                string    secondary;
                Command[] commands;
                if (isOld)
                {
                    primary   = GettextCatalog.GetString("The subversion working copy format is too old.");
                    secondary = GettextCatalog.GetString("Would you like to upgrade the working copy or" +
                                                         " disable subversion integration for this solution?");
                    commands = new [] {
                        UpgradeCommand,
                        DisableCommand
                    };
                }
                else
                {
                    primary   = GettextCatalog.GetString("The subversion working copy format is too new.");
                    secondary = GettextCatalog.GetString("Subversion integration will be disabled for this solution.");
                    commands  = new [] {
                        DisableCommand
                    };
                }

                if (MessageDialog.AskQuestion(primary, secondary, Toolkit.CurrentEngine.Defaults.MessageDialog.QuestionIcon, commands) != DisableCommand)
                {
                    action();
                }
            };

            if (Runtime.IsMainThread)
            {
                // Already in GUI thread
                del();
            }
            else
            {
                Runtime.RunInMainThread(del);
            }
        }
Esempio n. 13
0
        protected override async void OnToolEditClick(object sender, EventArgs e)
        {
            if (Current == null)
            {
                return;
            }

            //base.OnToolEditClick(sender, e);

            string fullpath = await DocumentEditor.Execute(Current);

            if (string.IsNullOrEmpty(fullpath))
            {
                return;
            }

            var rez = Command.Yes;

            while (rez != Command.No)
            {
                var question = new QuestionMessage("File", "Accept Changes?");
                question.Buttons.Add(Command.No);
                question.Buttons.Add(Command.Yes);
                rez = MessageDialog.AskQuestion(ParentWindow, question);
                if (rez == Command.Yes)
                {
                    try
                    {
                        Current.FileData = File.ReadAllBytes(fullpath);
                        rez = Command.No;
                    }
                    catch
                    {
                        MessageDialog.ShowMessage(ParentWindow, "File load trouble!:\n'" +
                                                  fullpath +
                                                  "'\nClose application that use it!",
                                                  "File");
                    }
                }
            }
        }
Esempio n. 14
0
        internal static void Show(bool isOld, Action action)
        {
            Action del = delegate {
                string    primary;
                string    secondary;
                Command[] commands;
                if (isOld)
                {
                    primary   = GettextCatalog.GetString("The subversion working copy format is too old.");
                    secondary = GettextCatalog.GetString("Would you like to upgrade the working copy or" +
                                                         " disable subversion integration for this solution?");
                    commands = new [] {
                        UpgradeCommand,
                        DisableCommand
                    };
                }
                else
                {
                    primary   = GettextCatalog.GetString("The subversion working copy format is too new.");
                    secondary = GettextCatalog.GetString("Subversion integration will be disabled for this solution.");
                    commands  = new [] {
                        DisableCommand
                    };
                }

                if (MessageDialog.AskQuestion(primary, secondary, Xwt.Drawing.Image.FromResource("question-48.png").WithSize(48), commands) != DisableCommand)
                {
                    action();
                }
            };

            if (Runtime.IsMainThread)
            {
                // Already in GUI thread
                del();
            }
            else
            {
                Runtime.RunInMainThread(del);
            }
        }
        internal static void Show(bool isOld, Action action)
        {
            Action del = delegate {
                string    primary;
                string    secondary;
                Command[] commands;
                if (isOld)
                {
                    primary   = GettextCatalog.GetString("The subversion working copy format is too old.");
                    secondary = GettextCatalog.GetString("Would you like to upgrade the working copy or" +
                                                         " disable subversion integration for this solution?");
                    commands = new [] {
                        UpgradeCommand,
                        DisableCommand
                    };
                }
                else
                {
                    primary   = GettextCatalog.GetString("The subversion working copy format is too new.");
                    secondary = GettextCatalog.GetString("Subversion integration will be disabled for this solution.");
                    commands  = new [] {
                        DisableCommand
                    };
                }

                if (MessageDialog.AskQuestion(primary, secondary, commands) != DisableCommand)
                {
                    action();
                }
            };

            if (DispatchService.IsGuiThread)
            {
                // Already in GUI thread
                del();
            }
            else
            {
                DispatchService.GuiDispatch(del);
            }
        }
Esempio n. 16
0
        private void ToolRemoveClick(object sender, EventArgs e)
        {
            if (dataTree.SelectedNode == null)
            {
                return;
            }
            var text = Locale.Get(base.Name, "Remove select items?");

            if (MessageDialog.AskQuestion("Confirmation", text, Command.No, Command.Yes) == Command.Yes)
            {
                var items = dataTree.Selection.GetItems <Node>();
                foreach (SchemaItemNode node in items)
                {
                    var obj = node.Item;
                    if (obj != null)
                    {
                        obj.Containers.FirstOrDefault()?.Remove(obj);
                    }
                }
            }
        }
Esempio n. 17
0
        private async void TooSearchClick(object sender, EventArgs e)
        {
            if (query == null || query.Table == null)
            {
                return;
            }

            if (viewResult.IsLoad())
            {
                if (MessageDialog.AskQuestion("Executing", "Suspend?", Command.No, Command.Yes) == Command.Yes)
                {
                    viewResult.LoadCancel();
                }
                return;
            }
            viewResult.SetCommand(query.ToCommand(false), query.Table.Schema, query.Table.Name + query.Order.ToString());
            await viewResult.SyncAsync();

            toolCount.Text = "<Executing>";
            gresult.Expand = true;
        }
Esempio n. 18
0
        public async static Task <Command> Send(Widget widget, Document document)
        {
            var work = document.CurrentWork;

            if (work != null)
            {
                if (work.User == null)
                {
                    var question = new QuestionMessage("Accept", "Accept to work?");
                    question.Buttons.Add(Command.No);
                    question.Buttons.Add(Command.Yes);
                    if (MessageDialog.AskQuestion((Window)GuiService.Main, question) == Command.Yes)
                    {
                        if (work.Stage != null && !work.Stage.Access.GetFlag(AccessType.Update, GuiEnvironment.User))
                        {
                            MessageDialog.ShowMessage((Window)GuiService.Main, "Access denied!", "Accept");
                        }
                        else
                        {
                            work.User = (User)GuiEnvironment.User;
                        }
                    }
                }
            }
            else
            {
                work = document.GetWorksUncompleted().FirstOrDefault();
                if (work != null && work.User != null && work.User != GuiEnvironment.User)
                {
                    var rezult = MessageDialog.AskQuestion("Accept", "Document current on " + work.User + " Accept anywhere?", Command.No, Command.Yes);
                    if (rezult == Command.No)
                    {
                        return(null);
                    }
                }
            }
            return(await Send(widget, new[] { document }, null, null, null));
        }
Esempio n. 19
0
        private async void ToolAcceptClick(object sender, EventArgs e)
        {
            if (listRows.SelectedItem == null)
            {
                return;
            }
            foreach (var s in listRows.Selection)
            {
                LogMap changes = (LogMap)s.Item;
                if (changes.Row.Status == DBStatus.Delete)
                {
                    var dr = MessageDialog.AskQuestion("Accept Deleting!", "Delete completly?", Command.No, Command.Yes, Command.Cancel);
                    if (dr != Command.Yes)
                    {
                        break;
                    }
                }
                await changes.Accept(GuiEnvironment.User);

                listDiff.ListSource = changes.Changes;
            }
            rowsView.UpdateFilter();
        }
Esempio n. 20
0
        protected virtual void PopulateViewBoxWithButtons(VBox vBox, IAsset asset)
        {
            var canDelete = _requiredAssets == null || !_requiredAssets.Contains(asset.Id);

            var deleteButton = new Button("Delete")
            {
                Sensitive = canDelete
            };

            deleteButton.Clicked += (sender, args) =>
            {
                if (
                    MessageDialog.AskQuestion(
                        $"Are you sure you wish to delete \"{asset.Name}\"? This action cannot be undone!", 0,
                        Command.No,
                        Command.Yes) == Command.Yes)
                {
                    _parkitect.Assets.DeleteAsset(asset);
                    MainView.ShowSidebarWidget(null, null);
                }
            };
            vBox.PackStart(deleteButton);
        }
Esempio n. 21
0
        private async void ToolMainRemoveClick(object sender, EventArgs e)
        {
            if (tree.SelectedNode == null)
            {
                return;
            }
            var question = new QuestionMessage("Deleting", "Delete selected items?");

            question.Buttons.Add(Command.No);
            question.Buttons.Add(Command.Yes);
            if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
            {
                var items = tree.Selection.GetItems <TableItemNode>();
                foreach (var node in items)
                {
                    if (node.Item is DBItem dbItem)
                    {
                        dbItem.Delete();
                        await dbItem.Save(GuiEnvironment.User);
                    }
                }
            }
        }
Esempio n. 22
0
        protected void ToolKitClicked(object sender, EventArgs e)
        {
            RadioButtonMenuItem mi = (RadioButtonMenuItem)sender;

            if (!mi.Checked)
            {
                mi.Checked = true;
                return;
            }

            Command c = MessageDialog.AskQuestion("Switching toolkits may cause the app to not start, the app will close in order to switch to the new toolkit, are you sure you want to continue?",
                                                  "In case the app doesnt start please delete the file found in: " + Settings.SettingsFile, new[] { Command.Yes, Command.No, Command.Cancel });

            if (c == Command.Yes)
            {
                Settings.SetToolkit((ToolkitType)mi.Tag);
                Settings.Save();
                Application.Exit();
            }
            else
            {
                mi.Checked = false;
            }
        }
Esempio n. 23
0
        public static void RowAccept(DBItem row, ref Command dr, Widget form)
        {
            if (row.Status != DBStatus.Actual)
            {
                var changes = new LogMap(row);
                if (changes.Row.Status == DBStatus.Delete)
                {
                    if (dr == Command.Save)
                    {
                        question.Text          = "Accept Deleting!";
                        question.SecondaryText = "Accept will delete item completly! Continue?";
                        dr = MessageDialog.AskQuestion(form.ParentWindow, question);
                        if (dr == Command.Cancel)
                        {
                            return;
                        }
                    }
                }
                changes.Accept(GuiEnvironment.User).GetAwaiter().GetResult();

                //dr = Command.Cancel;
                //MessageDialog.ShowMessage(form.ParentWindow, "Editor can not accept his chnges!");
            }
        }
Esempio n. 24
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. 25
0
        public static bool Initialize(DBProcedure procedure, Dictionary <string, object> existingParam)
        {
            var window = new FormParam();

            window.Label.Text = procedure.ToString();

            var table = new DBTable <DBItem>(procedure.Name + "Param")
            {
                Schema    = procedure.Schema,
                BlockSize = 1
            };

            foreach (var param in procedure.Parameters)
            {
                if (existingParam.ContainsKey(param.Name.ToString()))
                {
                    continue;
                }
                DBColumn col = new DBColumn
                {
                    Name  = param.Name != null && param.Name.Length > 0 ? param.Name : "NewColumn",
                    Table = table
                };
                if (param.Column != null)
                {
                    if (param.Column.IsPrimaryKey)
                    {
                        col.ReferenceTable = param.Column.Table;
                    }
                    if (param.Column.IsReference)
                    {
                        col.ReferenceTable = param.Column.ReferenceTable;
                    }
                }
                col.DataType = param.DataType;
                table.Columns.Add(col);
            }

            var row = table.NewItem();

            window.propertyes.FieldSource = row;
            window.propertyes.ResetFields();
            window.propertyes.EditState = EditListState.Edit;
            window.ButtonAcceptClick   += (s, e) =>
            {
                foreach (var column in table.Columns)
                {
                    if (row[column] == DBNull.Value &&
                        MessageDialog.AskQuestion("Параметры", "Не все Параметры были указаны, продолжить?", Command.No, Command.Yes) == Command.No)
                    {
                        return;
                    }
                    existingParam.Add(column.Name, row[column]);
                }
                window.Hide();
            };
            window.Show(null, Point.Zero);
            //p.Dispose();
            //ts.Dispose();
            return(true);
        }
Esempio n. 26
0
        private IEnumerable <Tile> LoadTiles()
        {
            yield return(CreateTile("Visit ParkitectNexus", App.DImages["parkitectnexus_logo-64x64.png"],
                                    Color.FromBytes(0xf3, 0x77, 0x35), _website.Launch));

            if (OperatingSystem.Detect() == SupportedOperatingSystem.Linux)
            {
                yield return
                    (CreateTile("Download URL", App.DImages["appbar.browser.wire.png"], Color.FromBytes(0xf3, 0x77, 0x35),
                                () =>
                {
                    var entry = new TextEntry();

                    var box = new HBox();
                    box.PackStart(new Label("URL:"));
                    box.PackStart(entry, true, true);

                    var dialog = new Dialog
                    {
                        Width = 300,
                        Icon = ParentWindow.Icon,
                        Title = "Enter URL to download",
                        Content = box
                    };
                    dialog.Buttons.Add(new DialogButton(Command.Cancel));
                    dialog.Buttons.Add(new DialogButton(Command.Ok));


                    var result = dialog.Run(ParentWindow);

                    NexusUrl url;
                    if (result.Label.ToLower() == "ok" && NexusUrl.TryParse(entry.Text, out url))
                    {
                        ObjectFactory.GetInstance <IApp>().HandleUrl(url);
                    }
                    dialog.Dispose();
                }));
            }

            yield return
                (CreateTile("Launch Parkitect", App.DImages["parkitect_logo.png"], Color.FromBytes(45, 137, 239),
                            () => { _parkitect.Launch(); }));

            yield return(CreateTile("Help", App.DImages["appbar.information.png"], Color.FromBytes(45, 137, 239), () =>
            {
                // Temporary help solution.
                Process.Start(
                    "https://parkitectnexus.com/forum/2/parkitectnexus-website-client/70/troubleshooting-mods-and-client");
            }));

            yield return(CreateTile("Donate!", App.DImages["appbar.thumbs.up.png"], Color.FromBytes(45, 137, 239), () =>
            {
                if (MessageDialog.AskQuestion("Maintaining this client and adding new features takes a lot of time.\n" +
                                              "If you appreciate our work, please consider sending a donation our way!\n" +
                                              "All donations will be used for further development of the ParkitectNexus Client and the website.\n" +
                                              "\nSelect Yes to visit PayPal and send a donation.", 1, Command.No,
                                              Command.Yes) == Command.Yes)
                {
                    Process.Start("https://paypal.me/ikkentim");
                }
            }));
        }
Esempio n. 27
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. 28
0
        protected override async void OnToolWindowAcceptClick(object sender, EventArgs e)
        {
            DBItem bufRow = ((TableLayoutList)toolWindow.Target).FieldSource as DBItem;

            if (!bufRow.Attached)
            {
                question.SecondaryText = "Check";

                if (Status == TableEditorStatus.Search && list.ListSource.Count > 0)
                {
                    question.Text = Locale.Get("TableEditor", "Found duplicate records!\nContinee?");
                    if (MessageDialog.AskQuestion(ParentWindow, question) == Command.No)
                    {
                        return;
                    }
                }
                if (mode == TableEditorMode.Referencing)
                {
                    if (bufRow[baseColumn].ToString() != OwnerRow.PrimaryId.ToString())
                    {
                        question.Text = Locale.Get("TableEditor", "Change reference?");
                        if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
                        {
                            bufRow[baseColumn] = OwnerRow.PrimaryId;
                        }
                    }
                }

                Table.Add(bufRow);
                try
                {
                    await bufRow.Save(GuiEnvironment.User);
                }
                catch (Exception ex)
                {
                    Helper.OnException(ex);
                    toolWindow.Visible = true;
                }

                if (bufRow.UpdateState != DBUpdateState.Default)
                {
                    return;
                }

                if (status == TableEditorStatus.Clone)
                {
                    question.Text = Locale.Get("TableEditor", "Clone References?");
                    if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
                    {
                        var relations = Table.GetChildRelations();
                        foreach (var relation in relations)
                        {
                            question.Text = string.Format(Locale.Get("TableEditor", "Clone Reference {0}?"), relation.Table);
                            if (MessageDialog.AskQuestion(ParentWindow, question) == Command.No)
                            {
                                continue;
                            }

                            var refrows = clonedRow.GetReferencing(relation, DBLoadParam.Load | DBLoadParam.Synchronize);

                            foreach (DBItem refrow in refrows)
                            {
                                var newRow = refrow.Clone() as DBItem;
                                newRow.PrimaryId        = DBNull.Value;
                                newRow[relation.Column] = bufRow.PrimaryId;
                                relation.Table.Add(newRow);
                            }
                            await relation.Table.Save();
                        }
                    }
                }
                //if (MessageDialog.ShowMessage(_rowTool, "Добавить еще поле?", "Добавление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==  Command.Yes)
                //{
                //    Status = _status;
                //    return;
                //}
            }
            //else if ((bufRow.DBState & DBRowState.Default) != DBRowState.Default)
            //{
            // //   if (_mode == TableFormMode.RefingTable)
            //        bufRow[_ocolumn] = _orow.Id;
            //    Save(Table);
            //    if ((bufRow.DBState & DBRowState.Default) != DBRowState.Default)
            //        return;
            //}
            Status   = TableEditorStatus.Default;
            Selected = bufRow;
            if (mode == TableEditorMode.Reference)
            {
                OnItemSelect(new ListEditorEventArgs(bufRow));
            }
        }
Esempio n. 29
0
        protected override void OnToolRemoveClick(object sender, EventArgs e)
        {
            if (Selected == null)
            {
                return;
            }
            // var deletWindow = new RowDeleting { Row = Selected };
            var rowsText = new StringBuilder();
            var temp     = DBList.Selection.GetItems <DBItem>();

            foreach (DBItem refRow in temp)
            {
                rowsText.AppendLine(refRow.ToString());
            }

            var text = new RichTextView();

            text.LoadText(rowsText.ToString(), Xwt.Formats.TextFormat.Plain);

            var window = new ToolWindow
            {
                Target = text,
                Mode   = ToolShowMode.Dialog
            };

            if (mode == TableEditorMode.Referencing || mode == TableEditorMode.Item)
            {
                window.AddButton("Exclude", async(object se, EventArgs arg) =>
                {
                    foreach (DBItem refRow in temp)
                    {
                        refRow[OwnerColumn] = null;
                    }

                    await Table.Save();
                    window.Hide();
                });
                //tw.ButtonAccept.Location = new Point (b.Location.X - 60, 3);
                //tw.ButtonClose.Location = new Point (b.Location.X - 120, 3);
            }
            window.Label.Text         = Common.Locale.Get("TableEditor", "Deleting!");
            window.ButtonAcceptText   = Common.Locale.Get("TableEditor", "Delete");
            window.ButtonAcceptClick += async(p1, p2) =>
            {
                question.SecondaryText = Common.Locale.Get("TableEditor", "Check Reference?");
                bool flag = MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes;
                list.ListSensetive = false;
                foreach (DBItem selectedRow in temp)
                {
                    RowDeleting?.Invoke(this, new ListEditorEventArgs()
                    {
                        Item = selectedRow
                    });

                    if (flag)
                    {
                        foreach (var relation in selectedRow.Table.GetChildRelations())
                        {
                            var childs = selectedRow.GetReferencing(relation, DBLoadParam.Load | DBLoadParam.Synchronize).ToList();
                            if (childs.Count == 0)
                            {
                                continue;
                            }
                            rowsText.Clear();
                            foreach (DBItem refRow in childs)
                            {
                                rowsText.AppendLine(refRow.ToString());
                            }
                            question.SecondaryText = string.Format(Common.Locale.Get("TableEditor", "Found reference on {0}. Delete?\n{1}"), relation.Table, rowsText);
                            if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
                            {
                                for (int j = 0; j < childs.Count; j++)
                                {
                                    ((DBItem)childs[j]).Delete();
                                }
                            }
                            else
                            {
                                question.SecondaryText = string.Format(Common.Locale.Get("TableEditor", "Found reference on {0}. Remove Refence?\n{1}"), relation.Table, rowsText);
                                if (MessageDialog.AskQuestion(ParentWindow, question) == Command.Yes)
                                {
                                    for (int j = 0; j < childs.Count; j++)
                                    {
                                        ((DBItem)childs[j])[relation.Column] = null;
                                    }
                                }
                            }
                            await relation.Table.Save();
                        }
                    }
                    selectedRow.Delete();
                }

                await Table.Save();

                list.ListSensetive = true;
                // list.QueueDraw(true, true);
                window.Hide();
            };
            window.Show(this, Point.Zero);
        }