コード例 #1
0
ファイル: Main.cs プロジェクト: jpheary/VS13.WinForms
 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; }
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: leojim/VS13.WinForms
        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; }
        }