示例#1
0
        private void AskServerAddress()
        {
            TextPrompt p = new TextPrompt()
            {
                PromptTitle = "Server Address", Hint = "https://condor.example.com", Text = m_config.Address, Keyboard = Keyboard.Url
            };

            p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
            {
                if (p.Text != "")
                {
                    //append a '/'
                    if (!p.Text.EndsWith("/"))
                    {
                        p.Text += "/";
                    }
                    //append scheme
                    if (!p.Text.StartsWith("http://") && !p.Text.StartsWith("https://"))
                    {
                        p.Text = "http://" + p.Text;
                    }
                    //set the address
                    m_config.Address = p.Text;

                    //initialize the app
                    Initialize();
                    //display toast
                    DependencyService.Get <INotification>().ShortAlert("Server address saved, you may now log in");
                }
            });
            p.Show(this);
        }
示例#2
0
        /// <inheritdoc/>
        public bool Show(IAnsiConsole console)
        {
            var prompt = new TextPrompt <char>(_prompt)
                         .InvalidChoiceMessage(InvalidChoiceMessage)
                         .ValidationErrorMessage(InvalidChoiceMessage)
                         .ShowChoices(ShowChoices)
                         .ShowDefaultValue(ShowDefaultValue)
                         .DefaultValue(Yes)
                         .AddChoice(Yes)
                         .AddChoice(No);

            var result = prompt.Show(console);

            return(result == Yes);
        }
        private void DrawProxyNames()
        {
            using (new EditorHelper.Horizontal()) {
                EditorGUILayout.LabelField("Proxy names", GUILayout.Width(128), GUILayout.ExpandWidth(false));
                if (EditorHelper.MiniButton("Add", 64))
                {
                    TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                    textPrompt.textLabel     = "Name";
                    textPrompt.textValidator = s => {
                        if (string.IsNullOrEmpty(s))
                        {
                            return(false);
                        }
                        foreach (Proxy proxy in proxies)
                        {
                            string proxyName = proxy.name;
                            if (proxyName.Equals(s))
                            {
                                return(false);
                            }
                        }

                        return(true);
                    };
                    textPrompt.onTextValueApplied = (s, o) => {
                        proxies.Add(new Proxy()
                        {
                            id   = ++proxyCounter,
                            name = s
                        });
                        editor.Focus();
                    };
                    textPrompt.Show();
                }
            }

            int indexToRemove = -1;

            using (new EditorHelper.IndentPadding(20)) {
                for (int i = 0; i < proxies.Count; i++)
                {
                    string oldName = proxies[i].name;
                    using (new EditorHelper.Horizontal()) {
                        EditorGUILayout.TextField("Id " + proxies[i].id, oldName, GUILayout.ExpandWidth(false), GUILayout.Width(256));
                        if (EditorHelper.MiniButton("-"))
                        {
                            indexToRemove = i;
                        }

                        if (EditorHelper.MiniButton("Rename"))
                        {
                            TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                            textPrompt.obj           = new object[] { proxies, i, oldName };
                            textPrompt.textLabel     = "New name";
                            textPrompt.text          = oldName;
                            textPrompt.textValidator = s => {
                                if (string.IsNullOrEmpty(s))
                                {
                                    return(false);
                                }
                                foreach (Proxy proxy in proxies)
                                {
                                    string groupName = proxy.name;
                                    if (groupName.Equals(s))
                                    {
                                        return(false);
                                    }
                                }

                                return(true);
                            };
                            textPrompt.onTextValueApplied = (s, o) => {
                                List <Proxy> _proxies = (List <Proxy>)o[0];
                                int          index    = (int)o[1];
                                _proxies[index].name = s;

                                editor.Focus();
                            };
                            textPrompt.Show();
                        }
                    }
                }
            }

            if (indexToRemove != -1)
            {
                proxies.RemoveAt(indexToRemove);
            }
        }
