Ejemplo n.º 1
0
        public MultiBoard()
        {
            InitializeComponent();

            //Debug
            //=========================

            //manage files
            if (!Directory.Exists(MainDirectory + @"\logs"))
            {
                Directory.CreateDirectory(MainDirectory + @"\logs");
            }
            if (File.Exists(MainDirectory + @"\logs\debugOld.log"))
            {
                File.Delete(MainDirectory + @"\logs\debugOld.log");
            }
            if (File.Exists(MainDirectory + @"\logs\debug.log"))
            {
                File.Move(MainDirectory + @"\logs\debug.log", MainDirectory + @"\logs\debugOld.log");
            }
            FileStream _debugLogStream = new FileStream(MainDirectory + @"\logs\debug.log", FileMode.Append);

            //connect listener
            TextWriterTraceListener myTextListener =
                new TextWriterTraceListener(_debugLogStream);

            Debug.Listeners.Add(myTextListener);
            Debug.AutoFlush = true;

            Debug.WriteLine("--DEBUG STARTED--");
            Debug.AutoFlush = true;

            //Clear error list
            //======================
            Properties.Settings.Default.ErrorList = "";
            Properties.Settings.Default.Save();
            //TODO redo

            //loadOverlay control
            _loadOverlay.Location = new Point(0, 0);
            this.Controls.Add(_loadOverlay);
            _loadOverlay.BringToFront();

            //keyboard list control
            _listkeyboardElement = new KeyboardList(MainDirectory);
            _listkeyboardElement.SelectedItem    += UserSelectedKeyboard;
            _listkeyboardElement.UpdateKeyboards += saveKeyboardsEvent;
            MAIN_PANEL.Controls.Add(_listkeyboardElement);
            _listkeyboardElement.Dock = DockStyle.Fill;

            //settings control
            _mainSettings.Hide();
            MAIN_PANEL.Controls.Add(_mainSettings);
            _mainSettings.Dock = DockStyle.Fill;

            //error control
            _errorContr.IgnoreClicked += errorIgnore;
            _errorContr.ReloadClicked += errorReload;
            _errorContr.ViewClicked   += errorView;

            Point p = new Point();

            p.X = this.Width - _errorContr.Width - 5;
            p.Y = this.Height - _errorContr.Height - 34 - 5;
            _errorContr.Location = p;

            _errorContr.Visible = false;
            this.Controls.Add(_errorContr);

            //errorManagePanel
            _errorManagePanel.Hide();
            MAIN_PANEL.Controls.Add(_errorManagePanel);
            _errorManagePanel.Dock = DockStyle.Fill;

            //addkeyboard control
            _addKeyboardContr = new addKeyboard();
            MAIN_PANEL.Controls.Add(_addKeyboardContr);
            _addKeyboardContr.Dock         = DockStyle.Fill;
            _addKeyboardContr.AddKeyboard += keyboardAdded;

            //loading keyboards
            backgroundWorker2.RunWorkerAsync();

            //AutoUpdate prompt
            if (Properties.Settings.Default.CheckForUpdates == 2)
            {
                CheckForUpdatesOverlay cfu = new CheckForUpdatesOverlay();
                cfu.Location = new Point(0, 0);
                this.Controls.Add(cfu);
                cfu.BringToFront();
            }

            //enable toggle button
            EnableB();

            //Version updates
            VERSION_LABEL.Text = Properties.Resources.Version;

            Debug.WriteLine("Construction main done");
        }