public MainMenuStrip(WindowMain mainWindow, Tabs tabs, BottomStatusBar statusBar)
            : base()
        {
            this.mainWindow = mainWindow;
            this.tabs = tabs;
            this.statusBar = statusBar;

            ToolStripMenuItem fileMenu = new ToolStripMenuItem("File");

            itemOpen = new ToolStripMenuItem("Open...");
            itemOpen.ShortcutKeys = Keys.Control | Keys.O;
            itemOpen.Click += new EventHandler(openClick);
            fileMenu.DropDownItems.Add(itemOpen);

            itemSave = new ToolStripMenuItem("Save");
            itemSave.Click += new EventHandler(saveClick);
            itemSave.ShortcutKeys = Keys.Control | Keys.S;
            itemSave.Enabled = false;
            fileMenu.DropDownItems.Add(itemSave);

            itemSaveAs = new ToolStripMenuItem("Save As...");
            itemSaveAs.Click += new EventHandler(saveAsClick);
            itemSaveAs.ShortcutKeys = Keys.Control | Keys.Alt | Keys.S;
            itemSaveAs.Enabled = false;
            fileMenu.DropDownItems.Add(itemSaveAs);

            fileMenu.DropDownItems.Add(new ToolStripSeparator());

            itemClose = new ToolStripMenuItem("Close");
            itemClose.Click += new EventHandler(closeClick);
            itemClose.ShortcutKeys = Keys.Control | Keys.W;
            itemClose.Enabled = false;
            fileMenu.DropDownItems.Add(itemClose);

            itemCloseAll = new ToolStripMenuItem("Close all");
            itemCloseAll.Click += new EventHandler(closeAllClick);
            itemCloseAll.ShortcutKeys = Keys.Control | Keys.Alt | Keys.W;
            itemCloseAll.Enabled = false;
            fileMenu.DropDownItems.Add(itemCloseAll);

            fileMenu.DropDownItems.Add(new ToolStripSeparator());

            itemExit = new ToolStripMenuItem("Exit");
            itemExit.Click += new EventHandler(exitClick);
            itemExit.ShortcutKeys = Keys.Alt | Keys.F4;
            fileMenu.DropDownItems.Add(itemExit);

            Items.Add(fileMenu);

            ToolStripMenuItem helpMenu = new ToolStripMenuItem("Help");

            itemAbout = new ToolStripMenuItem("About");
            itemAbout.Click += new EventHandler(aboutClick);
            helpMenu.DropDownItems.Add(itemAbout);

            Items.Add(helpMenu);
        }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            WindowMain window = new WindowMain();
            Config.load();

            string gameRoot = Config.getSetting("gameRoot");

            if (gameRoot == null)
            {
                if (File.Exists(Environment.CurrentDirectory + "7DaysToDie.exe"))
                {
                    Xml.initialize(Environment.CurrentDirectory);
                    window.Show();
                }

                else
                {
                    OpenFileDialog gameRootDialog = new OpenFileDialog();
                    gameRootDialog.Title = "Tool needs to find the game exe!";

                    gameRootDialog.FileOk += (sender1, e1) =>
                    {
                        gameRoot = gameRootDialog.FileName.Substring(0, gameRootDialog.FileName.LastIndexOf('\\'));
                        Config.setSetting("gameRoot", gameRoot);
                        Xml.initialize(gameRoot);
                        window.Show();
                    };

                    gameRootDialog.ShowDialog();
                }
            }

            else
            {
                Xml.initialize(gameRoot);
                window.Show();
            }

            Application.Run(window);
        }
Exemple #3
0
        public Tabs(WindowMain windowMain)
            : base()
        {
            Dock = DockStyle.Fill;
            DrawMode = TabDrawMode.OwnerDrawFixed;

            DrawItem += (sender, e) =>
            {
                e.Graphics.DrawString("x", e.Font, Brushes.Black, e.Bounds.Right - 13, e.Bounds.Top + 1);
                e.Graphics.DrawString(TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4);
                e.DrawFocusRectangle();
            };

            MouseDown += (sender, e) =>
            {
                for (int i = 0; i < TabPages.Count; i++)
                {
                    Rectangle r = GetTabRect(i);
                    Rectangle closeButton = new Rectangle(r.Right - 13, r.Top + 1, 11, 10);
                    if (closeButton.Contains(e.Location))
                    {
                        foreach (TabPlayer tab in TabPages)
                        {
                            if (TabPages.IndexOf(tab) == i)
                            {
                                windowMain.mainMenu.close(tab);
                            }
                        }
                    }
                }
            };

            ControlAdded += (sender, e) =>
            {
                windowMain.mainMenu.updateMenus(getTabCount());
            };

            ControlRemoved += (sender, e) =>
            {
                windowMain.mainMenu.updateMenus(getTabCount());
            };
        }