Пример #1
0
        void OnFilter()
        {
            IEnumerable getWords()
            {
                var list = new List <string>();

                foreach (DataColumn c in Table.Columns)
                {
                    list.Add(c.ColumnName);
                }

                list.AddRange(new string[] {
                    "", "and", "avg", "between", "child", "convert", "count", "false", "iif", "in", "is", "isnull", "len", "like", "max", "min", "not", "null", "or", "parent", "stdev", "substring", "sum", "trim", "true", "var",
                });

                return(list);
            }

            var ui = new UI.InputBoxEx()
            {
                Title    = "Filter",
                Prompt   = "Filter expression: [Tab] to complete",
                Text     = ViewRowFilter ?? string.Empty,
                History  = "DataRecordFilter",
                GetWords = getWords
            };

            if (!ui.Show())
            {
                return;
            }

            var text = ui.Text;

            if (text == ViewRowFilter)
            {
                return;
            }

            ViewRowFilter = text;

            NeedsNewFiles = true;
            UpdateRedraw(true);
        }
Пример #2
0
        void OnSort()
        {
            IEnumerable getWords()
            {
                var list = new List <string>();

                foreach (DataColumn c in Table.Columns)
                {
                    list.Add(c.ColumnName);
                }
                return(list);
            }

            var ui = new UI.InputBoxEx()
            {
                Title    = "Sort",
                Prompt   = "Sort column list: [Tab] to complete, comma to separate",
                Text     = ViewSort ?? string.Empty,
                History  = "DataRecordSort",
                GetWords = getWords
            };

            if (!ui.Show())
            {
                return;
            }

            var text = ui.Text;

            if (text == ViewSort)
            {
                return;
            }

            ViewSort = text;

            NeedsNewFiles = true;
            UpdateRedraw(true);
        }
Пример #3
0
        /// <summary>
        /// Shows a dialog with a number of input fields.
        /// </summary>
        public override Dictionary<string, PSObject> Prompt(string caption, string message, Collection<FieldDescription> descriptions)
        {
            if (descriptions == null) throw new ArgumentNullException("descriptions");

            var r = new Dictionary<string, PSObject>();

            if (Far.Api.UI.IsCommandMode)
            {
                if (!string.IsNullOrEmpty(caption))
                    WriteLine(PromptColor, BackgroundColor, caption);
                if (!string.IsNullOrEmpty(message))
                    WriteLine(message);
            }

            foreach (var current in descriptions)
            {
                var prompt = current.Name;

                var type = Type.GetType(current.ParameterAssemblyFullName);
                if (type.GetInterface(typeof(IList).FullName) != null)
                {
                    var arrayList = new ArrayList();
                    for (; ; )
                    {
                        var prompt2 = string.Format(null, "{0}[{1}]", prompt, arrayList.Count);
                        string text;
                        if (Far.Api.UI.IsCommandMode)
                        {
                            WriteLine(prompt2);

                            //TODO HelpMessage - is fine by [F1]?
                            for (; ; )
                            {
                                var ui = new UI.ReadLine() { Prompt = TextPrompt, HelpMessage = current.HelpMessage, History = Res.HistoryPrompt };
                                if (!ui.Show())
                                {
                                    A.AskStopPipeline();
                                    continue;
                                }
                                text = ui.Text;
                                break;
                            }
                            WriteLine(TextPrompt + text);
                        }
                        else
                        {
                            //TODO HelpMessage - not done
                            for (; ; )
                            {
                                var ui = new UI.InputBoxEx()
                                {
                                    Title = caption,
                                    Prompt = string.IsNullOrEmpty(message) ? prompt2 : message + "\r" + prompt2,
                                    History = Res.HistoryPrompt
                                };
                                if (!ui.Show())
                                {
                                    A.AskStopPipeline();
                                    continue;
                                }
                                text = ui.Text;
                                break;
                            }
                        }

                        if (text.Length == 0)
                            break;

                        arrayList.Add(text);
                    }
                    r.Add(prompt, new PSObject(arrayList));
                }
                else
                {
                    var safe = type == typeof(SecureString);

                    string text;
                    if (Far.Api.UI.IsCommandMode)
                    {
                        WriteLine(prompt);

                        //TODO HelpMessage - [F1] - really?
                        for (; ; )
                        {
                            var ui = new UI.ReadLine() { Prompt = TextPrompt, HelpMessage = current.HelpMessage, History = Res.HistoryPrompt, Password = safe };
                            if (!ui.Show())
                            {
                                A.AskStopPipeline();
                                continue;
                            }

                            text = ui.Text;
                            WriteLine(TextPrompt + (safe ? "*" : text));
                            break;
                        }
                    }
                    else
                    {
                        //TODO HelpMessage - not done
                        for (; ; )
                        {
                            var ui = new UI.InputBoxEx()
                            {
                                Title = caption,
                                Prompt = string.IsNullOrEmpty(message) ? prompt : message + "\r" + prompt,
                                History = Res.HistoryPrompt,
                                Password = safe
                            };
                            if (!ui.Show())
                            {
                                A.AskStopPipeline();
                                continue;
                            }

                            text = ui.Text;
                            break;
                        }
                    }
                    r.Add(prompt, ValueToResult(text, safe));
                }
            }
            return r;
        }
