示例#1
0
        /// <summary>
        /// Shows the subset form.
        /// </summary>
        public override bool Show()
        {
            // no job
            if (Items == null || Items.Length == 0)
            {
                return(false);
            }

            // drop items, Show() may be called several times
            _ListBox1.Items.Clear();
            _ListBox2.Items.Clear();

            // fill both lists
            if (Indexes != null && Indexes.Length > 0)
            {
                for (int index1 = 0; index1 < Items.Length; ++index1)
                {
                    FarItem item;
                    if (Array.IndexOf(Indexes, index1) < 0)
                    {
                        item = _ListBox1.Add(DoItemToString(Items[index1]));
                    }
                    else
                    {
                        item = _ListBox2.Add(DoItemToString(Items[index1]));
                    }
                    item.Data = index1;
                }
            }
            else
            {
                for (int index1 = 0; index1 < Items.Length; ++index1)
                {
                    _ListBox1.Add(DoItemToString(Items[index1])).Data = index1;
                }
            }

            // the last fake selected item for inserting to the end
            _ListBox2.Add(String.Empty).Data = -1;
            _ListBox2.SelectLast             = true;

            // go!
            if (!base.Show())
            {
                return(false);
            }

            // collect and reset selected indexes
            var r = new List <int>();

            foreach (FarItem item in _ListBox2.Items)
            {
                int index = (int)item.Data;
                if (index < 0)
                {
                    break;
                }
                r.Add(index);
            }
            Indexes = r.ToArray();
            return(true);
        }
示例#2
0
        public DebuggerDialog(DebuggerStopEventArgs e)
        {
            _InvocationInfo = e.InvocationInfo;

            int maxLine = 0;

            string[] lines = null;
            if (!string.IsNullOrEmpty(e.InvocationInfo.ScriptName) && File.Exists(e.InvocationInfo.ScriptName))
            {
                try
                {
                    lines = File.ReadAllLines(e.InvocationInfo.ScriptName, Encoding.Default);
                    foreach (string s in lines)
                    {
                        if (s.Length > maxLine)
                        {
                            maxLine = s.Length;
                        }
                    }
                }
                catch (IOException) { }
            }

            int dw = Math.Max(Math.Min(Far.Api.UI.WindowSize.X - 7, maxLine + 12), 73);
            int dh = 22;

            string title;
            int    h1;

            if (e.Breakpoints.Count > 0)
            {
                title = "DEBUG: Hit breakpoint(s)";
                h1    = e.Breakpoints.Count + 2;
            }
            else
            {
                title = "DEBUG: Step";
                h1    = 2;
            }

            _Dialog           = Far.Api.CreateDialog(-1, -1, dw, dh);
            _Dialog.HelpTopic = Far.Api.GetHelpTopic("DebuggerDialog");
            _Dialog.AddBox(3, 1, dw - 4, dh - 2, title);

            _List1          = _Dialog.AddListBox(4, 2, dw - 5, h1 + 1, null);
            _List1.Disabled = true;
            _List1.NoBox    = true;
            _List1.NoClose  = true;
            _List1.NoFocus  = true;
            if (e.Breakpoints.Count > 0)
            {
                foreach (Breakpoint bp in e.Breakpoints)
                {
                    CommandBreakpoint bpc = bp as CommandBreakpoint;
                    if (bpc != null && Kit.Equals(bpc.Command, Commands.AssertFarCommand.MyName))
                    {
                        A.InvokeCode("Remove-PSBreakpoint -Breakpoint $args[0]", bpc);
                    }
                }
            }
            foreach (string s in e.InvocationInfo.PositionMessage.Trim().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                _List1.Add(s);
            }

            _Dialog.AddText(0, -_List1.Rect.Height, 0, null).Separator = 1;

            _List2         = _Dialog.AddListBox(4, _List1.Rect.Bottom + 2, dw - 5, dh - 5, null);
            _List2.NoBox   = true;
            _List2.NoClose = true;
            if (lines != null)
            {
                foreach (string s in lines)
                {
                    _List2.Add(s);
                }
                int i = e.InvocationInfo.ScriptLineNumber - 1;
                _List2.Items[i].Checked = true;
            }

            _Dialog.AddText(0, -_List2.Rect.Height, 0, null).Separator = 1;

            _Step             = _Dialog.AddButton(0, -1, BtnStep);
            _Step.CenterGroup = true;

            _Over             = _Dialog.AddButton(0, 0, BtnOver);
            _Over.CenterGroup = true;

            _Out             = _Dialog.AddButton(0, 0, BtnOut);
            _Out.CenterGroup = true;

            _Console             = _Dialog.AddButton(0, 0, BtnInteractive);
            _Console.CenterGroup = true;
            _Console.NoBrackets  = true;

            _Edit             = _Dialog.AddButton(0, 0, BtnEdit);
            _Edit.CenterGroup = true;
            _Edit.NoBrackets  = true;

            // to be completed on show
            _View             = _Dialog.AddButton(0, 0, BtnView);
            _View.CenterGroup = true;
            _View.NoBrackets  = true;
            _View.NoClose     = true;

            _Goto                = _Dialog.AddButton(0, 0, BtnLine);
            _Goto.CenterGroup    = true;
            _Goto.NoBrackets     = true;
            _Goto.NoClose        = true;
            _Goto.ButtonClicked += OnGoto;

            _Quit             = _Dialog.AddButton(0, 0, BtnQuit);
            _Quit.CenterGroup = true;
            _Quit.NoBrackets  = true;

            _Dialog.Initialized += OnInitialized;
        }