示例#1
0
 /// <summary>
 /// Generates a pan action. If one sets the coordinate type to world both, new and old d, have to be that type
 /// </summary>
 /// <param name="oldD"></param>
 /// <param name="d"></param>
 /// <param name="scale"></param>
 /// <param name="mapPanel"></param>
 /// <param name="coordinatType"></param>
 public PanAction(PointD oldD, PointD newD, double scale, MapPanel mapPanel, CoordinateType coordinatType)
 {
     this.cType = coordinatType;
     this.oldD = oldD;
     this.d = newD;
     this.scale = scale;
     this.mapPanel = mapPanel;
 }
        public void SetImage(Image image)
        {
            if (Rotation != 0d)
            {
                throw new InvalidOperationException("Rotation must be zero.");
            }

            image.Source  = Bitmap;
            image.Stretch = Stretch.Fill;

            MapPanel.SetBoundingBox(image, BoundingBox);
        }
示例#3
0
        private void 软件设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form_Option formtemp = new Form_Option(MyMapEditor);

            formtemp.MdiParent          = this;
            formtemp.BtnOkClickHandler += () =>
            {
                MyMapEditor.PictureSize = formtemp.SetPictureSize;
            };
            formtemp.MainWindowRefresh += () => { MapPanel.Refresh(); };
            formtemp.Show();
        }
示例#4
0
 public MapDisplayer(MapPanel mapPanel, Label mapMessageBox)
 {
     this.mapPanel                   = mapPanel;
     this.mapMessageBox              = mapMessageBox;
     this.mapMessageBoxDefaultColor  = this.mapMessageBox.BackColor;
     this.mapMessageBoxColor         = this.mapMessageBoxDefaultColor;
     this.updateMapPanelHandler      = new EventHandler(updateMapPanel);
     this.updateMapMessageBoxHandler = new EventHandler(updateMapMessageBox);
     this.hideMapMessageBoxHandler   = new EventHandler(hideMapMessageBox);
     this.message      = "";
     this.timerMessage = "";
     this.poiLabels    = new Hashtable();
 }
示例#5
0
        private void PopulateToolBars(ToolStripPanel toolStripPanel, MapPanel mapPanel)
        {
            m_mapPanel = mapPanel;

            foreach (var control in toolStripPanel.Controls)
            {
                if (!(control is ToolStrip))
                {
                    continue;
                }
                m_toolBars.Add(new ToolBarBridge((ToolStrip)control, m_mapPanel, false));
            }
        }
        public ResourcesTool(MapPanel mapPanel, MapLayerFlag layers, ToolStripStatusLabel statusLbl, Label totalResourcesLbl, NumericUpDown brushSizeNud, CheckBox gemsCheckBox, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> url)
            : base(mapPanel, layers, statusLbl, plugin, url)
        {
            this.totalResourcesLbl = totalResourcesLbl;
            this.brushSizeNud      = brushSizeNud;
            this.gemsCheckBox      = gemsCheckBox;

            this.brushSizeNud.ValueChanged += BrushSizeNud_ValueChanged;

            navigationWidget.MouseoverSize = new Size((int)brushSizeNud.Value, (int)brushSizeNud.Value);

            Update();
        }
        private void DrawGUI(DwarfTime gameTime, float dx)
        {
            GUI.PreRender(gameTime, DwarfGame.SpriteBatch);
            DwarfGame.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp,
                                        null, null);
            Drawer.Render(DwarfGame.SpriteBatch, null, Game.GraphicsDevice.Viewport);
            GUI.Render(gameTime, DwarfGame.SpriteBatch, new Vector2(0, dx));

            Progress.Message = !GenerationComplete ? LoadingMessage : "";

            if (GenerationComplete)
            {
                Rectangle imageBounds      = MapPanel.GetImageBounds();
                float     scaleX           = ((float)imageBounds.Width / (float)PlayState.WorldWidth);
                float     scaleY           = ((float)imageBounds.Height / (float)PlayState.WorldHeight);
                Rectangle spawnRect        = GetSpawnRectangle();
                Rectangle spawnRectOnImage = GetSpawnRectangleOnImage();
                Drawer2D.DrawRect(DwarfGame.SpriteBatch, spawnRectOnImage, Color.Yellow, 3.0f);
                Drawer2D.DrawStrokedText(DwarfGame.SpriteBatch, "Spawn", DefaultFont, new Vector2(spawnRectOnImage.X - 5, spawnRectOnImage.Y - 20), Color.White, Color.Black);

                //ImageMutex.WaitOne();

                /*
                 * DwarfGame.SpriteBatch.Draw(MapPanel.Image.Image,
                 *  new Rectangle(MapPanel.GetImageBounds().Right + 2, MapPanel.GetImageBounds().Top,  spawnRect.Width * 4, spawnRect.Height * 4),
                 * spawnRect, Color.White);
                 */
                //ImageMutex.ReleaseMutex();
                CloseupPanel.Image.Image      = MapPanel.Image.Image;
                CloseupPanel.Image.SourceRect = spawnRect;


                if (ViewSelectionBox.CurrentValue == "Factions")
                {
                    foreach (Faction civ in NativeCivilizations)
                    {
                        Point     start   = civ.Center;
                        Vector2   measure = Datastructures.SafeMeasure(GUI.SmallFont, civ.Name);
                        Rectangle snapped =
                            MathFunctions.SnapRect(
                                new Vector2(start.X * scaleX + imageBounds.X, start.Y * scaleY + imageBounds.Y) -
                                measure * 0.5f, measure, imageBounds);

                        Drawer2D.DrawStrokedText(DwarfGame.SpriteBatch, civ.Name, GUI.SmallFont, new Vector2(snapped.X, snapped.Y), Color.White, Color.Black);
                    }
                }
            }

            GUI.PostRender(gameTime);
            DwarfGame.SpriteBatch.End();
        }
