Exemplo n.º 1
0
        private void world_MouseMove(object sender, MouseEventArgs e)
        {
            int posX = NormaliseSize(e.X);   // Convert.ToInt32(Math.Round(e.X * ssize));
            int posY = NormaliseSize(e.Y);   // Convert.ToInt32(Math.Round(e.Y * ssize));

            Point mouse = new Point(posX, posY);

            METAboltInstance.AvLocation CurrentLoc = null;

            try
            {
                CurrentLoc = instance.avlocations.Find(delegate(METAboltInstance.AvLocation g) { return(g.Rectangle.Contains(mouse) == true); });
            }
            catch {; }

            if (CurrentLoc != null)
            {
                if (!showing)
                {
                    UUID   akey  = (UUID)CurrentLoc.LocationName;
                    string apstn = "\nCoords.: " + Math.Round(CurrentLoc.Position.X).ToString(CultureInfo.CurrentCulture) + "/" + Math.Round(CurrentLoc.Position.Y).ToString(CultureInfo.CurrentCulture) + "/" + Math.Round(CurrentLoc.Position.Z).ToString(CultureInfo.CurrentCulture);

                    world.Cursor = Cursors.Hand;
                    string anme = string.Empty;

                    lock (instance.avnames)
                    {
                        if (instance.avnames.ContainsKey(akey))
                        {
                            avname = instance.avnames[akey];

                            if (instance.avtags.ContainsKey(akey))
                            {
                                anme = "\nTag: " + instance.avtags[akey];
                            }

                            toolTip1.SetToolTip(world, avname + anme + apstn);
                            avuuid = akey;
                        }
                        else
                        {
                            toolTip1.SetToolTip(world, CurrentLoc.LocationName + apstn);
                        }
                    }

                    //world.Cursor = Cursors.Hand;

                    showing = true;
                }
            }
            else
            {
                world.Cursor = Cursors.Cross;
                toolTip1.RemoveAll();
                showing = false;
            }
        }
Exemplo n.º 2
0
        private void world_MouseUp(object sender, MouseEventArgs e)
        {
            //px = e.X;
            //py = 255 - e.Y;

            px = NormaliseSize(e.X);   // Convert.ToInt32(Math.Round(e.X * ssize));
            //py = NormaliseSize(255 - e.Y);   // Convert.ToInt32(Math.Round(e.Y * ssize));
            py = NormaliseSize(e.Y);   // Convert.ToInt32(Math.Round(e.Y * ssize));

            nuX.Value = (decimal)px;
            nuY.Value = (decimal)py;
            nuZ.Value = (decimal)10;

            clickedx = px;   // NormaliseSize(e.X);
            clickedy = py;   // NormaliseSize(e.Y);

            //PlotSelected(e.X, e.Y);

            Point mouse = new Point(clickedx, clickedy);

            METAboltInstance.AvLocation CurrentLoc = null;

            button1.Enabled = true;

            try
            {
                CurrentLoc = instance.avlocations.Find(delegate(METAboltInstance.AvLocation g) { return(g.Rectangle.Contains(mouse) == true); });
            }
            catch {; }

            if (CurrentLoc != null)
            {
                (new frmProfile(instance, avname, avuuid)).Show();
            }
            else
            {
                PlotSelected(e.X, e.Y);
            }
        }
