- /*
- * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
- * $Id: MacroTrace.cs,v 1.2 2005/04/20 08:45:45 okajima Exp $
- */
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace Poderosa.MacroEnv
- {
- /// <summary>
- /// MacroTrace 偺奣梫偺愢柧偱偡丅
- /// </summary>
- internal class MacroTraceWindow : System.Windows.Forms.Form
- {
- internal static int _instanceCount;
- internal static Size _lastWindowSize = new Size();
- private System.Windows.Forms.TextBox _textBox;
- /// <summary>
- /// 昁梫側僨僓僀僫曄悢偱偡丅
- /// </summary>
- private System.ComponentModel.Container components = null;
- public MacroTraceWindow()
- {
- //
- // Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
- //
- InitializeComponent();
- //
- // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
- //
- this.Icon = GApp.Options.GuevaraMode? GIcons.GetOldGuevaraIcon() : GIcons.GetAppIcon();
- //埵抲偲僒僀僘偺挷惍
- int n = _instanceCount % 5;
- this.Location = new Point(GApp.Frame.Left + 30+20*n, GApp.Frame.Top + 30+20*n);
- if(_instanceCount>0) this.Size = _lastWindowSize;
- _instanceCount++;
- }
- /// <summary>
- /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows Form Designer generated code
- /// <summary>
- /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
- /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
- /// </summary>
- private void InitializeComponent()
- {
- this._textBox = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // _textBox
- //
- this._textBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this._textBox.Multiline = true;
- this._textBox.Name = "_textBox";
- this._textBox.ReadOnly = true;
- this._textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this._textBox.Size = new System.Drawing.Size(352, 237);
- this._textBox.TabIndex = 0;
- this._textBox.Text = "";
- this._textBox.BackColor = Color.FromKnownColor(KnownColor.Window);
- //
- // MacroTrace
- //
- this.StartPosition = FormStartPosition.Manual;
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
- this.ClientSize = new System.Drawing.Size(352, 237);
- this.Controls.AddRange(new System.Windows.Forms.Control[] {
- this._textBox});
- this.Name = "MacroTrace";
- this.ShowInTaskbar = false;
- this.ResumeLayout(false);
- }
- #endregion
- public void AdjustTitle(MacroModule mod) {
- this.Text = GApp.Strings.GetString("Caption.MacroTrace.Title") + mod.Title;
- }
- private string _lineToAdd;
- public void AddLine(string t) {
- //偙傟偼儅僋儘僗儗僢僪偐傜屇偽傟傞偺偱SendMessage傪巊偆昁梫偑偁傞
- if(_textBox.TextLength!=0) t = "rn"+t;
- _lineToAdd = t;
- Win32.SendMessage(this.Handle, GConst.WMG_MACRO_TRACE, IntPtr.Zero, IntPtr.Zero);
- }
- protected override void OnClosed(EventArgs args) {
- base.OnClosed(args);
- _lastWindowSize = this.Size;
- }
- protected override void WndProc(ref Message msg) {
- base.WndProc(ref msg);
- if(msg.Msg==GConst.WMG_MACRO_TRACE) {
- _textBox.AppendText(_lineToAdd);
- }
- }
- }
- }