Пример #1
0
        private void Сalibration_MouseDown(object sender, MouseEventArgs e)
        {
            int X = e.X;
            int Y = e.Y;

            if (!isVertexMoved && e.Button == MouseButtons.Left)
            {
                if (MakeMap.IsPointInRectangle(callibrationEdge.GetHead().X, callibrationEdge.GetHead().Y, e.X, e.Y))
                {
                    selectedLabel = callibrationEdge.GetHead();
                    isVertexMoved = true;
                }
                else if (MakeMap.IsPointInRectangle(callibrationEdge.GetEnd().X, callibrationEdge.GetEnd().Y, e.X, e.Y))
                {
                    isVertexMoved = true;
                    selectedLabel = callibrationEdge.GetEnd();
                }
                else if (MakeMap.IsPointOnEdge(e.X, e.Y, callibrationEdge.GetHead().X, callibrationEdge.GetHead().Y,
                                               callibrationEdge.GetEnd().X, callibrationEdge.GetEnd().Y + StaticViewer.Width))
                {
                    isCreatedEdge = true;
                }
            }
            else
            {
                lastClickCoordX = e.X;
                lastClickCoordY = e.Y;
            }
        }
Пример #2
0
        /// <summary>
        /// Инициализация карты
        /// </summary>
        /// <param name="img"></param>
        /// <param name="path"></param>
        public void Init(Image img = null, string path = null)
        {
            int w = 0;
            int h = 0;

            if (MakeMap.ViewPort != null)
            {
                w = MakeMap.ViewPort.View.Width;
                h = MakeMap.ViewPort.View.Height;
                Map.vertexes.RePaint            -= MakeMap.ViewPort.Invalidate;
                Map.edges.RePaint               -= MakeMap.ViewPort.Invalidate;
                MakeMap.ViewPort.View.MouseDown -= PictureBoxMap_MouseDown;
                MakeMap.ViewPort.View.MouseMove -= PictureBoxMap_MouseMove;
                MakeMap.ViewPort.View.MouseUp   -= PictureBoxMap_MouseUp;
            }
            else
            {
                Map.InitMap();
            }
            MakeMap.CreateViewer(pictureBoxMap, panelMapSubstrate, Font, toolStripStatusLabel);

            Map.vertexes.RePaint += MakeMap.ViewPort.Invalidate;
            Map.edges.RePaint    += MakeMap.ViewPort.Invalidate;

            if (path == null)
            {
                MakeMap.ViewPort.OpenPicture(h, w, img);
            }
            else
            {
                MakeMap.ViewPort.OpenPicture(h, w, path);
            }

            MakeMap.ViewPort.IsStreetLength_Visible = checkBox_StreetLength.Checked;
            MakeMap.ViewPort.IsPolice_Visible       = checkBox_Police.Checked;
            MakeMap.ViewPort.IsSign_Visible         = checkBox_Sign.Checked;
            MakeMap.ViewPort.IsStreetName_Visible   = checkBox_StreetName.Checked;
            MakeMap.ViewPort.IsTrafficLight_Visible = checkBox__TrafficLight.Checked;

            MakeMap.ViewPort.View.MouseDown += PictureBoxMap_MouseDown;
            MakeMap.ViewPort.View.MouseMove += PictureBoxMap_MouseMove;
            MakeMap.ViewPort.View.MouseUp   += PictureBoxMap_MouseUp;

            MakeMap.ViewPort.View.ContextMenuStrip = contextMenuVertex;
            Calibration(100);

            ToolStripMenuItem_Save.Enabled            = true;
            ToolStripMenuItem_SaveAs.Enabled          = true;
            ToolStripMenuItem_ChooseSubstrate.Enabled = true;
        }
Пример #3
0
        /// <summary>
        /// Создает контроллер создания и управления картой
        /// </summary>
        /// <param name="pb"></param>
        /// <param name="panel"></param>
        /// <param name="font"></param>
        private MakeMap(PictureBox pb, Panel panel, Font font, ToolStripStatusLabel statusLabel)
        {
            {
                StaticViewer.CreateViewer(font);

                this.StatusLabel = statusLabel;

                MapLocationX = 0;
                MapLocationY = 0;

                StaticViewer.Width = 10;

                ZoomCurValue = 1;
                view         = pb;
                substrate    = panel;
                view.Hide();
                view.Enabled = false;

                StaticViewer.Viewer.Resize();
                ViewPort = this;
            }
        }
Пример #4
0
 /// <summary>
 /// Создает объект контроллера отображения
 /// </summary>
 /// <param name="pb"></param>
 /// <param name="panel"></param>
 public static void CreateViewer(PictureBox pb, Panel panel, Font font, ToolStripStatusLabel statusLabel)
 {
     ViewPort = new MakeMap(pb, panel, font, statusLabel);
 }