private void Window_Loaded(object sender, RoutedEventArgs e) { const double WIDTH = 45; const double HEIGHT = 30; try { trkDarkness_ValueChanged(this, null); chkOverlay1_Checked(this, null); chkOverlay2_Checked(this, null); #region Back Buttons foreach (FlagBackType backType in Enum.GetValues(typeof(FlagBackType))) { FlagProps props = new FlagProps() { BackType = backType, Back1 = "FFF", Back2 = "000", Back3 = "888", }; panelBacks.Children.Add(GetFlagButton(props, WIDTH, HEIGHT, backType)); } #endregion #region Overlay Buttons foreach (FlagOverlayType overlayType in Enum.GetValues(typeof(FlagOverlayType))) { FlagProps props = new FlagProps() { BackType = FlagBackType.Solid, Back1 = "FFF", Overlay1 = new FlagOverlay() { Type = overlayType, Color = "000", }, }; panelOverlays1.Children.Add(GetFlagButton(props, WIDTH, HEIGHT, overlayType)); panelOverlays2.Children.Add(GetFlagButton(props, WIDTH, HEIGHT, overlayType)); } #endregion panelBacks.Children[0].Effect = _selectEffect; panelOverlays1.Children[0].Effect = _selectEffect; panelOverlays2.Children[0].Effect = _selectEffect; RedrawFlag(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void RedrawFlag() { canvasDebug.Children.Clear(); canvasSmall.Children.Clear(); canvasMed.Children.Clear(); canvasLarge.Children.Clear(); lblError.Text = ""; lblError.Visibility = Visibility.Collapsed; try { FlagProps props = new FlagProps() { BackType = _backType, Back1 = txtBack1.Text, Back2 = txtBack2.Text, Back3 = txtBack3.Text, }; if (chkOverlay1.IsChecked.Value) { props.Overlay1 = new FlagOverlay() { Type = _overlayType1, Color = txtOverlay1.Text, }; } if (chkOverlay2.IsChecked.Value) { props.Overlay2 = new FlagOverlay() { Type = _overlayType2, Color = txtOverlay2.Text, }; } canvasSmall.Children.Add(new FlagVisual(canvasSmall.ActualWidth, canvasSmall.Height, props)); canvasMed.Children.Add(new FlagVisual(canvasMed.ActualWidth, canvasMed.Height, props)); canvasLarge.Children.Add(new FlagVisual(canvasLarge.ActualWidth, canvasLarge.Height, props)); } catch (Exception ex) { lblError.Text = ex.Message; lblError.Visibility = Visibility.Visible; } }
private static UIElement GetFlagButton(FlagProps props, double width, double height, Enum enumValue) { //NOTE: I couldn't get mouse events to fire. Finally, I put a transparent rectangle over the flag visual, and that works Grid retVal = new Grid() { Margin = new Thickness(3) }; retVal.Children.Add(new FlagVisual(width, height, props)); retVal.Children.Add(new Rectangle() { Width = width, Height = height, Fill = Brushes.Transparent, ToolTip = enumValue.ToString(), Tag = enumValue }); // store it in the tag to make things easier return(retVal); }
public SpaceStation2D(Point3D position, World world, int materialID, Quaternion orientation, FlagProps flag = null) : base(position, world, materialID, orientation) { _partChances = GetPartChances(); _shipChances = GetShipChances(); if (flag != null) { this.Flag = new FlagVisual(FLAGWIDTH, FLAGHEIGHT, flag); } }