private void SelectPage(int Number) { if ((Config.Pages.Count > Number) && (Number >= 0)) { if (SelectedPage.Number > 7) { Launchpad.setSideLED(SelectedPage.Number - 8, 0); } else { Launchpad.setTopLEDs(SelectedPage.Number, 0); } SelectedPage = Config.GetPage(Number); if (SelectedPage.Number > 7) { Launchpad.setSideLED(Number - 8, 52); } else { Launchpad.setTopLEDs(Number, 52); } BuildLight(); BuildButtons(); } }
public void Initialize() { Pages.Clear(); var Page = new LPPage(0); Page.Initialize(); Pages.Add(Page); }
public MainWindow() { InitializeComponent(); this.Top = Properties.Settings.Default.Top; this.Left = Properties.Settings.Default.Left; this.Height = Properties.Settings.Default.Height; this.Width = Properties.Settings.Default.Width; // Very quick and dirty - but it does the job if (Properties.Settings.Default.Maximized) { WindowState = WindowState.Maximized; } FileInfo exeFile = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); configFile = String.Format("{0}\\config.xml", exeFile.DirectoryName); if (!File.Exists(configFile)) { LPConfig newConfig = new LPConfig(); for (int i = 0; i < 15; i++) { var Page = new LPPage(i); Page.Initialize(); newConfig.Pages.Add(Page); } newConfig.Save(configFile); } Launchpad = new LaunchpadInterface(); Launchpad.OnLaunchpadKeyPressed += Launchpad_OnLaunchpadKeyPressed; Launchpad.OnLaunchpadTopKeyPressed += Launchpad_OnLaunchpadTopKeyPressed; Launchpad.OnLaunchpadCCKeyPressed += Launchpad_OnLaunchpadCCKeyPressed; ((App)Application.Current).Config = LPConfig.Load(configFile); Config = ((App)Application.Current).Config; Initialize(); SelectedPage = Config.Pages.FirstOrDefault(); Launchpad.clearAllLEDs(); BuildLight(); BuildButtons(); SelectPage(0); }