public void ForceRender(MapViewer viewer)
 {
     Select();
     viewer.Close();
     RenderedMaps[facetList.SelectedIndex] = null;
     ShowMapButton_Click(this, new EventArgs());
 }
예제 #2
0
 public void ForceRender(MapViewer viewer)
 {
     Select();
     viewer.Close();
     RenderedMaps[facetList.SelectedIndex] = null;
     ShowMapButton_Click(this, new EventArgs());
 }
        private void ShowMapButton_Click(object sender, EventArgs e)
        {
            try { Application.OpenForms["MapViewer"].Close(); }
            catch { }

            MapViewer DWM = new MapViewer();

            if (RenderedMaps[facetList.SelectedIndex] == null)
            {
                TileMatrix matrix = Parameters.CurrentMap.Tiles;

                Bitmap bmp = new Bitmap(Parameters.CurrentMap.Width, Parameters.CurrentMap.Height);

                renderProgress.Visible = true;
                renderProgress.Value   = 0;
                renderProgress.Maximum = bmp.Width;

                for (int x = 0; x < Parameters.CurrentMap.Width; x++)
                {
                    for (int y = 0; y < Parameters.CurrentMap.Height; y++)
                    {
                        bmp.SetPixel(x, y, Cache.GetColor(matrix.GetLandTile(x, y).ID));
                    }

                    renderProgress.Increment(1);
                }

                renderProgress.Visible = false;

                bmp.Save(String.Format("Map{0}.bmp", facetList.SelectedIndex));
                RenderedMaps[facetList.SelectedIndex] = bmp;
            }

            if (RenderedMaps[facetList.SelectedIndex] != null)
            {
                DWM.Editor = this;

                System.Drawing.Size size = new System.Drawing.Size(RenderedMaps[facetList.SelectedIndex].Width, RenderedMaps[facetList.SelectedIndex].Height);

                int reductionPercentage = 100;

                while ((size.Width > Screen.GetWorkingArea(DWM).Width - 100 || size.Height > Screen.GetWorkingArea(DWM).Height - 100) && reductionPercentage > 0)
                {
                    double reduction = (double)reductionPercentage * 0.01;

                    size.Width  = (int)((double)RenderedMaps[facetList.SelectedIndex].Width * reduction);
                    size.Height = (int)((double)RenderedMaps[facetList.SelectedIndex].Height * reduction);

                    reductionPercentage -= 1;
                }

                size.Width  += 6;
                size.Height += 51;

                DWM.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - size.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - size.Height) / 2);
                DWM.Size     = size;

                Bitmap   newBMP = new Bitmap(DWM.mapImage.Width, DWM.mapImage.Height);
                Graphics g      = Graphics.FromImage(newBMP);
                g.DrawImage(RenderedMaps[facetList.SelectedIndex], 0, 0, DWM.mapImage.Width, DWM.mapImage.Height);
                g.Dispose();

                DWM.mapImage.Image = newBMP;
                DWM.Show();
                DWM.Focus();
                DWM.Select();
            }
        }
예제 #4
0
        private void ShowMapButton_Click(object sender, EventArgs e)
        {
            try { Application.OpenForms["MapViewer"].Close(); }
            catch { }

            MapViewer DWM = new MapViewer();

            if (RenderedMaps[facetList.SelectedIndex] == null)
            {
                TileMatrix matrix = Parameters.CurrentMap.Tiles;

                Bitmap bmp = new Bitmap(Parameters.CurrentMap.Width, Parameters.CurrentMap.Height);

                renderProgress.Visible = true;
                renderProgress.Value = 0;
                renderProgress.Maximum = bmp.Width;

                for (int x = 0; x < Parameters.CurrentMap.Width; x++)
                {
                    for (int y = 0; y < Parameters.CurrentMap.Height; y++)
                    {
                        bmp.SetPixel(x, y, Cache.GetColor(matrix.GetLandTile(x, y).ID));
                    }

                    renderProgress.Increment(1);
                }

                renderProgress.Visible = false;

                bmp.Save(String.Format("Map{0}.bmp", facetList.SelectedIndex));
                RenderedMaps[facetList.SelectedIndex] = bmp;
            }

            if (RenderedMaps[facetList.SelectedIndex] != null)
            {
                DWM.Editor = this;

                System.Drawing.Size size = new System.Drawing.Size(RenderedMaps[facetList.SelectedIndex].Width, RenderedMaps[facetList.SelectedIndex].Height);

                int reductionPercentage = 100;

                while ((size.Width > Screen.GetWorkingArea(DWM).Width - 100 || size.Height > Screen.GetWorkingArea(DWM).Height - 100) && reductionPercentage > 0)
                {
                    double reduction = (double)reductionPercentage * 0.01;

                    size.Width = (int)((double)RenderedMaps[facetList.SelectedIndex].Width * reduction);
                    size.Height = (int)((double)RenderedMaps[facetList.SelectedIndex].Height * reduction);

                    reductionPercentage -= 1;
                }

                size.Width += 6;
                size.Height += 51;

                DWM.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - size.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - size.Height) / 2);
                DWM.Size = size;

                Bitmap newBMP = new Bitmap(DWM.mapImage.Width, DWM.mapImage.Height);
                Graphics g = Graphics.FromImage(newBMP);
                g.DrawImage(RenderedMaps[facetList.SelectedIndex], 0, 0, DWM.mapImage.Width, DWM.mapImage.Height);
                g.Dispose();

                DWM.mapImage.Image = newBMP;
                DWM.Show();
                DWM.Focus();
                DWM.Select();
            }
        }