Ejemplo n.º 1
0
        ////////////////////////////////
        // Constructors & Destructors
        ////////////////////////////////
        public MainControler(String appName)
        {
            CheckEnvironment();

            coordCalculator = new CoordCalculator(this);

            config.SetDefaults();

            layerManager    = new LayerManager(this, config); // must be initialized first
            mainForm        = new MainForm(this, config, appName);

            // initialize the hardware key function mappings
            hardwareKeyDownFunctionMapping = new SortedList<HardwareKeyMappings, KeyPressedDelegate>();
            hardwareKeyDownFunctionMapping.Add(HardwareKeyMappings.TempMove, delegate() { mainForm.toggleTemporaryTool(Tool.Move); });
            hardwareKeyDownFunctionMapping.Add(HardwareKeyMappings.GPSTrackingTrigger, StartGPSTracking);
            hardwareKeyDownFunctionMapping.Add(HardwareKeyMappings.GPSTrackingStop, StopGPSTracking);
            hardwareKeyDownFunctionMapping.Add(HardwareKeyMappings.None, null);

            hardwareKeyUpFunctionMapping = new SortedList<HardwareKeyMappings, KeyPressedDelegate>();
            hardwareKeyUpFunctionMapping.Add(HardwareKeyMappings.TempMove, delegate() { mainForm.toggleTemporaryTool(Tool.Move); });
            hardwareKeyUpFunctionMapping.Add(HardwareKeyMappings.GPSTrackingTrigger, null);
            hardwareKeyUpFunctionMapping.Add(HardwareKeyMappings.GPSTrackingStop, null);
            hardwareKeyUpFunctionMapping.Add(HardwareKeyMappings.None, null);

            Point mapTabClientArea = mainForm.getMapTabClientArea();
            mapPanel = new MapPanel(this, config, mainForm, mapTabClientArea.X,
                mapTabClientArea.Y, 2);

            this.SettingsLoaded += new SettingsLoadedDelegate(MainControler_SettingsLoaded);

            LoadSettings(Program.AppDataPath + "\\" + config.ConfigFileName);

            mainForm.InitializeMyOwnComponents(mapPanel);
            activeDialogs = new List<IDialog>();

            //layerManager.ScaleChanged += new LayerManager.ScaleChangedDelegate(layerManager_ScaleChanged);
            //layerManager.DrawInfChanged += new LayerManager.DrawShapeInformationDelegate(layerManager_DrawInfChanged);
            layerManager.DrawInfChanged += new LayerManager.DrawShapeInformationDelegate(mainForm.OnDrawInfChanged);
            layerManager.DrawInfChanged += new LayerManager.DrawShapeInformationDelegate(mapPanel.OnDrawInfChanged);

            this.SettingsLoaded += new SettingsLoadedDelegate(this.SaveSettings);
            actionList.Clear();

            if (config.UseDefaultProject && File.Exists(config.DefaultProject))
                if (!openMWD(config.DefaultProject)) config.UseDefaultProject = false;
                else this.MainForm.ViewMode = ViewMode.Map;

            SystemWakeUp += new WakeUpDelegate(MainControler_SystemWakeUp);

            Program.NotifyIcon.Click += new EventHandler(notifyIcon_Click);
            mainForm.Deactivate += new EventHandler(mainForm_Deactivate);
            mainForm.Activated += new EventHandler(mainForm_Activated);
        }
Ejemplo n.º 2
0
        public MapPanel(MainControler mc, Config config, MainForm mainForm, int width, int height, int margin)
        {
            this.config = config;
            this.mainControler = mc;
            this.Visible = false;
            this.mainForm = mainForm;
            this.Width   = width - 2 * margin;
            this.Height  = height - 2 * margin;
            this.Top = margin;
            this.Left = margin;
            this.margin = margin;

            this.MouseDown += new MouseEventHandler(PanelMouseDown);
            this.MouseUp += new MouseEventHandler(PanelMouseUp);
            this.MouseMove += new MouseEventHandler(PanelMouseMove);

            dragStartPoint = new System.Drawing.Point(0, 0);
            itemList = new List<QuadTreePositionItem<IShape>>();

            drawingArea = new System.Drawing.Rectangle(1, 1, this.Width - 2, this.Height - 2);
            vectorRenderer = new GdiVectorRenderer();

            //backBuffer = new FastBitmap(this.ClientRectangle.Width,
             //   this.ClientRectangle.Height);

            // Menus
            shapeEditMenu = new ShapeEditMenu(mainForm);
            //geometryEditMenu = new EditGeometryMenu(mainForm);

            LayerManager lm = mainControler.LayerManager;

            lm.FirstLayerAdded += new LayerManager.LayerAddedDelegate(LayerManager_FirstLayerAdded);
            lm.LayerAdded += new LayerManager.LayerAddedDelegate(layerAdded);
            lm.ScaleChanged += new LayerManager.ScaleChangedDelegate(LayerManager_ScaleChanged);
            mainControler.SettingsLoaded += new MainControler.SettingsLoadedDelegate(mainControler_SettingsLoaded);
            lm.TransportPointLayer.ElementAdded += new TransportMultiPointLayer.ElementAddedDelagate(TransportLayer_ElementAdded);
            lm.TransportPolygonLayer.ElementAdded += new TransportPolygonLayer.ElementAddedDelegate(TransportLayer_ElementAdded);
            lm.TransportPolylineLayer.ElementAdded += new TransportPolylineLayer.ElementAddedDelagate(TransportLayer_ElementAdded);
            lm.ShapeRemoved += new LayerManager.ChangedDelegate(Model_ShapeRemoved);

            this.BackColor = System.Drawing.Color.White;

            toolTip = new GravurGIS.GUI.Controls.ToolTip();
            toolTip.Visible = false;

            this.Controls.Add(toolTip);

            northPointingMatrix = new Matrix2D();

            mainControler.WaypointAdded += new MainControler.WaypointAddedDelegate(mainControler_WaypointAdded);
            mainControler.TrackingStarted += new MainControler.WaypointAddedDelegate(mainControler_TrackingStarted);
            mainControler.TrackingStopped += new MainControler.NoParamDelegate(mainControler_TrackingStopped);
        }