Пример #1
0
        public MainForm()
        {
            Text = "ReSearcher";
            Icon = IconUtilities.loadCurrentModuleIcon();

            StartPosition = FormStartPosition.CenterScreen;
            Size          = new Size(
                (int)(Screen.PrimaryScreen.Bounds.Width * 0.6f),
                (int)(Screen.PrimaryScreen.Bounds.Height * 0.6f)
                );

            // assemble UI components
            // extension methods are in use here to provide a fluent and elegant component hierarchy
            this.appendControls(
                tabControl = new TabControl()
            {
                Dock = DockStyle.Fill, Padding = new Point(24, 4)
            },
                statusStrip = new StatusStrip(),
                new ToolStripPanel()
            {
                Dock = DockStyle.Top
            }.withControls(
                    new ToolStrip().withItems(
                        new ToolStripButton()
            {
                Text = "Search..."
            }.withAction(search),
                        new ToolStripSeparator(),
                        new ToolStripButton()
            {
                Text = "Browse..."
            }.withAction(browse),
                        new ToolStripButton()
            {
                Text = "Open..."
            }.withAction(open),
                        new ToolStripSeparator(),
                        new ToolStripButton()
            {
                Text = "Download..."
            }.withAction(download)
                        )
                    ),
                MainMenuStrip = new MenuStrip()
            {
                Dock = DockStyle.Top
            }.withItems(
                    new ToolStripMenuItem()
            {
                Text = "ReSearcher"
            }.withDropDownItems(
                        new ToolStripMenuItem()
            {
                Text = "Search..."
            }.withAction(search),
                        new ToolStripSeparator(),
                        new ToolStripMenuItem()
            {
                Text = "Browse..."
            }.withAction(browse),
                        new ToolStripMenuItem()
            {
                Text = "Open..."
            }.withAction(open),
                        new ToolStripSeparator(),
                        new ToolStripMenuItem()
            {
                Text = "Download..."
            }.withAction(download),
                        new ToolStripSeparator(),
                        new ToolStripMenuItem()
            {
                Text = "Settings"
            }.withAction(showSettings),
                        new ToolStripSeparator(),
                        new ToolStripMenuItem()
            {
                Text = "Quit"
            }.withAction(quit)
                        ),
                    new ToolStripMenuItem()
            {
                Text = "Tab"
            }.withDropDownItems(
                        new ToolStripMenuItem()
            {
                Text = "Close"
            }.withAction(closeSelectedTab)
                        ),
                    new ToolStripMenuItem()
            {
                Text = "Help"
            }.withDropDownItems(
                        new ToolStripMenuItem()
            {
                Text = "Help table of contents"
            }.withAction(showHelp),
                        new ToolStripMenuItem()
            {
                Text = "Help index"
            }.withAction(showHelpIndex),
                        new ToolStripSeparator(),
                        new ToolStripMenuItem()
            {
                Text = "Help online"
            }.withAction(showHelpOnline),
                        new ToolStripSeparator(),
                        new ToolStripMenuItem()
            {
                Text = "About"
            }.withAction(showHelpAbout)
                        )
                    )
                );
        }