Exemplo n.º 1
0
        public NewMap(MainWindow parentWindow)
        {
            InitializeComponent();

            this.newMap = new Map();
            this.DataContext = newMap;
            this.ParentWindow = parentWindow;
        }
Exemplo n.º 2
0
        public EditorControl(Map mapToEdit, MainWindow mainWindow)
        {
            InitializeComponent();
            Map = mapToEdit;
            MainWnd = mainWindow;
            Mapping = new Mapping(50, 42);
            this.DataContext = Map;
            ViewPortData viewPort = new ViewPortData() { CentreX = 0, CentreY = 0, Height = 500, Width = 500, Zoom = 1 };

            //var uriSource = new Uri(@"/WpfApplication1;component/Untitled.png", UriKind.Relative);
            //foo.Source = new BitmapImage(uriSource);
            BitmapImage img = new BitmapImage(new Uri("C:/Development/projects/Landwar/Shared/HexRed.png"));

            /*ImageBrush imgBrush = new ImageBrush(img);
            imgBrush.Viewbox = new Rect(0, 0, 1, 1);
            imgBrush.ViewboxUnits = BrushMappingMode.RelativeToBoundingBox;
            imgBrush.Stretch = Stretch.Uniform;*/

            SolidColorBrush redSolidColorBrush = new SolidColorBrush();
            redSolidColorBrush.Color = Color.FromArgb(255, 255, 0, 0);
            SolidColorBrush grnSolidColorBrush = new SolidColorBrush();
            grnSolidColorBrush.Color = Color.FromArgb(255, 0, 255, 0);

            for (int j = 0; j < mapToEdit.Height; ++j)
            {
                for (int i = 0; i < mapToEdit.Width; ++i)
                {
                    Point hexTopLeft = Mapping.GetHexTopLeftCorner(viewPort, mapToEdit.Hexes[j,i]);

                    Polygon pGon = GenerateHex(hexTopLeft.X, hexTopLeft.Y, Mapping.hexHeight, Mapping.hexWidth);
                    pGon.Stroke = Brushes.Purple;
                    pGon.StrokeThickness = 0;
                    pGon.ClipToBounds = true;
                    //pGon.Fill = imgBrush;

                    if (((double)i) % 2 == 0)
                    {
                        pGon.Fill = redSolidColorBrush;
                    }
                    else
                    {
                        pGon.Fill = grnSolidColorBrush;
                    }

                    pGon.MouseEnter += Polygon_MouseMove;

                    this.cnvMap.Children.Add(pGon);
                }
            }
        }