Exemple #1
0
 public SafeReaderWriterEnumerator(ThreadSafeObservableCollection <T> inner, ReaderWriterLockSlim @lock)
 {
     m_lock = @lock;
     // entering lock in constructor
     m_lock.EnterReadLock();
     m_Inner = inner.GetEnumerator();
 }
Exemple #2
0
        public ThreadSafeObservableCollection <Mediafile> ShuffledCollection()
        {
            var shuffled = new ThreadSafeObservableCollection <Mediafile>(LibVM.TracksCollection.Elements);

            shuffled.Shuffle();
            return(shuffled);
        }
Exemple #3
0
        /// <summary>
        /// Loads library from the database file.
        /// </summary>
        void LoadLibrary()
        {
            if (File.Exists(ApplicationData.Current.LocalFolder.Path + @"\library.db"))
            {
                OldItems           = db.GetTracks().ToList();
                TracksCollection   = new GroupedObservableCollection <string, Mediafile>(t => t.Title, OldItems, t => t.Title);
                PlaylistCollection = new ThreadSafeObservableCollection <Playlist>(OldItems.SelectMany(t => t.Playlists).DistinctBy(t => t.Name).ToList());

                Options.Add(new ContextMenuCommand(AddToPlaylistCommand, "New Playlist"));
                foreach (var list in PlaylistCollection)
                {
                    var cmd = new ContextMenuCommand(AddToPlaylistCommand, list.Name);
                    Options.Add(cmd);
                    var Playlists = new Dictionary <Playlist, IEnumerable <Mediafile> >();
                    Playlists.Add(list, db.PlaylistSort(list.Name));
                    ShellVM.PlaylistsItems.Add(new SplitViewMenu.SimpleNavMenuItem
                    {
                        Arguments       = Playlists,
                        Label           = list.Name,
                        DestinationPage = typeof(PlaylistView),
                        Symbol          = Symbol.List
                    });
                    GC.Collect();
                }
            }
            else
            {
                PlaylistCollection = new ThreadSafeObservableCollection <Playlist>();
            }
        }
Exemple #4
0
        private void UpdateProvider(ISecurityProvider provider)
        {
            if (_securityProvider == provider)
            {
                return;
            }

            if (_securityProvider != null)
            {
                _securityProvider.Added   -= AddSecurities;
                _securityProvider.Removed -= RemoveSecurities;
                _securityProvider.Cleared -= ClearSecurities;

                SecurityTextBox.ItemsSource = Enumerable.Empty <Security>();
                _itemsSource = null;
            }

            _securityProvider = provider;

            if (_securityProvider == null)
            {
                return;
            }

            var itemsSource = new ObservableCollectionEx <Security>();

            _itemsSource = new ThreadSafeObservableCollection <Security>(itemsSource);
            _itemsSource.AddRange(_securityProvider.LookupAll());

            _securityProvider.Added   += AddSecurities;
            _securityProvider.Removed += RemoveSecurities;
            _securityProvider.Cleared += ClearSecurities;

            SecurityTextBox.ItemsSource = itemsSource;
        }
 public void Constructor_WithNoParameters()
 {
     object sut = null;
     Assert.DoesNotThrow(() => sut = new ThreadSafeObservableCollection<TestPCB>());
     var actual = sut as ThreadSafeObservableCollection<TestPCB>;
     Assert.IsNotNull(actual, "Object is null");
 }
        public DiagramViewportViewModel(
            IModelService modelService,
            IDiagramService diagramService,
            IDiagramShapeUiFactory diagramShapeUiFactory,
            double minZoom,
            double maxZoom,
            double initialZoom)
            : base(modelService, diagramService)
        {
            MinZoom = minZoom;
            MaxZoom = maxZoom;

            _diagramNodeToViewModelMap      = new Map <ModelNodeId, DiagramNodeViewModel>();
            _diagramConnectorToViewModelMap = new Map <ModelRelationshipId, DiagramConnectorViewModel>();

            _diagramShapeUiFactory = diagramShapeUiFactory;
            _diagramShapeUiFactory.Initialize(modelService, this);

            ViewportCalculator         = new AutoMoveViewportViewModel(modelService, diagramService, minZoom, maxZoom, initialZoom);
            DiagramNodeViewModels      = new ThreadSafeObservableCollection <DiagramNodeViewModel>();
            DiagramConnectorViewModels = new ThreadSafeObservableCollection <DiagramConnectorViewModel>();
            MiniButtonPanelViewModel   = new MiniButtonPanelViewModel();

            DiagramNodeDoubleClickedCommand = new DelegateCommand <IDiagramNode>(i => DiagramNodeInvoked?.Invoke(i));

            ViewportCalculator.TransformChanged += OnViewportTransformChanged;
            DiagramService.DiagramChanged       += OnDiagramChanged;

            AddDiagram(diagramService.LatestDiagram);
        }
