예제 #1
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            string     textFile = DateTime.Now.ToString("yyyyMMdd") + "Log.txt";
            FileStream fs;

            //读取记事本记录
            if (File.Exists(textFile))
            {
                fs = new FileStream(textFile, FileMode.Open, FileAccess.Read);
                using (fs)
                {
                    int    fsLen  = (int)fs.Length;
                    byte[] heByte = new byte[fsLen];
                    int    r      = fs.Read(heByte, 0, heByte.Length);
                    string myStr  = System.Text.Encoding.UTF8.GetString(heByte);
                    SuccessInfomation.Text = myStr;
                    SuccessInfomation.ScrollToEnd();
                }
            }

            dispatcherTimer.Tick += new EventHandler(Send);
            int fen = Convert.ToInt32(ConfigurationManager.AppSettings["sjjg"]);

            dispatcherTimer.Interval = new TimeSpan(0, 0, fen); //两分钟
            dispatcherTimer.Start();
            #region
            //this.notifyIcon = new NotifyIcon();
            //this.notifyIcon.BalloonTipText = "系统监控中... ...";
            //this.notifyIcon.ShowBalloonTip(2000);
            //this.notifyIcon.Text = "系统监控中... ...";
            //this.notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
            //this.notifyIcon.Visible = true;
            ////打开菜单项
            //System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("打开");
            //open.Click += new EventHandler(Show);
            ////退出菜单项
            //System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出");
            //exit.Click += new EventHandler(Close);
            ////关联托盘控件
            //System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { open, exit };
            //notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);

            //this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler((o, e) =>
            //{
            //    if (e.Button == MouseButtons.Left) this.Show(o, e);
            //});
            #endregion
        }
예제 #2
0
        public void Infomation(object sender, EventArgs e)
        {
            string     textFile = DateTime.Now.ToString("yyyyMMdd") + "Log.txt";
            FileStream fs;

            if (File.Exists(textFile))
            {
                fs = new FileStream(textFile, FileMode.Open, FileAccess.Read);
                using (fs)
                {
                    using (fs)
                    {
                        int    fsLen  = (int)fs.Length;
                        byte[] heByte = new byte[fsLen];
                        int    r      = fs.Read(heByte, 0, heByte.Length);
                        string myStr  = System.Text.Encoding.UTF8.GetString(heByte);
                        SuccessInfomation.Text = myStr;
                        SuccessInfomation.ScrollToEnd();
                    }
                }
            }
        }