设备的管理器。
Inheritance: IDisposable
		/// <summary>
		/// 使用要打开的文件初始化主窗体。
		/// </summary>
		/// <param name="fileNames">要打开的文件。</param>
		/// <param name="device">设备管理器。</param>
		public MainForm(DeviceManager device, string[] fileNames)
			: this(device)
		{
			if (fileNames.Length > 0)
			{
				if (File.Exists(fileNames[0]))
				{
					this.OpenGame(fileNames[0]);
				}
			}
		}
		/// <summary>
		/// 初始化主窗体。
		/// </summary>
		/// <param name="devices">设备管理器。</param>
		public MainForm(DeviceManager devices)
		{
			this.Location = JigsawSetting.Default.MainLocation;
			InitializeComponent();
			this.deviceManager = devices;
			this.ClientSize = JigsawSetting.Default.MainSize;
			this.WindowState = JigsawSetting.Default.MainState;
			this.gameManager = new GameManager(devices, this.renderPanel,
				EnumExt.Parse<JigsawRendererType>(JigsawSetting.Default.Renderer));
			InitGameManager();
			InitToolStrip();
			InitScaleMenu();
		}
Example #3
0
		static void Main(string[] fileNames)
		{
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.ThreadException += (sender, e) =>
			{
				new BugReportForm(e.Exception).ShowDialog();
				Application.Exit();
			};
			AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
			{
				new BugReportForm(e.ExceptionObject as Exception).ShowDialog();
			};
			DeviceManager device = new DeviceManager();
			if (!device.SupportD2D)
			{
				MessageBox.Show("您的操作系统不支持 Direct2D 特性,不能运行此游戏");
				return;
			}
			Application.Run(new MainForm(device, fileNames));
		}
		/// <summary>
		/// 初始化 <see cref="GameManager"/> 类的新实例。
		/// </summary>
		/// <param name="devices">设备管理器。</param>
		public GameManager(DeviceManager devices, JigsawRenderPanel renderPanel, JigsawRendererType rendererType)
		{
			this.devices = devices;
			this.renderPanel = renderPanel;
			// 初始化设备。
			this.renderPanel.Devices = devices;
			this.renderPanel.Paint += this.renderPanel_Paint;
			this.renderTarget = devices.RenderTarget;
			// 初始化画刷。
			selectionRectBrush = new SolidColorBrush(renderTarget, Color.Black);
			selectionRectStyle = new StrokeStyle(this.devices.D2DFactory,
				new StrokeStyleProperties() { DashStyle = DashStyle.Dash });
			this.RendererType = rendererType;
		}
		/// <summary>
		/// 使用指定的设备管理器初始化 <see cref="JigsawSerializeContext"/> 类的新实例。
		/// </summary>
		/// <param name="manager">设备管理器。</param>
		public JigsawSerializeContext(DeviceManager manager)
		{
			this.manager = manager;
		}