Пример #1
0
            public static void ConfigureActiveStatement(LineProperties props)
            {
                props.FgColor     = Color.Black;
                props.TextBgColor = ConfigManager.Config.DebugInfo.CodeActiveStatementColor;
                props.Symbol     |= LineSymbol.Arrow;

                if (ConfigManager.Config.DebugInfo.ShowInstructionProgression)
                {
                    InstructionProgress state = new InstructionProgress();
                    InteropEmu.DebugGetInstructionProgress(ref state);

                    LineProgress progress = new LineProgress();
                    progress.Current = (int)state.OpCycle;
                    progress.Maxixum = frmOpCodeTooltip.OpCycles[state.OpCode];
                    switch (state.OpMemoryOperationType)
                    {
                    case InteropMemoryOperationType.DmcRead: progress.Color = Color.FromArgb(255, 160, 221); progress.Text = "DMC"; break;

                    case InteropMemoryOperationType.DummyRead: progress.Color = Color.FromArgb(184, 160, 255); progress.Text = "DR"; break;

                    case InteropMemoryOperationType.DummyWrite: progress.Color = Color.FromArgb(255, 245, 137); progress.Text = "DW"; break;

                    case InteropMemoryOperationType.Read: progress.Color = Color.FromArgb(150, 176, 255); progress.Text = "R"; break;

                    case InteropMemoryOperationType.Write: progress.Color = Color.FromArgb(255, 171, 150); progress.Text = "W"; break;

                    default: progress.Color = Color.FromArgb(143, 255, 173); progress.Text = "X"; break;
                    }
                    props.Progress = progress;
                }
            }
