DisplayMode Enumeration

Defines identifiers that indicate the display modes used by ByteViewer.

Namespace: System.ComponentModel.Design
Assembly: System.Design (in system.design.dll)

'Declaration
Public Enumeration DisplayMode
'Usage
Dim instance As DisplayMode

public enum DisplayMode
public enum DisplayMode

 Member nameDescription
AnsiAn ANSI format display. 
AutoA display mode that automatically selects a display mode. In this mode, the bytes are examined to determine if they are hexadecimal or printable. If the bytes are in hexadecimal format, the Hexdump mode is selected. If the characters match a printable character set, a test is run to automatically select either the Ansi or Unicode display mode. 
HexdumpA hexadecimal format display. 
UnicodeA Unicode format display. 

The DisplayMode identifiers are used to indicate the display mode used to display each byte sequence.

The following code example demonstrates how to use DisplayMode identifiers. This code example is part of a larger example provided for the ByteViewer class.

Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Windows.Forms

Public Class ByteViewerForm
   Inherits System.Windows.Forms.Form
   Private button1 As System.Windows.Forms.Button
   Private button2 As System.Windows.Forms.Button
   Private byteviewer As System.ComponentModel.Design.ByteViewer
   
    Public Sub New()
        ' Initialize the controls other than the ByteViewer.
        InitializeForm()

        ' Initialize the ByteViewer.
        byteviewer = New ByteViewer
        byteviewer.Location = New Point(8, 46)
        byteviewer.Size = New Size(600, 338)
        byteviewer.Anchor = AnchorStyles.Left Or AnchorStyles.Bottom Or AnchorStyles.Top
        byteviewer.SetBytes(New Byte() {})
        Me.Controls.Add(byteviewer)
    End Sub

    ' Show a file selection dialog and cues the byte viewer to 
    ' load the data in a selected file.
    Private Sub loadBytesFromFile(ByVal sender As Object, ByVal e As EventArgs)
        Dim ofd As New OpenFileDialog
        If ofd.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then
            Return
        End If
        byteviewer.SetFile(ofd.FileName)
    End Sub

    ' Clear the bytes in the byte viewer.
    Private Sub clearBytes(ByVal sender As Object, ByVal e As EventArgs)
        byteviewer.SetBytes(New Byte() {})
    End Sub

    ' Changes the display mode of the byte viewer according to the 
    ' Text property of the RadioButton sender control.
    Private Sub changeByteMode(ByVal sender As Object, ByVal e As EventArgs)
        Dim rbutton As System.Windows.Forms.RadioButton = _
            CType(sender, System.Windows.Forms.RadioButton)

        Dim mode As DisplayMode
        Select Case rbutton.Text
            Case "ANSI"
                mode = DisplayMode.Ansi
            Case "Hex"
                mode = DisplayMode.Hexdump
            Case "Unicode"
                mode = DisplayMode.Unicode
            Case Else
                mode = DisplayMode.Auto
        End Select

        ' Sets the display mode.
        byteviewer.SetDisplayMode(mode)
    End Sub

    Private Sub InitializeForm()
        Me.SuspendLayout()
        Me.ClientSize = New System.Drawing.Size(680, 440)
        Me.MinimumSize = New System.Drawing.Size(660, 400)
        Me.Size = New System.Drawing.Size(680, 440)
        Me.Name = "Byte Viewer Form"
        Me.Text = "Byte Viewer Form"

        Me.button1 = New System.Windows.Forms.Button
        Me.button1.Location = New System.Drawing.Point(8, 8)
        Me.button1.Size = New System.Drawing.Size(190, 23)
        Me.button1.Name = "button1"
        Me.button1.Text = "Set Bytes From File..."
        Me.button1.TabIndex = 0
        AddHandler Me.button1.Click, AddressOf Me.loadBytesFromFile
        Me.Controls.Add(Me.button1)

        Me.button2 = New System.Windows.Forms.Button
        Me.button2.Location = New System.Drawing.Point(198, 8)
        Me.button2.Size = New System.Drawing.Size(190, 23)
        Me.button2.Name = "button2"
        Me.button2.Text = "Clear Bytes"
        AddHandler Me.button2.Click, AddressOf Me.clearBytes
        Me.button2.TabIndex = 1

        Me.Controls.Add(Me.button2)

        Dim group As New System.Windows.Forms.GroupBox
        group.Location = New Point(418, 3)
        group.Size = New Size(220, 36)
        group.Text = "Display Mode"
        Me.Controls.Add(group)

        Dim rbutton1 As New System.Windows.Forms.RadioButton
        rbutton1.Location = New Point(6, 15)
        rbutton1.Size = New Size(46, 16)
        rbutton1.Text = "Auto"
        rbutton1.Checked = True
        AddHandler rbutton1.Click, AddressOf Me.changeByteMode
        group.Controls.Add(rbutton1)

        Dim rbutton2 As New System.Windows.Forms.RadioButton
        rbutton2.Location = New Point(54, 15)
        rbutton2.Size = New Size(50, 16)
        rbutton2.Text = "ANSI"
        AddHandler rbutton2.Click, AddressOf Me.changeByteMode
        group.Controls.Add(rbutton2)

        Dim rbutton3 As New System.Windows.Forms.RadioButton
        rbutton3.Location = New Point(106, 15)
        rbutton3.Size = New Size(46, 16)
        rbutton3.Text = "Hex"
        AddHandler rbutton3.Click, AddressOf Me.changeByteMode
        group.Controls.Add(rbutton3)

        Dim rbutton4 As New System.Windows.Forms.RadioButton
        rbutton4.Location = New Point(152, 15)
        rbutton4.Size = New Size(64, 16)
        rbutton4.Text = "Unicode"
        AddHandler rbutton4.Click, AddressOf Me.changeByteMode
        group.Controls.Add(rbutton4)
        Me.ResumeLayout(False)
    End Sub

    <STAThread()> _
    Shared Sub Main()
        Application.Run(New ByteViewerForm)
    End Sub
