Пример #1
0
 private void OnBlogKeyUp(object sender, KeyEventArgs e)
 {
     //Event handler for new blog entry
     Cursor.Current = Cursors.WaitCursor;
     try {
         if (e.KeyCode == Keys.Enter)
         {
             BlogEntry entry = new BlogEntry();
             entry.Date    = DateTime.Now;
             entry.Comment = this.txtComment.Text;
             entry.UserID  = Environment.UserName;
             if (BlogGateway.AddBlogEntry(entry))
             {
                 this.txtComment.Clear();
                 lock (this.txtBlog) {
                     this.msViewRefresh.PerformClick();
                 }
             }
         }
     }
     catch (Exception ex) { reportError(ex); }
     finally { Cursor.Current = Cursors.Default; }
 }
Пример #2
0
        private void OnItemClick(object sender, EventArgs e)
        {
            //Event handler for menu/toolbar item clicked
            try {
                ToolStripItem item = (ToolStripItem)sender;
                switch (item.Name)
                {
                case "msFileNew":
                case "tsNew":
                case "csNew":
                    ChildWindow win = new ChildWindow();
                    win.MdiParent = this;
                    //win.Activated += new EventHandler(OnWindowActivated);
                    //win.Deactivate += new EventHandler(OnWindowDeactivated);
                    //win.FormClosing += new FormClosingEventHandler(OnWindowClosing);
                    //win.FormClosed += new FormClosedEventHandler(OnWindowClosed);
                    win.WindowState = FormWindowState.Maximized;
                    win.Show();
                    break;

                case "msFileOpen":
                case "tsOpen":
                case "csOpen":
                    break;

                case "msFileSaveAs":
                    break;

                case "msFilePageSetup":
                    break;

                case "msFilePrint":
                    break;

                case "msFilePrintPreview":
                    break;

                case "msFileExit":
                    this.Close();
                    break;

                case "msViewRefresh":
                case "tsRefresh":
                    DataSet ds = BlogGateway.ViewBlog();
                    this.txtBlog.Clear();
                    for (int i = 0; i < ds.Tables["BlogTable"].Rows.Count; i++)
                    {
                        string _entry = ds.Tables["BlogTable"].Rows[i]["Date"] + " [" + ds.Tables["BlogTable"].Rows[i]["UserID"] + "]\r\n" + ds.Tables["BlogTable"].Rows[i]["Comment"] + "\r\n";
                        this.txtBlog.AppendText(_entry);
                        this.txtBlog.AppendText("\r\n");
                    }
                    break;

                case "msViewFont":
                    FontDialog fd = new FontDialog();
                    fd.FontMustExist = true;
                    fd.Font          = this.Font;
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        this.Font = this.msMain.Font = this.tsMain.Font = this.ssMain.Font = fd.Font;
                    }
                    break;

                case "msViewToolbar": this.tsMain.Visible = (this.msViewToolbar.Checked = (!this.msViewToolbar.Checked)); break;

                case "msViewStatusBar": this.ssMain.Visible = (this.msViewStatusBar.Checked = (!this.msViewStatusBar.Checked)); break;

                case "msToolsConfig": break;

                case "msWinCascade": this.LayoutMdi(MdiLayout.Cascade); break;

                case "msWinTileH": this.LayoutMdi(MdiLayout.TileHorizontal); break;

                case "msWinTileV": this.LayoutMdi(MdiLayout.TileVertical); break;

                case "msHelpAbout": break;
                }
            }
            catch (Exception ex) { reportError(ex); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }