示例#1
0
        private void SelectDevice()
        {
            var lst = Directory.GetFiles(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYBOARD), "*" + MdConstant.E_KEYBOARD).ToList();
            var fm  = new FmSelectTextDialog(lst, lst.Select(ele => Path.GetFileNameWithoutExtension(ele)).ToList(), "Select a device");

            fm.ShowModal();
            var outputInd = fm.OutputIndex;

            if (outputInd >= 0)
            {
                var kb = MdCore.Deserialize <ClKeyboard>(fm.OutputValues[outputInd]);
                MdSessionData.CurrentKeyboardType = kb;
                MdSessionData.CurrentLayout       = kb.GenerateLayout();
                var ucl = new UCKeyboard(MdSessionData.CurrentKeyboardType, MdSessionData.CurrentLayout);
                MdSessionData.CurrentKeyboardUI = ucl;
                this.PnMain.Content             = ucl;
                this.BtnSelectDevice.Text       = "Device: " + kb.Name;
            }
        }
示例#2
0
        public static void Init()
        {
            MdConfig.Init();
            CurrentKeyboardType = new ClKeyboard();
            CurrentLayout       = new ClLayoutContainer();
            CurrentKeyboardUI   = new UCKeyboard();
            KeyMenuKey          = new ClKey();
            CurrentInputMethod  = new ClDisplayCharacterContainer();
            KeyGroup            = new ClKeyGroup();
            SP = new SerialPort();

            if (File.Exists("favicon.ico"))
            {
                WindowIcon = new Icon(Path.Combine(MdConstant.root, MdConstant.N_ICON));
            }


            CurrentInputMethod = MdConfig.Main.GetCurrentInputMethod();
            KeyGroup           = MdCore.Deserialize <ClKeyGroup>(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_KEYGROUP, "Core" + MdConstant.E_KEYGROUP));
        }
示例#3
0
        public static void FirstRunCheck()
        {
            bool needsRestore = false;

            try
            {
                var cfg = MdCore.Deserialize <MdConfig>(Path.Combine(MdPersistentData.ConfigPath, MdConstant.N_CONFIG));
                if (cfg.ConfigVersion != MdConfig.SoftwareVersion)
                {
                    needsRestore = true;
                }
            }
            catch (Exception ex)
            {
                needsRestore = true;
            }

            if (needsRestore)
            {
                ResetDefaults();
            }
        }
示例#4
0
        public void LoadLayoutFile()
        {
            var dialog = new OpenFileDialog();

            dialog.Filters.Add(new FileDialogFilter(this.Keyboard.Name + " layout", "*." + this.Keyboard.SaveFileExtension));
            dialog.Title     = "Load Layout";
            dialog.Directory = new Uri(Environment.CurrentDirectory + MdConstant.psep + "layouts");
            try
            {
                dialog.ShowDialog(this);
                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    MdSessionData.CurrentLayout = MdCore.Deserialize <ClLayoutContainer>(dialog.FileName);
                    LoadLayout(MdSessionData.CurrentLayout);
                    this.SavePath         = dialog.FileName;
                    this.LLayoutName.Text = Path.GetFileNameWithoutExtension(this.SavePath);
                    this.BtnSave.Text     = "Save Layout";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#5
0
 public ClDisplayCharacterContainer GetCurrentInputMethod()
 {
     return(MdCore.Deserialize <ClDisplayCharacterContainer>(Path.Combine(MdPersistentData.ConfigPath, MdConstant.D_INPUT_METHOD, this.CurrentInputMethod)));
 }
示例#6
0
 public static void Init()
 {
     Main = MdCore.Deserialize <MdConfig>(Path.Combine(MdPersistentData.ConfigPath, MdConstant.N_CONFIG));
 }
示例#7
0
 public static void Init()
 {
     Main       = MdCore.Deserialize <MdPersistentData>(MdConstant.N_PERSISTENT_DATA);
     ConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ArbitesData");
 }