Exemplo n.º 3
0
        private void UpdateMiniMap(Simulator ssim)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke((MethodInvoker) delegate { UpdateMiniMap(ssim); });
            }
            else
            {
                sim = ssim;

                if (sim != client.Network.CurrentSim)
                {
                    return;
                }

                //Bitmap nbmp = new Bitmap(256, 256);

                Bitmap bmp = _MapLayer == null ? new Bitmap(256, 256) : (Bitmap)_MapLayer.Clone();

                Graphics g = Graphics.FromImage(bmp);

                //nbmp.Dispose();

                if (_MapLayer == null)
                {
                    g.Clear(this.BackColor);
                    g.FillRectangle(Brushes.White, 0f, 0f, 256f, 256f);
                    label6.Visible = true;
                }
                else
                {
                    label6.Visible = false;
                }

                if (_LandLayer != null)
                {
                    //nbmp = new Bitmap(256, 256);

                    bmp = _LandLayer == null ? new Bitmap(256, 256) : (Bitmap)_LandLayer.Clone();
                    //g = Graphics.FromImage((Bitmap)_LandLayer.Clone());

                    g = Graphics.FromImage(bmp);

                    //nbmp.Dispose();

                    //ColorMatrix cm = new ColorMatrix();
                    //cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = cm.Matrix44 = 1f;
                    //cm.Matrix33 = 1.0f;

                    //ImageAttributes ia = new ImageAttributes();
                    //ia.SetColorMatrix(cm);

                    if (_MapLayer != null)
                    {
                        g.DrawImage(_MapLayer, new Rectangle(0, 0, _MapLayer.Width, _MapLayer.Height), 0, 0, _MapLayer.Width, _MapLayer.Height, GraphicsUnit.Pixel);   //, ia);
                    }
                }

                // Draw compass points
                StringFormat strFormat = new StringFormat();
                strFormat.Alignment = StringAlignment.Center;

                g.DrawString("N", new Font("Arial", 12), Brushes.Black, new RectangleF(0, 0, bmp.Width, bmp.Height), strFormat);
                g.DrawString("N", new Font("Arial", 9, FontStyle.Bold), Brushes.White, new RectangleF(0, 2, bmp.Width, bmp.Height), strFormat);

                strFormat.LineAlignment = StringAlignment.Center;
                strFormat.Alignment     = StringAlignment.Near;

                g.DrawString("W", new Font("Arial", 12), Brushes.Black, new RectangleF(0, 0, bmp.Width, bmp.Height), strFormat);
                g.DrawString("W", new Font("Arial", 9, FontStyle.Bold), Brushes.White, new RectangleF(2, 0, bmp.Width, bmp.Height), strFormat);

                strFormat.LineAlignment = StringAlignment.Center;
                strFormat.Alignment     = StringAlignment.Far;

                g.DrawString("E", new Font("Arial", 12), Brushes.Black, new RectangleF(0, 0, bmp.Width, bmp.Height), strFormat);
                g.DrawString("E", new Font("Arial", 9, FontStyle.Bold), Brushes.White, new RectangleF(-2, 0, bmp.Width, bmp.Height), strFormat);

                strFormat.LineAlignment = StringAlignment.Far;
                strFormat.Alignment     = StringAlignment.Center;

                g.DrawString("S", new Font("Arial", 12), Brushes.Black, new RectangleF(0, 0, bmp.Width, bmp.Height), strFormat);
                g.DrawString("S", new Font("Arial", 9, FontStyle.Bold), Brushes.White, new RectangleF(0, 0, bmp.Width, bmp.Height), strFormat);

                // V0.9.8.0 changes for OpenSIM compatibility
                Vector3 myPos = new Vector3();

                // Rollback change from 9.2.1
                //if (!sim.AvatarPositions.ContainsKey(client.Self.AgentID))
                //{
                //    myPos = instance.SIMsittingPos();
                //}
                //else
                //{
                //    myPos = sim.AvatarPositions[client.Self.AgentID];
                //}

                myPos = instance.SIMsittingPos();

                // Draw self position
                int rg = instance.Config.CurrentConfig.RadarRange;

                if (checkBox1.Checked)
                {
                    rg *= 2;

                    Rectangle  myrect         = new Rectangle(((int)Math.Round(myPos.X, 0)) - (rg / 2), (255 - ((int)Math.Round(myPos.Y, 0))) - (rg / 2 - 4), rg + 2, rg + 2);
                    SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(128, 0, 0, 255));
                    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected;
                    g.FillEllipse(semiTransBrush, myrect);

                    myrect = new Rectangle(((int)Math.Round(myPos.X, 0)) - (rg / 4), (255 - ((int)Math.Round(myPos.Y, 0))) - (rg / 4 - 4), rg / 2 + 2, rg / 2 + 2);
                    //semiTransBrush = new SolidBrush(Color.FromArgb(128, 0, 245, 225));
                    g.DrawEllipse(new Pen(Color.Blue, 1), myrect);

                    myrect = new Rectangle((int)Math.Round(myPos.X, 0) - 2, 255 - ((int)Math.Round(myPos.Y, 0) - 2), 7, 7);
                    g.FillEllipse(new SolidBrush(Color.Yellow), myrect);
                    g.DrawEllipse(new Pen(Brushes.Red, 3), myrect);
                }
                else
                {
                    Rectangle myrect = new Rectangle((int)Math.Round(myPos.X, 0) - 2, 255 - ((int)Math.Round(myPos.Y, 0) - 2), 7, 7);
                    g.FillEllipse(new SolidBrush(Color.Yellow), myrect);
                    g.DrawEllipse(new Pen(Brushes.Red, 3), myrect);
                }

                if (clickedx != 0 && clickedy != 0)
                {
                    Point mouse = new Point(clickedx, clickedy);

                    METAboltInstance.AvLocation CurrentLoc = null;

                    try
                    {
                        CurrentLoc = instance.avlocations.Find(delegate(METAboltInstance.AvLocation gck) { return(gck.Rectangle.Contains(mouse) == true); });
                    }
                    catch {; }

                    if (CurrentLoc == null)
                    {
                        Rectangle selectedrect = new Rectangle(clickedx - 2, clickedy - 2, 10, 10);
                        g.DrawEllipse(new Pen(Brushes.Red, 2), selectedrect);
                    }
                }

                if (chkResident.Checked)
                {
                    int       i    = 0;
                    Rectangle rect = new Rectangle();


                    if (myPos.Z < 0.1f)
                    {
                        myPos.Z = 1020f;   // Convert.ToSingle(client.Self.GlobalPosition.Z);    //1024f;
                    }

                    client.Network.CurrentSim.AvatarPositions.ForEach(
                        delegate(KeyValuePair <UUID, Vector3> pos)
                    {
                        int x = (int)pos.Value.X - 2;
                        int y = 255 - (int)pos.Value.Y - 2;

                        rect = new Rectangle(x, y, 7, 7);

                        Vector3 oavPos = new Vector3(0, 0, 0);
                        oavPos.X       = pos.Value.X;
                        oavPos.Y       = pos.Value.Y;
                        oavPos.Z       = pos.Value.Z;

                        if (oavPos.Z < 0.1f)
                        {
                            oavPos.Z = 1020f;
                        }

                        if (pos.Key != client.Self.AgentID)
                        {
                            if (myPos.Z - oavPos.Z > 20)
                            {
                                g.FillRectangle(Brushes.DarkRed, rect);
                                g.DrawRectangle(new Pen(Brushes.Red, 1), rect);
                            }
                            else if (myPos.Z - oavPos.Z > -11 && myPos.Z - oavPos.Z < 11)
                            {
                                g.FillEllipse(Brushes.LightGreen, rect);
                                g.DrawEllipse(new Pen(Brushes.Green, 1), rect);
                            }
                            else
                            {
                                g.FillRectangle(Brushes.MediumBlue, rect);
                                g.DrawRectangle(new Pen(Brushes.Red, 1), rect);
                            }
                        }

                        i++;
                    }
                        );
                }

                g.DrawImage(bmp, 0, 0);

                world.Image = bmp;

                strFormat.Dispose();
                g.Dispose();

                string strInfo = string.Format(CultureInfo.CurrentCulture, "Total Avatars: {0}", client.Network.CurrentSim.AvatarPositions.Count);
                lblSimData.Text = strInfo;

                strInfo = string.Format(CultureInfo.CurrentCulture, "{0}/{1}/{2}/{3}", client.Network.CurrentSim.Name,
                                        Math.Round(myPos.X, 0),
                                        Math.Round(myPos.Y, 0),
                                        Math.Round(myPos.Z, 0));
                label2.Text = "http://slurl.com/secondlife/" + strInfo;
            }
        }