コード例 #1
0
 private void Position_Changed(object sender, EventArgs e)
 {
     offsetLabel.Text = string.Format("Offset {0}",
                                      OperandDisplayHelper.Changebase(
                                          Math.Max(0, (hexBox.CurrentLine - 1) * hexBox.BytesPerLine + hexBox.CurrentPositionInLine - 1)
                                          .ToString(CultureInfo.InvariantCulture), ENumericBase.Dec, Settings.Default.OperandDisplayBase));
 }
コード例 #2
0
ファイル: GridControl.cs プロジェクト: destnity/Reflexil
        private void Grid_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            var    grid         = (DataGridView)sender;
            string strRowNumber = OperandDisplayHelper.Changebase(e.RowIndex.ToString(CultureInfo.InvariantCulture),
                                                                  ENumericBase.Dec, Settings.Default.RowIndexDisplayBase);
            string strRowCount = OperandDisplayHelper.Changebase(grid.RowCount.ToString(CultureInfo.InvariantCulture),
                                                                 ENumericBase.Dec, Settings.Default.RowIndexDisplayBase);

            while (strRowNumber.Length < strRowCount.Length)
            {
                strRowNumber = "0" + strRowNumber;
            }

            var size = e.Graphics.MeasureString(strRowNumber, grid.Font);

            if (grid.RowHeadersWidth < (size.Width + 20))
            {
                grid.RowHeadersWidth = Convert.ToInt32(size.Width + 20);
            }

            var b = SystemBrushes.ControlText;

            e.Graphics.DrawString(strRowNumber, grid.Font, b, e.RowBounds.Location.X + 15,
                                  e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2));
        }
コード例 #3
0
        protected virtual void Grid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.Value is OpCode)
            {
                Grid.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = PluginFactory.GetInstance().GetOpcodeDesc((OpCode)e.Value);
            }
            else if (e.Value is MethodDefinition)
            {
                var mdef = (MethodDefinition)e.Value;
                Grid.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = String.Format("RVA: {0}", mdef.RVA);
            }
            else if (e.Value is TypeReference && Grid.Rows[e.RowIndex].DataBoundItem is CustomAttributeArgument)
            {
                // Hack to display terminal attribute type (can be wrapped)
                var argument = (CustomAttributeArgument)Grid.Rows[e.RowIndex].DataBoundItem;
                if (!(argument.Value is CustomAttributeArgument))
                {
                    return;
                }

                var wrappedargument = (CustomAttributeArgument)argument.Value;
                e.Value = wrappedargument.Type;
            }
            else if (e.Value is CustomAttributeArgument)
            {
                e.Value = OperandDisplayHelper.ToString((CustomAttributeArgument)e.Value);
            }
            else if (e.Value is CustomAttributeArgument[])
            {
                e.Value = OperandDisplayHelper.ToString((CustomAttributeArgument[])e.Value);
            }
            else if (OwnerDefinition is MethodDefinition)
            {
                if ((e.Value is short || e.Value is int || e.Value is long || e.Value is sbyte) ||
                    (e.Value is ushort || e.Value is uint || e.Value is ulong || e.Value is byte))
                {
                    var tipbuilder = new StringBuilder();
                    var values     = Enum.GetValues(typeof(ENumericBase));
                    for (var i = 0; i < values.Length; i++)
                    {
                        if (i > 0)
                        {
                            tipbuilder.AppendLine();
                        }

                        var item = (ENumericBase)values.GetValue(i);
                        tipbuilder.Append(item);
                        tipbuilder.Append(": ");
                        tipbuilder.Append(OperandDisplayHelper.Changebase(e.Value.ToString(), ENumericBase.Dec, item));
                    }

                    Grid.Rows[e.RowIndex].Cells[e.ColumnIndex].ToolTipText = tipbuilder.ToString();
                }

                e.Value = OperandDisplayHelper.ToString(OwnerDefinition as MethodDefinition, e.Value);
            }
        }
コード例 #4
0
 private void BaseCombo_SelectionChangeCommitted(object sender, EventArgs e)
 {
     TextBox.Text = OperandDisplayHelper.Changebase(TextBox.Text, PreviousBase, CurrentBase);
     PreviousBase = CurrentBase;
 }