Exemple #7
0
        public static ThreadSafeObservableCollection <TChild> CopyToChild <T, TChild>(this ThreadSafeObservableCollection <T> Enum) where TChild : class, new()
        {
            T      _t      = (T)Activator.CreateInstance(typeof(T));
            TChild _tChild = (TChild)Activator.CreateInstance(typeof(TChild));

            PropertyInfo[] selfPropertys  = _t.GetType().GetProperties();
            PropertyInfo[] childPropertys = _tChild.GetType().GetProperties();
            ThreadSafeObservableCollection <TChild> ChildEnum = new ThreadSafeObservableCollection <TChild>();

            foreach (T selfItem in Enum)
            {
                TChild childItem = new TChild();
                foreach (var property in selfPropertys)
                {
                    foreach (var childProperty in childPropertys)
                    {
                        if (property.Name == childProperty.Name)
                        {
                            property.SetValue(childItem, property.GetValue(selfItem, null), null);
                        }
                    }
                }
                ChildEnum.Add(childItem);
            }
            return(ChildEnum);
        }
        public async void StopAfter(object path)
        {
            Mediafile mediaFile = null;

            if (path is Mediafile)
            {
                mediaFile             = path as Mediafile;
                isPlayingFromPlaylist = false;
            }
            else if (path is ThreadSafeObservableCollection <Mediafile> )
            {
                mediaFile = (path as ThreadSafeObservableCollection <Mediafile>)[0];
            }
            else if (path is Playlist)
            {
                using (Service.PlaylistService service = new Service.PlaylistService((path as Playlist).Name, (path as Playlist).IsPrivate, (path as Playlist).Password))
                {
                    if (service.IsValid)
                    {
                        var songList = new ThreadSafeObservableCollection <Mediafile>(await service.GetTracks().ConfigureAwait(false));
                        mediaFile = songList[0];
                    }
                }
            }
            else
            {
                return;
            }

            Messenger.Instance.NotifyColleagues(MessageTypes.MSG_STOP_AFTER_SONG, mediaFile);
        }
        private void ButtonRemoveOnlineAccount_Clicked(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                OfxDownloadData ofxData = b.DataContext as OfxDownloadData;

                if (ofxData != null)
                {
                    OnlineAccount oa = ofxData.OnlineAccount;

                    if (oa != null)
                    {
                        MessageBoxResult result = MessageBoxEx.Show("Permanently delete the online account \"" + ofxData.Caption + "\"", null, MessageBoxButton.YesNo);

                        if (result == MessageBoxResult.Yes)
                        {
                            oa.OnDelete();
                            foreach (Account a in myMoney.Accounts.GetAccounts())
                            {
                                if (a.OnlineAccount == oa)
                                {
                                    a.OnlineAccount = null;
                                }
                            }
                        }
                    }

                    ThreadSafeObservableCollection <OfxDownloadData> entries = this.OfxEventTree.ItemsSource as ThreadSafeObservableCollection <OfxDownloadData>;
                    entries.Remove(ofxData);
                }
            }
        }
Exemple #10
0
 private async Task <Mediafile> GetMediafileFromParameterAsync(object path, bool sendUpdateMessage = false)
 {
     if (path is Mediafile)
     {
         isPlayingFromPlaylist = false;
         return(path as Mediafile);
     }
     else if (path is ThreadSafeObservableCollection <Mediafile> )
     {
         SendLibraryLoadedMessage(path as ThreadSafeObservableCollection <Mediafile>, sendUpdateMessage);
         return((path as ThreadSafeObservableCollection <Mediafile>)[0]);
     }
     else if (path is Playlist)
     {
         using (Service.PlaylistService service = new Service.PlaylistService((path as Playlist).Name, (path as Playlist).IsPrivate, (path as Playlist).Password))
         {
             if (service.IsValid)
             {
                 var songList = new ThreadSafeObservableCollection <Mediafile>(await service.GetTracks().ConfigureAwait(false));
                 SendLibraryLoadedMessage(songList, sendUpdateMessage);
                 return(songList[0]);
             }
         }
     }
     return(null);
 }
Exemple #11
0
 public PlaylistsCollectionViewModel()
 {
     Playlists = new ThreadSafeObservableCollection <Playlist>();
     Init();
     Messenger.Instance.Register(Messengers.MessageTypes.MsgAddPlaylist, new Action <Message>(HandleAddPlaylistMessage));
     Messenger.Instance.Register(Messengers.MessageTypes.MsgRemovePlaylist, new Action <Message>(HandleRemovePlaylistMessage));
 }
Exemple #12
0
 public GroupedObservableCollection(Func <TElement, TKey> readKey, IEnumerable <TElement> items, Func <TElement, TKey> orderFunc)
     : this(readKey)
 {
     Elements = new ThreadSafeObservableCollection <TElement>();
     // var ordered = items.OrderBy(orderFunc);
     Elements.AddRange(items);
 }
