/// <summary> /// Adiciona um separador de chat com todas as suas mensagens /// <para>Se o separador já existir não adiciona.</para> /// </summary> /// <param name="displayName">Nome a mostrar no título do separador</param> /// <param name="displayId">Id a mostrar no titulo do separador</param> /// <param name="idName">Id a colocar no Name (identificador) do separador</param> private void AddSeparadorChat(string displayName, string displayId, string idName) { string tabHeader = displayId == null ? displayName : $"{displayName} ({displayId})"; bool existeTabIgual = false; TabItems.ForEach(tab => { if ((string)tab.Header != tabHeader) { return; } existeTabIgual = true; }); if (existeTabIgual) { return; } ChatTabControl.DataContext = null; int count = TabItems.Count; TabItem novaTabItem = new TabItem { Header = tabHeader, Name = idName, HeaderTemplate = ChatTabControl.FindResource("TabHeader") as DataTemplate }; ScrollViewer chatScrollViewer = new ScrollViewer { Name = $"{idName}ScrollViewer" }; ItemsControl chatItemsControl = new ItemsControl(); StackPanel chatStackPanel = new StackPanel { Name = $"{idName}StackPanel" }; chatItemsControl.Items.Add(chatStackPanel); chatScrollViewer.Content = chatItemsControl; novaTabItem.Content = chatScrollViewer; TabItems.Insert(count, novaTabItem); ChatTabControl.DataContext = TabItems; ChatTabControl.SelectedItem = novaTabItem; if (idName == "id0") { return; } MainViewModel.ServerConnectService.EntrarChat(idName); }
public MainWindowViewModel() { this.Title = AppProductInfo.Title; this.Settings = new SettingsViewModel(); this.CompositeDisposable.Add(new PropertyChangedEventListener(StatusService.Current) { { () => StatusService.Current.Message, (sender, args) => this.StatusMessage = StatusService.Current.Message }, }); this.CompositeDisposable.Add(new PropertyChangedEventListener(KanColleClient.Current) { { () => KanColleClient.Current.IsStarted, (sender, args) => this.UpdateMode() }, { () => KanColleClient.Current.IsInSortie, (sender, args) => this.UpdateMode() }, }); this._browser = new BrowserViewModel(); this.UpdateMode(); Models.Settings.Current.PropertyChanged += (_, __) => this.UpdateLayout(Models.Settings.Current.LRSplit); Fiddler.FiddlerApplication.OnReadResponseBuffer += (_, e) => DownloadActive = true; Fiddler.FiddlerApplication.OnReadRequestBuffer += (_, e) => UploadActive = true; Fiddler.FiddlerApplication.BeforeRequest += _ => { System.Threading.Interlocked.Increment(ref _outstandingRequests); RaisePropertyChanged(nameof(OutstandingRequests)); }; Fiddler.FiddlerApplication.BeforeResponse += _ => { System.Threading.Interlocked.Decrement(ref _outstandingRequests); RaisePropertyChanged(nameof(OutstandingRequests)); }; Fiddler.FiddlerApplication.BeforeReturningError += _ => { if (_.responseCode == 408) { return; } System.Threading.Interlocked.Decrement(ref _outstandingRequests); RaisePropertyChanged(nameof(OutstandingRequests)); }; this.Ships = new ShipsViewModel(); this.SlotItems = new SlotItemsViewModel(); this.Admiral = new AdmiralViewModel(this); this.Materials = new MaterialsViewModel(); this.Fleets = new FleetsViewModel(); this.Shipyard = new ShipyardViewModel(); this.Quests = new QuestsViewModel(); this.Expeditions = new ExpeditionsViewModel(this.Fleets); this.TabItems = new ObservableCollection <TabItemViewModel> { StartContentViewModel.Instance, new OverviewViewModel(this), this.Fleets, this.Shipyard, this.Quests, this.Expeditions, new ToolsViewModel(), new SettingsViewModel(), #region DEBUG #if false new DebugTabViewModel(), #endif #endregion }; if (_mini = Models.Settings.Current.MiniLayout) { TabItems.Insert(0, _browser); } this.SelectedItem = this.TabItems.FirstOrDefault(); }