⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit8.pas

📁 Dicom Delphi code 看DICOM图像
💻 PAS
字号:
unit Unit8;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, ExtCtrls, IniFiles;

type
  TfrmSetting = class(TForm)
    Button1: TButton;
    Button2: TButton;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Panel1: TPanel;
    rbPML1: TRadioButton;
    rbPML2: TRadioButton;
    rgTLanguage: TRadioGroup;
    rgTColor: TRadioGroup;
    rgShowRuler: TRadioGroup;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    cbMRadious: TComboBox;
    cbMASize: TComboBox;
    Panel2: TPanel;
    rbEREnable: TRadioButton;
    rbERDisable: TRadioButton;
    GroupBox4: TGroupBox;
    rgMouseScroll: TRadioGroup;
    rgSmoothImage: TRadioGroup;
    GroupBox5: TGroupBox;
    GroupBox6: TGroupBox;
    Label3: TLabel;
    cbATColor: TComboBox;
    Label6: TLabel;
    cbATSize: TComboBox;
    GroupBox7: TGroupBox;
    Label4: TLabel;
    cbLineColor: TComboBox;
    GroupBox9: TGroupBox;
    Label7: TLabel;
    Label8: TLabel;
    cbRTColor: TComboBox;
    cbRTSize: TComboBox;
    GroupBox8: TGroupBox;
    GroupBox10: TGroupBox;
    Label5: TLabel;
    edtCXRatio: TEdit;
    Label9: TLabel;
    Label10: TLabel;
    edtMItemCount: TEdit;
    edtCYRatio: TEdit;
    cbAssociaFile: TCheckBox;

    procedure SaveSettingValue;
    procedure LoadSettingValue;

    procedure Button2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmSetting: TfrmSetting;

implementation

uses Unit1;

{$R *.dfm}

procedure TfrmSetting.SaveSettingValue;
var
  Ini: TIniFile;
begin
  //Error Report
  if rbEREnable.Checked then
    giEnableErrorReport := 1
  else
    giEnableErrorReport := 0;

  //OCX Language
  if rbPML1.Checked then
    giOCXLanguage := 1
  else
    giOCXLanguage := 0;

  //Magnifycation Radious
  Case cbMRadious.ItemIndex of
    1:
      giMagRadious := 4;
    2:
      giMagRadious := 6;
    else
      giMagRadious := 2;
  end;

  //Magnifycation Size
  Case cbMASize.ItemIndex of
    1:
      giMagSize := 80;
    2:
      giMagSize := 100;
    3:
      giMagSize := 120;
    else
      giMagSize := 60;
  end;

  //Overlay Language
  if rgTLanguage.ItemIndex=0 then
   giOverlayLanguage := 0
  else
   giOverlayLanguage := 1;

  //Overlay Color
  if rgTColor.ItemIndex=1 then
   giOverlayColor := 0
  else
   giOverlayColor := 1;

  //Overlay Show Ruler
  if rgShowRuler.ItemIndex=1 then
   giOverlayShowRuler := 0
  else
   giOverlayShowRuler := 1;

  //Mouse Scroll
  if rgMouseScroll.ItemIndex=1 then
   giEnableMouseWheel := 0
  else
   giEnableMouseWheel := 1;

  //Smooth Image
  if rgSmoothImage.ItemIndex=1 then
   giEnableSmooth := 0
  else
   giEnableSmooth := 1;

  //Measurement Annotation Text Color
  giMSATextColor := cbATColor.ItemIndex+1;

  //Measurement Result Text Color
  giMSRTextColor := cbRTColor.ItemIndex+1;

  //Measurement Line Color
  giMSLineColor := cbLineColor.ItemIndex+1;

  //Measurement Annotation Text Size
  case cbATSize.ItemIndex of
    1:
      giMSATextSize := 9;
    2:
      giMSATextSize := 10;
    3:
      giMSATextSize := 12;
    4:
      giMSATextSize := 14;
    5:
      giMSATextSize := 16;
    6:
      giMSATextSize := 18;
    else
      giMSATextSize := 8;
  end;
  Form1.DICOMX1.ImageMeasureTextFontSize := giMSATextSize;

  case cbRTSize.ItemIndex of
    1:
      giMSRTextSize := 9;
    2:
      giMSRTextSize := 10;
    3:
      giMSRTextSize := 12;
    4:
      giMSRTextSize := 14;
    5:
      giMSRTextSize := 16;
    6:
      giMSRTextSize := 18;
    else
      giMSRTextSize := 8;
  end;
  Form1.DICOMX1.ImageMeasureFontSize := giMSRTextSize;
  
  Form1.InitialMenuItem;

  try
    //Measurement Count
    giMSItemCount := StrToInt(edtMItemCount.Text);
    //Pixel Spcae X
    if Trim(edtCXRatio.Text)<>'' then
      Form1.DICOMX1.DICOMPixelSpaceWidth := StrToFloat(edtCXRatio.Text);
    //Pixel Spcae Y
    if Trim(edtCYRatio.Text)<>'' then
      Form1.DICOMX1.DICOMPixelSpaceHeight := StrToFloat(edtCYRatio.Text);
  finally
  end;

  Ini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'Setting.cfg');
  try