Exemple #13
0
        public DiagramViewportViewModel(
            [NotNull] IModelEventSource modelEventSource,
            [NotNull] IDiagramEventSource diagramEventSource,
            [NotNull] IDiagramShapeUiFactory diagramShapeUiFactory,
            [NotNull] IDecorationManager <IMiniButton, IDiagramShapeUi> miniButtonManager,
            double minZoom,
            double maxZoom,
            double initialZoom)
            : base(modelEventSource, diagramEventSource)
        {
            MinZoom = minZoom;
            MaxZoom = maxZoom;

            _diagramNodeToViewModelMap      = new Map <ModelNodeId, DiagramNodeViewModel>();
            _diagramConnectorToViewModelMap = new Map <ModelRelationshipId, DiagramConnectorViewModel>();

            DiagramShapeUiFactory    = diagramShapeUiFactory;
            MiniButtonPanelViewModel = (MiniButtonPanelViewModel)miniButtonManager;

            ViewportCalculator         = new AutoMoveViewportViewModel(modelEventSource, diagramEventSource, minZoom, maxZoom, initialZoom);
            DiagramNodeViewModels      = new ThreadSafeObservableCollection <DiagramNodeViewModel>();
            DiagramConnectorViewModels = new ThreadSafeObservableCollection <DiagramConnectorViewModel>();

            DiagramNodeDoubleClickedCommand = new DelegateCommand <IDiagramNode>(i => DiagramNodeInvoked?.Invoke(i));

            ViewportCalculator.TransformChanged += OnViewportTransformChanged;
            DiagramEventSource.DiagramChanged   += OnDiagramChanged;

            AddDiagram(diagramEventSource.LatestDiagram);
        }
Exemple #14
0
        public static async Task RemoveFolder(this StorageLibraryChange change, ThreadSafeObservableCollection <Mediafile> Library, LibraryService LibraryService)
        {
            int successCount = 0;
            List <Mediafile> RemovedMediafiles = new List <Mediafile>();

            //iterate all the files in the library that were in
            //the deleted folder.
            foreach (var mediaFile in await LibraryService.Query(string.IsNullOrEmpty(change.PreviousPath) ? change.Path.ToUpperInvariant() : change.PreviousPath.ToUpperInvariant()))
            {
                //verify that the file was deleted because it can be a false call.
                //we do not want to delete a file that exists.
                if (!SharedLogic.VerifyFileExists(mediaFile.Path, 200))
                {
                    RemovedMediafiles.Add(mediaFile);
                    successCount++;
                }
            }
            if (successCount > 0)
            {
                Library.RemoveRange(RemovedMediafiles);
                await LibraryService.RemoveMediafiles(RemovedMediafiles);

                await SharedLogic.NotificationManager.ShowMessageAsync(string.Format("{0} Mediafiles Removed. Folder Path: {1}", successCount, change.Path), 5);
            }
        }
		private void UpdateProvider(ISecurityProvider provider)
		{
			if (_securityProvider == provider)
				return;

			if (_securityProvider != null)
			{
				_securityProvider.Added -= AddSecurities;
				_securityProvider.Removed -= RemoveSecurities;
				_securityProvider.Cleared -= ClearSecurities;

				SecurityTextBox.ItemsSource = Enumerable.Empty<Security>();
				_itemsSource = null;
			}

			_securityProvider = provider;

			if (_securityProvider == null)
				return;

			var itemsSource = new ObservableCollectionEx<Security>();

			_itemsSource = new ThreadSafeObservableCollection<Security>(itemsSource);
			_itemsSource.AddRange(_securityProvider.LookupAll());

			_securityProvider.Added += AddSecurities;
			_securityProvider.Removed += RemoveSecurities;
			_securityProvider.Cleared += ClearSecurities;

			SecurityTextBox.ItemsSource = itemsSource;
		}
Exemple #16
0
		public MainWindow()
		{
			InitializeComponent();

			var assetsSource = new ObservableCollectionEx<Security>();
			var optionsSource = new ObservableCollectionEx<Security>();

			Options.ItemsSource = optionsSource;
			Assets.ItemsSource = assetsSource;

			_assets = new ThreadSafeObservableCollection<Security>(assetsSource);
			_options = new ThreadSafeObservableCollection<Security>(optionsSource);

			// попробовать сразу найти месторасположение Quik по запущенному процессу
			Path.Text = QuikTerminal.GetDefaultPath();

			var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(5) };
			timer.Tick += (sender, args) =>
			{
				if (!_isDirty)
					return;

				_isDirty = false;
				RefreshChart();
			};
			timer.Start();

			//
			// добавляем тестовый данные для отображения графика

			var asset = new Security { Id = "RIM4@FORTS" };

			Connector = new FakeConnector(new[] { asset });

			PosChart.AssetPosition = new Position
			{
				Security = asset,
				CurrentValue = -1,
			};

			PosChart.MarketDataProvider = Connector;
			PosChart.SecurityProvider = Connector;

			var expDate = new DateTime(2014, 6, 14);

			PosChart.Positions.Add(new Position
			{
				Security = new Security { Code = "RI C 110000", Strike = 110000, ImpliedVolatility = 45, OptionType = OptionTypes.Call, ExpiryDate = expDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id },
				CurrentValue = 10,
			});
			PosChart.Positions.Add(new Position
			{
				Security = new Security { Code = "RI P 95000", Strike = 95000, ImpliedVolatility = 30, OptionType = OptionTypes.Put, ExpiryDate = expDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id },
				CurrentValue = -3,
			});

			PosChart.Refresh(100000, 10, new DateTime(2014, 5, 5), expDate);

			Instance = this;
		}
