public void RefreshUI()
        {
            gridContents.Children.Clear();

            RoomData roomData = SecretBaseDatabase.GetRoomAt(index);


            Image room = new Image();

            room.HorizontalAlignment = HorizontalAlignment.Left;
            room.VerticalAlignment   = VerticalAlignment.Top;
            room.Width  = roomData.Image.PixelWidth;
            room.Height = roomData.Image.PixelHeight;
            room.Source = roomData.Image;

            gridContents.Children.Add(room);

            for (int x = 0; x < roomData.Width; x++)
            {
                for (int y = 0; y < roomData.Height; y++)
                {
                    Rectangle type = new Rectangle();
                    type.Width  = 16;
                    type.Height = 16;
                    type.HorizontalAlignment = HorizontalAlignment.Left;
                    type.VerticalAlignment   = VerticalAlignment.Top;
                    type.StrokeThickness     = 0;
                    type.Margin = new Thickness(16 * x, 16 * y, 0, 0);
                    type.Fill   = GetTypeColor(roomData.PlacementGrid[x, y]);
                    gridContents.Children.Add(type);
                }
            }

            Image trainer = new Image();

            trainer.HorizontalAlignment = HorizontalAlignment.Left;
            trainer.VerticalAlignment   = VerticalAlignment.Top;
            trainer.Width  = 16;
            trainer.Height = 24;
            trainer.Margin = new Thickness(16 * roomData.TrainerX, 16 * roomData.TrainerY - 8, 0, 0);
            trainer.Source = ResourceDatabase.GetImageFromName("MaleSecretBase0");
            gridContents.Children.Add(trainer);
        }
Example #2
0
        public void LoadLocation(byte id)
        {
            LocationData locationData = SecretBaseDatabase.GetLocationFromID(id);

            imageRouteSign.Visibility = Visibility.Visible;
            imageLocation.Visibility  = Visibility.Visible;
            labelRoute.Visibility     = Visibility.Visible;
            imageLocation.Source      = locationData.Image;
            imageRouteSign.Source     = ResourceDatabase.GetImageFromName("RouteSign" + (locationData.RouteData.ID >= 124 ? "Water" : "Land"));
            labelRoute.Content        = "Route " + locationData.RouteData.ID;

            ToolTip routeTooltip = new ToolTip();

            BitmapSource routeImage = locationData.RouteData.Image;

            Grid tooltip = new Grid();

            tooltip.Width  = routeImage.PixelWidth / 8 + 10;
            tooltip.Height = routeImage.PixelHeight / 8 + 10;

            Image route = new Image();

            route.HorizontalAlignment = HorizontalAlignment.Left;
            route.VerticalAlignment   = VerticalAlignment.Top;
            route.Width   = routeImage.PixelWidth / 8;
            route.Height  = routeImage.PixelHeight / 8;
            route.Margin  = new Thickness(5, 5, 5, 5);
            route.Stretch = Stretch.Uniform;
            route.Source  = routeImage;

            Image pinpoint = new Image();

            pinpoint.HorizontalAlignment = HorizontalAlignment.Left;
            pinpoint.VerticalAlignment   = VerticalAlignment.Top;
            pinpoint.Width  = 12;
            pinpoint.Height = 12;
            pinpoint.Source = ResourceDatabase.GetImageFromName("RouteLocationSelector");
            pinpoint.Margin = new Thickness(locationData.MapX * 2, locationData.MapY * 2, 0, 0);

            tooltip.Children.Add(route);
            tooltip.Children.Add(pinpoint);
            imageLocation.ToolTip = tooltip;
        }
        public SecretBaseLocationChooser(byte location, SecretBaseManager manager, bool startInvalid)
        {
            InitializeComponent();

            this.originalLocation = location;
            this.location         = (location == 0 ? (byte)181 : location);
            this.manager          = manager;
            this.startInvalid     = startInvalid;

            for (int i = 0; i < SecretBaseDatabase.NumLocations; i++)
            {
                LocationData locationData = SecretBaseDatabase.GetLocationAt(i);

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Tag = locationData.ID;
                StackPanel stackPanel = new StackPanel();
                stackPanel.Orientation = Orientation.Horizontal;
                Grid grid = new Grid();
                grid.Width  = 16;
                grid.Height = 16;

                Image type = new Image();
                type.Width  = 16;
                type.Height = 16;
                type.HorizontalAlignment = HorizontalAlignment.Center;
                type.VerticalAlignment   = VerticalAlignment.Center;
                type.Source = ResourceDatabase.GetImageFromName("SecretBaseType" + locationData.Type.ToString());

                Label layout = new Label();
                layout.Padding                    = new Thickness(0, 0, 0, 0);
                layout.Width                      = 16;
                layout.Height                     = 16;
                layout.HorizontalAlignment        = HorizontalAlignment.Center;
                layout.VerticalAlignment          = VerticalAlignment.Center;
                layout.HorizontalContentAlignment = HorizontalAlignment.Center;
                layout.VerticalContentAlignment   = VerticalAlignment.Center;
                layout.Content                    = locationData.Layout.ToString();
                layout.FontWeight                 = FontWeights.Bold;
                //layout.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));

                grid.Children.Add(type);
                grid.Children.Add(layout);

                Label label = new Label();
                label.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                label.Padding           = new Thickness(4, 0, 4, 0);
                label.Content           = "Route " + locationData.RouteData.ID;
                if ((startInvalid || originalLocation != locationData.ID) && manager != null && manager.IsLocationInUse(locationData.ID))
                {
                    label.Foreground = new SolidColorBrush(Color.FromRgb(220, 0, 0));
                }
                else if (OriginalLocationData != null && locationData.Type == OriginalLocationData.Type && locationData.Layout == OriginalLocationData.Layout)
                {
                    label.Foreground = new SolidColorBrush(Color.FromRgb(0, 140, 60));
                    label.FontWeight = FontWeights.Bold;
                }

                stackPanel.Children.Add(grid);
                stackPanel.Children.Add(label);
                listViewItem.Content = stackPanel;
                listViewSecretBases.Items.Add(listViewItem);
                if (locationData.ID == this.location)
                {
                    listViewSecretBases.SelectedIndex = listViewSecretBases.Items.Count - 1;
                }
            }
            if (listViewSecretBases.SelectedIndex == -1)
            {
                OnLocationSelected(null, null);
            }
        }