0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その556

Posted at

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

ドッキングウィンドウでコンテンツ間通信せよ。

方針

  • Timer使う。

写真

image.png

サンプルコード

using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using System.Drawing;
using System.Runtime.InteropServices;

namespace Dock
{
	public partial class Win1: WeifenLuo.WinFormsUI.Docking.DockContent {
		public TextBox bo1;
		public Win1() {
			bo1 = new TextBox();
			bo1.Text = "本日は晴天なり";
			bo1.Multiline = true;
			bo1.Font = new Font("MS Pゴシック", 12);
			bo1.Dock = DockStyle.Fill;
			Controls.AddRange(new Control[] {
				bo1
			});
		}
	}
	public partial class Win2: WeifenLuo.WinFormsUI.Docking.DockContent {
		public int state = 0;
		public Win2() {
			Button btn0 = new Button();
			btn0.Location = new Point(50, 50);
			btn0.Text = "send";
			btn0.Click += btn0_Click;
			Controls.AddRange(new Control[] {
				btn0
			});
		}
		void btn0_Click(object sender, System.EventArgs e) {
			state = 1;
		}
	}
	public partial class Win3: WeifenLuo.WinFormsUI.Docking.DockContent {
		public Win3() {
		}
	}
	public partial class Form1: Form {
		public Win2 left1;
		public Win2 right1;
		public Win1 bottom1;
		public Win1 center1;
		public Form1() {
			ClientSize = new Size(800, 600);
			Text = "dock";
			var dockPanel1 = new DockPanel();
			dockPanel1.ShowDocumentIcon = true;
			dockPanel1.Dock = DockStyle.Fill;
			dockPanel1.DocumentStyle = DocumentStyle.DockingWindow;
			Controls.Add(dockPanel1);
			left1 = new Win2();
			left1.TabText = "left1";
			left1.Show(dockPanel1, DockState.DockLeft);
			right1 = new Win2();
			right1.TabText = "right1";
			right1.Show(dockPanel1, DockState.DockRight);
			bottom1 = new Win1();
			bottom1.TabText = "bottom1";
			bottom1.Show(dockPanel1, DockState.DockBottom);
			center1 = new Win1();
			center1.TabText = "center1";
			center1.Show(dockPanel1, DockState.Document);
			dockPanel1.UpdateDockWindowZOrder(DockStyle.Left, true);
			Timer timer = new Timer {
				Interval = 1000
			};
			timer.Tick += timer_Tick;
			timer.Start();
		}
		private void timer_Tick(object sender, EventArgs e) {
			if (left1.state == 1)
			{
				bottom1.bo1.AppendText("left1 send\n");
				left1.state = 0;
			}
			if (right1.state == 1)
			{
				bottom1.bo1.AppendText("right1 send\n");
				right1.state = 0;
			}
		}
		[STAThread]
		public static void Main() {
			Application.Run(new Form1());
		}
	}
}






以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?