Exemple #17
0
        private async void HandleExecuteCmdMessage(Message message)
        {
            if (message.Payload == null)
            {
                return;
            }

            if (message.Payload is List <object> list)
            {
                double volume = 0;
                if ((double)list[3] == 50.0)
                {
                    volume = SettingsHelper.GetLocalSetting <double>("volume", 50.0);
                }
                else
                {
                    volume = (double)list[3];
                }
                Mediafile libraryMediaFile = null;
                if (list[0] is IReadOnlyList <IStorageItem> files)
                {
                    List <Mediafile> mediafileList = new List <Mediafile>(files.Count);
                    foreach (IStorageItem item in files)
                    {
                        if (item.IsOfType(StorageItemTypes.File))
                        {
                            mediafileList.Add(await TagReaderHelper.CreateMediafile(item as StorageFile));
                        }
                    }
                    NowPlayingQueue = new ThreadSafeObservableCollection <Mediafile>();
                    NowPlayingQueue.AddRange(mediafileList);
                    libraryMediaFile = NowPlayingQueue[0];
                }
                else
                {
                    var id = SettingsHelper.GetLocalSetting <long>("NowPlayingID", 0L);
                    libraryMediaFile = _service.GetMediafile(id);
                    if (libraryMediaFile == null)
                    {
                        var path = SettingsHelper.GetLocalSetting <string>("path", null);
                        if (path != null)
                        {
                            if (await Task.Run(() => File.Exists(path)))
                            {
                                libraryMediaFile = await TagReaderHelper.CreateMediafile(await StorageFile.GetFileFromPathAsync(path));
                            }
                        }
                    }
                }

                await Load(libraryMediaFile, (bool)list[2], (double)list[1], volume);
            }
            else
            {
                GetType().GetTypeInfo().GetDeclaredMethod(message.Payload as string)?.Invoke(this, new object[] { });
            }

            message.HandledStatus = MessageHandledStatus.HandledCompleted;
        }
Exemple #18
0
 protected Log(LogConfiguration config, ExceptionWriter writer)
 {
     ThrowHelper.IfNullThenThrow(()=>config);
     LogItems = new ThreadSafeObservableCollection<LogEntry>();
     LogEntries = new ThreadSafeObservableCollection<string>();
     _configuration = config;
     Writer = writer;
 }
Exemple #19
0
 public AggregatedSkillResult(string displayName, bool isHeal, AggregationType type, ThreadSafeObservableCollection <SkillResult> skillLog)
 {
     DisplayName                 = displayName;
     IsHeal                      = isHeal;
     AggregationType             = type;
     SkillLog                    = skillLog;
     SkillLog.CollectionChanged += SkillLog_CollectionChanged;
 }
Exemple #20
0
 public MainViewModel()
 {
     Posts         = new ThreadSafeObservableCollection <Post>();
     Notifications = new ThreadSafeObservableCollection <Notification>();
     Circles       = new ThreadSafeObservableCollection <KeyValuePair <string, string> >();
     Circles.Add(new KeyValuePair <string, string>("Main", "1"));
     InYourCircles = new ThreadSafeObservableCollection <KeyValuePair <string, string> >();
 }
Exemple #21
0
        private async void Initiate()
        {
            var deviceWatcher = DeviceInformation.CreateWatcher(StorageDevice.GetDeviceSelector());

            deviceWatcher.Start();
            deviceWatcher.Added += DeviceWatcher_Added;
            Devices              = new ThreadSafeObservableCollection <DeviceInformation>(await GetDevices());
        }
		public CandlesWindow()
		{
			InitializeComponent();

			var candlesSource = new ObservableCollectionEx<QuikCandle>();
			CandleDetails.ItemsSource = candlesSource;
			Candles = new ThreadSafeObservableCollection<QuikCandle>(candlesSource);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="PortfolioPickerWindow"/>.
		/// </summary>
		public PortfolioPickerWindow()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<Portfolio>();
			PortfoliosCtrl.ItemsSource = itemsSource;
			Portfolios = new ThreadSafeObservableCollection<Portfolio>(itemsSource);
		}
 public MainWindow()
 {
     InitializeComponent();
     DataContext = this;
     ListNode    = new ThreadSafeObservableCollection <Node>();
     ListNode.CollectionChanged += ListNode_CollectionChanged;
     TestSql.Test();
 }
Exemple #25
0
        public static void InitializeNonAsync(MembersContainer container)
        {
            Members = new ThreadSafeObservableCollection<MemberViewModel>();

            PopulateMembersCollectionTask(container);

            container.SavingChanges += (s, o) => RefreshMembersListTask(container.ObjectStateManager);
        }
