private void SetInvalidateRegions() { if (mainControler.GpsControler.Opened && mainControler.HasActiveDisplay) { if (config.GpsViewMode == GpsView.StaticMap) { recList.Clear(); p = CoordCalculator.calculateDisplayCoords(oldGk, mainControler.MapPanel.DX, mainControler.MapPanel.DY, mainControler.LayerManager.Scale); // Clipping: We do not need to invalide if the point is out of our view if (isInDrawingArea(p, mainControler.MapPanel.DrawingArea)) { tempRec.X = Convert.ToInt32(Math.Min(p.x - 2, Int32.MaxValue)); tempRec.Y = Convert.ToInt32(Math.Min(p.y - 2, Int32.MaxValue)); tempRec.Width = config.GpsLayerPointWidth + 4; tempRec.Height = config.GpsLayerPointWidth + 4; recList.Add(tempRec); } p = CoordCalculator.calculateDisplayCoords(gkToRender, mainControler.MapPanel.DX, mainControler.MapPanel.DY, mainControler.LayerManager.Scale); // Clipping: We do not need to invalide if the point is out of our view if (isInDrawingArea(p, mainControler.MapPanel.DrawingArea)) { tempRec.X = System.Convert.ToInt32(Math.Min(p.x - 2, Int32.MaxValue)); tempRec.Y = System.Convert.ToInt32(Math.Min(p.y - 2, Int32.MaxValue)); recList.Add(tempRec); oldGk = gkToRender; } this.mainControler.MapPanel.InvalidateRegion(recList); } else //config.GpsViewMode == GpsView.staticPoint { double scale = mainControler.LayerManager.Scale; mainControler.MapPanel.DX = mainControler.MapPanel.DrawingArea.Width / -2 + gkToRender.r_value * scale; mainControler.MapPanel.DY = this.mainControler.MapPanel.DrawingArea.Height / 2 + gkToRender.h_value * scale; this.mainControler.MapPanel.RequesLayerChange(); this.mainControler.MapPanel.Invalidate(); } } }
public override bool Render(RenderProperties rp) { // clip everything outside drawingArea // in this case this means, draw nothing if (isInDrawingArea(p, rp.DrawingArea)) { SolidBrush brush = new SolidBrush(config.GpsLayerPointColor); p = CoordCalculator.calculateDisplayCoords( gkToRender, rp.DX, rp.DY, this.mainControler.LayerManager.Scale); rp.G.FillEllipse(brush, new Rectangle( Convert.ToInt32(p.x), Convert.ToInt32(p.y), config.GpsLayerPointWidth, config.GpsLayerPointWidth)); } return(true); }
//////////////////////////////// // 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); }