Inheritance: System.EventArgs
Esempio n. 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            //Point pt = convertCoordsDiamond(e.X, e.Y);
            if (map == null) return;
            if (MapPanelClicked != null)
            {
                XCom.Interfaces.Base.IMapTile tile = null;

                Point p = convertCoordsDiamond(e.X, e.Y);
                if (p.Y >= 0 && p.Y < map.MapSize.Rows &&
                    p.X >= 0 && p.X < map.MapSize.Cols)
                    tile = map[p.Y, p.X];

                if (tile != null)
                {
                    clickPoint.X = p.X;
                    clickPoint.Y = p.Y;

                    map.SelectedTile = new MapLocation(clickPoint.Y, clickPoint.X, map.CurrentHeight);
                    MapPanelClickEventArgs mpe = new MapPanelClickEventArgs();
                    mpe.ClickTile = tile;
                    mpe.MouseEventArgs = e;
                    mpe.ClickLocation = new MapLocation(clickPoint.Y, clickPoint.X, map.CurrentHeight);
                    MapPanelClicked(this, mpe);

                    //RmpSquareClicked(clickPoint.Y, clickPoint.X, e.Button);
                }
            }

            Refresh();
        }
Esempio n. 2
0
        private void panelClick(object sender, MapPanelClickEventArgs e)
        {
            idxLabel.Text = this.Text;
            try
            {
                if (currEntry != null && e.MouseEventArgs.Button == MouseButtons.Right)
                {
                    RmpEntry selEntry = ((XCMapTile) e.ClickTile).Rmp;
                    if (selEntry != null)
                    {
                        bool ExistingLink = false;
                        bool SpaceAvailable = false;
                        int SpaceAt = 512;
                        for (int i = 0; i < 5; i++)
                        {
                            if (currEntry[i].Index == selEntry.Index)
                            {
                                ExistingLink = true;
                                break;
                            }
                            if (currEntry[i].Index == (byte) LinkTypes.NotUsed)
                            {
                                SpaceAvailable = true;
                                if (i < SpaceAt)
                                    SpaceAt = i;
                            }
                        }
                        if (!ExistingLink && SpaceAvailable)
                        {
                            currEntry[SpaceAt].Index = selEntry.Index;
                            currEntry[SpaceAt].Distance = calcLinkDistance(currEntry, selEntry, null);
                        }

                        if (AutoconnectNodes.Checked)
                        {
                            ExistingLink = false;
                            SpaceAvailable = false;
                            SpaceAt = 512;
                            for (int i = 0; i < 5; i++)
                            {
                                if (selEntry[i].Index == currEntry.Index)
                                {
                                    ExistingLink = true;
                                    break;
                                }
                                if (selEntry[i].Index == (byte) LinkTypes.NotUsed)
                                {
                                    SpaceAvailable = true;
                                    if (i < SpaceAt)
                                        SpaceAt = i;
                                }
                            }
                            if (!ExistingLink && SpaceAvailable)
                            {
                                selEntry[SpaceAt].Index = currEntry.Index;
                                selEntry[SpaceAt].Distance = calcLinkDistance(selEntry, currEntry, null);
                            }
                        }

                        fillGUI();
                        Refresh();
                        return;
                    }
                }


                currEntry = ((XCMapTile) e.ClickTile).Rmp;

                if (currEntry == null && e.MouseEventArgs.Button == MouseButtons.Right)
                {
                    if (map is XCMapFile)
                    {
                        RmpEntry prevEntry = (((XCMapFile) map).Rmp.Length > 0
                            ? ((XCMapFile) map).Rmp[((XCMapFile) map).Rmp.Length - 1]
                            : null);

                        currEntry = ((XCMapFile) map).AddRmp(e.ClickLocation);
                        if (AutoconnectNodes.Checked)
                        {
                            currEntry[0].Index = (byte) (((XCMapFile) map).Rmp.Length - 2);
                            if (prevEntry != null)
                            {
                                currEntry[0].Distance = calcLinkDistance(currEntry, prevEntry, txtDist1);
                                for (int pI = 0; pI < prevEntry.NumLinks; pI++)
                                {
                                    if (prevEntry[pI].Index == 0xFF)
                                    {
                                        prevEntry[pI].Index = (byte) (((XCMapFile) map).Rmp.Length - 1);
                                        prevEntry[pI].Distance = calcLinkDistance(prevEntry, currEntry, null);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }


            }
            catch
            {
                return;
            }

            fillGUI();
        }