示例#4
0
        private void DrawMaterialNames()
        {
            using (new EditorHelper.Horizontal()) {
                EditorGUILayout.LabelField("Group names", GUILayout.Width(128), GUILayout.ExpandWidth(false));
                if (EditorHelper.MiniButton("Add", 64))
                {
                    TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                    textPrompt.textLabel     = "Name";
                    textPrompt.textValidator = s => {
                        if (string.IsNullOrEmpty(s))
                        {
                            return(false);
                        }
                        foreach (string groupName in groupNames)
                        {
                            if (groupName.Equals(s))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    };
                    textPrompt.onTextValueApplied = (s, o) => {
                        groupCounter++;
                        groupNames.Add(s);
                        ids.Add(groupCounter);
                        editor.Focus();
                    };
                    textPrompt.Show();
                }
            }

            int indexToRemove = -1;

            using (new EditorHelper.IndentPadding(20)) {
                for (int i = 0; i < groupNames.Count; i++)
                {
                    string oldName = groupNames[i];
                    using (new EditorHelper.Horizontal()) {
                        EditorGUILayout.TextField("#" + ids[i], oldName, GUILayout.ExpandWidth(false), GUILayout.Width(256));
                        if (EditorHelper.MiniButton("-"))
                        {
                            if (IsIdInUse(ids[i]))
                            {
                                DLog.Log($"Group name {oldName} is in use, cannot delete");
                                return;
                            }
                            indexToRemove = i;
                        }
                        if (EditorHelper.MiniButton("Rename"))
                        {
                            TextPrompt textPrompt = EditorWindow.GetWindow <TextPrompt>();
                            textPrompt.obj           = new object[] { groupNames, i, oldName };
                            textPrompt.textLabel     = "New name";
                            textPrompt.text          = oldName;
                            textPrompt.textValidator = s => {
                                if (string.IsNullOrEmpty(s))
                                {
                                    return(false);
                                }
                                foreach (string groupName in groupNames)
                                {
                                    if (groupName.Equals(s))
                                    {
                                        return(false);
                                    }
                                }
                                return(true);
                            };
                            textPrompt.onTextValueApplied = (s, o) => {
                                List <string> _groupNames = (List <string>)o[0];
                                int           index       = (int)o[1];
                                _groupNames[index] = s;
                                editor.Focus();
                            };
                            textPrompt.Show();
                        }
                    }
                }
            }

            if (indexToRemove != -1)
            {
                groupNames.RemoveAt(indexToRemove);
                ids.RemoveAt(indexToRemove);
            }
        }
示例#5
0
        private void ToolbarClicked(object sender, EventArgs e)
        {
            ToolbarItem tappedItem = sender as ToolbarItem;

            if (tappedItem == m_mnuProjectInfo)
            {
                ProjectInfoPage p = new ProjectInfoPage();
                p.Description.Text = m_proj.Description;
                p.Title            = this.Title;
                ((NavigationPage)m_mdp.Detail).PushAsync(p);
            }
            else if (tappedItem == m_mnuDelProj)
            {
                Prompt p = new Prompt()
                {
                    PromptTitle = "Are you sure?", PositiveButtonText = "Yes", NegativeButtonText = "No"
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    DeleteCommand cmd = new DeleteCommand()
                    {
                        Title = m_proj.ID
                    };
                    cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
                    {
                        if ((string)response.GetValue("result") != "success")
                        {
                            DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                            return;
                        }
                        //update the project list
                        ((MainPage)m_mdp).DeleteProject(m_proj);
                        //go back to the home page
                        ((MainPage)m_mdp).DisplayHome();
                    });
                    CondorAPI.getInstance().Execute(cmd);
                });
                p.Show(m_mdp);
            }
            else if (tappedItem == m_mnuAddMember)
            {
                TextPrompt p = new TextPrompt()
                {
                    PromptTitle = "Enter a Mattermost User ID", Hint = "user_id", PositiveButtonText = "Add", NegativeButtonText = "Cancel", Keyboard = Keyboard.Plain
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    AddMemberCommand cmd = new AddMemberCommand()
                    {
                        Project = m_proj.ID, Member = p.Text
                    };
                    cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
                    {
                        if ((string)response.GetValue("result") != "success")
                        {
                            DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                            return;
                        }
                        //update the task with the new member
                        Member newMember = new Member()
                        {
                            Role = Role.MEMBER, ID = p.Text
                        };
                        m_proj.Members.Add(newMember);
                        //reload the project display
                        ReloadProjectDisplay();
                    });
                    CondorAPI.getInstance().Execute(cmd);
                });
                p.Show(m_mdp);
            }
            else if (tappedItem == m_mnuCreateTask)
            {
                ManageTaskPrompt p = new ManageTaskPrompt(m_proj)
                {
                    CanAssign = false, CanSetTitle = true, CanDelete = false, PositiveButtonText = "Create", NegativeButtonText = "Cancel"
                };
                p.OnPromptSaved += new Prompt.PromptClosedEventListener(() =>
                {
                    CreateTaskCommand cmd = new CreateTaskCommand()
                    {
                        Project = m_proj.ID, Title = p.TaskTitle, Due = p.Date, Description = p.Description
                    };
                    cmd.OnResponseReceived += new APICommand.ResponseReceivedHandler((response) =>
                    {
                        if ((string)response.GetValue("result") != "success")
                        {
                            DependencyService.Get <INotification>().ShortAlert("ERROR: " + (string)response.GetValue("msg"));
                            return;
                        }
                        //update the project with the new Task
                        Models.Task t = new Models.Task()
                        {
                            Name = p.TaskTitle, Due = p.Date, Description = p.Description
                        };
                        m_proj.Tasks.Add(t);
                        //reload the project display
                        ReloadProjectDisplay();
                    });
                    CondorAPI.getInstance().Execute(cmd);
                });
                p.Show(m_mdp);
            }
        }