void ShowPredefinedColorDialog(PredefinedColorSelected callback) { if (predefinedColorDialog == null) { predefinedColorDialog = new PredefinedColorDialog(Screen); // A 値をライト色で用いることはできないため、選択範囲から除外しておきます。 predefinedColorDialog.PredefinedColors.RemoveAll((p) => p.Color.A != 255); } // コールバックを設定してから表示します。 predefinedColorDialog.Selected = callback; predefinedColorDialog.Show(); }
public PredefinedColorList(Screen screen, PredefinedColorDialog owner) : base(screen) { this.owner = owner; paging.ItemCountPerPage = 5; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage(); pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage(); pageButtonPanel.Children.Add(forwardPageButton); for (int i = 0; i < itemButtons.Length; i++) { itemButtons[i] = new ItemButton(screen); itemButtons[i].KeyDown += OnListItemButtonKeyDown; itemButtons[i].Click += OnListItemButtonClick; stackPanel.Children.Add(itemButtons[i]); } }
public PredefinedColorGrid(Screen screen, PredefinedColorDialog owner) : base(screen) { this.owner = owner; paging.ItemCountPerPage = columnCount * rowCount; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage(); pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load<Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage(); pageButtonPanel.Children.Add(forwardPageButton); var vColorPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center }; stackPanel.Children.Add(vColorPanel); for (int i = 0; i < rowCount; i++) { var hColorPanel = new StackPanel(screen); vColorPanel.Children.Add(hColorPanel); for (int j = i * columnCount; j < (i + 1) * columnCount; j++) { itemButtons[j] = new ItemButton(screen); hColorPanel.Children.Add(itemButtons[j]); int mod = j % columnCount; if (mod == 0) { itemButtons[j].KeyDown += OnLeftColorButtonKeyDown; } else if (mod == columnCount - 1) { itemButtons[j].KeyDown += OnRightColorButtonKeyDown; } itemButtons[j].GotFocus += OnItemButtonGotFocus; itemButtons[j].LostFocus += OnItemButtonLostFocus; itemButtons[j].Click += OnItemButtonClick; } } }
public PredefinedColorGrid(Screen screen, PredefinedColorDialog owner) : base(screen) { this.owner = owner; paging.ItemCountPerPage = columnCount * rowCount; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load <Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage(); pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load <Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage(); pageButtonPanel.Children.Add(forwardPageButton); var vColorPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center }; stackPanel.Children.Add(vColorPanel); for (int i = 0; i < rowCount; i++) { var hColorPanel = new StackPanel(screen); vColorPanel.Children.Add(hColorPanel); for (int j = i * columnCount; j < (i + 1) * columnCount; j++) { itemButtons[j] = new ItemButton(screen); hColorPanel.Children.Add(itemButtons[j]); int mod = j % columnCount; if (mod == 0) { itemButtons[j].KeyDown += OnLeftColorButtonKeyDown; } else if (mod == columnCount - 1) { itemButtons[j].KeyDown += OnRightColorButtonKeyDown; } itemButtons[j].GotFocus += OnItemButtonGotFocus; itemButtons[j].LostFocus += OnItemButtonLostFocus; itemButtons[j].Click += OnItemButtonClick; } } }
public PredefinedColorList(Screen screen, PredefinedColorDialog owner) : base(screen) { this.owner = owner; paging.ItemCountPerPage = 5; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = stackPanel; var pageButtonPanel = new StackPanel(screen) { HorizontalAlignment = HorizontalAlignment.Right }; stackPanel.Children.Add(pageButtonPanel); var backPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Left, Content = new Image(screen) { Texture = screen.Content.Load <Texture2D>("UI/ArrowLeft") } }; backPageButton.Click += (Control s, ref RoutedEventContext c) => BackPage(); pageButtonPanel.Children.Add(backPageButton); pageTextBlock = new TextBlock(screen) { Width = BlockViewerGame.SpriteSize * 2, ForegroundColor = Color.White, BackgroundColor = Color.Black, ShadowOffset = new Vector2(2) }; pageButtonPanel.Children.Add(pageTextBlock); var forwardPageButton = new Button(screen) { Focusable = false, Width = BlockViewerGame.SpriteSize, HorizontalAlignment = HorizontalAlignment.Right, Content = new Image(screen) { Texture = screen.Content.Load <Texture2D>("UI/ArrowRight") } }; forwardPageButton.Click += (Control s, ref RoutedEventContext c) => ForwardPage(); pageButtonPanel.Children.Add(forwardPageButton); for (int i = 0; i < itemButtons.Length; i++) { itemButtons[i] = new ItemButton(screen); itemButtons[i].KeyDown += OnListItemButtonKeyDown; itemButtons[i].Click += OnListItemButtonClick; stackPanel.Children.Add(itemButtons[i]); } }