private void RadioAuto_checkedChanged(object source, EventArgs e) { if (_radioAuto.Checked) { _byteViewer.SetDisplayMode(DisplayMode.Auto); } }
// 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; switch (rbutton.Text) { case "ANSI": mode = DisplayMode.Ansi; break; case "Hex": mode = DisplayMode.Hexdump; break; case "Unicode": mode = DisplayMode.Unicode; break; default: mode = DisplayMode.Auto; break; } // Sets the display mode. byteviewer.SetDisplayMode(mode); }
public ByteViewerForm(byte[] b, string name) { // 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 | AnchorStyles.Bottom | AnchorStyles.Top; byteviewer.SetDisplayMode(DisplayMode.Hexdump); byteviewer.SetBytes(b); this.MaximizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Controls.Add(byteviewer); this.Name = "Binary Viewer - " + name; this.Text = "Binary Viewer - " + name; }
protected override void Show( IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { object data = objectProvider.GetObject(); using (Form f = new Form()) using (ByteViewer viewer = new ByteViewer()) { if (data is nDNS.Message) viewer.SetBytes(((nDNS.Message) data).RawBytes); else return; viewer.SetDisplayMode(DisplayMode.Hexdump); viewer.Dock = DockStyle.Fill; f.FormBorderStyle = FormBorderStyle.SizableToolWindow; f.Text = "DNS Packet Byte Array Viewer"; f.ClientSize = viewer.Size; f.Controls.Add(viewer); windowService.ShowDialog(f); } }
//private void DoVSExportActiveProject(object aSender, EventArgs e) { // if (!ValidationHelpers.ValidateCurrentProjectNotNull()) { // AddMessage("No project to export."); // return; // } // if (OtaUtils.CurrentIdeVersion == 1) { // AddMessage("C#Builder 1.0 is not supported."); // return; // } // string bdsFile = OtaUtils.GetCurrentProject().FileName; // string vsFile; // if (ValidationHelpers.ValidateCurrentProjectIsCSharp()) // { // vsFile = Path.ChangeExtension(bdsFile, "csproj"); // } else if (ValidationHelpers.ValidateCurrentProjectIsVB()) { // vsFile = Path.ChangeExtension(bdsFile, "vbproj"); // } else { // AddMessage("Only C# and VB projects can be exported. Current project is " + bdsFile); // return; // } // string xsltFile = GetXsltFile(); // AddMessage("Visual Studio Conversion Tool"); // AddMessage("Using transform document: " + xsltFile); // AddMessage("Input file: " + bdsFile); // AddMessage("Output file: " + vsFile); // try { // Lextm.Xml.XmlConvertor.ConvertXmlUsingXsl(bdsFile, // xsltFile, // vsFile); // AddMessage("Done."); // } catch (Exception ex) { // Lextm.Windows.Forms.MessageBoxFactory.Fatal(ex); // } //} //private static string GetXsltFile() { // return OtaUtils.GetIdeRootDir() + @"Bin\VSExport.xsl"; //} // protected void DoStartProjectTarget(object aSender, EventArgs e) { // if (!ValidationHelpers.ValidateCurrentProjectTargetExists()) { // return; // } // // string _Target = OTAUtils.GetProjectTarget(OTAUtils.GetCurrentProject()); // Process.Start(_Target); // } private void DoViewModuleHexDump(object aSender, EventArgs AEventArgs) { if (!ValidationHelpers.ValidateCurrentEditorNotNull()) { return; } // TODO: make it non-modal. string _FileName = OtaUtils.GetCurrentEditorFileName(); FrmViewHexaDump _Frm = new FrmViewHexaDump(); ByteViewer _Ctr = new ByteViewer(); _Ctr.SetDisplayMode(DisplayMode.Hexdump); _Ctr.SetFile(_FileName); _Ctr.Dock = DockStyle.Fill; _Frm.pnlHost.Controls.Add(_Ctr); _Frm.ShowDialog(); }
private void InitializeComponent() { ComponentResourceManager resources = new ComponentResourceManager(typeof(BinaryEditor)); _byteViewer = new ByteViewer(); _buttonOK = new Button(); _buttonSave = new Button(); _groupBoxMode = new GroupBox(); _radioButtonsTableLayoutPanel = new TableLayoutPanel(); _radioUnicode = new RadioButton(); _radioAuto = new RadioButton(); _radioAnsi = new RadioButton(); _radioHex = new RadioButton(); _okSaveTableLayoutPanel = new TableLayoutPanel(); _overarchingTableLayoutPanel = new TableLayoutPanel(); _byteViewer.SuspendLayout(); _groupBoxMode.SuspendLayout(); _radioButtonsTableLayoutPanel.SuspendLayout(); _okSaveTableLayoutPanel.SuspendLayout(); _overarchingTableLayoutPanel.SuspendLayout(); SuspendLayout(); // // byteViewer // resources.ApplyResources(_byteViewer, "byteViewer"); _byteViewer.SetDisplayMode(DisplayMode.Auto); _byteViewer.Name = "byteViewer"; _byteViewer.Margin = Padding.Empty; _byteViewer.Dock = DockStyle.Fill; // // buttonOK // resources.ApplyResources(_buttonOK, "buttonOK"); _buttonOK.AutoSizeMode = AutoSizeMode.GrowAndShrink; _buttonOK.DialogResult = DialogResult.OK; _buttonOK.Margin = new Padding(0, 0, 3, 0); _buttonOK.MinimumSize = new Size(75, 23); _buttonOK.Name = "buttonOK"; _buttonOK.Padding = new Padding(10, 0, 10, 0); _buttonOK.Click += new EventHandler(ButtonOK_click); // // buttonSave // resources.ApplyResources(_buttonSave, "buttonSave"); _buttonSave.AutoSizeMode = AutoSizeMode.GrowAndShrink; _buttonSave.Margin = new Padding(3, 0, 0, 0); _buttonSave.MinimumSize = new Size(75, 23); _buttonSave.Name = "buttonSave"; _buttonSave.Padding = new Padding(10, 0, 10, 0); _buttonSave.Click += new EventHandler(ButtonSave_click); // // groupBoxMode // resources.ApplyResources(_groupBoxMode, "groupBoxMode"); _groupBoxMode.AutoSizeMode = AutoSizeMode.GrowAndShrink; _groupBoxMode.Controls.Add(_radioButtonsTableLayoutPanel); _groupBoxMode.Margin = new Padding(0, 3, 0, 3); _groupBoxMode.Name = "groupBoxMode"; _groupBoxMode.Padding = new Padding(0); _groupBoxMode.TabStop = false; // // radioButtonsTableLayoutPanel // resources.ApplyResources(_radioButtonsTableLayoutPanel, "radioButtonsTableLayoutPanel"); _radioButtonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); _radioButtonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); _radioButtonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); _radioButtonsTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); _radioButtonsTableLayoutPanel.Controls.Add(_radioUnicode, 3, 0); _radioButtonsTableLayoutPanel.Controls.Add(_radioAuto, 0, 0); _radioButtonsTableLayoutPanel.Controls.Add(_radioAnsi, 2, 0); _radioButtonsTableLayoutPanel.Controls.Add(_radioHex, 1, 0); _radioButtonsTableLayoutPanel.Margin = new Padding(9); _radioButtonsTableLayoutPanel.Name = "radioButtonsTableLayoutPanel"; _radioButtonsTableLayoutPanel.RowStyles.Add(new RowStyle()); // // radioUnicode // resources.ApplyResources(_radioUnicode, "radioUnicode"); _radioUnicode.Margin = new Padding(3, 0, 0, 0); _radioUnicode.Name = "radioUnicode"; _radioUnicode.CheckedChanged += new EventHandler(RadioUnicode_checkedChanged); // // radioAuto // resources.ApplyResources(_radioAuto, "radioAuto"); _radioAuto.Checked = true; _radioAuto.Margin = new Padding(0, 0, 3, 0); _radioAuto.Name = "radioAuto"; _radioAuto.CheckedChanged += new EventHandler(RadioAuto_checkedChanged); // // radioAnsi // resources.ApplyResources(_radioAnsi, "radioAnsi"); _radioAnsi.Margin = new Padding(3, 0, 3, 0); _radioAnsi.Name = "radioAnsi"; _radioAnsi.CheckedChanged += new EventHandler(RadioAnsi_checkedChanged); // // radioHex // resources.ApplyResources(_radioHex, "radioHex"); _radioHex.Margin = new Padding(3, 0, 3, 0); _radioHex.Name = "radioHex"; _radioHex.CheckedChanged += new EventHandler(RadioHex_checkedChanged); // // okSaveTableLayoutPanel // resources.ApplyResources(_okSaveTableLayoutPanel, "okSaveTableLayoutPanel"); _okSaveTableLayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; _okSaveTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); _okSaveTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); _okSaveTableLayoutPanel.Controls.Add(_buttonOK, 0, 0); _okSaveTableLayoutPanel.Controls.Add(_buttonSave, 1, 0); _okSaveTableLayoutPanel.Margin = new Padding(0, 9, 0, 0); _okSaveTableLayoutPanel.Name = "okSaveTableLayoutPanel"; _okSaveTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); // // overarchingTableLayoutPanel // resources.ApplyResources(_overarchingTableLayoutPanel, "overarchingTableLayoutPanel"); _overarchingTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); _overarchingTableLayoutPanel.Controls.Add(_byteViewer, 0, 0); _overarchingTableLayoutPanel.Controls.Add(_groupBoxMode, 0, 1); _overarchingTableLayoutPanel.Controls.Add(_okSaveTableLayoutPanel, 0, 2); _overarchingTableLayoutPanel.Name = "overarchingTableLayoutPanel"; _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); _overarchingTableLayoutPanel.RowStyles.Add(new RowStyle()); // // BinaryUI // AcceptButton = _buttonOK; resources.ApplyResources(this, "$this"); AutoScaleMode = AutoScaleMode.Font; CancelButton = _buttonOK; Controls.Add(_overarchingTableLayoutPanel); FormBorderStyle = FormBorderStyle.FixedDialog; HelpButton = true; MaximizeBox = false; MinimizeBox = false; Name = "BinaryUI"; ShowIcon = false; ShowInTaskbar = false; HelpRequested += new HelpEventHandler(Form_HelpRequested); HelpButtonClicked += new CancelEventHandler(Form_HelpButtonClicked); _byteViewer.ResumeLayout(false); _byteViewer.PerformLayout(); _groupBoxMode.ResumeLayout(false); _groupBoxMode.PerformLayout(); _radioButtonsTableLayoutPanel.ResumeLayout(false); _radioButtonsTableLayoutPanel.PerformLayout(); _okSaveTableLayoutPanel.ResumeLayout(false); _okSaveTableLayoutPanel.PerformLayout(); _overarchingTableLayoutPanel.ResumeLayout(false); _overarchingTableLayoutPanel.PerformLayout(); ResumeLayout(false); }
private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(BinaryEditor)); byteViewer = new ByteViewer(); buttonOK = new System.Windows.Forms.Button(); buttonSave = new System.Windows.Forms.Button(); groupBoxMode = new System.Windows.Forms.GroupBox(); radioAuto = new System.Windows.Forms.RadioButton(); radioHex = new System.Windows.Forms.RadioButton(); radioAnsi = new System.Windows.Forms.RadioButton(); radioUnicode = new System.Windows.Forms.RadioButton(); groupBoxMode.SuspendLayout(); SuspendLayout(); // // byteViewer // byteViewer.SetDisplayMode(DisplayMode.Auto); byteViewer.AccessibleDescription = ((string)(resources.GetObject("byteViewer.AccessibleDescription"))); byteViewer.AccessibleName = ((string)(resources.GetObject("byteViewer.AccessibleName"))); byteViewer.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("byteViewer.Anchor"))); byteViewer.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("byteViewer.Dock"))); byteViewer.Location = ((System.Drawing.Point)(resources.GetObject("byteViewer.Location"))); byteViewer.Size = ((System.Drawing.Size)(resources.GetObject("byteViewer.Size"))); byteViewer.TabIndex = ((int)(resources.GetObject("byteViewer.TabIndex"))); // // buttonOK // buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK; buttonOK.Click += new EventHandler(this.ButtonOK_click); buttonOK.AccessibleDescription = ((string)(resources.GetObject("buttonOK.AccessibleDescription"))); buttonOK.AccessibleName = ((string)(resources.GetObject("buttonOK.AccessibleName"))); buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("buttonOK.Anchor"))); buttonOK.Location = ((System.Drawing.Point)(resources.GetObject("buttonOK.Location"))); buttonOK.Size = ((System.Drawing.Size)(resources.GetObject("buttonOK.Size"))); buttonOK.TabIndex = ((int)(resources.GetObject("buttonOK.TabIndex"))); buttonOK.Text = resources.GetString("buttonOK.Text"); // // buttonSave // buttonSave.Click += new EventHandler(this.ButtonSave_click); buttonSave.AccessibleDescription = ((string)(resources.GetObject("buttonSave.AccessibleDescription"))); buttonSave.AccessibleName = ((string)(resources.GetObject("buttonSave.AccessibleName"))); buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("buttonSave.Anchor"))); buttonSave.Location = ((System.Drawing.Point)(resources.GetObject("buttonSave.Location"))); buttonSave.Size = ((System.Drawing.Size)(resources.GetObject("buttonSave.Size"))); buttonSave.TabIndex = ((int)(resources.GetObject("buttonSave.TabIndex"))); buttonSave.Text = resources.GetString("buttonSave.Text"); // // groupBoxMode // groupBoxMode.TabStop = false; groupBoxMode.Controls.AddRange(new System.Windows.Forms.Control[] { this.radioUnicode, this.radioAnsi, this.radioHex, this.radioAuto }); groupBoxMode.Location = ((System.Drawing.Point)(resources.GetObject("groupBoxMode.Location"))); groupBoxMode.Size = ((System.Drawing.Size)(resources.GetObject("groupBoxMode.Size"))); groupBoxMode.TabIndex = ((int)(resources.GetObject("groupBoxMode.TabIndex"))); groupBoxMode.Text = resources.GetString("groupBoxMode.Text"); // // radioAuto // radioAuto.TabStop = true; radioAuto.Checked = true; radioAuto.CheckedChanged += new EventHandler(this.RadioAuto_checkedChanged); radioAuto.AccessibleDescription = ((string)(resources.GetObject("radioAuto.AccessibleDescription"))); radioAuto.AccessibleName = ((string)(resources.GetObject("radioAuto.AccessibleName"))); radioAuto.Location = ((System.Drawing.Point)(resources.GetObject("radioAuto.Location"))); radioAuto.Size = ((System.Drawing.Size)(resources.GetObject("radioAuto.Size"))); radioAuto.TabIndex = ((int)(resources.GetObject("radioAuto.TabIndex"))); radioAuto.Text = resources.GetString("radioAuto.Text"); // // radioHex // radioHex.CheckedChanged += new EventHandler(this.RadioHex_checkedChanged); radioHex.AccessibleDescription = ((string)(resources.GetObject("radioHex.AccessibleDescription"))); radioHex.AccessibleName = ((string)(resources.GetObject("radioHex.AccessibleName"))); radioHex.Location = ((System.Drawing.Point)(resources.GetObject("radioHex.Location"))); radioHex.Size = ((System.Drawing.Size)(resources.GetObject("radioHex.Size"))); radioHex.TabIndex = ((int)(resources.GetObject("radioHex.TabIndex"))); radioHex.Text = resources.GetString("radioHex.Text"); // // radioAnsi // radioAnsi.CheckedChanged += new EventHandler(this.RadioAnsi_checkedChanged); radioAnsi.AccessibleDescription = ((string)(resources.GetObject("radioAnsi.AccessibleDescription"))); radioAnsi.AccessibleName = ((string)(resources.GetObject("radioAnsi.AccessibleName"))); radioAnsi.Location = ((System.Drawing.Point)(resources.GetObject("radioAnsi.Location"))); radioAnsi.Size = ((System.Drawing.Size)(resources.GetObject("radioAnsi.Size"))); radioAnsi.TabIndex = ((int)(resources.GetObject("radioAnsi.TabIndex"))); radioAnsi.Text = resources.GetString("radioAnsi.Text"); // // radioUnicode // radioUnicode.CheckedChanged += new EventHandler(this.RadioUnicode_checkedChanged); radioUnicode.AccessibleDescription = ((string)(resources.GetObject("radioUnicode.AccessibleDescription"))); radioUnicode.AccessibleName = ((string)(resources.GetObject("radioUnicode.AccessibleName"))); radioUnicode.Location = ((System.Drawing.Point)(resources.GetObject("radioUnicode.Location"))); radioUnicode.Size = ((System.Drawing.Size)(resources.GetObject("radioUnicode.Size"))); radioUnicode.TabIndex = ((int)(resources.GetObject("radioUnicode.TabIndex"))); radioUnicode.Text = resources.GetString("radioUnicode.Text"); // // Win32Form1 // FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; MaximizeBox = false; AcceptButton = buttonOK; CancelButton = buttonOK; AccessibleDescription = ((string)(resources.GetObject("$this.AccessibleDescription"))); AccessibleName = ((string)(resources.GetObject("$this.AccessibleName"))); AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize"))); ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize"))); HelpRequested += new HelpEventHandler(this.Form_HelpRequested); Controls.AddRange(new System.Windows.Forms.Control[] { this.groupBoxMode, this.buttonSave, this.buttonOK, this.byteViewer }); Icon = null; StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition"))); Text = resources.GetString("$this.Text"); ResumeLayout(false); }