public static void SaveProfilesTexture(BackgroundWorker worker) { float buttonSize = 0.1f; int gridWidth = 4; int gridHeight = 2; while ((gridWidth * (gridHeight - 1)) < profiles.Count) { if (gridWidth == gridHeight - 1) { gridWidth++; } else { gridHeight++; } } Profile p = new Profile(DirectoryInfo.FolderPath); ButtonGrid g = p.NewGrid(); g.filename = DirectoryInfo.ProfilesTextureName; g.GridWidth = gridWidth; g.GridHeight = gridHeight; g.Width = gridWidth * buttonSize; g.Height = gridHeight * buttonSize; g.Outline = true; GridButton resetButton = g.NewButton(0, 0); resetButton.Width = gridWidth / 2; resetButton.Text = "Reset Seated Position"; resetButton.FontSize = 0.0125; GridButton laserButton = g.NewButton(2, 0); laserButton.Width = gridWidth - (gridWidth / 2); laserButton.Text = "Toggle Laser Mode"; laserButton.FontSize = 0.0125; int gridX = 0; int gridY = 1; foreach (Profile profile in profiles) { GridButton b = g.NewButton(gridX, gridY); b.Text = profile.Name; gridX++; if (gridX >= gridWidth) { gridX = 0; gridY++; } } g.CreateAndSaveImage(worker); }
private void GridSelected(object sender, SelectionChangedEventArgs e) { this.ButtonGrid = (ButtonGrid)GridNameBox.SelectedItem; this.CurrentButton = null; this.SelectedX = -1; this.SelectedY = -1; UpdateDisplayAndImage(); }
public ButtonGrid NewGrid() { ButtonGrid grid = new ButtonGrid(); grid.parent = this; grid.DeconflictFilename(); this.grids.Add(grid); Save(); return(grid); }
private void NewProfile(object sender, RoutedEventArgs e) { this.ButtonGrid = null; this.CurrentButton = null; this.SelectedX = -1; this.SelectedY = -1; this.Profile = Profiles.NewProfile(); UpdateDisplayAndImage(); UpdateProfileImage(); }
private void NewGrid(object sender, RoutedEventArgs e) { if (this.Profile == null) { return; } this.CurrentButton = null; this.SelectedX = -1; this.SelectedY = -1; this.ButtonGrid = this.Profile.NewGrid(); UpdateDisplayAndImage(); }
private void ProfileSelected(object sender, SelectionChangedEventArgs e) { if (ProfileNameBox.SelectedItem != this.Profile && ProfileNameBox.SelectedItem != null) { this.Profile = (Profile)ProfileNameBox.SelectedItem; this.ButtonGrid = null; this.CurrentButton = null; this.SelectedX = -1; this.SelectedY = -1; if (this.Profile.grids.Count > 0) { this.ButtonGrid = this.Profile.grids[0]; } UpdateDisplayAndImage(); } }
private void DeleteGrid(object sender, RoutedEventArgs e) { if (this.ButtonGrid == null || this.Profile == null) { return; } MessageBoxResult result = MessageBox.Show("Delete this button grid?", "Confirm", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { var temp = this.ButtonGrid; this.ButtonGrid = null; this.CurrentButton = null; this.SelectedX = -1; this.SelectedY = -1; this.Profile.DeleteGrid(temp); UpdateDisplayAndImage(); } }
public void DeleteGrid(ButtonGrid grid) { this.grids.Remove(grid); File.Delete(Path.Combine(DirectoryInfo.FolderPath, this.directory, grid.filename)); Save(); }