示例#8
0
        private void BrowseBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_dlg = new OpenFileDialog();

            open_dlg.Filter = Program.ImageFilter;
            if (open_dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            MapPanel.Map.Image = Image.FromFile(open_dlg.FileName);
            Program.SetResolution(MapPanel.Map.Image);
            MapPanel.Invalidate();
        }
示例#9
0
        private void GameStartButton_Click(object sender, RoutedEventArgs e)
        {
            string playerName = PlayerNameInputTBx.Text;

            if (playerName != "")
            {
                player = new Player(playerName);
                tabControl.SelectedIndex = 0;
                UpdateLayout();
                MapPanel.Focus();
                DrawMap();
                MapGetButton.Content = "Move by Arrow Keys or W/A/S/D to find Pokemon";
            }
        }
示例#10
0
 private void 保存并生成代码ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         var fileMap = new FileMap();
         fileMap.MapSave(MyMapEditor, saveFileDialog);
         MapPanel.Refresh();
         fileMap.GenerateMapCode(MyMapEditor, folderBrowserDialog, false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#11
0
        private void BuildingListBoxItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            // If selected index is -1 (no selection) do nothing
            if (BuildingList.SelectedIndex == -1)
            {
                return;
            }

            Building item = (BuildingList.SelectedItem as Building);

            BuildingSelected(item.Key);
            MapPanel.ScrollToHorizontalOffset(item.Hor - 230);
            MapPanel.ScrollToVerticalOffset(item.Ver - 125);
        }
示例#12
0
        private void Form_Main_KeyDown(object sender, KeyEventArgs e)
        {
            this.Focus();
            MapPanel.Focus();
            if (PressedKeys.Contains(e.KeyCode) == false)
            {
                PressedKeys.Add(e.KeyCode);
            }
            foreach (Keys k in PressedKeys)
            {
                switch (k)
                {
                case Keys.W:    //按下W键的行为
                    MyMapEditor.UpMapSeIndex();
                    break;

                case Keys.A:    //按下A键的行为
                    MyMapEditor.LeftMapSeIndex();
                    break;

                case Keys.S:    //按下W键的行为
                    MyMapEditor.DownMapSeIndex();
                    break;

                case Keys.D:    //按下A键的行为
                    MyMapEditor.RightMapSeIndex();
                    break;

                case Keys.M:
                    适应屏幕ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.D1:
                case Keys.D2:
                case Keys.D3:
                case Keys.D4:
                case Keys.D5:
                case Keys.D6:
                case Keys.D7:
                case Keys.D8:
                case Keys.D9:
                case Keys.D0:
                    new QuickPlaceKey(MyMapEditor).KeyNumQuickPlace(k);
                    MapPlaceCom();
                    break;
                }
            }
            MapPanel.Refresh();
        }