Exemple #26
0
        public MainWindow()
        {
            InitializeComponent();

            var assetsSource = new ObservableCollectionEx <Security>();

            Assets.ItemsSource = assetsSource;
            _assets            = new ThreadSafeObservableCollection <Security>(assetsSource);

            // попробовать сразу найти месторасположение Quik по запущенному процессу
            Path.Text = QuikTerminal.GetDefaultPath();

            //
            // добавляем тестовый данные для отображения доски опционов

            var asset = new Security {
                Id = "RIU4@FORTS", LastTrade = new Trade {
                    Price = 56000
                }
            };

            var connector = new FakeConnector(new[] { asset });

            var expiryDate = new DateTime(2014, 09, 15);

            Desk.MarketDataProvider = connector;
            Desk.SecurityProvider   = connector;
            Desk.CurrentTime        = new DateTime(2014, 08, 15);

            Desk.Options = new[]
            {
                CreateStrike(05000, 10, 122, OptionTypes.Call, expiryDate, asset, 100),
                CreateStrike(10000, 10, 110, OptionTypes.Call, expiryDate, asset, 343),
                CreateStrike(15000, 10, 100, OptionTypes.Call, expiryDate, asset, 3454),
                CreateStrike(20000, 78, 85, OptionTypes.Call, expiryDate, asset, null),
                CreateStrike(25000, 32, 65, OptionTypes.Call, expiryDate, asset, 100),
                CreateStrike(30000, 3245, 30, OptionTypes.Call, expiryDate, asset, 55),
                CreateStrike(35000, 3454, 65, OptionTypes.Call, expiryDate, asset, 456),
                CreateStrike(40000, 34, 85, OptionTypes.Call, expiryDate, asset, 4),
                CreateStrike(45000, 3566, 100, OptionTypes.Call, expiryDate, asset, 67),
                CreateStrike(50000, 454, 110, OptionTypes.Call, expiryDate, asset, null),
                CreateStrike(55000, 10, 122, OptionTypes.Call, expiryDate, asset, 334),

                CreateStrike(05000, 10, 122, OptionTypes.Put, expiryDate, asset, 100),
                CreateStrike(10000, 10, 110, OptionTypes.Put, expiryDate, asset, 343),
                CreateStrike(15000, 6788, 100, OptionTypes.Put, expiryDate, asset, 3454),
                CreateStrike(20000, 10, 85, OptionTypes.Put, expiryDate, asset, null),
                CreateStrike(25000, 567, 65, OptionTypes.Put, expiryDate, asset, 100),
                CreateStrike(30000, 4577, 30, OptionTypes.Put, expiryDate, asset, 55),
                CreateStrike(35000, 67835, 65, OptionTypes.Put, expiryDate, asset, 456),
                CreateStrike(40000, 13245, 85, OptionTypes.Put, expiryDate, asset, 4),
                CreateStrike(45000, 10, 100, OptionTypes.Put, expiryDate, asset, 67),
                CreateStrike(50000, 454, 110, OptionTypes.Put, expiryDate, asset, null),
                CreateStrike(55000, 10, 122, OptionTypes.Put, expiryDate, asset, 334)
            };

            Desk.RefreshOptions();
        }
Exemple #27
0
        public PlayerInfo(Player user, DamageTracker tracker)
        {
            Tracker = tracker;
            Player = user;
            SkillLog = new ThreadSafeObservableCollection<SkillResult>();

            Received = new SkillStats(tracker, SkillLog);
            Dealt = new SkillStats(tracker, SkillLog);
        }
        public MainWindow()
        {
            InitializeComponent();

            var assetsSource  = new ObservableCollectionEx <Security>();
            var optionsSource = new ObservableCollectionEx <Security>();

            Options.ItemsSource = optionsSource;
            Assets.ItemsSource  = assetsSource;

            _assets  = new ThreadSafeObservableCollection <Security>(assetsSource);
            _options = new ThreadSafeObservableCollection <Security>(optionsSource);

            _model     = new OptionDeskModel();
            Desk.Model = _model;

            _putBidSmile   = SmileChart.CreateSmile("Put (B)", Colors.DarkRed);
            _putAskSmile   = SmileChart.CreateSmile("Put (A)", Colors.Red);
            _putLastSmile  = SmileChart.CreateSmile("Put (L)", Colors.OrangeRed);
            _callBidSmile  = SmileChart.CreateSmile("Call (B)", Colors.GreenYellow);
            _callAskSmile  = SmileChart.CreateSmile("Call (A)", Colors.DarkGreen);
            _callLastSmile = SmileChart.CreateSmile("Call (L)", Colors.DarkOliveGreen);

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(5)
            };

            timer.Tick += (sender, args) =>
            {
                if (!_isDirty)
                {
                    return;
                }

                _isDirty = false;

                RefreshSmile();
                RefreshChart();
            };
            timer.Start();

            Level1FieldsCtrl.ItemsSource = new[]
            {
                Level1Fields.ImpliedVolatility,
                Level1Fields.Delta,
                Level1Fields.Gamma,
                Level1Fields.Vega,
                Level1Fields.Theta,
                Level1Fields.Rho,
            }.ToDictionary(t => t, t => t.GetDisplayName());
            Level1FieldsCtrl.SelectedFields = _model.EvaluateFildes.ToArray();

            Instance = this;

            DrawTestData();
            InitConnector();
        }