//     Ini.WriteInteger('General', 'ShowOverlay', giShowOverlay);
//     Ini.WriteInteger('General', 'ImageZoom', giImageZoom);
//     Ini.WriteInteger('General', 'ImageTool', giImageTool);
     Ini.WriteInteger('General', 'AssociateFile', giAssociateFile);
     Ini.WriteInteger('General', 'ErrorReport', giEnableErrorReport);
     Ini.WriteInteger('General', 'MouseScroll', giEnableMouseWheel);
     Ini.WriteInteger('General', 'SmoothImage', giEnableSmooth);
     Ini.WriteInteger('General', 'MagRadious', giMagRadious);
     Ini.WriteInteger('General', 'MagSize', giMagSize);
     Ini.WriteInteger('General', 'OCXLanguage', giOCXLanguage);
     Ini.WriteInteger('General', 'OverlayLanguage', giOverlayLanguage);
     Ini.WriteInteger('General', 'OverlayColor', giOverlayColor);
     Ini.WriteInteger('General', 'OverlayRuler', giOverlayShowRuler);
     Ini.WriteInteger('Measurement', 'ItemCount', giMSItemCount);
     Ini.WriteInteger('Measurement', 'AnnotationTextColor', giMSATextColor);
     Ini.WriteInteger('Measurement', 'AnnotationTextSize', giMSATextSize);
     Ini.WriteInteger('Measurement', 'ResultTextColor', giMSRTextColor);
     Ini.WriteInteger('Measurement', 'ResultTextSize', giMSRTextSize);
     Ini.WriteInteger('Measurement', 'LineColor', giMSLineColor);
  finally
    Ini.Free;
  end;
end;

procedure TfrmSetting.LoadSettingValue;
begin
  //AssociateFile
  if giAssociateFile=1 then
    cbAssociaFile.Checked := True
  else
    cbAssociaFile.Checked := False;

  //Error Report
  if giEnableErrorReport=1 then
    rbEREnable.Checked := True
  else
    rbERDisable.Checked := True;

  //OCX Language
  if giOCXLanguage=1 then
    rbPML1.Checked := True
  else
    rbPML2.Checked := True;

  //Magnifycation Radious
  Case giMagRadious of
    4:
      cbMRadious.ItemIndex := 1;
    6:
      cbMRadious.ItemIndex := 2;
    else
      cbMRadious.ItemIndex := 0;
  end;

  //Magnifycation Size
  Case giMagSize of
    80:
      cbMASize.ItemIndex := 1;
    100:
      cbMASize.ItemIndex := 2;
    120:
      cbMASize.ItemIndex := 3;
    else
      cbMASize.ItemIndex := 0;
  end;

  //Overlay Language
  if giOverlayLanguage=0 then
   rgTLanguage.ItemIndex := 0
  else
   rgTLanguage.ItemIndex := 1;

  //Overlay Color
  if giOverlayColor=1 then
   rgTColor.ItemIndex := 0
  else
   rgTColor.ItemIndex := 1;

  //Overlay Show Ruler
  if giOverlayShowRuler=1 then
   rgShowRuler.ItemIndex := 0
  else
   rgShowRuler.ItemIndex := 1;

  //Mouse Scroll
  if giEnableMouseWheel=1 then
   rgMouseScroll.ItemIndex := 0
  else
   rgMouseScroll.ItemIndex := 1;

  //Smooth Image
  if giEnableSmooth=1 then
   rgSmoothImage.ItemIndex := 0
  else
   rgSmoothImage.ItemIndex := 1;

  //Measurement Count
  edtMItemCount.Text := IntToStr(giMSItemCount);

  //Measurement Annotation Text Color
  cbATColor.ItemIndex := giMSATextColor-1;

  //Measurement Annotation Text Size
  cbATSize.ItemIndex := cbATSize.Items.IndexOf(IntToStr(giMSATextSize));

  //Measurement Result Text Color
  cbRTColor.ItemIndex := giMSRTextColor-1;

  //Measurement Annotation Text Size
  cbRTSize.ItemIndex := cbRTSize.Items.IndexOf(IntToStr(giMSRTextSize));

  //Measurement Line Color
  cbLineColor.ItemIndex := giMSLineColor-1;

end;

procedure TfrmSetting.Button2Click(Sender: TObject);
begin
  frmSetting.Close;
end;

procedure TfrmSetting.FormShow(Sender: TObject);
begin
  edtCXRatio.Text := FloatToStrF(Form1.DICOMX1.DICOMPixelSpaceWidth ,ffFixed,4,2);
  edtCYRatio.Text := FloatToStrF(Form1.DICOMX1.DICOMPixelSpaceHeight ,ffFixed,4,2);
  PageControl1.TabIndex := 0;
  LoadSettingValue;
  Button1.SetFocus;
end;

procedure TfrmSetting.Button1Click(Sender: TObject);
var
  lphKey: HKEY;
  sKeyName: string;
  sKeyValue: string;
begin
  if cbAssociaFile.Checked then
    giAssociateFile := 1
  else
    giAssociateFile := 0;
  SaveSettingValue;
  if giAssociateFile=1 then
  begin
    sKeyName := 'DICOMFile';
    sKeyValue := 'DICOM Medical File';
    RegCreateKey(HKEY_CLASSES_ROOT, pchar(sKeyName), lphKey);
    RegSetValue(lphKey, '', REG_SZ, pchar(sKeyValue), 0);
    sKeyName := '.dcm';
    sKeyValue := 'DICOMFile';
    RegCreateKey(HKEY_CLASSES_ROOT, pchar(sKeyName), lphKey);
    RegSetValue(lphKey, '', REG_SZ, pchar(sKeyValue), 0);
    sKeyName := 'DICOMFile';
    sKeyValue := Application.ExeName  + ' "%1"';
    RegCreateKey(HKEY_CLASSES_ROOT, pchar(sKeyName), lphKey);
    RegSetValue(lphKey, 'DefaultIcon', REG_SZ, pchar(Application.ExeName+',0'), MAX_PATH);
    RegSetValue(lphKey, 'Shell\Open\Command', REG_SZ, pchar(sKeyValue), MAX_PATH);
  end;
  frmSetting.Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -