private bool createActionImages(Ints actions, Floats buttonXY) { int actionCount = actions.count(); for (int i = 0; i < actionCount; i++) { int cmdIndex = actions.get(i); if (cmdIndex >= buttonCaptions.Length) continue; ImageSource imageSource = WPFImageSourceHelper.Instance.ActionImageSource(cmdIndex); if (imageSource == null) continue; string cmdName = buttonCaptions[cmdIndex]; System.Diagnostics.Trace.WriteLine(string.Format("{0},{1}", cmdIndex, cmdName)); Image image = new Image() { Source = imageSource, ToolTip = cmdName, Tag = cmdIndex, Width = imageSource.Width, Height = imageSource.Height }; image.MouseDown += new MouseButtonEventHandler(image_MouseDown); _owner.TempCanvas.Children.Add(image); Canvas.SetLeft(image, buttonXY.get(2 * i) - image.Width / 2); Canvas.SetTop(image, buttonXY.get(2 * i + 1) - image.Height / 2); ActionImages.Add(image); ActionImages.Add(image); } return actionCount == 0 || ActionImages.Count > 0; }
private void createActionButtons(Ints actions, Floats buttonXY) { if (ActionButtons == null) ActionButtons = new List<Button>(); int actionCount = actions.count(); for (int i = 0; i < actionCount; i++) { int cmdIndex = actions.get(i); if (cmdIndex >= buttonCaptions.Length) continue; string cmdName = buttonCaptions[cmdIndex]; Button button = new Button() { Content = cmdName, Tag = cmdIndex, Width = cmdName.Length * 14 + 8, Height = 24 }; button.Click += new RoutedEventHandler(button_Click); _owner.TempCanvas.Children.Add(button); Canvas.SetLeft(button, buttonXY.get(2 * i) - button.Width / 2); Canvas.SetTop(button, buttonXY.get(2 * i + 1) - button.Height / 2); ActionButtons.Add(button); } }