private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            pictureBox1.Focus();

            if (Image == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                if (DragControlEnabled)
                {
                    if (r_isSelectingSector)
                    {
                        var args = new MinimapSectorSelectedEventArgs();
                        args.Sector = s_lastSector.X + (s_lastSector.Y * Form_Main._miniMap.allSectorSize.Width) + 1;
                        OnSectorSelected(args);
                    }

                    r_isDragging  = true;
                    _lastMousePos = e.Location;

                    var p = mouseToPos(e.Location);

                    var t = Form_Main._miniMap.ImgPosToMapPos(p);

                    timer1.Start();
                }
                else
                {
                    var p = mouseToPos(e.Location);

                    var t = Form_Main._miniMap.ImgPosToMapPos(p);

                    // Click to move instead of smooth dragging because WinForms performance is awful with this, used like 17% of my CPU..
                    // I also want to keep it simple and not include stuff like OpenGL or DirectX, so this is it.
                    ZoomPosition(p, c_zoomScale);
                    FixViewport();
                    pictureBox1.Invalidate();
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                // Dropdown shenanigans go here

                var ctx = new ContextMenu();

                ctx.MenuItems.Add(new MenuItem("Placeholder"));

                ctx.Show(pictureBox1, e.Location);
            }
        }
示例#2
0
        int serverStartTime = 553; // Placeholder I guess? This is 09:13 in minutes since 00:00

        private void control_MinimapViewer1_SectorSelected(object sender, MinimapSectorSelectedEventArgs e)
        {
            textBox1.Text = $"Assuming server start at 09:13, sector {e.Sector} refreshes at the following times:{Environment.NewLine}{Environment.NewLine}";

            int      refresh = serverStartTime + (int)Math.Floor(((double)e.Sector - 1) / 8);
            DateTime time    = new DateTime();

            time = time.AddMinutes(refresh);

            while (true)
            {
                if (time.Day > 1 && time.Hour > 8)
                {
                    break;
                }

                textBox1.Text += "\t" + time.Hour.ToString("D2") + ":" + time.Minute.ToString("D2") + Environment.NewLine;
                time           = time.AddMinutes((Form_Main._miniMap.allSectorSize.Width * Form_Main._miniMap.allSectorSize.Height) / 8);
            }
        }
 protected virtual void OnSectorSelected(MinimapSectorSelectedEventArgs e)
 {
     SectorSelected?.Invoke(this, e);
 }