Esempio n. 1
0
        public ControlWindow()
        {
            Map = new MapControl(this);
            PlayerList = new StatusControl(this);
            //History = new HistoryControl (PlayerList);
			
            Map.Dock = DockStyle.Fill;
            PlayerList.Dock = DockStyle.Fill;
            //History.Dock = DockStyle.Top;
			
            this.Text = "MineProxy";
            this.WindowState = FormWindowState.Maximized;
			
            //Right panel, date picker + player list
            datePick.Value = DateTime.Now.Date;
            datePick.ValueChanged += HandleDatePickValueChanged;
            datePick.Dock = DockStyle.Top;
            PlayerList.Dock = DockStyle.Fill;
            Panel right = new Panel();
            right.Controls.Add(PlayerList);
            right.Controls.Add(datePick);
            right.Dock = DockStyle.Fill;
			
            SplitContainer split = new SplitContainer();
            split.Panel1.Controls.Add(Map);
            split.Panel2.Controls.Add(right);
            split.SplitterWidth = 10;
            split.SplitterDistance = Width / 2;
            split.Orientation = Orientation.Vertical;
            split.Dock = DockStyle.Fill;
            Controls.Add(split);
            //Controls.Add (History);
			
            this.MainMenuStrip = new MenuStrip();
            this.MainMenuStrip.Items.Add("Pardon").Click += HandlePardonClick;
            this.MainMenuStrip.Items.Add("Ban").Click += HandleBanClick;
            this.MainMenuStrip.Items.Add("Overworld").Click += HandleNetherCheckedChanged;
            
            this.MainMenuStrip.Items.Add("Reload").Click += HandleRegionReloadClick;
            //this.MainMenuStrip.Items.Add ("History Search").Click += HistorySearch;
            this.MainMenuStrip.Items.Add("TP-Nuxas").Click += HandleTpNuxasClick;
            ;
            this.MainMenuStrip.Items.Add("TP-Player").Click += HandleTpPlayerClick;
            ;


            this.MainMenuStrip.Visible = true;
            this.MainMenuStrip.BringToFront();
            this.Controls.Add(this.MainMenuStrip);
        }
Esempio n. 2
0
        public static void Paint(Graphics g, MapControl map, int Width, int Height, CoordDouble center, float scale)
        {
            if (map.Dimension > Dimensions.End)
                return;
			
            CoordDouble topleft = center - new CoordDouble(Width / 2 * scale, 0, Height / 2 * scale);
			
            //Determine center region
            int rx = (int)center.X & -512;
            int rz = (int)center.Z & -512;
            //Sub region chunk index
            int scx = (((int)center.X) >> 4) & 0x1F;
            int scz = (((int)center.Z) >> 4) & 0x1F;
            //Region changed
            if (rx != lastCX || rz != lastCY)
            {
                lastCX = rx;
                lastCY = rz;
                //Load region
                //lastReg = McaFile.Load(map.Dimension, rx, rz);
            }
			
            //..
            if (scale < 1)
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            else
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;


            float drawSize = regionSize / scale - 1;

            int xStart = (int)Math.Floor(topleft.X / regionSize) * regionSize;
            int xEnd = (int)Math.Ceiling((topleft.X + Width * scale) / regionSize) * regionSize;
            int yStart = (int)Math.Floor(topleft.Z / regionSize) * regionSize;
            int yEnd = (int)Math.Ceiling((topleft.Z + Height * scale) / regionSize) * regionSize;
	
            for (int x = xStart; x <= xEnd; x += regionSize)
            {
                for (int z = yStart; z <= yEnd; z += regionSize)
                {
                    float px = ((x - (float)topleft.X) / scale);
                    float py = ((z - (float)topleft.Z) / scale);
					
                    if (lastReg != null)
                    {
                        if (x == rx && z == rz)
                        {
                            int subSize = (int)(drawSize / 32) - 1;
                            for (int dx = 0; dx < 32; dx++)
                            {
                                for (int dz = 0; dz < 32; dz++)
                                {
                                    float pdx = ((x + (dx << 4) - (float)topleft.X) / scale);
                                    float pdy = ((z + (dz << 4) - (float)topleft.Z) / scale);
    				
                                    if (lastReg.HasChunk(dx, dz))
                                    {
                                        if (dx == scx && dz == scz)
                                        {
                                            //Highlighted
                                            g.FillRectangle(Brushes.Orange, pdx, pdy, subSize, subSize);
                                            McaChunk c = lastReg.chunks [dx, dz];
                                            g.DrawString(c.ToString(), font, Brushes.Black, pdx, pdy);
                                        } else
                                            g.FillRectangle(Brushes.Green, pdx, pdy, subSize, subSize);
                                    }
                                }
                            }
                            //Console.WriteLine (lastReg);
                            //using (Image b = Bitmap.FromFile(basePath+path))
                            //	g.DrawImage (b, px, py, drawSize, drawSize);
                        }
                    }

                    string path = McaFile.Path(map.Dimension, x, z);
                    if (File.Exists(path))
                    {
                        //Draw Age border
                        Color c = Color.FromArgb(128, AgeColor(File.GetLastWriteTime(path)));
                        using (Pen p = new Pen(c))
                        {
                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

                            g.DrawRectangle(p, px, py, drawSize, drawSize);
                        }
                        g.DrawString((x >> 9) + "," + (z >> 9), font, Brushes.GreenYellow, px, py);
                    } else
                    {
                        //g.DrawRectangle (Pens.Orange, px, py, drawSize, drawSize);
                        //g.DrawString (path, font, Brushes.Purple, px, py);
                        //g.DrawString (scale.ToString (), font, Brushes.Purple, px, py);
                    }
                }
            }
        }
