Exemple #1
0
        /// <summary>
        /// Save the new settings of the keyboard
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void keyboardSave(object sender, EventArgs e)
        {
            KeyboardSettings k = sender as KeyboardSettings;
            KeyBoardGUI      b = k.ConnectedKeyboard;

            //Check file exist
            if (File.Exists(_mainDirectory + @"\saves\" + b.KeyboardUuid + ".mkb"))
            {
                File.Move(_mainDirectory + @"\saves\" + b.KeyboardUuid + ".mkb", _mainDirectory + @"\saves\" + k.KbUuid + ".mkb");
            }
            else
            {
                //report error
                Properties.Settings.Default.ErrorList += ",File rename error --> " + b.KeyboardName;
                Properties.Settings.Default.Save();
                Console.WriteLine("File rename error");
            }

            //Applies new settings to keyboard class
            b.KeyboardName = k.KbName;
            b.KeyboardUuid = k.KbUuid;
            b.ComPort      = k.KbPort;

            //call event for saving settings
            if (UpdateKeyboards != null)
            {
                UpdateKeyboards(this, new KeyboardToArgs()
                {
                    Keyboard = null
                });
            }
        }
Exemple #2
0
        /// <summary>
        /// Setup settings of keyboard list panel
        /// </summary>
        /// <param name="name">
        /// The name of the keyboard
        /// </param>
        /// <param name="uuid">
        /// The dynamic id of the keyboard
        /// </param>
        /// <param name="port">
        /// The comport of the keyboard</param>
        /// <param name="boardGui">
        /// The keyboard class it represents
        /// </param>
        public KeyboardListPanel(string name, string uuid, string port, KeyBoardGUI boardGui)
        {
            InitializeComponent();

            NAME_LABEL.Text    = name;
            UUID_LABEL.Text    = uuid;
            KeyboardName       = name;
            _keyboardUuid      = uuid;
            _keyboardPort      = port;
            _connectedBoardGui = boardGui;
        }
Exemple #3
0
        /// <summary>
        /// Settings to load in the user control
        /// </summary>
        /// <param name="kName">
        /// Uuid of the keyboard
        /// </param>
        /// <param name="kId">
        /// Keyboard ID
        /// </param>
        /// <param name="kCom">
        /// The com port of the keyboard
        /// </param>
        /// <param name="boardGui">
        /// The keyboard class in represents
        /// </param>
        public KeyboardSettings(string kName, string kId, string kCom, KeyBoardGUI boardGui)
        {
            InitializeComponent();

            KbName            = kName;
            KbUuid            = kId;
            KbPort            = kCom;
            ConnectedKeyboard = boardGui;

            KEYBOARD_NAME_TEXTBOX.Text = kName;
            KEYBOARD_UUID_TEXTBOX.Text = kId;
            KEYBOARD_COMP_TEXTBOX.Text = kCom;
        }
Exemple #4
0
        /// <summary>
        /// Keyboard delete request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void keyboardDelete(object sender, EventArgs e)
        {
            KeyboardSettings k = sender as KeyboardSettings;
            KeyBoardGUI      b = k.ConnectedKeyboard;

            //MOVE FILES TO .DEL FOLDER
            //=============================

            //.del directory
            if (Directory.Exists(_mainDirectory + @"\.del"))
            {
                Directory.Delete(_mainDirectory + @"\.del", true);
            }
            Directory.CreateDirectory(_mainDirectory + @"\.del");

            //keyboard file
            if (File.Exists(_mainDirectory + @"\saves\" + b.KeyboardUuid + ".mkb"))
            {
                File.Move(_mainDirectory + @"\saves\" + b.KeyboardUuid + ".mkb"
                          , _mainDirectory + @"\.del\" + b.KeyboardUuid + ".mkb");
            }
            else
            {
                //report error
                Properties.Settings.Default.ErrorList += ",File delete error --> " + b.KeyboardName;
                Properties.Settings.Default.Save();
                Console.WriteLine("File delete error");
            }

            createUndo("Undo " + b.KeyboardName + " delete");
            _undo = b.KeyboardUuid;

            //dispose representing keyboardPanel
            foreach (KeyboardListPanel p in _KeyboardPanelList)
            {
                if (p.ConnectedBoardGui == b)
                {
                    p.Dispose();
                }
            }

            //dispose Keyboard settings control
            k.Dispose();

            //Call delete event for saving new settings
            UpdateKeyboards?.Invoke(this, new KeyboardToArgs()
            {
                Keyboard = b
            });
        }
Exemple #5
0
        /// <summary>
        /// Add a Keyboard to the keyboardList
        /// </summary>
        /// <param name="itemName">
        /// Uuid of the Keyboard
        /// </param>
        /// <param name="uuidItem">
        /// Dynamic ID of the keyboard
        /// </param>
        /// <param name="comportItem">
        /// The com port of the keyboard
        /// </param>
        /// <param name="boardGui">
        /// The keyboard class it represents
        /// </param>
        public void addItem(string itemName, string uuidItem, string comportItem, KeyBoardGUI boardGui)
        {
            //Create panel and add to control
            KeyboardListPanel obj = new KeyboardListPanel(itemName, uuidItem, comportItem, boardGui);

            obj.Location              = _nextPoint;
            obj.Visible               = true;
            obj.BoardSettingsClicked += bsClicked;
            obj.OpenBoardClicked     += obClicked;
            MAIN_PANEL.Controls.Add(obj);

            _KeyboardPanelList.Add(obj);

            //Draw point on control
            if (_nextPoint.X == 31)
            {
                _nextPoint.X = _nextPoint.X + obj.Width + 31;
            }
            else
            {
                _nextPoint.X = 31;
                _nextPoint.Y = _nextPoint.Y + obj.Height + 31;
            }
        }