Пример #2
0
        private void DrawLine(Graphics g, int currentLine, int marginLeft, int positionY, int lineHeight)
        {
            string codeString    = _contents[currentLine];
            string addressString = this.Addressing?[currentLine];
            string commentString = this.Comments?[currentLine];

            float codeStringLength    = g.MeasureString(codeString, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width;
            float addressStringLength = g.MeasureString(addressString, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width;

            if (currentLine >= this.SelectionStart && currentLine <= this.SelectionStart + this.SelectionLength)
            {
                //Highlight current line
                using (Brush brush = new SolidBrush(Color.FromArgb(230, 238, 255))) {
                    int offset = currentLine - 1 == this.SelectedLine ? 1 : 0;
                    g.FillRectangle(brush, marginLeft, positionY + offset, Math.Max(_maxLineWidth, this.ClientRectangle.Width), lineHeight - offset);
                }
                if (currentLine == this.SelectedLine)
                {
                    g.DrawRectangle(Pens.Blue, marginLeft + 1, positionY + 1, Math.Max(_maxLineWidth, this.ClientRectangle.Width - marginLeft) - 1, lineHeight);
                }
            }

            //Adjust background color highlights based on number of spaces in front of content
            marginLeft += (LineIndentations != null ? LineIndentations[currentLine] : 0);

            Color          textColor      = Color.Black;
            LineProperties lineProperties = GetLineStyle(currentLine);

            if (lineProperties != null)
            {
                //Process background, foreground, outline color and line symbol
                textColor = lineProperties.FgColor ?? Color.Black;

                if (lineProperties.BgColor.HasValue)
                {
                    using (Brush bgBrush = new SolidBrush(lineProperties.BgColor.Value)) {
                        g.FillRectangle(bgBrush, marginLeft, positionY + 1, codeStringLength, lineHeight - 1);
                    }
                }
                if (lineProperties.OutlineColor.HasValue)
                {
                    using (Pen outlinePen = new Pen(lineProperties.OutlineColor.Value, 1)) {
                        g.DrawRectangle(outlinePen, marginLeft, positionY + 1, codeStringLength, lineHeight - 1);
                    }
                }
            }

            this.DrawLineText(g, currentLine, marginLeft, positionY, codeString, addressString, commentString, codeStringLength, addressStringLength, textColor, lineHeight);
        }
Пример #3
0
        private void DrawLineSymbols(Graphics g, int positionY, LineProperties lineProperties, int lineHeight)
        {
            if (lineProperties.Symbol.HasFlag(LineSymbol.Circle))
            {
                using (Brush brush = new SolidBrush(lineProperties.OutlineColor.Value)) {
                    g.FillEllipse(brush, 3, positionY + 4, lineHeight - 3, lineHeight - 3);
                }
            }
            if (lineProperties.Symbol.HasFlag(LineSymbol.CircleOutline) && lineProperties.OutlineColor.HasValue)
            {
                using (Pen pen = new Pen(lineProperties.OutlineColor.Value, 1)) {
                    g.DrawEllipse(pen, 3, positionY + 4, lineHeight - 3, lineHeight - 3);
                }
            }
            if (lineProperties.Symbol.HasFlag(LineSymbol.Arrow))
            {
                int arrowY = positionY + lineHeight / 2 + 1;
                if (Program.IsMono)
                {
                    using (Brush brush = new SolidBrush(lineProperties.BgColor.Value)) {
                        g.FillRectangle(brush, 1, arrowY - lineHeight * 0.25f / 2, lineHeight - 1, lineHeight * 0.35f);
                    }
                    g.DrawRectangle(Pens.Black, 1, arrowY - lineHeight * 0.25f / 2, lineHeight - 1, lineHeight * 0.35f);
                }
                else
                {
                    using (Pen pen = new Pen(Color.Black, lineHeight * 0.33f)) {
                        //Outline
                        g.DrawLine(pen, 3, arrowY, 3 + lineHeight * 0.25f, arrowY);
                        pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                        g.DrawLine(pen, 3 + lineHeight * 0.25f, arrowY, 3 + lineHeight * 0.75f, arrowY);

                        //Fill
                        pen.Width -= 2f;
                        pen.Color  = lineProperties.BgColor.Value;
                        pen.EndCap = System.Drawing.Drawing2D.LineCap.Square;
                        g.DrawLine(pen, 4, arrowY, 3 + lineHeight * 0.25f - 1, arrowY);
                        pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                        g.DrawLine(pen, 3 + lineHeight * 0.25f, arrowY, lineHeight * 0.75f + 1, arrowY);
                    }
                }
            }
        }
Пример #4
0
        public void SetLineColor(int lineNumber, Color?fgColor = null, Color?bgColor = null, Color?outlineColor = null, LineSymbol symbol = LineSymbol.None)
        {
            if (lineNumber != -1)
            {
                if (_lineNumberIndex.ContainsKey(lineNumber))
                {
                    LineProperties properties = new LineProperties()
                    {
                        BgColor      = bgColor,
                        FgColor      = fgColor,
                        OutlineColor = outlineColor,
                        Symbol       = symbol
                    };

                    _lineProperties[_lineNumberIndex[lineNumber]] = properties;
                    this.Invalidate();
                }
            }
        }
Пример #5
0
            public static void GetBreakpointLineProperties(LineProperties props, int cpuAddress, AddressTypeInfo addressInfo)
            {
                DebugInfo info = ConfigManager.Config.DebugInfo;

                foreach (Breakpoint breakpoint in BreakpointManager.Breakpoints)
                {
                    if (breakpoint.Matches(cpuAddress, addressInfo))
                    {
                        Color      fgColor      = Color.White;
                        Color?     bgColor      = null;
                        Color      bpColor      = breakpoint.BreakOnExec ? info.CodeExecBreakpointColor : (breakpoint.BreakOnWrite ? info.CodeWriteBreakpointColor : info.CodeReadBreakpointColor);
                        Color      outlineColor = bpColor;
                        LineSymbol symbol;
                        if (breakpoint.Enabled)
                        {
                            bgColor = bpColor;
                            symbol  = LineSymbol.Circle;
                        }
                        else
                        {
                            fgColor = Color.Black;
                            symbol  = LineSymbol.CircleOutline;
                        }

                        if (breakpoint.MarkEvent)
                        {
                            symbol |= LineSymbol.Mark;
                        }

                        if (!string.IsNullOrWhiteSpace(breakpoint.Condition))
                        {
                            symbol |= LineSymbol.Plus;
                        }

                        props.FgColor      = fgColor;
                        props.TextBgColor  = bgColor;
                        props.OutlineColor = outlineColor;
                        props.Symbol       = symbol;
                        return;
                    }
                }
            }
Пример #6
0
            public LineProperties GetLineStyle(int cpuAddress, int lineNumber)
            {
                DebugInfo       info        = ConfigManager.Config.DebugInfo;
                LineProperties  props       = new LineProperties();
                AddressTypeInfo addressInfo = _code.GetAddressInfo(lineNumber);

                GetBreakpointLineProperties(props, cpuAddress, addressInfo);

                bool isActiveStatement = _code._currentActiveAddress.HasValue && _code.ctrlCodeViewer.GetLineIndex((int)_code._currentActiveAddress.Value) == lineNumber;

                if (isActiveStatement)
                {
                    props.FgColor     = Color.Black;
                    props.TextBgColor = info.CodeActiveStatementColor;
                    props.Symbol     |= LineSymbol.Arrow;
                }
                else if (_code._code.UnexecutedAddresses.Contains(lineNumber))
                {
                    props.LineBgColor = info.CodeUnexecutedCodeColor;
                }
                else if (_code._code.SpeculativeCodeAddreses.Contains(lineNumber))
                {
                    props.LineBgColor = info.CodeUnidentifiedDataColor;
                }
                else if (_code._code.VerifiedDataAddresses.Contains(lineNumber))
                {
                    props.LineBgColor = info.CodeVerifiedDataColor;
                }

                switch (_code._code.LineMemoryType[lineNumber])
                {
                case 'P': props.AddressColor = Color.Gray; break;

                case 'W': props.AddressColor = Color.DarkBlue; break;

                case 'S': props.AddressColor = Color.DarkRed; break;

                case 'N': props.AddressColor = Color.DarkGreen; break;
                }

                return(props);
            }
Пример #7
0
        private void DrawMargin(Graphics g, int currentLine, int marginLeft, int regularMargin, int positionY, int lineHeight)
        {
            if (this.ShowLineNumbers)
            {
                //Show line number
                this.DrawLineNumber(g, currentLine, regularMargin, positionY);
            }
            if (this.ShowContentNotes && this.ShowSingleContentLineNotes)
            {
                g.DrawString(_contentNotes[currentLine], this.Font, Brushes.Gray, regularMargin + 6, positionY, StringFormat.GenericTypographic);
            }

            //Adjust background color highlights based on number of spaces in front of content
            marginLeft += (LineIndentations != null ? LineIndentations[currentLine] : 0);

            LineProperties lineProperties = GetLineStyle(currentLine);

            if (lineProperties != null)
            {
                this.DrawLineSymbols(g, positionY, lineProperties, lineHeight);
            }
        }
Пример #8
0
            public LineProperties GetLineStyle(int cpuAddress, int lineNumber)
            {
                DebugInfo      info  = ConfigManager.Config.DebugInfo;
                LineProperties props = null;

                if (_code._currentActiveAddress.HasValue && cpuAddress == _code._currentActiveAddress)
                {
                    props = new LineProperties()
                    {
                        TextBgColor = info.CodeActiveStatementColor, Symbol = LineSymbol.Arrow
                    };
                }
                else if (_code._unexecutedAddresses.Contains(lineNumber))
                {
                    props = new LineProperties()
                    {
                        LineBgColor = info.CodeUnexecutedCodeColor
                    };
                }
                else if (_code._speculativeCodeAddreses.Contains(lineNumber))
                {
                    props = new LineProperties()
                    {
                        LineBgColor = info.CodeUnidentifiedDataColor
                    };
                }
                else if (_code._verifiedDataAddresses.Contains(lineNumber))
                {
                    props = new LineProperties()
                    {
                        LineBgColor = info.CodeVerifiedDataColor
                    };
                }

                foreach (Breakpoint breakpoint in BreakpointManager.Breakpoints)
                {
                    if (breakpoint.Matches(cpuAddress))
                    {
                        Color?     fgColor      = Color.White;
                        Color?     bgColor      = null;
                        Color      bpColor      = breakpoint.BreakOnExec ? info.CodeExecBreakpointColor : (breakpoint.BreakOnWrite ? info.CodeWriteBreakpointColor : info.CodeReadBreakpointColor);
                        Color?     outlineColor = bpColor;
                        LineSymbol symbol;
                        if (breakpoint.Enabled)
                        {
                            bgColor = bpColor;
                            symbol  = LineSymbol.Circle;
                        }
                        else
                        {
                            fgColor = Color.Black;
                            symbol  = LineSymbol.CircleOutline;
                        }

                        if (_code._currentActiveAddress.HasValue && breakpoint.Matches((int)_code._currentActiveAddress.Value))
                        {
                            fgColor = Color.Black;
                            bgColor = Color.Yellow;
                            symbol |= LineSymbol.Arrow;
                        }

                        if (props == null)
                        {
                            props = new LineProperties();
                        }
                        props.FgColor      = fgColor;
                        props.TextBgColor  = bgColor;
                        props.OutlineColor = outlineColor;
                        props.Symbol       = symbol;
                        break;
                    }
                }

                return(props);
            }
Пример #9
0
        private void DrawLine(Graphics g, int currentLine, int marginLeft, int positionY)
        {
            if (this.ShowLineNumbers)
            {
                //Show line number
                string lineNumber = _lineNumbers[currentLine] >= 0 ? _lineNumbers[currentLine].ToString(_showLineInHex ? "X4" : "") : "..";
                float  width      = g.MeasureString(lineNumber, this.Font).Width;
                g.DrawString(lineNumber, this.Font, Brushes.Gray, marginLeft - width, positionY);
                if (this.ShowLineNumberNotes)
                {
                    width = g.MeasureString(_lineNumberNotes[currentLine], _noteFont).Width;
                    g.DrawString(_lineNumberNotes[currentLine], _noteFont, Brushes.Gray, marginLeft - width, positionY + this.Font.Size + 3);
                }
            }

            if (currentLine == this.CursorPosition)
            {
                //Highlight current line
                g.FillRectangle(Brushes.AliceBlue, marginLeft, positionY, this.ClientRectangle.Width - marginLeft, this.LineHeight);
            }

            Color textColor = Color.Black;

            if (_lineProperties.ContainsKey(currentLine))
            {
                //Process background, foreground, outline color and line symbol
                LineProperties lineProperties = _lineProperties[currentLine];
                textColor = lineProperties.FgColor ?? Color.Black;

                float stringLength = g.MeasureString(_contents[currentLine], this.Font).Width;

                if (lineProperties.BgColor.HasValue)
                {
                    using (Brush bgBrush = new SolidBrush(lineProperties.BgColor.Value)) {
                        g.FillRectangle(bgBrush, marginLeft + 1, positionY + 1, stringLength, this.LineHeight - 1);
                    }
                }
                if (lineProperties.OutlineColor.HasValue)
                {
                    using (Pen outlinePen = new Pen(lineProperties.OutlineColor.Value, 1)) {
                        g.DrawRectangle(outlinePen, marginLeft + 1, positionY + 1, stringLength, this.LineHeight - 1);
                    }
                }

                if (lineProperties.Symbol.HasFlag(LineSymbol.Circle))
                {
                    using (Brush brush = new SolidBrush(lineProperties.OutlineColor.Value)) {
                        g.FillEllipse(brush, 1, positionY + 2, this.LineHeight - 3, this.LineHeight - 3);
                    }
                }
                if (lineProperties.Symbol.HasFlag(LineSymbol.CircleOutline) && lineProperties.OutlineColor.HasValue)
                {
                    using (Pen pen = new Pen(lineProperties.OutlineColor.Value, 1)) {
                        g.DrawEllipse(pen, 1, positionY + 2, this.LineHeight - 3, this.LineHeight - 3);
                    }
                }
                if (lineProperties.Symbol.HasFlag(LineSymbol.Arrow))
                {
                    int arrowY = positionY + this.LineHeight / 2 + 1;
                    using (Pen pen = new Pen(Color.Black, this.LineHeight * 0.33f)) {
                        //Outline
                        g.DrawLine(pen, 3, arrowY, 3 + this.LineHeight * 0.25f, arrowY);
                        pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                        g.DrawLine(pen, 3 + this.LineHeight * 0.25f, arrowY, 3 + this.LineHeight * 0.75f, arrowY);

                        //Fill
                        pen.Width -= 2f;
                        pen.Color  = lineProperties.BgColor.Value;
                        pen.EndCap = System.Drawing.Drawing2D.LineCap.Square;
                        g.DrawLine(pen, 4, arrowY, 3 + this.LineHeight * 0.25f - 1, arrowY);
                        pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
                        g.DrawLine(pen, 3 + this.LineHeight * 0.25f, arrowY, this.LineHeight * 0.75f + 1, arrowY);
                    }
                }
            }

            string lineText = _contents[currentLine];

            using (Brush fgBrush = new SolidBrush(textColor)) {
                g.DrawString(lineText, this.Font, fgBrush, marginLeft, positionY);
                if (this.ShowContentNotes)
                {
                    g.DrawString(_contentNotes[currentLine], _noteFont, Brushes.Gray, marginLeft, positionY + this.Font.Size + 3);
                }
                this.DrawHighlightedSearchString(g, lineText, marginLeft, positionY);
                this.DrawHighlightedCompareString(g, lineText, currentLine, marginLeft, positionY);
            }
        }