示例#1
0
        private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (Debugger.Net.DebugClient.inst() == null)
            {
                return;
            }
            Label lbl = sender as Label;

            Json.JLeaf wrapper = lbl.Tag as Json.JLeaf;
            if (wrapper != null)
            {
                string newValue = Dlg.InputDlg.Show(String.Format("Set Value of {0}", wrapper.Name), "New Value:", wrapper.Value);
                if (newValue != null && newValue != wrapper.Value)
                {
                    string        tildePath = wrapper.GetTildePath();
                    Json.JWrapper topLevel  = wrapper.GetTopMost();
                    wrapper.Value = newValue;
                    if (topLevel.Name.Equals("This"))
                    {
                        // The userdata int is stored as "Depth" but need the index here
                        int value = Debug.SessionData.inst().CallStack.Count - 1;
                        tildePath = String.Format("{0}~{1}", value - ((int)topLevel.UserData), tildePath);
                        Debugger.Net.DebugClient.inst().SetThisValue(tildePath, newValue);
                    }
                    else if (topLevel.Name.Equals("Globals"))
                    {
                        Debugger.Net.DebugClient.inst().SetGlobalValue(tildePath, newValue);
                    }
                    else
                    {
                        Debugger.Net.DebugClient.inst().SetStackValue(tildePath, newValue);
                    }
                }
            }
        }
        void editor_MouseHover(object sender, MouseEventArgs e)
        {
            var pos = editor.GetPositionFromPoint(e.GetPosition(editor));

            if (pos != null)
            {
                string wordHovered = editor.Document.GetWordUnderMouse(pos.Value, true);
                if (Debugger.Debug.SessionData.inst().LocalData != null)
                {
                    Json.JWrapper wrapper = null;

                    //This -> Stack -> Globals
                    if (Debugger.Debug.SessionData.inst().ThisData != null)
                    {
                        wrapper = Debugger.Debug.SessionData.inst().ThisData.ContainsKey(wordHovered);
                    }
                    if (wrapper == null)
                    {
                        wrapper = Debugger.Debug.SessionData.inst().LocalData.ContainsKey(wordHovered);
                    }
                    if (wrapper == null && Debugger.Debug.SessionData.inst().GlobalData != null)
                    {
                        wrapper = Debugger.Debug.SessionData.inst().GlobalData.ContainsKey(wordHovered);
                    }

                    if (wrapper != null)
                    {
                        InsightWindow window = new InsightWindow(editor.TextArea);
                        window.Content = new Controls.JWrapView()
                        {
                            DataContext = wrapper
                        };
                        window.MinHeight     = 160;
                        window.MaxHeight     = 240;
                        window.SizeToContent = SizeToContent.Width;
                        window.Show();
                    }
                }
                e.Handled = true;
            }
        }
        void editor_MouseHover(object sender, MouseEventArgs e)
        {
            var pos = editor.GetPositionFromPoint(e.GetPosition(editor));

            if (pos != null)
            {
                string wordHovered = editor.Document.GetWordUnderMouse(pos.Value, true);
                if (Debugger.Debug.SessionData.inst().LocalData != null)
                {
                    Json.JWrapper wrapper = null;

                    // Try to find it in "this"
                    string[] words = wordHovered.Split('.');
                    if (Debugger.Debug.SessionData.inst().ThisData != null)
                    {
                        wrapper = Debugger.Debug.SessionData.inst().ThisData.ResolveDotPath(words);
                    }
                    if (wrapper != null && wrapper.Parent == null)
                    {
                        wrapper = null; //reset to null so other checks have an opportunity
                    }
                    // Check the Stack
                    if (wrapper == null)
                    {
                        wrapper = Debugger.Debug.SessionData.inst().LocalData.ResolveDotPath(words);
                    }
                    if (wrapper != null && wrapper.Parent == null)
                    {
                        wrapper = null; //reset to null so globals can have a chance
                    }
                    // Check the globals
                    if (wrapper == null && Debugger.Debug.SessionData.inst().GlobalData != null)
                    {
                        wrapper = Debugger.Debug.SessionData.inst().GlobalData.ResolveDotPath(words);
                    }

                    // If something has been found then show it in AvalonEdit's "Insight Window"
                    if (wrapper != null && wrapper.Parent != null)   //null check prevents display of all stack levels
                    {
                        InsightWindow window = new InsightWindow(editor.TextArea);
                        window.Background = new SolidColorBrush(Colors.Black);
                        if (wrapper is Json.JLeaf)
                        {
                            window.Content = new Label {
                                Content = ((Json.JLeaf)wrapper).Value
                            }
                        }
                        ;
                        else
                        {
                            window.Content = new Controls.JWrapView()
                            {
                                DataContext = wrapper
                            }
                        };
                        window.MaxHeight     = 240;
                        window.SizeToContent = SizeToContent.WidthAndHeight;
                        window.Left          = Mouse.GetPosition(this).X;
                        window.Top           = Mouse.GetPosition(this).X;
                        window.Show();
                    }
                }
                e.Handled = true;
            }
        }

        void editor_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                var newFontSize = editor.TextArea.FontSize + e.Delta / 50;
                editor.TextArea.FontSize = Math.Max(1, newFontSize);
                e.Handled = true;
            }
        }

        void aModelData_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("CurrentLine") || e.PropertyName.Equals("CurrentSection"))
            {
                bpMargin.InvalidateVisual();
            }
        }