public void addToLayoutChooser(Keymap keymap) { if (this.isInLayoutChooser(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("LayoutChooser"); if (level1 == null) { this.jsonObj.Add("LayoutChooser", new JArray()); } level1 = this.jsonObj.GetValue("LayoutChooser"); JArray array = (JArray)level1; JObject newObj = new JObject(); newObj.Add("Title", keymap.getName()); newObj.Add("Keymap", keymap.Filename); array.Add(newObj); this.jsonObj.Remove("LayoutChooser"); this.jsonObj.Add("LayoutChooser", array); save(); }
public void removeFromLayoutChooser(Keymap keymap) { if (!this.isInLayoutChooser(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("LayoutChooser"); if (level1 != null && level1.Type == JTokenType.Array) { JArray array = (JArray)level1; foreach (JToken token in array) { if (token.Type == JTokenType.Object) { string filename = ((JObject)token).GetValue("Keymap").ToString(); if (filename == keymap.Filename) { token.Remove(); this.jsonObj.Remove("LayoutChooser"); this.jsonObj.Add("LayoutChooser", array); save(); return; } } } } }
public void addToApplicationSearch(Keymap keymap, string search) { if (this.isInApplicationSearch(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("Applications"); if (level1 == null) { this.jsonObj.Add("Applications", new JArray()); } level1 = this.jsonObj.GetValue("Applications"); JArray array = (JArray)level1; JObject newObj = new JObject(); newObj.Add("Search", search); newObj.Add("Keymap", keymap.Filename); array.Add(newObj); this.jsonObj.Remove("Applications"); this.jsonObj.Add("Applications", array); save(); }
public void setSearchStringFor(Keymap keymap, string search) { if (!isInApplicationSearch(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("Applications"); if (level1 != null && level1.Type == JTokenType.Array) { JArray array = (JArray)level1; foreach (JToken token in array) { if (token.Type == JTokenType.Object) { string filename = ((JObject)token).GetValue("Keymap").ToString(); if (filename == keymap.Filename) { ((JObject)token).Remove("Search"); ((JObject)token).Add("Search", search); this.jsonObj.Remove("Applications"); this.jsonObj.Add("Applications", array); save(); return; } } } } }
private void selectKeymap(Keymap keymap) { this.currentKeymap = keymap; this.tbKeymapTitle.Text = keymap.getName(); string searchstring = KeymapDatabase.Current.getKeymapSettings().getSearchStringFor(this.currentKeymap); if (searchstring != null && searchstring != "") { this.tbApplicationSearch.Text = searchstring; this.tbApplicationSearch.Foreground = new SolidColorBrush(Colors.Black); } else { this.tbApplicationSearch.Text = this.tbApplicationSearch.Tag.ToString(); this.tbApplicationSearch.Foreground = new SolidColorBrush(Colors.Gray); } this.cbApplicationSearch.IsChecked = KeymapDatabase.Current.getKeymapSettings().isInApplicationSearch(this.currentKeymap); this.cbLayoutChooser.IsChecked = KeymapDatabase.Current.getKeymapSettings().isInLayoutChooser(this.currentKeymap); this.tbDelete.Visibility = this.currentKeymap.Filename == KeymapDatabase.Current.getKeymapSettings().getDefaultKeymap() ? Visibility.Hidden : Visibility.Visible; this.fillConnectionLists(keymap, 0); this.fillKeymapList(KeymapDatabase.Current.getAllKeymaps()); }
public bool deleteKeymap(Keymap keymap) { if (keymap.Filename == this.getKeymapSettings().getDefaultKeymap()) { return(false); } this.getKeymapSettings().removeFromLayoutChooser(keymap); this.getKeymapSettings().removeFromApplicationSearch(keymap); File.Delete(Settings.Default.keymaps_path + keymap.Filename); return(true); }
public bool isInApplicationSearch(Keymap keymap) { List <ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings(); foreach (ApplicationSearchSetting setting in allKeymaps) { if (setting.Keymap == keymap.Filename) { return(true); } } return(false); }
private void fillConnectionLists(Keymap keymap, int wiimote) { bool defaultKeymap = wiimote == 0 && keymap.Filename == KeymapDatabase.Current.getDefaultKeymap().Filename; this.spWiimoteConnections.Children.Clear(); this.spNunchukConnections.Children.Clear(); this.spClassicConnections.Children.Clear(); this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.IR), keymap, wiimote, defaultKeymap, this.spWiimoteConnections); this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.WIIMOTE), keymap, wiimote, defaultKeymap, this.spWiimoteConnections); this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.NUNCHUK), keymap, wiimote, defaultKeymap, this.spNunchukConnections); this.appendConnectionList(KeymapDatabase.Current.getAvailableInputs(KeymapInputSource.CLASSIC), keymap, wiimote, defaultKeymap, this.spClassicConnections); }
public bool isInLayoutChooser(Keymap keymap) { List <LayoutChooserSetting> allKeymaps = this.getLayoutChooserSettings(); foreach (LayoutChooserSetting setting in allKeymaps) { if (setting.Keymap == keymap.Filename) { return(true); } } return(false); }
public string getSearchStringFor(Keymap keymap) { List <ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings(); foreach (ApplicationSearchSetting setting in allKeymaps) { if (setting.Keymap == keymap.Filename) { return(setting.Search); } } return(null); }
private void appendConnectionList(List <KeymapInput> list, Keymap keymap, int wiimote, bool defaultKeymap, Panel container) { foreach (KeymapInput input in list) { KeymapOutConfig config = keymap.getConfigFor(wiimote, input.Key); if (config != null) { KeymapConnectionRow row = new KeymapConnectionRow(input, config, defaultKeymap); row.OnConfigChanged += connectionRow_OnConfigChanged; row.OnDragStart += output_OnDragStart; row.OnDragStop += output_OnDragStop; container.Children.Add(row); } } }
public Keymap(Keymap parent, string filename) { this.Parent = parent; this.Filename = filename; if (File.Exists(Settings.Default.keymaps_path + filename)) { StreamReader reader = File.OpenText(Settings.Default.keymaps_path + filename); this.jsonObj = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); reader.Close(); } else { this.jsonObj = new JObject(); this.jsonObj.Add("Title", "New Keymap"); save(); } }
public Action <Keymap> OnClick; //filename public KeymapRow(Keymap keymap, bool active, bool defaultk) { InitializeComponent(); this.keymap = keymap; this.tbName.Text = keymap.getName(); if (active) { this.border.Background = highlightBrush; } else { this.border.MouseUp += border_MouseUp; this.border.Cursor = Cursors.Hand; } if (defaultk) { this.tbDefault.Visibility = Visibility.Visible; } }
public KeymapRow(Keymap keymap, bool active, bool defaultk) { InitializeComponent(); this.keymap = keymap; this.tbName.Text = keymap.getName(); if (active) { this.border.Background = highlightBrush; } else { this.border.MouseUp += border_MouseUp; this.border.Cursor = Cursors.Hand; } if (defaultk) { this.tbDefault.Visibility = Visibility.Visible; } }
public List <Keymap> getAllKeymaps() { List <Keymap> list = new List <Keymap>(); string[] files = Directory.GetFiles(Settings.Default.keymaps_path, "*.json"); string defaultKeymapFilename = this.getKeymapSettings().getDefaultKeymap(); Keymap defaultKeymap = new Keymap(null, defaultKeymapFilename); list.Add(defaultKeymap); foreach (string filepath in files) { string filename = Path.GetFileName(filepath); if (filename != Settings.Default.keymaps_config && filename != defaultKeymapFilename) { list.Add(new Keymap(defaultKeymap, filename)); } } return(list); }
private void rClear_MouseUp(object sender, MouseButtonEventArgs e) { if (this.config.Stack.Count == 1) { if (this.fromDefault) { this.SetConfig(new KeymapOutConfig(KeymapDatabase.Current.getDisableOutput(), false)); } else { Keymap defaultKeymap = KeymapDatabase.Current.getDefaultKeymap(); this.config.Stack = defaultKeymap.getConfigFor(0, this.input.Key).Stack; this.config.Inherited = true; this.SetConfig(this.config); } } else if (this.config.Stack.Count > 1) { this.config.Stack.RemoveAt(this.config.Stack.Count - 1); this.SetConfig(this.config); } }
public void addToLayoutChooser(Keymap keymap) { if (this.isInLayoutChooser(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("LayoutChooser"); if (level1 == null) { this.jsonObj.Add("LayoutChooser",new JArray()); } level1 = this.jsonObj.GetValue("LayoutChooser"); JArray array = (JArray)level1; JObject newObj = new JObject(); newObj.Add("Title", keymap.getName()); newObj.Add("Keymap", keymap.Filename); array.Add(newObj); this.jsonObj.Remove("LayoutChooser"); this.jsonObj.Add("LayoutChooser",array); save(); }
public void setSearchStringFor(Keymap keymap, string search) { if (!isInApplicationSearch(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("Applications"); if (level1 != null && level1.Type == JTokenType.Array) { JArray array = (JArray)level1; foreach (JToken token in array) { if (token.Type == JTokenType.Object) { string filename = ((JObject)token).GetValue("Keymap").ToString(); if (filename == keymap.Filename) { ((JObject)token).Remove("Search"); ((JObject)token).Add("Search",search); this.jsonObj.Remove("Applications"); this.jsonObj.Add("Applications", array); save(); return; } } } } }
public void removeFromLayoutChooser(Keymap keymap) { if (!this.isInLayoutChooser(keymap)) { return; } JToken level1 = this.jsonObj.GetValue("LayoutChooser"); if (level1 != null && level1.Type == JTokenType.Array) { JArray array = (JArray)level1; foreach (JToken token in array) { if (token.Type == JTokenType.Object) { string filename = ((JObject)token).GetValue("Keymap").ToString(); if (filename == keymap.Filename) { token.Remove(); this.jsonObj.Remove("LayoutChooser"); this.jsonObj.Add("LayoutChooser",array); save(); return; } } } } }
public bool isInLayoutChooser(Keymap keymap) { List<LayoutChooserSetting> allKeymaps = this.getLayoutChooserSettings(); foreach (LayoutChooserSetting setting in allKeymaps) { if (setting.Keymap == keymap.Filename) { return true; } } return false; }
public bool isInApplicationSearch(Keymap keymap) { List<ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings(); foreach (ApplicationSearchSetting setting in allKeymaps) { if (setting.Keymap == keymap.Filename) { return true; } } return false; }
public string getSearchStringFor(Keymap keymap) { List<ApplicationSearchSetting> allKeymaps = this.getApplicationSearchSettings(); foreach (ApplicationSearchSetting setting in allKeymaps) { if (setting.Keymap == keymap.Filename) { return setting.Search; } } return null; }
private void bAddKeymap_MouseUp(object sender, MouseButtonEventArgs e) { Keymap newKeymap = KeymapDatabase.Current.createNewKeymap(); selectKeymap(newKeymap); }
private void appendConnectionList(List<KeymapInput> list, Keymap keymap, int wiimote, bool defaultKeymap, Panel container) { foreach (KeymapInput input in list) { KeymapOutConfig config = keymap.getConfigFor(wiimote, input.Key); if (config != null) { KeymapConnectionRow row = new KeymapConnectionRow(input, config, defaultKeymap); row.OnConfigChanged += connectionRow_OnConfigChanged; row.OnDragStart += output_OnDragStart; row.OnDragStop += output_OnDragStop; container.Children.Add(row); } } }