Exemple #29
0
        /// <summary>
        /// Asynchronously construct initial list of members from database.
        /// Usually done at program startup.
        /// </summary>
        /// <param name="container"></param>
        public static void Initialize(MembersContainer container)
        {
            Members = new ThreadSafeObservableCollection<MemberViewModel>();

            // do asynchronous update on the list
            new Task(delegate { PopulateMembersCollectionTask(container); }).Start();

            container.SavingChanges += (s, o) => RefreshMembersListTask(container.ObjectStateManager);
        }
Exemple #30
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MyTradeGrid"/>.
		/// </summary>
		public MyTradeGrid()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<MyTrade>();
			ItemsSource = itemsSource;

			_trades = new ThreadSafeObservableCollection<MyTrade>(itemsSource) { MaxCount = 10000 };
		}
Exemple #31
0
        private void SetUpDuplicatedItemsSource(ThreadSafeObservableCollection <TViewModel> viewModels)
        {
            _originalItemsSource = viewModels;
            ((INotifyCollectionChanged)_originalItemsSource).CollectionChanged += OnOriginalCollectionChanged;

            _presentedItemsSource = new ThreadSafeObservableCollection <TViewModel>(_originalItemsSource);

            ItemsSource = _presentedItemsSource;
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="TradeGrid"/>.
		/// </summary>
		public TradeGrid()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<Trade>();
			ItemsSource = itemsSource;

			_trades = new ThreadSafeObservableCollection<Trade>(itemsSource) { MaxCount = 1000000 };
		}
        /// <summary>
        /// Создать <see cref="PortfolioPickerWindow"/>.
        /// </summary>
        public PortfolioPickerWindow()
        {
            InitializeComponent();

            var itemsSource = new ObservableCollectionEx <Portfolio>();

            PortfoliosCtrl.ItemsSource = itemsSource;
            Portfolios = new ThreadSafeObservableCollection <Portfolio>(itemsSource);
        }
Exemple #34
0
        public PlayerInfo(Player user, DamageTracker tracker)
        {
            Tracker  = tracker;
            Player   = user;
            SkillLog = new ThreadSafeObservableCollection <SkillResult>();

            Received = new SkillStats(tracker, SkillLog);
            Dealt    = new SkillStats(tracker, SkillLog);
        }
 public RoutesListViewModel(RobotViewModel robotFace)
 {
     this.robotFace = robotFace;
     AutomaticMode = true;
     Routes = new ThreadSafeObservableCollection<RouteViewModel>();
     newRoutesListener = new SocketListener(2000) {Working = true};
     Refresh();
     SubscribeToEvents();
 }
        public StrategiesWindow()
        {
            InitializeComponent();

            Dashboard.ItemsSource = _items;
            TakeProfit.EditValue  = StopLoss.EditValue = 0m;

            _itemsTs = new ThreadSafeObservableCollection <StrategyItem>(_items);
        }
Exemple #37
0
        public CandlesWindow()
        {
            InitializeComponent();

            var candlesSource = new ObservableCollectionEx <QuikCandle>();

            CandleDetails.ItemsSource = candlesSource;
            Candles = new ThreadSafeObservableCollection <QuikCandle>(candlesSource);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="ExecutionGrid"/>.
		/// </summary>
		public ExecutionGrid()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<ExecutionMessage>();
			ItemsSource = itemsSource;

			_messages = new ThreadSafeObservableCollection<ExecutionMessage>(itemsSource) { MaxCount = 1000000 };
		}
Exemple #39
0
		/// <summary>
		/// Initializes a new instance of the <see cref="OrderLogGrid"/>.
		/// </summary>
		public OrderLogGrid()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<OrderLogItem>();
			ItemsSource = itemsSource;

			_items = new ThreadSafeObservableCollection<OrderLogItem>(itemsSource) { MaxCount = 100000 };
		}
Exemple #40
0
        public Surface()
        {
            InitializeComponent();
            Instance = this;

            tsListener           = new ThreadSafeSquareTuioListener(this, Dispatcher);
            cursors              = new ThreadSafeObservableCollection <TuioCursor>();
            lCursors.ItemsSource = cursors;
        }
Exemple #41
0
		/// <summary>
		/// Создать <see cref="NewsGrid"/>.
		/// </summary>
		public NewsGrid()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<News>();
			ItemsSource = itemsSource;

			_news = new ThreadSafeObservableCollection<News>(itemsSource) { MaxCount = 10000 };
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="Level1Grid"/>.
		/// </summary>
		public Level1Grid()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<Level1ChangeMessage>();
			ItemsSource = itemsSource;

			_messages = new ThreadSafeObservableCollection<Level1ChangeMessage>(itemsSource) { MaxCount = 10000 };
		}
