private void OnAuthorDeleted(User author, ChatRoom room, User by) { var chatRoom = _chatRooms.First(r => r.Room == room); chatRoom .Users .Remove(author); chatRoom.Messages.Add(new ChatMessage { Body = LocalizedStrings.Str3208Params.Put(author.Name), CreationDate = TimeHelper.Now, }); }
public DiagramShapeViewModelBase CreateViewModel(IDiagramShape diagramShape, bool isDescriptionVisible) { if (diagramShape is IDiagramNode) { return(new DiagramNodeViewModel(Diagram, (IDiagramNode)diagramShape, isDescriptionVisible)); } if (diagramShape is IDiagramConnector) { var diagramConnector = (IDiagramConnector)diagramShape; var sourceNode = _diagramNodeViewModels.First(i => i.DiagramShape == diagramConnector.Source); var targetNode = _diagramNodeViewModels.First(i => i.DiagramShape == diagramConnector.Target); return(new DiagramConnectorViewModel(Diagram, diagramConnector, sourceNode, targetNode)); } throw new NotImplementedException(); }
public SkillBreakdownViewModel(PlayerInfo playerInfo) { ComboBoxEntities = new ThreadSafeObservableCollection <ComboBoxEntity> { new ComboBoxEntity(SkillViewType.FlatView, "Flat View"), new ComboBoxEntity(SkillViewType.AggregatedSkillIdView, "Aggregate by Id"), new ComboBoxEntity(SkillViewType.AggregatedSkillNameView, "Aggregate by Name") }; //NOTE: These are duplicated in the xaml because of a wpf bug SortDescriptionMappings = new Dictionary <SkillViewType, IList <SortDescription> > { { SkillViewType.FlatView, new List <SortDescription> { new SortDescription(nameof(SkillResult.Time), ListSortDirection.Ascending) } }, { SkillViewType.AggregatedSkillIdView, new List <SortDescription> { new SortDescription(nameof(AggregatedSkillResult.Amount), ListSortDirection.Descending) } }, { SkillViewType.AggregatedSkillNameView, new List <SortDescription> { new SortDescription(nameof(AggregatedSkillResult.Amount), ListSortDirection.Descending) } } }; //set the intial view var initialView = SkillViewType.AggregatedSkillNameView; SortDescriptionSource = SortDescriptionMappings[initialView]; SelectedCollectionView = ComboBoxEntities.First(cbe => cbe.Key == initialView); PlayerInfo = playerInfo; SkillLog = PlayerInfo.SkillLog; //subscribe to future changes and invoke manually SkillLog.CollectionChanged += (sender, args) => { UpdateAggregatedSkillLogs(args.NewItems.Cast <SkillResult>()); CasualMessenger.Instance.Messenger.Send(new ScrollPlayerStatsMessage(), this); }; UpdateAggregatedSkillLogs(SkillLog); }
public MainWindow() { ConfigManager.RegisterService(_portfolios); Orders = new ObservableCollection <Order>(); InitializeComponent(); Loaded += OnLoaded; Chart.OrderSettings.Security = _security; Chart.OrderSettings.Portfolio = _portfolios.First(); Chart.OrderSettings.Volume = 5; _chartUpdateTimer.Interval = TimeSpan.FromMilliseconds(100); _chartUpdateTimer.Tick += ChartUpdateTimerOnTick; _chartUpdateTimer.Start(); }
/// <summary> /// Adds all albums to <see cref="AlbumCollection"/>. /// </summary> /// <remarks>This is still experimental, a lot of performance improvements are needed. /// For instance, for each loop needs to be removed. /// Maybe we can use direct database queries and fill the AlbumCollection with it? /// </remarks> public void AddAlbums() { foreach (var song in LibVM.TracksCollection.Elements) { Album alb = null; if (!AlbumCollection.Any(t => t.AlbumName == song.Album && t.Artist == song.LeadArtist)) { alb = new Album(); alb.AlbumName = song.Album; alb.Artist = song.LeadArtist; alb.AlbumArt = song.AttachedPicture; AlbumCollection.Add(alb); } else { AlbumCollection.First(t => t.AlbumName == song.Album && t.Artist == song.LeadArtist).AlbumSongs.Add(song); } } }
private void ConnectClick(object sender, RoutedEventArgs e) { if (_connector == null) { if (IsQuik.IsChecked == true) { var isDde = IsDde.IsChecked == true; if (isDde && Path.Text.IsEmpty()) { MessageBox.Show(this, LocalizedStrings.Str2969); return; } // создаем подключение var trader = new QuikTrader(Path.Text) { IsDde = isDde }; if (isDde) { // изменяем метаданные так, чтобы начали обрабатывать дополнительные колонки опционов var columns = trader.SecuritiesTable.Columns; columns.Add(DdeSecurityColumns.Strike); columns.Add(DdeSecurityColumns.ImpliedVolatility); columns.Add(DdeSecurityColumns.UnderlyingSecurity); columns.Add(DdeSecurityColumns.TheorPrice); columns.Add(DdeSecurityColumns.OptionType); columns.Add(DdeSecurityColumns.ExpiryDate); } _connector = trader; } else { var trader = new PlazaTrader { Address = Address.Text.To <EndPoint>(), IsCGate = IsCGate.IsChecked == true }; trader.Tables.Add(trader.TableRegistry.Volatility); if (IsAutorization.IsChecked == true) { trader.Login = Login.Text; trader.Password = Password.Password; } _connector = trader; } Desk.MarketDataProvider = _connector; Desk.SecurityProvider = _connector; Desk.CurrentTime = null; // добавляем в выпадающий список только фьючерсы _connector.NewSecurities += securities => this.GuiAsync(() => { _assets.AddRange(securities.Where(s => s.Type == SecurityTypes.Future)); if (SelectedAsset == null && _assets.Count > 0) { SelectedAsset = _assets.First(); } if (SelectedAsset != null) { var newStrikes = securities .Where(s => s.Type == SecurityTypes.Option && s.UnderlyingSecurityId.CompareIgnoreCase(SelectedAsset.Id)) .ToArray(); if (newStrikes.Length > 0) { _options.AddRange(newStrikes); Desk.Options = _options; Desk.RefreshOptions(); } } }); _connector.SecuritiesChanged += securities => { this.GuiAsync(() => { if (SelectedAsset == null) { return; } var newStrikes = securities .Where(s => s.Type == SecurityTypes.Option && s.UnderlyingSecurityId.CompareIgnoreCase(SelectedAsset.Id)) .Where(s => !_options.Contains(s)) .ToArray(); if (newStrikes.Length > 0) { _options.AddRange(newStrikes); Desk.Options = _options; Desk.RefreshOptions(); } if (Desk.Options.Intersect(securities).Any()) { Desk.RefreshOptions(); } }); }; // подписываемся на событие новых сделок чтобы обновить текущую цену фьючерса _connector.NewTrades += trades => this.GuiAsync(() => { var asset = SelectedAsset; if (asset == null) { return; } if (asset.LastTrade != null) { LastPrice.Text = asset.LastTrade.Price.To <string>(); } }); _connector.Connected += () => { var trader = _connector as QuikTrader; if (trader != null && trader.IsDde) { var quikTrader = trader; quikTrader.StartExport(new[] { quikTrader.SecuritiesTable, quikTrader.TradesTable }); } else { _connector.StartExport(); } }; } if (_connector.ConnectionState == ConnectionStates.Connected) { _connector.Disconnect(); } else { _connector.Connect(); } }
public SkillBreakdownViewModel(PlayerInfo playerInfo) { ComboBoxEntities = new ThreadSafeObservableCollection<ComboBoxEntity> { new ComboBoxEntity(SkillViewType.FlatView, "Flat View"), new ComboBoxEntity(SkillViewType.AggregatedSkillIdView, "Aggregate by Id"), new ComboBoxEntity(SkillViewType.AggregatedSkillNameView, "Aggregate by Name") }; //NOTE: These are duplicated in the xaml because of a wpf bug SortDescriptionMappings = new Dictionary<SkillViewType, IList<SortDescription>> { { SkillViewType.FlatView, new List<SortDescription> { new SortDescription(nameof(SkillResult.Time), ListSortDirection.Ascending) } }, { SkillViewType.AggregatedSkillIdView, new List<SortDescription> { new SortDescription(nameof(AggregatedSkillResult.Amount), ListSortDirection.Descending) } }, { SkillViewType.AggregatedSkillNameView, new List<SortDescription> { new SortDescription(nameof(AggregatedSkillResult.Amount), ListSortDirection.Descending) } } }; //set the intial view var initialView = SkillViewType.AggregatedSkillNameView; SortDescriptionSource = SortDescriptionMappings[initialView]; SelectedCollectionView = ComboBoxEntities.First(cbe => cbe.Key == initialView); PlayerInfo = playerInfo; SkillLog = PlayerInfo.SkillLog; //subscribe to future changes and invoke manually SkillLog.CollectionChanged += (sender, args) => { PopulateAggregatedSkillLogs(); CasualMessenger.Instance.Messenger.Send(new ScrollPlayerStatsMessage(), this); }; PopulateAggregatedSkillLogs(); }