Esempio n. 3
0
        public static void Paint(Graphics g, MapControl map, int Width, int Height, CoordDouble center, float scale)
        {
            if (map.Dimension > Dimensions.End)
            {
                return;
            }

            CoordDouble topleft = center - new CoordDouble(Width / 2 * scale, 0, Height / 2 * scale);

            //Determine center region
            int rx = (int)center.X & -512;
            int rz = (int)center.Z & -512;
            //Sub region chunk index
            int scx = (((int)center.X) >> 4) & 0x1F;
            int scz = (((int)center.Z) >> 4) & 0x1F;

            //Region changed
            if (rx != lastCX || rz != lastCY)
            {
                lastCX = rx;
                lastCY = rz;
                //Load region
                //lastReg = McaFile.Load(map.Dimension, rx, rz);
            }

            //..
            if (scale < 1)
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            }
            else
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            }


            float drawSize = regionSize / scale - 1;

            int xStart = (int)Math.Floor(topleft.X / regionSize) * regionSize;
            int xEnd   = (int)Math.Ceiling((topleft.X + Width * scale) / regionSize) * regionSize;
            int yStart = (int)Math.Floor(topleft.Z / regionSize) * regionSize;
            int yEnd   = (int)Math.Ceiling((topleft.Z + Height * scale) / regionSize) * regionSize;

            for (int x = xStart; x <= xEnd; x += regionSize)
            {
                for (int z = yStart; z <= yEnd; z += regionSize)
                {
                    float px = ((x - (float)topleft.X) / scale);
                    float py = ((z - (float)topleft.Z) / scale);

                    if (lastReg != null)
                    {
                        if (x == rx && z == rz)
                        {
                            int subSize = (int)(drawSize / 32) - 1;
                            for (int dx = 0; dx < 32; dx++)
                            {
                                for (int dz = 0; dz < 32; dz++)
                                {
                                    float pdx = ((x + (dx << 4) - (float)topleft.X) / scale);
                                    float pdy = ((z + (dz << 4) - (float)topleft.Z) / scale);

                                    if (lastReg.HasChunk(dx, dz))
                                    {
                                        if (dx == scx && dz == scz)
                                        {
                                            //Highlighted
                                            g.FillRectangle(Brushes.Orange, pdx, pdy, subSize, subSize);
                                            McaChunk c = lastReg.chunks [dx, dz];
                                            g.DrawString(c.ToString(), font, Brushes.Black, pdx, pdy);
                                        }
                                        else
                                        {
                                            g.FillRectangle(Brushes.Green, pdx, pdy, subSize, subSize);
                                        }
                                    }
                                }
                            }
                            //Console.WriteLine (lastReg);
                            //using (Image b = Bitmap.FromFile(basePath+path))
                            //	g.DrawImage (b, px, py, drawSize, drawSize);
                        }
                    }

                    string path = McaFile.Path(map.Dimension, x, z);
                    if (File.Exists(path))
                    {
                        //Draw Age border
                        Color c = Color.FromArgb(128, AgeColor(File.GetLastWriteTime(path)));
                        using (Pen p = new Pen(c))
                        {
                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

                            g.DrawRectangle(p, px, py, drawSize, drawSize);
                        }
                        g.DrawString((x >> 9) + "," + (z >> 9), font, Brushes.GreenYellow, px, py);
                    }
                    else
                    {
                        //g.DrawRectangle (Pens.Orange, px, py, drawSize, drawSize);
                        //g.DrawString (path, font, Brushes.Purple, px, py);
                        //g.DrawString (scale.ToString (), font, Brushes.Purple, px, py);
                    }
                }
            }
        }