static Image getImageForElement (Skin.ElementConfig config) { var img = new Image (); img.VerticalAlignment = System.Windows.VerticalAlignment.Top; img.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; img.Source = config.Image; img.Stretch = Stretch.Fill; img.Margin = new Thickness (config.X, config.Y, 0, 0); img.Width = config.Width; img.Height = config.Height; return img; }
public ViewWindow (Skin skin, Skin.Background skinBackground, IControllerReader reader) { InitializeComponent (); DataContext = this; _skin = skin; _reader = reader; ControllerGrid.Width = skinBackground.Image.PixelWidth; ControllerGrid.Height = skinBackground.Image.PixelHeight; var brush = new ImageBrush (skinBackground.Image); brush.Stretch = Stretch.Uniform; ControllerGrid.Background = brush; foreach (var trigger in _skin.AnalogTriggers) { var grid = getGridForAnalogTrigger (trigger); _triggersWithGridImages.Add (new Tuple <Skin.AnalogTrigger,Grid> (trigger, grid)); ControllerGrid.Children.Add (grid); } foreach (var button in _skin.Buttons) { var image = getImageForElement (button.Config); _buttonsWithImages.Add (new Tuple <Skin.Button,Image> (button, image)); image.Visibility = Visibility.Hidden; ControllerGrid.Children.Add (image); } foreach (var button in _skin.RangeButtons) { var image = getImageForElement (button.Config); _rangeButtonsWithImages.Add (new Tuple <Skin.RangeButton,Image> (button, image)); image.Visibility = Visibility.Hidden; ControllerGrid.Children.Add (image); } foreach (var stick in _skin.AnalogSticks) { var image = getImageForElement (stick.Config); _sticksWithImages.Add (new Tuple <Skin.AnalogStick,Image> (stick, image)); ControllerGrid.Children.Add (image); } _reader.ControllerStateChanged += reader_ControllerStateChanged; _reader.ControllerDisconnected += reader_ControllerDisconnected; try { _keybindings = new Keybindings (Keybindings.XML_FILE_PATH, _reader); } catch (ConfigParseException) { MessageBox.Show ("Error parsing keybindings.xml. Not binding any keys to gamepad inputs"); } }
public ViewWindow (Skin skin, Skin.Background skinBackground, IControllerReader reader) { InitializeComponent (); DataContext = this; _skin = skin; _reader = reader; ControllerGrid.Width = skinBackground.Image.PixelWidth; ControllerGrid.Height = skinBackground.Image.PixelHeight; var brush = new ImageBrush (skinBackground.Image); brush.Stretch = Stretch.Uniform; ControllerGrid.Background = brush; foreach (var trigger in _skin.AnalogTriggers) { var grid = getGridForAnalogTrigger (trigger); _triggersWithGridImages.Add (new Tuple <Skin.AnalogTrigger,Grid> (trigger, grid)); ControllerGrid.Children.Add (grid); } foreach (var button in _skin.Buttons) { var image = getImageForElement (button.Config); _buttonsWithImages.Add (new Tuple <Skin.Button,Image> (button, image)); image.Visibility = Visibility.Hidden; ControllerGrid.Children.Add (image); } foreach (var button in _skin.RangeButtons) { var image = getImageForElement (button.Config); _rangeButtonsWithImages.Add (new Tuple <Skin.RangeButton,Image> (button, image)); image.Visibility = Visibility.Hidden; ControllerGrid.Children.Add (image); } foreach (var stick in _skin.AnalogSticks) { var image = getImageForElement (stick.Config); _sticksWithImages.Add (new Tuple <Skin.AnalogStick,Image> (stick, image)); ControllerGrid.Children.Add (image); } _reader.ControllerStateChanged += reader_ControllerStateChanged; _reader.ControllerDisconnected += reader_ControllerDisconnected; }
static public LoadResults LoadAllSkinsFromParentFolder (string path) { var skins = new List <Skin> (); var errs = new List <string> (); foreach (var skinDir in Directory.GetDirectories(path)) { try { var skin = new Skin (skinDir); skins.Add (skin); } catch (ConfigParseException e) { errs.Add (skinDir + " :: " + e.Message); } } return new LoadResults { SkinsLoaded = skins, ParseErrors = errs }; }
static Grid getGridForAnalogTrigger (Skin.AnalogTrigger trigger) { var img = new Image (); img.VerticalAlignment = VerticalAlignment.Top; img.HorizontalAlignment = trigger.Direction == Skin.AnalogTrigger.DirectionValue.Left ? HorizontalAlignment.Right : HorizontalAlignment.Left; img.VerticalAlignment = trigger.Direction == Skin.AnalogTrigger.DirectionValue.Up ? VerticalAlignment.Bottom : VerticalAlignment.Top; img.Source = trigger.Config.Image; img.Stretch = Stretch.None; img.Margin = new Thickness (0, 0, 0, 0); img.Width = trigger.Config.Width; img.Height = trigger.Config.Height; var grid = new Grid (); grid.HorizontalAlignment = HorizontalAlignment.Left; grid.VerticalAlignment = VerticalAlignment.Top; grid.Margin = new Thickness (trigger.Config.X, trigger.Config.Y, 0, 0); grid.Width = trigger.Config.Width; grid.Height = trigger.Config.Height; grid.Children.Add (img); return grid; }
public ViewWindow(Skin skin, Skin.Background skinBackground, IControllerReader reader) { InitializeComponent(); DataContext = this; _skin = skin; _reader = reader; Title = skin.Name; ControllerGrid.Width = skinBackground.Width; ControllerGrid.Height = skinBackground.Height; var brush = new SolidColorBrush(skinBackground.Color); ControllerGrid.Background = brush; if (skinBackground.Image != null) { var img = new Image(); img.VerticalAlignment = VerticalAlignment.Top; img.HorizontalAlignment = HorizontalAlignment.Left; img.Source = skinBackground.Image; img.Stretch = Stretch.Uniform; img.Margin = new Thickness(0, 0, 0, 0); img.Width = skinBackground.Image.PixelWidth; img.Height = skinBackground.Image.PixelHeight; ControllerGrid.Children.Add(img); } foreach (var detail in _skin.Details) { if (bgIsActive(skinBackground.Name, detail.Config.TargetBackgrounds, detail.Config.IgnoreBackgrounds)) { var image = getImageForElement(detail.Config); ControllerGrid.Children.Add(image); } } foreach (var trigger in _skin.AnalogTriggers) { if (bgIsActive(skinBackground.Name, trigger.Config.TargetBackgrounds, trigger.Config.IgnoreBackgrounds)) { var grid = getGridForAnalogTrigger(trigger); _triggersWithGridImages.Add(new Tuple <Skin.AnalogTrigger, Grid>(trigger, grid)); ControllerGrid.Children.Add(grid); } } foreach (var button in _skin.Buttons) { if (bgIsActive(skinBackground.Name, button.Config.TargetBackgrounds, button.Config.IgnoreBackgrounds)) { var image = getImageForElement(button.Config); _buttonsWithImages.Add(new Tuple <Skin.Button, Image>(button, image)); image.Visibility = Visibility.Hidden; ControllerGrid.Children.Add(image); } } foreach (var button in _skin.RangeButtons) { if (bgIsActive(skinBackground.Name, button.Config.TargetBackgrounds, button.Config.IgnoreBackgrounds)) { var image = getImageForElement(button.Config); _rangeButtonsWithImages.Add(new Tuple <Skin.RangeButton, Image>(button, image)); image.Visibility = Visibility.Hidden; ControllerGrid.Children.Add(image); } } foreach (var stick in _skin.AnalogSticks) { if (bgIsActive(skinBackground.Name, stick.Config.TargetBackgrounds, stick.Config.IgnoreBackgrounds)) { var image = getImageForElement(stick.Config); _sticksWithImages.Add(new Tuple <Skin.AnalogStick, Image>(stick, image)); ControllerGrid.Children.Add(image); } } _reader.ControllerStateChanged += reader_ControllerStateChanged; _reader.ControllerDisconnected += reader_ControllerDisconnected; try { _keybindings = new Keybindings(Keybindings.XML_FILE_PATH, _reader); } catch (ConfigParseException) { MessageBox.Show("Error parsing keybindings.xml. Not binding any keys to gamepad inputs"); } MassBlinkReductionEnabled = Properties.Settings.Default.MassFilter; AnalogBlinkReductionEnabled = Properties.Settings.Default.AnalogFilter; ButtonBlinkReductionEnabled = Properties.Settings.Default.ButtonFilter; Topmost = Properties.Settings.Default.TopMost; }