Ejemplo n.º 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
                });
            }
        }
Ejemplo n.º 2
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
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// USer clicked on Settings icon of keyboard
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bsClicked(object sender, EventArgs e)
        {
            //Show settings control of keyboard
            KeyboardListPanel k   = sender as KeyboardListPanel;
            KeyboardSettings  obj = new KeyboardSettings(k.KeyboardName, k.KeyboardUuid, k.KeyboardPort, k.ConnectedBoardGui);

            obj.Save   += keyboardSave;
            obj.Delete += keyboardDelete;

            obj.Location = new Point(0, 0);
            obj.Visible  = true;
            this.Controls.Add(obj);
            obj.BringToFront();
        }