Exemple #43
0
        private void Refresh(String guid, ThreadSafeObservableCollection <UsbDeviceViewModel> deviceList, UsbDeviceViewModel selectedDevice, Action <UsbDeviceViewModel> setSelectedDevice, String deviceId = null, String devicePath = null)
        {
            if (String.IsNullOrEmpty(deviceId) && String.IsNullOrEmpty(devicePath))
            {
                if (selectedDevice != null)
                {
                    deviceId = selectedDevice.DeviceId;
                }
                else if (deviceList.Count > 0)
                {
                    deviceId = deviceList[0].DeviceId;
                }
            }

            deviceList.Clear();

            UsbDevice[] usbDevices = UsbDevice.GetDevices(new Guid(guid));

            List <UsbDeviceViewModel> usbDeviceViewModels = new List <UsbDeviceViewModel>();

            foreach (UsbDevice usbDevice in usbDevices)
            {
                usbDeviceViewModels.Add(new UsbDeviceViewModel(usbDevice));
            }

            deviceList.AddRange(usbDeviceViewModels);

            if (!String.IsNullOrEmpty(deviceId))
            {
                foreach (UsbDeviceViewModel usbDeviceViewModel in deviceList)
                {
                    if (usbDeviceViewModel.DeviceId.Equals(deviceId, StringComparison.CurrentCultureIgnoreCase))
                    {
                        setSelectedDevice(usbDeviceViewModel);
                        return;
                    }
                }
            }

            if (!String.IsNullOrEmpty(devicePath))
            {
                foreach (UsbDeviceViewModel usbDeviceViewModel in deviceList)
                {
                    if (usbDeviceViewModel.DevicePath.Equals(devicePath, StringComparison.CurrentCultureIgnoreCase))
                    {
                        setSelectedDevice(usbDeviceViewModel);
                        return;
                    }
                }
            }

            if (deviceList.Count > 0)
            {
                setSelectedDevice(deviceList[0]);
            }
        }
 public JobMonitor(SocketListener <DataHolder> socketListener, ThreadSafeObservableCollection <ClientInfo> connectedClientInfo)
 {
     this.SocketListener                     = socketListener;
     this.ManagedJobInfo                     = new ThreadSafeObservableCollection <JobInfo>();
     this.ReadOnlyManagedJobInfo             = new ReadOnlyObservableCollection <JobInfo>(this.ManagedJobInfo);
     this.ManagedJobInfo.CollectionChanging += this.ManagedJobInfo_CollectionChanging;
     this.ManagedJobInfo.CollectionChanged  += this.ManagedJobInfo_CollectionChanged;
     this.SocketListener.OnDataReceived     += this.SocketListener_OnDataReceived;
     this.ConnectedClientInfo                = connectedClientInfo;
 }
        public ContextViewModel(IssueRepository allissues, User user)
        {
            _allissues = allissues;
            User = user;
            Issues = new ThreadSafeObservableCollection<IssueViewModel>();

            _allissues
                .Where(x => x.Repo.Owner.Login == user.Username)
                .Subscribe(CheckInternal);
        }
        public UsbDeviceViewModel(UsbDevice usbDevice)
        {
            this.Properties         = new ThreadSafeObservableCollection <NameValueTypeViewModel>();
            this.RegistryProperties = new ThreadSafeObservableCollection <NameValueTypeViewModel>();
            this.Interfaces         = new ThreadSafeObservableCollection <NameValueTypeViewModel>();

            this.TreeViewItems = new ThreadSafeObservableCollection <UsbDeviceViewModel>();

            this.Refresh(usbDevice);
        }
Exemple #47
0
		/// <summary>
		/// Initializes a new instance of the <see cref="PortfolioComboBox"/>.
		/// </summary>
		public PortfolioComboBox()
		{
			DisplayMemberPath = "Name";

			var itemsSource = new ObservableCollectionEx<Portfolio>();
			ItemsSource = itemsSource;

			Portfolios = new ThreadSafeObservableCollection<Portfolio>(itemsSource);
			Connector = ConfigManager.TryGetService<IConnector>();
		}
Exemple #48
0
        public PlayerInfo(Player user, DamageTracker tracker)
        {
            Tracker = tracker;
            Player = user;
            Received = new SkillStats();
            Dealt = new SkillStats();
            SkillLog = new ThreadSafeObservableCollection<SkillResult>();

            Dealt.PropertyChanged += DealtOnPropertyChanged;
        }
		public MainWindow()
		{
			InitializeComponent();

			var errorSource = new ObservableCollectionEx<SettingsError>();
			Results.ItemsSource = errorSource;
			_settingErrors = new ThreadSafeObservableCollection<SettingsError>(errorSource);

			FindTerminals();
		}
            public void Test_PCB_CollectionChanged()
            {
                var collectionChanged = false;
                var sut = new ThreadSafeObservableCollection<TestPCB>();
                sut.CollectionChanged += (s, e) => collectionChanged = sut_CollectionChanged(e);
                var item = new TestPCB();

                sut.Add(item);

                Assert.IsTrue(collectionChanged);
            }
		private void FillBoards(IExchangeInfoProvider provider)
		{
			var itemsSource = new ObservableCollectionEx<ExchangeBoard> { _emptyBoard };
			var boards = new ThreadSafeObservableCollection<ExchangeBoard>(itemsSource);

			boards.AddRange(provider.Boards);

			provider.BoardAdded += boards.Add;
			
			Boards = boards;
		}
