Ejemplo n.º 1
0
        internal void UpdateRecentMap(string filename)
        {
            HabProperties hps = DHCFG.Items["RecentMaps"];

            if (filename != null && !hps.ContainsValue(Path.GetFullPath(filename)))
            {
                int length = (hps.Count >= 5) ? hps.Count : (hps.Count + 1);

                for (int i = length; i > 1; i--)
                {
                    hps[i + ""] = hps[(i - 1) + ""];
                }

                hps["1"] = Path.GetFullPath(filename);
            }

            fileToolStripMenuItem.DropDownItems.Clear();

            fileToolStripMenuItem.DropDownItems.Add(openFileToolStripMenuItem);

            if (hps.Count > 0)
            {
                fileToolStripMenuItem.DropDownItems.Add(recentToolStripSeparator);
            }

            object value;
            string key;

            for (int i = 1; i <= hps.Count; i++)
            {
                if (hps.TryGetValue(key = i + "", out value))
                {
                    ToolStripMenuItem tsmi = new ToolStripMenuItem();
                    tsmi.Name   = key;
                    tsmi.Text   = Path.GetFileName(value as string);
                    tsmi.Tag    = value;
                    tsmi.Click += new EventHandler(loadRecentMap_Click);

                    fileToolStripMenuItem.DropDownItems.Add(tsmi);
                }
            }

            fileToolStripMenuItem.DropDownItems.Add(propertiesToolStripSeparator);
            fileToolStripMenuItem.DropDownItems.Add(propertiesToolStripMenuItem);
            fileToolStripMenuItem.DropDownItems.Add(exitToolStripSeparator);
            fileToolStripMenuItem.DropDownItems.Add(exitToolStripMenuItem);
        }