Esempio n. 1
0
        private void SelectDevice()
        {
            var lst = Directory.GetFiles(Path.Combine(MdConstant.Root, 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.DeserializeFromPath <Keyboard>(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;
            }
        }
Esempio n. 2
0
        public static void Init()
        {
            MdConfig.Init();
            CurrentKeyboardType = new Keyboard();
            CurrentLayout       = new LayoutContainer();
            CurrentKeyboardUI   = new UCKeyboard();
            KeyMenuKey          = new Key();
            CurrentInputMethod  = new DisplayCharacterContainer();
            KeyGroup            = new KeyGroup();
            SP = new SerialPort();

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

            CurrentInputMethod = MdConfig.Main.GetCurrentInputMethod();
            KeyGroup           = MdCore.DeserializeFromPath <KeyGroup>(Path.Combine(MdConstant.Root, MdConstant.D_KEYGROUP, "Core" + MdConstant.E_KEYGROUP));
        }
Esempio n. 3
0
        public static void FirstRunCheck()
        {
            bool needsRestore = false;

            try
            {
                var cfg = MdCore.DeserializeFromPath <MdConfig>(Path.Combine(MdConstant.Root, MdConstant.N_CONFIG));
                if (cfg.ConfigVersion != MdConfig.SoftwareVersion)
                {
                    needsRestore = true;
                }
            }
            catch
            {
                needsRestore = true;
            }

            if (needsRestore)
            {
                ResetDefaults();
            }
        }
Esempio n. 4
0
        public void LoadLayoutFile()
        {
            var dialog = new OpenFileDialog();

            dialog.Filters.Add(new FileFilter(this.Keyboard.Name + " layout", "*." + this.Keyboard.SaveFileExtension));
            dialog.Title     = "Load Layout";
            dialog.Directory = new Uri(Environment.CurrentDirectory + MdConstant.PathSeparator + "layouts");
            try
            {
                dialog.ShowDialog(this);
                if (!string.IsNullOrEmpty(dialog.FileName))
                {
                    MdSessionData.CurrentLayout = MdCore.DeserializeFromPath <LayoutContainer>(dialog.FileName);
                    LoadLayout(MdSessionData.CurrentLayout);
                    this.SavePath         = dialog.FileName;
                    this.LLayoutName.Text = Path.GetFileNameWithoutExtension(this.SavePath);
                    this.DisplaySavedChangedSignal();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 5
0
 public DisplayCharacterContainer GetCurrentInputMethod()
 {
     return(MdCore.DeserializeFromPath <DisplayCharacterContainer>(Path.Combine(MdConstant.Root, MdConstant.D_INPUT_METHOD, this.CurrentInputMethod)));
 }
Esempio n. 6
0
 public static void Init()
 {
     Main = MdCore.DeserializeFromPath <MdConfig>(Path.Combine(MdConstant.Root, MdConstant.N_CONFIG));
 }