Exemple #52
0
		public ChatPanel()
		{
			InitializeComponent();

			var context = new ObservableCollectionEx<RoomItem>();
			ChatRoomsTree.DataContext = context;

			_chatRooms = new ThreadSafeObservableCollection<RoomItem>(context);

			WhenLoaded(ChatControl_OnLoaded);
		}
        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();
        }
            public void Test_NonPCB_WithChange()
            {
                object temp = null;
                var item = 10.0d;

                Assert.DoesNotThrow(() => temp = new ThreadSafeObservableCollection<double>());

                var sut = temp as ThreadSafeObservableCollection<double>;
                Assert.IsNotNull(sut, "Could not cast sut to proper type.");

                Assert.DoesNotThrow(() => sut.Add(item), "Exception adding item.");
                Assert.DoesNotThrow(() => item = 4.0d, "Exception changing item.");
            }
            public void Test_PCB_WithoutChange()
            {
                var called = false;

                var item = new TestPCB();
                item.PropertyChanged += (s, e) =>
                {
                    called = true;
                    Debug.WriteLine(e.PropertyName);
                };

                var sut = new ThreadSafeObservableCollection<TestPCB> {item};

                Assert.IsFalse(called);
            }
Exemple #56
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LogSourceNode"/>.
		/// </summary>
		/// <param name="key">The unique key.</param>
		/// <param name="name">The display name.</param>
		/// <param name="parentNode">The parent node.</param>
		public LogSourceNode(Guid key, string name, LogSourceNode parentNode)
		{
			//if (key.IsEmpty())
			//	throw new ArgumentNullException("key");

			if (name.IsEmpty())
				throw new ArgumentNullException(nameof(name));

			Key = key;
			Name = name;
			ParentNode = parentNode;

			KeyStr = Key.ToString();
			ChildNodes = new ThreadSafeObservableCollection<LogSourceNode>(new ObservableCollectionEx<LogSourceNode>());
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="ExchangeComboBox"/>.
		/// </summary>
		public ExchangeComboBox()
		{
			IsEditable = true;

			var itemsSource = new ObservableCollectionEx<Exchange> { _emptyExchange };
			_exchanges = new ThreadSafeObservableCollection<Exchange>(itemsSource);

			//_exchanges.AddRange(Exchange.EnumerateExchanges().OrderBy(b => b.Name));

			DisplayMemberPath = "Name";

			Exchanges = _exchanges;
			ItemsSource = Exchanges;

			SelectedExchange = _emptyExchange;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="ExchangeBoardComboBox"/>.
		/// </summary>
		public ExchangeBoardComboBox()
		{
			IsEditable = true;

			var itemsSource = new ObservableCollectionEx<ExchangeBoard> { _emptyBoard };
			_boards = new ThreadSafeObservableCollection<ExchangeBoard>(itemsSource);

			//_boards.AddRange(ExchangeBoard.EnumerateExchangeBoards().OrderBy(b => b.Code));

			DisplayMemberPath = "Code";

			Boards = _boards;
			ItemsSource = Boards;

			SelectedBoard = _emptyBoard;
		}
		public SessionsPanel()
		{
			InitializeComponent();

			Sessions.GroupingColumnConverters.Add("Session.Type", (IValueConverter)Resources["enumConverter"]);

			var source = new ObservableCollectionEx<SessionStrategy>();
			var strategies = new ThreadSafeObservableCollection<SessionStrategy>(source);
			strategies.AddRange(Registry.Sessions.SelectMany(s =>
			{
				s.Strategies.Added += strategies.Add;
				return s.Strategies.ToArray();
			}));
			Registry.Sessions.Added += s =>
			{
				s.Strategies.Added += strategies.Add;
			};

			IValueConverter converter = new StatisticsStorageConverter();

			_view = CollectionViewSource.GetDefaultView(source);
			_view.Filter = obj =>
			{
				var sessionStrategy = obj as SessionStrategy;
				if (sessionStrategy != null)
				{
					var result = sessionStrategy.Session.StartTime >= FromDate && sessionStrategy.Session.EndTime <= ToDate;

					var profitValue = converter.Convert(sessionStrategy.Statistics, typeof(string), "Net Profit", CultureInfo.CurrentCulture);
					if (profitValue != null)
					{
						var profit = profitValue.To<decimal>();
						result &= profit >= ProfitFrom && profit <= ProfitTo;
					}
					else
						result &= ShowEmptyProfit.IsChecked == true;

					return result;
				}

				return true;
			};

			Sessions.ItemsSource = source;
		}
		/// <summary>
		/// Создать <see cref="PortfolioEditor"/>.
		/// </summary>
		public PortfolioEditor()
		{
			InitializeComponent();

			var itemsSource = new ObservableCollectionEx<Portfolio>();
			PortfolioTextBox.ItemsSource = itemsSource;
			_portfolios = new ThreadSafeObservableCollection<Portfolio>(itemsSource);

			Connector = ConfigManager.TryGetService<IConnector>();

			if (Connector == null)
			{
				ConfigManager.ServiceRegistered += (t, s) =>
				{
					if (typeof(IConnector) != t)
						return;

					GuiDispatcher.GlobalDispatcher.AddAction(() => Connector = (IConnector)s);
				};
			}
		}