public void Initialize()
        {
            var pads = LaunchpadInterface.getConnectedLaunchpads();

            foreach (var Pad in pads)
            {
                cboLaunchpadIn.Items.Add(Pad._midiName);
            }
            cboLaunchpadIn.SelectedIndex = Config.Launchpad;

            for (int n = -1; n < WaveOut.DeviceCount; n++)
            {
                var caps = WaveOut.GetCapabilities(n);
                cboOutputDevice.Items.Add(caps.ProductName);
            }
            cboOutputDevice.SelectedIndex = Config.Output + 1;

            if (Config.PushToTalk == null)
            {
                Config.PushToTalk = new LPPushToTalk()
                {
                    Enabled     = false,
                    MouseButton = PushToTalkButton.MOUSE4
                };
            }

            chkEnablePTT.IsChecked  = Config.PushToTalk.Enabled;
            cboPTTKey.SelectedIndex = (int)Config.PushToTalk.MouseButton;
        }
        public void Initialize()
        {
            Launchpad.Disconnect();

            var Interfaces = LaunchpadInterface.getConnectedLaunchpads();

            Launchpad.Connect(Interfaces[Config.Launchpad]);
        }
        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);
        }