示例#13
0
        private void PrintMaps()
        {
            Html.AppendLine("<div class=\"row\">");
            Html.AppendLine("<div class=\"col-md-12\">");
            List <Bitmap> maps = MapPanel.CreateBitmaps(_world, _site);

            Html.AppendLine("<table>");
            Html.AppendLine("<tr>");
            PrintSiteMap();
            Html.AppendLine("<td>" + MakeLink(BitmapToHtml(maps[0]), LinkOption.LoadMap) + "</td>");
            Html.AppendLine("<td>" + MakeLink(BitmapToHtml(maps[1]), LinkOption.LoadMap) + "</td>");
            Html.AppendLine("</tr></table></br>");
            Html.AppendLine("</div>");
            Html.AppendLine("</div>");
        }
        public CellTriggersTool(MapPanel mapPanel, MapLayerFlag layers, ToolStripStatusLabel statusLbl, ComboBox triggerCombo, IGamePlugin plugin, UndoRedoList <UndoRedoEventArgs> url)
            : base(mapPanel, layers, statusLbl, plugin, url)
        {
            this.mapPanel.MouseDown            += MapPanel_MouseDown;
            this.mapPanel.MouseUp              += MapPanel_MouseUp;
            this.mapPanel.MouseMove            += MapPanel_MouseMove;
            (this.mapPanel as Control).KeyDown += WaypointsTool_KeyDown;
            (this.mapPanel as Control).KeyUp   += WaypointsTool_KeyUp;

            this.triggerCombo = triggerCombo;

            navigationWidget.MouseCellChanged += MouseoverWidget_MouseCellChanged;

            UpdateStatus();
        }
示例#15
0
        void set_click_location()
        {
            fRightClickLocation = PointF.Empty;

            Point      mouse = MapPanel.PointToClient(Cursor.Position);
            RectangleF rect  = MapPanel.MapRectangle;

            if (rect.Contains(mouse))
            {
                float dx = (mouse.X - rect.X) / rect.Width;
                float dy = (mouse.Y - rect.Y) / rect.Height;

                fRightClickLocation = new PointF(dx, dy);
            }
        }
示例#16
0
 private void MapPanel_MouseMove(object sender, MouseEventArgs e)
 {
     if (!mouseDown)
     {
         return;
     }
     if (DrawObstacle.Checked)
     {
         obstacleList[lineCounter].Add(e.Location);
         if (obstacleList[lineCounter].Count < 2)
         {
             return;
         }
         MapPanel.Refresh();
     }
 }
示例#17
0
 public bool MapClicked(Tile clickedXy, MapPanel mapPanel, Main main, MouseButtons eButtons)
 {
     if (eButtons == MouseButtons.Primary)
     {
         if (clickedXy.CityHere != null)
         {
             mapPanel.ShowCityWindow(clickedXy.CityHere);
         }
         else
         {
             return(mapPanel.ActivateUnits(clickedXy));
         }
     }
     _game.ActiveTile = clickedXy;
     return(true);
 }
示例#18
0
        private void MapContextEdit_Click(object sender, EventArgs e)
        {
            if (MapPanel.SelectedLocation != null)
            {
                int index = fMap.Locations.IndexOf(MapPanel.SelectedLocation);

                MapLocationForm dlg = new MapLocationForm(MapPanel.SelectedLocation);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    fMap.Locations[index] = dlg.MapLocation;
                    MapPanel.Invalidate();

                    Session.Modified = true;
                }
            }
        }
