コード例 #1
0
        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);
        }