private void CityStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { var city = (TsCityItem)((ToolStripComboBox)sender).SelectedItem; _scale = 0.2f; _startPoint = new PointF(city.X - 1000, city.Z - 1000); MapPanel.Invalidate(); }
public TsMapCanvas(SetupForm f) { InitializeComponent(); //_appSettings = f.AppSettings; //JsonHelper.SaveSettings(_appSettings); _mapper = this.CreateMapper(); _palette = SettingsManager.Current.Settings.Palette.ToBrushPalette(); _mapper.Parse(); CityStripComboBox.Items.AddRange(_mapper.Cities.Where(x => !x.Hidden).ToArray()); if (!_mapper.IsEts2) { _startPoint = new PointF(-105000, 15000); } else { _startPoint = new PointF(-1000, -4000); } _renderer = this.CreateRenderer(_mapper); // Panning around MapPanel.MouseDown += (s, e) => { _dragging = true; _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseUp += (s, e) => _dragging = false; MapPanel.MouseMove += (s, e) => { if (_dragging) { MapPanel.Invalidate(); _startPoint.X -= (e.X - _lastPoint.X) / _scale; _startPoint.Y -= (e.Y - _lastPoint.Y) / _scale; } _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseWheel += (s, e) => { _scale += (e.Delta > 0 ? 1 : -1) * 0.05f * _scale; _scale = Math.Max(_scale, 0.0005f); MapPanel.Invalidate(); }; MapPanel.Resize += TsMapCanvas_Resize; Closed += (s, e) => { f.Close(); _tileMapGeneratorForm?.Close(); }; }
public TsMapCanvas(Form f, string path, List <Mod> mods) { InitializeComponent(); _mapper = new TsMapper(path, mods); _palette = new SimpleMapPalette(); if (path.Contains("American Truck Simulator")) { _pos = new PointF(-103000, -54444); _mapper.IsEts2 = false; } else { _pos = new PointF(850, -920); _mapper.IsEts2 = true; } _mapper.Parse(); _renderer = new TsMapRenderer(_mapper); Timer t = new Timer { Interval = 1000 / 30 }; t.Tick += (s, a) => MapPanel.Invalidate(); t.Start(); // Panning around MapPanel.MouseDown += (s, e) => _dragPoint = e.Location; MapPanel.MouseUp += (s, e) => _dragPoint = null; MapPanel.MouseMove += (s, e) => { if (_dragPoint == null) { return; } var spd = _mapScale / Math.Max(MapPanel.Width, MapPanel.Height); _pos.X = _pos.X - (e.X - _dragPoint.Value.X) * spd; _pos.Y = _pos.Y - (e.Y - _dragPoint.Value.Y) * spd; _dragPoint = e.Location; }; MapPanel.MouseWheel += TsMapCanvas_MouseWheel; MapPanel.Resize += TsMapCanvas_Resize; Closed += (s, e) => { f.Close(); _imageExportForm?.Close(); }; }
private void ItemVisibilityToolStripMenuItem_Click(object sender, EventArgs e) { _itemVisibilityForm = new ItemVisibilityForm(_renderFlags); _itemVisibilityForm.Show(); _itemVisibilityForm.BringToFront(); _itemVisibilityForm.UpdateItemVisibility += (renderFlags) => { _renderFlags = renderFlags; MapPanel.Invalidate(); }; }
private void localizationSettingsToolStripMenuItem_Click(object sender, EventArgs e) { _localizationSettingsForm = new LocalizationSettingsForm(_mapper.LocalizationList, _mapper.SelectedLocalization); _localizationSettingsForm.Show(); _localizationSettingsForm.BringToFront(); _localizationSettingsForm.UpdateLocalization += (locIndex) => { _mapper.UpdateLocalization(locIndex); CityStripComboBox.Items.Clear(); CityStripComboBox.Items.AddRange(_mapper.Cities.Where(x => !x.Hidden).ToArray()); _localizationSettingsForm.Close(); MapPanel.Invalidate(); }; }
private void ResetMapToolStripMenuItem_Click(object sender, EventArgs e) { _scale = 0.2f; _startPoint = (!_mapper.IsEts2) ? new PointF(-105000, 15000) : new PointF(-1000, -4000); MapPanel.Invalidate(); }
private void FullMapToolStripMenuItem_Click(object sender, EventArgs e) { ZoomOutAndCenterMap(MapPanel.Width, MapPanel.Height, out _startPoint, out _scale); MapPanel.Invalidate(); }
private void TsMapCanvas_Resize(object sender, System.EventArgs e) { MapPanel.Invalidate(); }
public TsMapCanvas(SetupForm f, string path, List <Mod> mods) { InitializeComponent(); _appSettings = f.AppSettings; JsonHelper.SaveSettings(_appSettings); _mapper = new TsMapper(path, mods); _palette = new SimpleMapPalette(); _mapper.Parse(); CityStripComboBox.Items.AddRange(_mapper.Cities.Where(x => !x.Hidden).ToArray()); if (!_mapper.IsEts2) { _startPoint = new PointF(-105000, 15000); } else { _startPoint = new PointF(-1000, -4000); } _renderer = new TsMapRenderer(_mapper); Timer t = new Timer { Interval = 1000 / 30 }; t.Tick += (s, a) => MapPanel.Invalidate(); t.Start(); // Panning around MapPanel.MouseDown += (s, e) => { _dragging = true; _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseUp += (s, e) => _dragging = false; MapPanel.MouseMove += (s, e) => { if (_dragging) { _startPoint.X -= (e.X - _lastPoint.X) / _scale; _startPoint.Y -= (e.Y - _lastPoint.Y) / _scale; } _lastPoint = new PointF(e.X, e.Y); }; MapPanel.MouseWheel += (s, e) => { _scale += (e.Delta > 0 ? 1 : -1) * 0.05f * _scale; _scale = Math.Max(_scale, 0.0005f); }; MapPanel.Resize += TsMapCanvas_Resize; Closed += (s, e) => { f.Close(); _tileMapGeneratorForm?.Close(); }; }