public void SaveSettings(Config configToSave) { string appSavePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\" + Config.ProgramName; TextWriter tw = null; try { if (!Directory.Exists(appSavePath)) Directory.CreateDirectory(appSavePath); XmlSerializer ser = new XmlSerializer(typeof(Config)); tw = new StreamWriter(appSavePath + "\\" + configToSave.ConfigFileName, false); ser.Serialize(tw, configToSave); } catch (Exception ex) { MessageBox.Show( String.Format( "Fehler 0x8000 - Konnte Einstellungen nicht in Datei {0}{1} speichern!{2}Fehlermeldung: {3}", appSavePath, configToSave.ConfigFileName, Environment.NewLine, ex.Message)); } finally { if (tw != null) tw.Close(); } }
void MainControler_SettingsLoaded(Config config) { if ( ( config.UseGPS && layerManager.GPSLayer == null) || gpsControler == null || !gpsControler.Opened) { addGPSLayer(); } else if (!config.UseGPS) { removeGPSLayer(); } this.hardwareKeyDownFunctionMapping.TryGetValue(config.KeyMapping_Up, out upButtonDownAction); this.hardwareKeyDownFunctionMapping.TryGetValue(config.KeyMapping_Down, out downButtonDownAction); this.hardwareKeyDownFunctionMapping.TryGetValue(config.KeyMapping_Left, out leftButtonDownAction); this.hardwareKeyDownFunctionMapping.TryGetValue(config.KeyMapping_Right, out rightButtonDownAction); this.hardwareKeyDownFunctionMapping.TryGetValue(config.KeyMapping_Enter, out enterButtonDownAction); this.hardwareKeyUpFunctionMapping.TryGetValue(config.KeyMapping_Up, out upButtonUpAction); this.hardwareKeyUpFunctionMapping.TryGetValue(config.KeyMapping_Down, out downButtonUpAction); this.hardwareKeyUpFunctionMapping.TryGetValue(config.KeyMapping_Left, out leftButtonUpAction); this.hardwareKeyUpFunctionMapping.TryGetValue(config.KeyMapping_Right, out rightButtonUpAction); this.hardwareKeyUpFunctionMapping.TryGetValue(config.KeyMapping_Enter, out enterButtonUpAction); }
public void LoadDefaultSettings() { if (MessageBox.Show("Aktuelle Einstellungen überschreiben\nund Standard-Einstellungen laden?", "Standard-Einstellungen", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { this.config = new Config(); config.SetDefaults(); SettingsLoaded(this.config); } }
private void LoadSettings(string filePath) { FileStream fs = null; try { if (File.Exists(filePath)) { XmlSerializer ser = new XmlSerializer(typeof(Config)); fs = new FileStream(filePath, FileMode.Open); config = (Config)ser.Deserialize(fs); } } catch (Exception ex) { //File.Delete(filePath); MessageBox.Show( String.Format("Fehler beim Laden der Einstellungen!\nVerwende Standardwerte.{0}Fehlermeldung: {1}", Environment.NewLine, ex.Message)); } finally { if (fs != null) fs.Close(); // we have to initialize some default values which are not explicitely saved in the XML file // for this reason we have to this no matter if we loaded the file or not config.InitStaticData(); } OnSettingsChanged(); }
void mainControler_SettingsLoaded(Config config) { this.config = config; }
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); }
void mainControler_SettingsLoaded(Config config) { this.config = config; try { switch (config.NewLayerStyle) { case NewLayerStyles.SpecificColor: this.newLayerStyle = new SpecificColorStyle(config.NewLayerStaticColor); break; default: // Random Color this.newLayerStyle = new RandomColorStyle(); break; } } catch { MessageBox.Show("Fehler beim Laden der Einstellungen für das Erstellen neuer Layer - verwende Standard"); this.newLayerStyle = new RandomColorStyle(); } }
//////////////// // 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(); }