private void MainForm_Load(object sender, EventArgs e) { { toolStripProgressBar1.ProgressBar.SetColor(ProgressBarColor.Yellow); toolStripProgressBar1.Visible = false; //注册消息打印 GlobalMessage.Handlers += PrintStatus; } { annoLinkListPanel.Dock = DockStyle.Left; annoLinkListPanel.Aspect = 0; } { annoPictureListPanel.Dock = DockStyle.Right; annoPictureListPanel.Width = 200; annoPictureListPanel.Targets.Add(canva); annoPictureListPanel.Targets.Add(annoLinkListPanel); } { brushListPanel.Dock = DockStyle.Right; brushListPanel.Width = 30; foreach (Type item in BrushBase.GetBrushTypes()) { brushListPanel.Add(Assembly.GetExecutingAssembly().CreateInstance(item.FullName) as BrushBase); } brushListPanel.Targets.Add(canva); //注册取消画笔消息接收 GlobalMessage.Handlers += BrushCancel; } { canva.Dock = DockStyle.Left; } }
private async void AnnoLoaderForm_Load(object sender, EventArgs e) { { toolStripProgressBar1.ProgressBar.SetColor(ProgressBarColor.Yellow); toolStripProgressBar1.Visible = false; //注册消息打印 GlobalMessage.Handlers += PrintStatus; } { textBox1.MouseUp += TextBox1_MouseUp;; } { brushListPanel.Dock = DockStyle.Left; brushListPanel.Width = 30; foreach (Type item in BrushBase.GetBrushTypes()) { brushListPanel.Add(Assembly.GetExecutingAssembly().CreateInstance(item.FullName) as BrushBase); } brushListPanel.ItemSelected += (_sender, _item, _e) => { if (_item == null) { return; } listView1.Columns.Clear(); listView1.Groups.Clear(); listView1.Items.Clear(); foreach (FieldInfo field in _item.AnnoType.GetFields(FieldsOrder.BaseToSub)) { listView1.Columns.Add($"{field.Name}<{field.FieldType.Name}>"); } listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); TextBox2_TextChanged(this, EventArgs.Empty); }; brushListPanel.Index = 0; } try { using (StreamReader sr = new StreamReader(AnnoFilePath)) { GlobalMessage.Add("status", "正在读取文本..."); FileContext = await sr.ReadToEndAsync(); GlobalMessage.Add("status", "正在加载文本..."); string display = FileContext.Substring(0, Math.Min(textBox1.MaxLength, FileContext.Length)).Replace("\n", "\r\n"); textBox1.Text = display; if (FileContext.Length > textBox1.MaxLength) { GlobalMessage.Add("status", $"就绪,显示文本前{ textBox1.MaxLength }个字符"); } else { GlobalMessage.Add("status", "就绪"); } } } catch (FileNotFoundException ex) { GlobalMessage.Add("exception", ex.Message); } }