📄 ezdicomdemo.cs
字号:
// z_200
//
this.z_200.Index = 4;
this.z_200.Text = "200%";
this.z_200.Click += new System.EventHandler(this.some_zoom_menu_selected);
//
// menuSmooth
//
this.menuSmooth.Index = 1;
this.menuSmooth.Text = "Smooth";
this.menuSmooth.Click += new System.EventHandler(this.ToggleSmooth);
//
// menu_Colours
//
this.menu_Colours.Index = 2;
this.menu_Colours.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuColBW,
this.menuColHot,
this.menuColIBW,
this.menuColIHot});
this.menu_Colours.Text = "Colour scheme";
//
// menuColBW
//
this.menuColBW.Checked = true;
this.menuColBW.Index = 0;
this.menuColBW.Text = "Black and white";
this.menuColBW.Click += new System.EventHandler(this.menuColourScheme);
//
// menuColHot
//
this.menuColHot.Index = 1;
this.menuColHot.Text = "Hot Metal";
this.menuColHot.Click += new System.EventHandler(this.menuColourScheme);
//
// menuColIBW
//
this.menuColIBW.Index = 2;
this.menuColIBW.Text = "Inverted B&&W";
this.menuColIBW.Click += new System.EventHandler(this.menuColourScheme);
//
// menuColIHot
//
this.menuColIHot.Index = 3;
this.menuColIHot.Text = "Inverted Hot Metal";
this.menuColIHot.Click += new System.EventHandler(this.menuColourScheme);
//
// menu_Mosaics
//
this.menu_Mosaics.Index = 3;
this.menu_Mosaics.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuMos11,
this.menuMos22,
this.menuMos33});
this.menu_Mosaics.Text = "Mosaic";
this.menu_Mosaics.Click += new System.EventHandler(this.menuMosaic);
//
// menuMos11
//
this.menuMos11.Checked = true;
this.menuMos11.Index = 0;
this.menuMos11.Text = "1x1";
this.menuMos11.Click += new System.EventHandler(this.menuMosaic);
//
// menuMos22
//
this.menuMos22.Index = 1;
this.menuMos22.Text = "2x2";
this.menuMos22.Click += new System.EventHandler(this.menuMosaic);
//
// menuMos33
//
this.menuMos33.Index = 2;
this.menuMos33.Text = "3x3";
this.menuMos33.Click += new System.EventHandler(this.menuMosaic);
//
// menuToggleHeader
//
this.menuToggleHeader.Index = 4;
this.menuToggleHeader.Text = "Display header";
this.menuToggleHeader.Click += new System.EventHandler(this.ToggleHeader);
//
// menuItem4
//
this.menuItem4.Index = 3;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuAbout});
this.menuItem4.Text = "&About";
//
// menuAbout
//
this.menuAbout.Index = 0;
this.menuAbout.Text = "ez&Dicom component in C#";
this.menuAbout.Click += new System.EventHandler(this.menuAbout_Click);
//
// saveFileDialog1
//
this.saveFileDialog1.FileName = "doc1";
//
// panel1
//
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.the_ezdicom});
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 35);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(688, 534);
this.panel1.TabIndex = 2;
//
// the_ezdicom
//
this.the_ezdicom.ContainingControl = this;
this.the_ezdicom.Dock = System.Windows.Forms.DockStyle.Fill;
this.the_ezdicom.Name = "the_ezdicom";
this.the_ezdicom.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("the_ezdicom.OcxState")));
this.the_ezdicom.Size = new System.Drawing.Size(688, 534);
this.the_ezdicom.TabIndex = 1;
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(688, 569);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panel1,
this.toolBar1});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "MainForm";
this.Text = "ezDICOM in C#";
this.Load += new System.EventHandler(this.MainForm_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.the_ezdicom)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void axezDICOMX1_Enter(object sender, System.EventArgs e)
{
}
private void MainForm_Load(object sender, System.EventArgs e)
{
// turn off toolbar in the DICOM control
the_ezdicom.DCMtoolbar = false;
// make a ContextMenu for the views
// MenuItem tempMenuItem = menu_Zooms.CloneMenu();
// Assign the cloned MenuItem to the ContextMenu.
//cm_Zoom.MenuItems.Add(tempMenuItem);
//toolBarButton2.DropDownMenu = cm_Zoom;
// turn off smoothing, and make this coherent in the menus
the_ezdicom.DCMsmoothOn = false;
menuSmooth.Checked = false;
is_smoothed = false;
toolBar1.Buttons[current_tool].Pushed = true;
}
private void menuAbout_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Visual C# demo of EZDicom by Tom Womack. \nDemonstrates use of the ActiveX component \n\n" + the_ezdicom.DCMversionInfo);
}
private void some_zoom_menu_selected(object sender, System.EventArgs e)
{
int zoom = -1;
if (sender == z_bestfit) {zoom = -1;}
if (sender == z_50) {zoom = 50;}
if (sender == z_100) {zoom = 100;}
if (sender == z_150) {zoom = 150;}
if (sender == z_200) {zoom = 200;}
if (zoom == -1) the_ezdicom.DCMbestFitZoom = true;
else
{
the_ezdicom.DCMbestFitZoom = false;
the_ezdicom.DCMzoomPct = zoom;
}
ClearChecks(menu_Zooms);
// and check the one we're on
((MenuItem)sender ).Checked = true;
}
private void file_open_Click(object sender, System.EventArgs e)
{
openFileDialog1.ShowDialog();
string fn = openFileDialog1.FileName;
the_ezdicom.DCMfilename = fn;
}
private void ToggleSmooth(object sender, System.EventArgs e)
{
is_smoothed = !is_smoothed;
menuSmooth.Checked = is_smoothed;
the_ezdicom.DCMsmoothOn = is_smoothed;
}
private void ToggleHeader(object sender, System.EventArgs e)
{
is_header = !is_header;
ReflectHeaderState(is_header);
}
private void ReflectHeaderState(bool s)
{
the_ezdicom.DCMshowHeader = s;
if (s)
menuToggleHeader.Text = "Display image";
else
menuToggleHeader.Text = "Display header";
}
private void ClearChecks(MenuItem mic)
{
IEnumerator k = mic.MenuItems.GetEnumerator();
while (k.MoveNext())
((MenuItem) k.Current).Checked = false;
}
private void ReflectColourScheme(int c)
{
the_ezdicom.DCMcolorScheme = c;
ClearChecks(menu_Colours);
if (c==+1) menuColBW.Checked = true;
if (c==+2) menuColHot.Checked = true;
if (c==-1) menuColIBW.Checked = true;
if (c==-2) menuColIHot.Checked = true;
}
private void menuMosaic(object sender, System.EventArgs e)
{
int nmos = -1;
if (sender == menuMos11) nmos=1;
if (sender == menuMos22) nmos=2;
if (sender == menuMos33) nmos=3;
ClearChecks(menu_Mosaics);
((MenuItem)sender).Checked = true;
the_ezdicom.DCMmosaicRows = nmos;
the_ezdicom.DCMmosaicFirstSlice = 1;
the_ezdicom.DCMmosaicLastSlice = 9999;
the_ezdicom.DCMmosaicCols = nmos;
}
private void menuColourScheme(object sender, System.EventArgs e)
{
if (sender == menuColBW) colourscheme = +1;
if (sender == menuColHot) colourscheme = +2;
if (sender == menuColIBW) colourscheme = -1;
if (sender == menuColIHot) colourscheme = -2;
ReflectColourScheme(colourscheme);
}
private void menuCopyIt(object sender, System.EventArgs e)
{
bool a = the_ezdicom.DCMcopyImage2Clipboard;
}
private void menuSaveAs(object sender, System.EventArgs e)
{
saveFileDialog1.Filter = "Bitmap file|*.BMP|JPEG file|*.JPG";
DialogResult a = saveFileDialog1.ShowDialog();
if (a == DialogResult.OK)
the_ezdicom.DCMsaveToFile = saveFileDialog1.FileName;
}
private void ToolButtonClicked(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
((ToolBarButton)toolBar1.Buttons[current_tool]).Pushed = false;
current_tool = Convert.ToInt32(e.Button.Tag) - 1;
((ToolBarButton)(toolBar1.Buttons[current_tool])).Pushed = true;
the_ezdicom.DCMtool = 1 + current_tool;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void file_exit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -