public SettingsChatItemViewModel(ChatConfig config) { chatDataService = ServiceLocator.Current.GetInstance <IChatDataService>(); chatConfig = config; _enabled = config.Enabled; _name = config.ChatName; _iconURL = config.IconURL ?? _iconURL; chat = chatDataService.GetChat(config.ChatName); if (chat != null) { _status = chat.Status; } foreach (var param in config.Parameters) { if (param.IsVisible) { SettingsFields.Add( new SettingsFieldViewModel(param) ); } } }
public void Initialize() { //watch Ctrl down to switch click-through #if !DEBUG keyboardListener = new KeyboardListener(); keyboardListener.KeyDown += keyboardListener_KeyDown; keyboardListener.KeyUp += keyboardListener_KeyUp; #endif if (AppConfig.IsReplyBoxPersistent) { IsOverlayVisible = true; SendTextEditMode = true; } AppConfig.PropertyChanged += AppConfig_PropertyChanged; Win.ShowStatus(); EnableMouseTransparency = AppConfig.MouseTransparency && Keyboard.Modifiers != ModifierKeys.Control; _generalDataService.Start(); ChannelList = _dataService.ChatChannels; SelectedChatChannel = ChannelList[0]; MessengerInstance.Register <bool>(this, "ReopenMainWindow", (message) => { if (message) { IsWindowReopen = true; } }); MessengerInstance.Register <ChatMessage>(this, "SetChannel", (message) => { SelectedChatChannel = ChannelList.FirstOrDefault(channel => channel.ChatName == message.ChatName && channel.ChannelName == message.Channel) ?? ChannelList[0]; }); MessengerInstance.Register <ChatMessage>(this, "SetReplyTo", (message) => { SelectedChatChannel = ChannelList.FirstOrDefault(channel => channel.ChatName == message.ChatName && channel.ChannelName == message.Channel) ?? ChannelList[0]; ReplyCarretPos = 0; SendText = message.FromUserName + ", "; ReplyCarretPos = Int32.MaxValue; }); var steamChat = _dataService.GetChat(SettingsRegistry.ChatTitleSteam); if (steamChat != null) { steamChat.RequestData = (what) => { if (what.Equals("SteamGuardCode", StringComparison.InvariantCultureIgnoreCase)) { UI.Dispatch(() => { steamGuardWindow.Show(); }); } return(null); }; } }