DicomServer/Desktop/Worklist SCP/worklistForm.cs

124 lines
3.9 KiB
C#
Raw Normal View History

2024-12-13 10:06:20 +08:00
using FellowOakDicom;
using FellowOakDicom.Log;
using Microsoft.Extensions.Options;
using NLog;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
namespace Worklist_SCP
{
public partial class worklistForm : Form
{
public worklistForm()
{
InitializeComponent();
}
private void btn_start_or_stop_Click(object sender, EventArgs e)
{
if (btn_start_or_stop.Text == "启动")
{
new DicomSetupBuilder().RegisterServices(s => s.AddFellowOakDicom().AddLogManager<ConsoleLogManager>()).Build();
WorklistServer.Start(int.Parse(txt_port.Text), txt_aet.Text);
btn_start_or_stop.Text = "停止";
string msgStr = "worklist scp开始监听"+ txt_aet.Text+" 端口:"+ txt_port.Text;
DoData(msgStr);
}
else if (btn_start_or_stop.Text == "停止")
{
WorklistServer.Stop();
btn_start_or_stop.Text = "启动";
string msgStr = "worklist scp停止监听" + txt_aet.Text + " 端口:" + txt_port.Text;
DoData(msgStr);
}
}
private void worklistForm_Load(object sender, EventArgs e)
{
//logger.Info("这是一条信息日志");
//logger.Warn("这是一条警告日志");
//logger.Error("这是一条错误日志");
//logger.Error("aa");
//byte[] utf8Bytes = Encoding.UTF8.GetBytes("AA");
//// 将UTF-8字节转换为GB18030编码的字节
//byte[] gb18030Bytes = Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding("UTF-8"), utf8Bytes);
// return gb18030Bytes;
string worklistModel = ConfigurationManager.AppSettings["worklistModel"] == "0" ? "本地模式" : "远程模式";
this.Text +=("【DICOM工作模式"+worklistModel+"】");
txt_aet.Text = ConfigurationManager.AppSettings["worklistScpAET"];
txt_port.Text =ConfigurationManager.AppSettings["worklistScpPort"];
btn_start_or_stop_Click(null,null);
}
private delegate void DoDataDelegate(object txtContent);
/// <summary>
/// 异步赋值
/// </summary>
/// <param name="number"></param>
private void DoData(object txtContent)
{
if (txt_msg.InvokeRequired)
{
DoDataDelegate d = DoData;
txt_msg.Invoke(d, txtContent);
}
else
{
txt_msg.AppendText("\r\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "消息 : " + txtContent.ToString() + "\r\n");
}
}
bool isClose = false;
private void 退ToolStripMenuItem_Click(object sender, EventArgs e)
{
if(MessageBox.Show("退出后影像设备将无法接收HIS系统登记的患者信息确定退出吗","提示:",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning)==DialogResult.OK)
{
isClose=true;
Application.Exit();
}
}
private void worklistForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isClose)
{
this.Hide();
e.Cancel = true;
this.notifyIcon1.ShowBalloonTip(5000);
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Show();
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
this.Show();
}
}
}