Ejemplo n.º 1
0
        private void ItemVisibilityToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _itemVisibilityForm = new ItemVisibilityForm(_renderFlags);
            _itemVisibilityForm.Show();
            _itemVisibilityForm.BringToFront();

            _itemVisibilityForm.UpdateItemVisibility += (renderFlags) =>
            {
                _renderFlags = renderFlags;
                MapPanel.Invalidate();
            };
        }
Ejemplo n.º 2
0
        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();
            };
        }
Ejemplo n.º 3
0
 private void ResetMapToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _scale      = 0.2f;
     _startPoint = (!_mapper.IsEts2) ? new PointF(-105000, 15000) : new PointF(-1000, -4000);
     MapPanel.Invalidate();
 }
Ejemplo n.º 4
0
 private void FullMapToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ZoomOutAndCenterMap(MapPanel.Width, MapPanel.Height, out _startPoint, out _scale);
     MapPanel.Invalidate();
 }
Ejemplo n.º 5
0
 private void TsMapCanvas_Resize(object sender, System.EventArgs e)
 {
     MapPanel.Invalidate();
 }
Ejemplo n.º 6
0
        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();
            };
        }