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; } }
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)); }
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(); } }
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); } }
public DisplayCharacterContainer GetCurrentInputMethod() { return(MdCore.DeserializeFromPath <DisplayCharacterContainer>(Path.Combine(MdConstant.Root, MdConstant.D_INPUT_METHOD, this.CurrentInputMethod))); }
public static void Init() { Main = MdCore.DeserializeFromPath <MdConfig>(Path.Combine(MdConstant.Root, MdConstant.N_CONFIG)); }