示例#1
0
        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);
        }
示例#2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (WindowState == WindowState.Maximized)
            {
                // Use the RestoreBounds as the current values will be 0, 0 and the size of the screen
                Properties.Settings.Default.Top       = RestoreBounds.Top;
                Properties.Settings.Default.Left      = RestoreBounds.Left;
                Properties.Settings.Default.Height    = RestoreBounds.Height;
                Properties.Settings.Default.Width     = RestoreBounds.Width;
                Properties.Settings.Default.Maximized = true;
            }
            else
            {
                Properties.Settings.Default.Top       = this.Top;
                Properties.Settings.Default.Left      = this.Left;
                Properties.Settings.Default.Height    = this.Height;
                Properties.Settings.Default.Width     = this.Width;
                Properties.Settings.Default.Maximized = false;
            }

            Launchpad.clearAllLEDs();
            Properties.Settings.Default.Save();
        }