Пример #4
0
        void OnSort()
        {
            Func<IEnumerable> getWords = delegate
            {
                var list = new List<string>();
                foreach (DataColumn c in Table.Columns)
                    list.Add(c.ColumnName);
                return list;
            };

            var ui = new UI.InputBoxEx()
            {
                Title = "Sort",
                Prompt = "Sort column list: [Tab] to complete, comma to separate",
                Text = ViewSort ?? string.Empty,
                History = "DataRecordSort",
                GetWords = getWords
            };
            if (!ui.Show())
                return;

            var text = ui.Text;
            if (text == ViewSort)
                return;

            ViewSort = text;

            NeedsNewFiles = true;
            UpdateRedraw(true);
        }
Пример #5
0
        void OnFilter()
        {
            Func<IEnumerable> getWords = delegate
            {
                var list = new List<string>();
                foreach (DataColumn c in Table.Columns)
                    list.Add(c.ColumnName);

                list.AddRange(new string[] {
            "","and","avg","between","child","convert","count","false","iif","in","is","isnull","len","like","max","min","not","null","or","parent","stdev","substring","sum","trim","true","var",
            });

                return list;
            };

            var ui = new UI.InputBoxEx()
            {
                Title = "Filter",
                Prompt = "Filter expression: [Tab] to complete",
                Text = ViewRowFilter ?? string.Empty,
                History = "DataRecordFilter",
                GetWords = getWords
            };
            if (!ui.Show())
                return;

            var text = ui.Text;
            if (text == ViewRowFilter)
                return;

            ViewRowFilter = text;

            NeedsNewFiles = true;
            UpdateRedraw(true);
        }
Пример #6
0
        /// <summary>
        /// Shows a dialog with a number of input fields.
        /// </summary>
        public override Dictionary <string, PSObject> Prompt(string caption, string message, Collection <FieldDescription> descriptions)
        {
            if (descriptions == null)
            {
                throw new ArgumentNullException("descriptions");
            }

            var r = new Dictionary <string, PSObject>();

            foreach (var current in descriptions)
            {
                var prompt = current.Name;

                var type = Type.GetType(current.ParameterAssemblyFullName);
                if (type.GetInterface(typeof(IList).FullName) != null)
                {
                    var arrayList = new ArrayList();
                    for (;;)
                    {
                        var    prompt2 = string.Format(null, "{0}[{1}]", prompt, arrayList.Count);
                        string text;
                        {
                            //TODO HelpMessage - not done
                            for (;;)
                            {
                                var ui = new UI.InputBoxEx()
                                {
                                    Title   = caption,
                                    Prompt  = string.IsNullOrEmpty(message) ? prompt2 : message + "\r" + prompt2,
                                    History = Res.HistoryPrompt
                                };
                                if (!ui.Show())
                                {
                                    A.AskStopPipeline();
                                    continue;
                                }
                                text = ui.Text;
                                break;
                            }
                        }
                        if (text.Length == 0)
                        {
                            break;
                        }

                        arrayList.Add(text);
                    }
                    r.Add(prompt, new PSObject(arrayList));
                }
                else
                {
                    var    safe = type == typeof(SecureString);
                    string text;
                    {
                        //TODO HelpMessage - not done
                        for (;;)
                        {
                            var ui = new UI.InputBoxEx()
                            {
                                Title    = caption,
                                Prompt   = string.IsNullOrEmpty(message) ? prompt : message + "\r" + prompt,
                                History  = Res.HistoryPrompt,
                                Password = safe
                            };
                            if (!ui.Show())
                            {
                                A.AskStopPipeline();
                                continue;
                            }

                            text = ui.Text;
                            break;
                        }
                    }
                    r.Add(prompt, ValueToResult(text, safe));
                }
            }
            return(r);
        }