Ejemplo n.º 1
0
        public frmSpyhole()
        {
            _sysShutdown = false;
              _isRunAtOnce = false;
              _strTrace = new StringBuilder();

              _jn = new ProgramJournal();
              _jn.OutputTextBox = _txtTrace;

              InitializeComponent();

              _initLocation();

              this.Icon = Properties.Resources.spyhole004i;
              //this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
              this.MaximizeBox = false;
              this.MinimizeBox = false;
              this.ControlBox = false;

              _cmdOk.Click += new EventHandler(_cmdOk_Click);

              //  создание трея для сокрытия формы
              pNi = new NotifyIcon();	//this.components
              pNi.Icon = Properties.Resources.spyhole004i;
              pNi.Text = "Spyhole";
              pNi.DoubleClick += new EventHandler(_niOnDoubleClick);
              pNi.ContextMenu = CreateMenu();
              pNi.Visible = true;

              //_thdRunTask = null;
              _bw = new BackgroundWorker();
              _bw.WorkerReportsProgress = true;
              _bw.WorkerSupportsCancellation = true;
              _bw.DoWork += new DoWorkEventHandler(_bw_DoWork);
              _bw.ProgressChanged += new ProgressChangedEventHandler(_bw_ProgressChanged);
              _bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_bw_RunWorkerCompleted);

              this.Load += new EventHandler(frmSpyhole_Load);
              this.Closing += new CancelEventHandler(_OnClosing);
              this.Closed += new EventHandler(_OnClosed);

              _cmdSave2Reg.Image = Properties.Resources.Save.ToBitmap();

              _ts.ImageScalingSize = new Size(32, 32);
              _tsbStart.Image = Properties.Resources.Down.ToBitmap();
              _tsbStop.Image = Properties.Resources.Cancel.ToBitmap();
              _tsbClear.Image = Properties.Resources.Blank.ToBitmap();

              _IsTrace = true;

              SetNIMenuEnabledOnOff();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show output information to the display and write to the log file,
        /// if they defined.
        /// </summary>
        /// <param name="aTitle"></param>
        /// <param name="aText"></param>
        /// <param name="aType"></param>
        public void Write(string aTitle, string aText, ProgramJournal.Type aType)
        {
            if (aTitle != null)
              {
            DateTime dt = DateTime.Now;
            string dtStr = string.Empty;

            switch (aType)
            {
              case Type.Debug:
              case Type.Error:
              case Type.Message:
            dtStr = "[" + dt.ToShortDateString()
                + " " + dt.ToShortTimeString() + "]";
            break;
              case Type.Trace:
              case Type.Warning:
            dtStr = "{" + dt.ToLongTimeString() + "}";
            break;
            }

            if (aTitle.Length > 0)
            {
              aText = aTitle.ToUpper() + " " + dtStr + " - " + aText;
            }
            else
            {
              aText = dtStr + " " + aText;
            }
              }

              if (_txb != null)
              {
            _txb.Text += Environment.NewLine + aText;
            _txb.Refresh();
            //_txb.Parent.Refresh();
              }

              if (_sw != null && aType != Type.Debug && aType != Type.Trace)
              {
            _sw.WriteLine(aText);
              }

              if (_isConsleOutput && aType != Type.Debug && aType != Type.Trace)
              {
            System.Console.WriteLine(aText);
              }
        }