示例#19
0
        private void MapPanel_MouseClick(object sender, MouseEventArgs e)
        {
            switch (currentClickAction)
            {
            case ClickAction.SetP1Spawn:
                p1Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.SetP2Spawn:
                p2Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.SetP3Spawn:
                p3Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.SetP4Spawn:
                p4Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.SetB1Spawn:
                b1Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.SetB2Spawn:
                b2Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.SetB3Spawn:
                b3Spawn            = e.Location;
                currentClickAction = ClickAction.None;
                break;

            case ClickAction.None:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            MapPanel.Invalidate();
        }
        public override string Print()
        {
            Html = new StringBuilder();
            Html.AppendLine("<h1>" + _worldConstruction.Name + ", " + _worldConstruction.Type + "</h1><br />");

            if (_worldConstruction.Coordinates.Any())
            {
                List <Bitmap> maps = MapPanel.CreateBitmaps(_world, _worldConstruction);

                Html.AppendLine("<table>");
                Html.AppendLine("<tr>");
                Html.AppendLine("<td>" + MakeLink(BitmapToHtml(maps[0]), LinkOption.LoadMap) + "</td>");
                Html.AppendLine("<td>" + MakeLink(BitmapToHtml(maps[1]), LinkOption.LoadMap) + "</td>");
                Html.AppendLine("</tr></table></br>");
            }

            Html.AppendLine("<b>Connects</b><br />");
            Html.AppendLine("<ul>");
            Html.AppendLine("<li>" + (_worldConstruction.Site1 != null ? _worldConstruction.Site1.ToLink() : "UNKNOWN SITE") + "</li>");
            Html.AppendLine("<li>" + (_worldConstruction.Site2 != null ? _worldConstruction.Site2.ToLink() : "UNKNOWN SITE") + "</li>");
            Html.AppendLine("</ul>");
            Html.AppendLine("</br>");

            if (_worldConstruction.MasterConstruction != null)
            {
                Html.AppendLine("<b>Part of</b><br />");
                Html.AppendLine("<ul>");
                Html.AppendLine("<li>" + _worldConstruction.MasterConstruction.ToLink() + ", " + _worldConstruction.MasterConstruction.Type + "</li>");
                Html.AppendLine("</ul>");
                Html.AppendLine("</br>");
            }

            if (_worldConstruction.Sections.Any())
            {
                Html.AppendLine("<b>Sections</b><br />");
                Html.AppendLine("<ul>");
                foreach (WorldConstruction segment in _worldConstruction.Sections)
                {
                    Html.AppendLine("<li>" + segment.ToLink() + ", " + segment.Type + "</li>");
                }
                Html.AppendLine("</ul>");
                Html.AppendLine("</br>");
            }

            PrintEventLog(_worldConstruction.Events, WorldConstruction.Filters, _worldConstruction);
            return(Html.ToString());
        }
示例#21
0
 public bool MapClicked(Tile clickedXy, MapPanel mapPanel, Main main, bool interval, MouseEventArgs e,
                        int[] mouseDownTile)
 {
     if (e.Buttons == MouseButtons.Primary)
     {
         if (clickedXy.CityHere != null)
         {
             mapPanel.ShowCityWindow(clickedXy.CityHere);
         }
         else
         {
             return(mapPanel.ActivateUnits(clickedXy));
         }
     }
     _game.ActiveTile = clickedXy;
     return(true);
 }
示例#22
0
        public ApplicationBridge(MenuStrip menuStrip,
                                 ToolStripContainer toolStripContainer, MapPanel mapPanel)
            : base(false)
        {
            m_commandHistory = CommandHistory.Instance;

            m_menuStripBridge = new MenuStripBridge(menuStrip);

            m_toolStripContainer = toolStripContainer;
            m_toolBars           = new List <ToolBarBridge>();
            PopulateToolBars(toolStripContainer.TopToolStripPanel);
            PopulateToolBars(toolStripContainer.BottomToolStripPanel);
            PopulateToolBars(toolStripContainer.LeftToolStripPanel);
            PopulateToolBars(toolStripContainer.RightToolStripPanel);

            m_editorBridge = new EditorBridge(mapPanel);
        }
        public ToolBarBridge(ToolStrip toolStrip, MapPanel mapPanel, bool readOnly)
            : base(readOnly)
        {
            m_toolStrip      = toolStrip;
            m_toolBarButtons = new List <ToolBarButtonBridge>();
            m_mapPanel       = mapPanel;

            foreach (ToolStripItem toolStripItem in m_toolStrip.Items)
            {
                if (!(toolStripItem is ToolStripButton))
                {
                    continue;
                }
                m_toolBarButtons.Add(
                    new ToolBarButtonBridge((ToolStripButton)toolStripItem, mapPanel, readOnly));
            }
        }
        private void InitializeBtn_Click(object sender, EventArgs e)
        {
            //Reinitiate
            StartBtn.Enabled = true;
            generation       = 0;
            terminate        = false;
            sameFitness      = 0;

            lblGen.Text        = "0";
            lblChromosome.Text = "0";
            lblBestFit.Text    = "0";
            lblStatus.Text     = "Not started";
            lblTerminate.Text  = "0";

            currentPopulation = null;
            MapPanel.Refresh();
        }
示例#25
0
        /// <Summary>
        /// Initializes a new instance of the StarMap class.
        /// </Summary>
        public StarMap()
        {
            InitializeComponent();

            MouseWheel += StarMap_MouseWheel;
            Resize     += delegate { Zoom(); };

            MapPanel.Paint += MapPanel_Paint;


            nameFont = new Font("Arial", (float)7.5, FontStyle.Regular, GraphicsUnit.Point);

            verticalScrollBar.GotFocus   += delegate { MapPanel.Focus(); };
            horizontalScrollBar.GotFocus += delegate { MapPanel.Focus(); };

            MapPanel.ArrowKeyPressed += new KeyEventHandler(MapPanel_ArrowKeyPressed);
        }
        private void PerformRedoUndo(int RedoUndoElement)
        {
            // Make sure we are within range
            if ((RedoUndoElement >= 0) && (lRedoUndoList.Count() > RedoUndoElement))
            {
                RedoUndoInfo RedoUndo = lRedoUndoList.ElementAt(RedoUndoElement);
                ///////////////////////////////////////////////////////////////////////////////////
                // Get Image Info
                sBackgroundImageName = RedoUndo.BackgroundImageName;
                sFullPathToImage     = RedoUndo.FullPathToImage;
                if (sFullPathToImage != null && System.IO.File.Exists(sFullPathToImage))
                {
                    MapPanel.BackgroundImage = Image.FromFile(sFullPathToImage);
                }
                else
                {
                    MapPanel.BackgroundImage = null;
                }
                ///////////////////////////////////////////////////////////////////////////////////
                // Get Audio Info
                sAudioName                         = RedoUndo.AudioName;
                AudioInfo_TextBox.Text             = RedoUndo.AudioInfoTextBoxText;
                AudioLoopStart_NumericUpDown.Value = RedoUndo.AudioLoopStart_NumericUpDownValue;
                AudioLoopEnd_NumericUpDown.Value   = RedoUndo.AudioLoopEnd_NumericUpDownValue;
                ///////////////////////////////////////////////////////////////////////////////////
                // Get Weather Info
                lWeatherEffectOne = RedoUndo.lWeatherEffectOne;
                lWeatherEffectTwo = RedoUndo.lWeatherEffectTwo;

                WeatherEffect1_ComboBox.SelectedIndex     = RedoUndo.WeatherEffect1_ComboBoxSelectedIndex;
                WeatherEffect2_ComboBox.SelectedIndex     = RedoUndo.WeatherEffect2_ComboBoxSelectedIndex;
                WeatherEffectOnePower_NumericUpDown.Value = RedoUndo.WeatherEffectOnePower_NumericUpDownValue;
                WeatherEffectTwoPower_NumericUpDown.Value = RedoUndo.WeatherEffectTwoPower_NumericUpDownValue;
                ///////////////////////////////////////////////////////////////////////////////////
                // Get Numeric Up/Downs Info
                TileRows_NumericUpDown.Value = oMapGrid.TileRowsValue = RedoUndo.TileRows_NumericUpDownValue;
                TileCols_NumericUpDown.Value = oMapGrid.TileColsValue = RedoUndo.TileCols_NumericUpDownValue;
                ///////////////////////////////////////////////////////////////////////////////////
                // Get Level Data
                lLevelInfoList = RedoUndo.lLevelDataList;

                // Invalidate the Map
                MapPanel.Invalidate();
            }
        }
示例#27
0
        private void UpdateEnvBttn_Click(object sender, EventArgs e)
        {
            int w = MapPanel.Width;
            int h = MapPanel.Height;

            if (w == decimal.ToInt32(WidthSpinBttn.Value) && h == decimal.ToInt32(HeightSpinBttn.Value))
            {
                return;
            }

            MapPanel.Width  = decimal.ToInt32(WidthSpinBttn.Value);
            MapPanel.Height = decimal.ToInt32(HeightSpinBttn.Value);
            int dx = MapPanel.Width - w;

            SimOptions.Left    += dx;
            ToggleSimBttn.Left += dx;
            MapPanel.Refresh();
        }
示例#28
0
        public EditorBridge(MapPanel mapPanel, MapTreeView mapTreeView)
            : base(false)
        {
            m_mapPanel    = mapPanel;
            m_mapTreeView = mapTreeView;

            Panel innerPanel = m_mapPanel.InnerPanel;

            innerPanel.MouseDown                += OnMapPanelMouseDown;
            innerPanel.MouseMove                += OnMapPanelMouseMove;
            innerPanel.MouseUp                  += OnMapPanelMouseUp;
            m_mapPanel.DrawTileEvent            += OnDrawTile;
            m_mapPanel.SaveEvent                += OnSave;
            m_mapPanel.LoadEvent                += OnLoad;
            m_mapTreeView.LayerNewAction        += OnLayerNew;
            m_mapTreeView.LayerPropertiesAction += OnLayerProperties;
            m_mapTreeView.LayerDeleteAction     += OnLayerDelete;
        }
示例#29
0
        private void PrintMaps()
        {
            if (_entity.SiteHistory.Count == 0)
            {
                return;
            }

            List <Bitmap> maps     = MapPanel.CreateBitmaps(_world, _entity);
            TableMaker    mapTable = new TableMaker();

            mapTable.StartRow();
            mapTable.AddData(MakeLink(BitmapToHtml(maps[0]), LinkOption.LoadMap));
            mapTable.AddData(MakeLink(BitmapToHtml(maps[1]), LinkOption.LoadMap));
            mapTable.EndRow();
            Html.AppendLine(mapTable.GetTable() + "</br>");
            maps[0].Dispose();
            maps[1].Dispose();
        }
示例#30
0
        private void DefaultEnvBttn_Click(object sender, EventArgs e)
        {
            HeightSpinBttn.Value   = HeightSpinBttn.Minimum;
            WidthSpinBttn.Value    = WidthSpinBttn.Minimum;
            MapScaleSpinBttn.Value = 10.0M;

            if (!SimulationOn)
            {
                // Clear obstacles
                obstacleList = new List <List <Point> >();
                lineCounter  = -1;
                // Don't draw robot
                drawRobot = false;
                MapPanel.Refresh();
            }

            SaveEnvBttn_Click(sender, e);
        }
示例#31
0
        private void MapPanel_MouseClick(object sender, MouseEventArgs e)
        {
            MapPanel.Focus();

            if (_controlDown)
            {
                // Add a sector to the map
                AddSector(e.X / SectorLabel.Width, e.Y / SectorLabel.Height);
            }
            else
            {
                if (_selectedSector != null)
                {
                    _selectedSector.BackColor = _normalColour;
                }
                _selectedSector = null;
            }
        }