End Class


package ByteViewerForm; 

import System.*;
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Windows.Forms.*;
   
public class ByteViewerForm extends System.Windows.Forms.Form
{
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Button button2;
    private System.ComponentModel.Design.ByteViewer byteViewer;

    public ByteViewerForm()
    {
        // Initialize the controls other than the ByteViewer.
        InitializeForm();

        // Initialize the ByteViewer.
        byteViewer = new ByteViewer();
        byteViewer.set_Location(new Point(8, 46));
        byteViewer.set_Size(new Size(600, 338));
        byteViewer.set_Anchor(
            AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top);
        byteViewer.SetBytes(new ubyte[]{});
        this.get_Controls().Add(byteViewer);
    } //ByteViewerForm

    // Show a file selection dialog and cues the byte viewer to 
    // load the data in a selected file.
    private void LoadBytesFromFile(Object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();
        if (ofd.ShowDialog() != DialogResult.OK) {
            return;
        }
        byteViewer.SetFile(ofd.get_FileName());
    } //LoadBytesFromFile

    // Clear the bytes in the byte viewer.
    private void ClearBytes(Object sender, EventArgs e)
    {
        byteViewer.SetBytes(new ubyte[]{});
    } //ClearBytes

    // Changes the display mode of the byte viewer according to the 
    // Text property of the RadioButton sender control.
    private void ChangeByteMode(Object sender, EventArgs e)
    {
        System.Windows.Forms.RadioButton rbutton = 
            (System.Windows.Forms.RadioButton)sender;
        DisplayMode mode;

        if (rbutton.get_Text().Equals("ANSI")) {
            mode = DisplayMode.Ansi;
        }
        else {
            if (rbutton.get_Text().Equals("Hex")) {
                mode = DisplayMode.Hexdump;
            }
            else {
                if (rbutton.get_Text().Equals("Unicode")) {
                    mode = DisplayMode.Unicode;
                }
                else {
                    mode = DisplayMode.Auto;
                }
            }
        }

        // Sets the display mode.
        byteViewer.SetDisplayMode(mode);
    } //ChangeByteMode

    private void InitializeForm()
    {
        this.SuspendLayout();
        this.set_ClientSize(new System.Drawing.Size(680, 440));
        this.set_MinimumSize(new System.Drawing.Size(660, 400));
        this.set_Size(new System.Drawing.Size(680, 440));
        this.set_Name("Byte Viewer Form");
        this.set_Text("Byte Viewer Form");
        this.button1 = new System.Windows.Forms.Button();
        this.button1.set_Location(new System.Drawing.Point(8, 8));
        this.button1.set_Size(new System.Drawing.Size(190, 23));
        this.button1.set_Name("button1");
        this.button1.set_Text("Set Bytes From File...");
        this.button1.set_TabIndex(0);
        this.button1.add_Click(new EventHandler(this.LoadBytesFromFile));
        this.get_Controls().Add(this.button1);
        this.button2 = new System.Windows.Forms.Button();
        this.button2.set_Location(new System.Drawing.Point(198, 8));
        this.button2.set_Size(new System.Drawing.Size(190, 23));
        this.button2.set_Name("button2");
        this.button2.set_Text("Clear Bytes");
        this.button2.add_Click(new EventHandler(this.ClearBytes));
        this.button2.set_TabIndex(1);
        this.get_Controls().Add(this.button2);

        System.Windows.Forms.GroupBox group = 
            new System.Windows.Forms.GroupBox();
        group.set_Location(new Point(418, 3));
        group.set_Size(new Size(220, 36));
        group.set_Text("Display Mode");
        this.get_Controls().Add(group);

        System.Windows.Forms.RadioButton rbutton1 = 
            new System.Windows.Forms.RadioButton();
        rbutton1.set_Location(new Point(6, 15));
        rbutton1.set_Size(new Size(46, 16));
        rbutton1.set_Text("Auto");
        rbutton1.set_Checked(true);
        rbutton1.add_Click(new EventHandler(this.ChangeByteMode));
        group.get_Controls().Add(rbutton1);

        System.Windows.Forms.RadioButton rbutton2 = 
            new System.Windows.Forms.RadioButton();
        rbutton2.set_Location(new Point(54, 15));
        rbutton2.set_Size(new Size(50, 16));
        rbutton2.set_Text("ANSI");
        rbutton2.add_Click(new EventHandler(this.ChangeByteMode));
        group.get_Controls().Add(rbutton2);

        System.Windows.Forms.RadioButton rbutton3 = 
            new System.Windows.Forms.RadioButton();
        rbutton3.set_Location(new Point(106, 15));
        rbutton3.set_Size(new Size(46, 16));
        rbutton3.set_Text("Hex");
        rbutton3.add_Click(new EventHandler(this.ChangeByteMode));
        group.get_Controls().Add(rbutton3);

        System.Windows.Forms.RadioButton rbutton4 = 
            new System.Windows.Forms.RadioButton();
        rbutton4.set_Location(new Point(152, 15));
        rbutton4.set_Size(new Size(64, 16));
        rbutton4.set_Text("Unicode");
        rbutton4.add_Click(new EventHandler(this.ChangeByteMode));
        group.get_Controls().Add(rbutton4);
        this.ResumeLayout(false);
    } //InitializeForm

    /** @attribute STAThread()
     */
    public static void main(String[] args)
    {
        Application.Run(new ByteViewerForm());
    } //main
} //ByteViewerForm

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: