Пример #1
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            if (newTab.Checked && multiBoard.Boards.Count != 0)
            {
                ApplicationSettings.newTab = true;
            }
            else if (!newTab.Checked)
            {
                ApplicationSettings.newTab = false;
                Board toRemove = (Board)Tabs.CurrentPage.Tag;
                Tabs.Remove(Tabs.CurrentPage);
                toRemove.Dispose();
            }
            WzImage mapImage = null;
            string  mapName = null, streetName = null;

            if (NewSelect.Checked)
            {
                ApplicationSettings.lastRadioIndex = 0;
                MapLoader.CreateMap("<Untitled>", "<Untitled>", MapLoader.CreateStandardMapMenu(rightClickHandler), new XNA.Point(int.Parse(newWidth.Text), int.Parse(newHeight.Text)), new XNA.Point(int.Parse(newWidth.Text) / 2, int.Parse(newHeight.Text) / 2), 8, Tabs, multiBoard);
                DialogResult = DialogResult.OK;
                Close();
                return;
            }
            else if (XMLSelect.Checked)
            {
                ApplicationSettings.lastRadioIndex = 1;
                try
                {
                    mapImage = (WzImage) new WzXmlDeserializer(false, null).ParseXML(XMLBox.Text)[0];
                }
                catch
                {
                    Warning.Error("Error while loading XML. Aborted.");
                    return;
                }
                //mapImage = WZXML.LoadMap(XMLBox.Text, ref mapName, ref streetName);
            }
            else if (WZSelect.Checked)
            {
                ApplicationSettings.lastRadioIndex = 2;
                if ((string)mapNamesBox.SelectedItem == "MapLogin")
                {
                    mapImage   = (WzImage)Program.WzManager["ui"]["MapLogin.img"];
                    mapName    = "MapLogin";
                    streetName = "";
                }
                else if ((string)mapNamesBox.SelectedItem == "MapLogin1")
                {
                    mapImage   = (WzImage)Program.WzManager["ui"]["MapLogin1.img"];
                    mapName    = "MapLogin1";
                    streetName = "";
                }
                else if ((string)mapNamesBox.SelectedItem == "CashShopPreview")
                {
                    mapImage   = (WzImage)Program.WzManager["ui"]["CashShopPreview.img"];
                    mapName    = "CashShopPreview";
                    streetName = "";
                }
                else
                {
                    string mapid  = ((string)mapNamesBox.SelectedItem).Substring(0, 9);
                    string mapcat = "Map" + mapid.Substring(0, 1);
                    mapImage   = (WzImage)Program.WzManager["map"].GetObjectFromPath("Map.wz/Map/" + mapcat + "/" + mapid + ".img");
                    mapName    = WzInfoTools.GetMapNameById(mapid);
                    streetName = WzInfoTools.GetStreetNameById(mapid);
                }
            }
            MapLoader.CreateMapFromImage(mapImage, mapName, streetName, Tabs, multiBoard, rightClickHandler);
            DialogResult = DialogResult.OK;
            Close();
        }