/// <summary> /// Load a content from a asset file name /// </summary> /// <param name="assetFileName">Asset name, relative to the loader root directory, and including the file extension.</param> /// <returns>Return a Configuration file instance corresponding to the asset file name</returns> public override object Load(string assetFileName) { HotKeyConfiguration config = null; if (assetFileName.Length > 4 && assetFileName[assetFileName.Length - 4] == '.') // need to have 5 char mini x.xxx and a point before the format suffix. { //get the 4 last char string fileFormat = assetFileName.Substring(assetFileName.Length - 3, 3).ToUpper(); if (this._supportFormat.Contains(fileFormat)) { try { config = SerializerHelper.Load <HotKeyConfiguration>(assetFileName); } catch { throw; } } else { throw new ContentLoadException(typeof(HotKeyCfgContentResolver).FullName, string.Format(Pulsar.Resources.Exceptions.ContentManager.FormatNotSupportByResolver, assetFileName, typeof(HotKeyCfgContentResolver).FullName)); } } else { throw new ContentLoadException(typeof(HotKeyCfgContentResolver).FullName, string.Format(Pulsar.Resources.Exceptions.ContentManager.FileNameIncorrect, assetFileName)); } return(config); }
private static async void InputService_HotKeyPressed(object sender, HotKey hotKey) { if (ChannelSession.Settings.HotKeys.ContainsKey(hotKey.ToString())) { HotKeyConfiguration hotKeyConfiguration = ChannelSession.Settings.HotKeys[hotKey.ToString()]; await ChannelSession.Services.Command.Queue(hotKeyConfiguration.CommandID); } }
private static async void InputService_HotKeyPressed(object sender, HotKey hotKey) { if (ChannelSession.Settings.HotKeys.ContainsKey(hotKey.ToString())) { HotKeyConfiguration hotKeyConfiguration = ChannelSession.Settings.HotKeys[hotKey.ToString()]; CommandBase command = ChannelSession.AllCommands.FirstOrDefault(c => c.ID.Equals(hotKeyConfiguration.CommandID)); if (command != null) { await command.Perform(); } } }
private static async void InputService_HotKeyPressed(object sender, HotKey hotKey) { if (ChannelSession.Settings.HotKeys.ContainsKey(hotKey.ToString())) { HotKeyConfiguration hotKeyConfiguration = ChannelSession.Settings.HotKeys[hotKey.ToString()]; CommandModelBase command = ChannelSession.Settings.GetCommand(hotKeyConfiguration.CommandID); if (command != null) { await command.Perform(); } } }
public void Init() { if (Directory.Exists(path + "/" + application)) { string[] files = Directory.GetFiles(path + "/" + application); if (files.Length > 0) { foreach (string file in files) { File.Delete(file); } } } if (!Directory.Exists("Content")) { Directory.CreateDirectory("Content"); } this._graphics = new GraphicsConfiguration(); this._graphics.BitsPerPixel = 32; this._graphics.IsMouseVisible = true; this._graphics.IsVerticalSync = false; this._graphics.Resolution = new Resolution(800, 600); this._graphics.Styles = Styles.Default; this._graphics.IsLightEngineActive = false; this._graphics.IsParticuleEngineActive = false; this._audio = new AudioConfiguration(); this._audio.FadeMusic = false; this._audio.FxVolume = 0f; this._audio.MasterVolume = 0f; this._audio.MaxSounds = 0; this._audio.MusicVolume = 0f; this._audio.Mute = true; this._game = new GameConfiguration(); this._game.Culture = CultureInfo.CurrentCulture.Name; this._game.Skin = string.Empty; this._game.SkinFont = string.Empty; this._hotKeys = new HotKeyConfiguration(); SerializerHelper.Save("Content/graphics.xml", this._graphics); SerializerHelper.Save("Content/audio.xml", this._audio); SerializerHelper.Save("Content/game.xml", this._game); SerializerHelper.Save("Content/keys.xml", this._hotKeys); }
private async void AddHotKeyButton_Click(object sender, RoutedEventArgs e) { await this.Window.RunAsyncOperation(async() => { if (this.CommandNameComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("A command must be selected"); return; } CommandBase command = (CommandBase)this.CommandNameComboBox.SelectedItem; if (this.KeyComboBox.SelectedIndex < 0) { await MessageBoxHelper.ShowMessageDialog("A hot key configuration must be set"); return; } HotKeyModifiersEnum modifiers = HotKeyModifiersEnum.None; if (this.ShiftCheckBox.IsChecked.GetValueOrDefault()) { modifiers |= HotKeyModifiersEnum.Shift; } if (this.ControlCheckBox.IsChecked.GetValueOrDefault()) { modifiers |= HotKeyModifiersEnum.Control; } if (this.AltCheckBox.IsChecked.GetValueOrDefault()) { modifiers |= HotKeyModifiersEnum.Alt; } HotKeyConfiguration hotKey = new HotKeyConfiguration(modifiers, EnumHelper.GetEnumValueFromString <InputKeyEnum>((string)this.KeyComboBox.SelectedItem), command.ID); ChannelSession.Settings.HotKeys[hotKey.ToString()] = hotKey; ChannelSession.Services.InputService.RegisterHotKey(hotKey.Modifiers, hotKey.Key); this.RefreshList(); }); }
public void Init() { if (Directory.Exists(path + "/" + application)) { string[] files = Directory.GetFiles(path + "/" + application); if (files.Length > 0) { foreach (string file in files) { File.Delete(file); } } } if (!Directory.Exists("Content")) { Directory.CreateDirectory("Content"); } this._graphics = new GraphicsConfiguration(); this._graphics.BitsPerPixel = 32; this._graphics.IsMouseVisible = true; this._graphics.IsVerticalSync = false; this._graphics.Resolution = new Resolution(800, 600); this._graphics.Styles = Styles.Default; this._graphics.IsLightEngineActive = false; this._graphics.IsParticuleEngineActive = false; this._audio = new AudioConfiguration(); this._audio.FadeMusic = false; this._audio.FxVolume = 0f; this._audio.MasterVolume = 0f; this._audio.MaxSounds = 0; this._audio.MusicVolume = 0f; this._audio.Mute = true; this._game = new GameConfiguration(); this._game.Culture = CultureInfo.CurrentCulture.Name; this._game.Skin = string.Empty; this._hotKeys = new HotKeyConfiguration(); this._language = new Language(); this._language.Key = CultureInfo.CurrentCulture.Name; this._language.Name = CultureInfo.CurrentCulture.NativeName; FunctionTranslation func = new FunctionTranslation(); func.Key = "DEFAULT"; Translation trans = new Translation(); trans.Key = "HELLO_WORLD"; trans.Value = "Bonjour le monde !"; func.Translations.Add(trans); this._language.Functions.Add(func); SerializerHelper.Save("Content/graphics.xml", this._graphics); SerializerHelper.Save("Content/audio.xml", this._audio); SerializerHelper.Save("Content/game.xml", this._game); SerializerHelper.Save("Content/keys.xml", this._hotKeys); SerializerHelper.Save("Content/" + this._language.Key + ".xml", this._language); }
public HotKeyUI(HotKeyConfiguration hotKey, CommandBase command) { this.HotKey = hotKey; this.Command = command; }