static void Main() { startTicks = Environment.TickCount; // make sure only one instance exists using (AppExecutionManager execMgr = new AppExecutionManager(appName)) { if (execMgr.IsFirstInstance) { // Set the maximum allowed amount of connections up // This is needed for MapServer and other outgoing connections // since the garbage collector is not that fast ServicePointManager.DefaultConnectionLimit = 100; MainControler mainController = null; try { // create a notify icon notifyIcon = new Utilities.NotifyIcon(); // load the application icon (Resource ID 32512) IntPtr hIcon = Win32.LoadIcon(Win32.GetModuleHandle(null), "#32512"); // add the Icon to the systray notifyIcon.Add(hIcon); mainController = new MainControler(appName); } catch (Exception e) { logException(e); MessageBox.Show(String.Format("Es trat ein Fehler beim Laden der Anwendung auf.{0}Nachricht: {1}", Environment.NewLine, e.Message), "Fehler"); notifyIcon.Remove(); execMgr.Dispose(); } try { Application.Run(mainController.MainForm); } catch (Exception e) { string logfile = logException(e); MessageBox.Show(String.Format("Es trat leider ein Programmfehler auf.{0}Nachricht: {1}{0}Log: {2}", Environment.NewLine, e.Message, logfile), "Fehler"); } finally { notifyIcon.Remove(); execMgr.Dispose(); } } else { try { if (!execMgr.ActivateFirstInstance()) MessageBox.Show( String.Format("Es kann nur eine Programm-Instanz von {0} ausgeführt werden.\nDie bereits laufende Instanz konnte jedoch leider nicht aktiviert werden.", appName), "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } catch (Exception ex) { MessageBox.Show("Es läuft bereits eine Instanz von GravurGIS. Es konnt diese jedoch nicht aktiviert werden, da folgender Fehler auftrat: " + ex.Message); } } } }
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); }
//////////////// // Constructors //////////////// public LayerManager(MainControler mc, Config config) { this.config = config; this.mainControler = mc; layerArray = new List<Layer>(); layerListViewMappingList = new SortedList<int, int>(); layerShapeMappingList = new SortedList<int, int>(); layerArray.Clear(); transportPointLayer = new TransportMultiPointLayer(this, config); transportPolylineLayer = new TransportPolylineLayer(this, config); transportPolygonLayer = new TransportPolygonLayer(this, config); // Initialize the quadtree for the transportLayer data with assumed properties transportLayerQuadtree = new QuadTree<IShape>(new DRect(0.0d, 0.0d, 100.0d, 100.0d), 4); this.ScaleChanged += new ScaleChangedDelegate(transportLayerQuadtree.ZoomReactor); currentlyVisibleIShapes = new List<QuadTreePositionItem<IShape>>(); mainControler.SettingsLoaded += new MainControler.SettingsLoadedDelegate(mainControler_SettingsLoaded); this.NewLayerStyle = new RandomColorStyle(); }