Пример #1
0
        public TeamspeakViewModel(ITeamspeakService teamspeakService, TeamspeakUserData userData)
        {
            this.isShuttingDown        = false;
            this.UserData              = userData;
            this.ChatMessages          = new ObservableCollection <ChatMsgViewModel>();
            this.Notifications         = new ObservableCollection <TSNotificationViewModel>();
            this.Channels              = new ObservableCollection <ChannelViewModel>();
            this.CurrentChannelClients = new ObservableCollection <ClientViewModel>();

            var channelsSource = new AutoRefreshCollectionViewSource();

            channelsSource.Source = this.Channels;
            this.ChannelsSource   = channelsSource;
            this.ChannelsSource.SortDescriptions.Add(new SortDescription("OrderIndex", ListSortDirection.Ascending));

            this.TeamspeakService = teamspeakService;
            this.TeamspeakService.NewServerInfo        += TeamspeakService_NewServerInfo;
            this.TeamspeakService.ClientChannelChanged += TeamspeakService_ClientChannelChanged;
            this.TeamspeakService.ConnectionRefused    += TeamspeakService_ConnectionRefused;
            this.TeamspeakService.TalkStatusChanged    += TeamspeakService_TalkStatusChanged;
            this.TeamspeakService.TextMessageReceived  += TeamspeakService_TextMessageReceived;
            this.TeamspeakService.ClientEnteredChannel += TeamspeakService_ClientEnteredChannel;
            this.TeamspeakService.ClientExitedChannel  += TeamspeakService_ClientExitedChannel;
            this.TeamspeakService.ChannelAdded         += TeamspeakService_ChannelAdded;
            this.TeamspeakService.ChannelRemoved       += TeamspeakService_ChannelRemoved;
            this.TeamspeakService.ChannelUpdated       += TeamspeakService_ChannelUpdated;

            Task.Factory.StartNew((state) =>
            {
                // Start this on another thread so that we don't hold up anything creating us
                this.TeamspeakService.Connect();
            }, null, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #2
0
        public PriceListViewModel(ICommerceController commerceController)
        {
            this.controller       = commerceController;
            this.ConfigureCommand = new DelegateCommand(() => Commands.OpenCommerceSettingsCommand.Execute(null));

            var collectionViewSource = new AutoRefreshCollectionViewSource();

            collectionViewSource.Source = this.controller.ItemPrices;
            this.ItemPrices             = collectionViewSource;

            switch (this.UserData.PriceTrackerSortProperty)
            {
            case CommerceUserData.PRICE_TRACKER_SORT_NAME:
                this.OnSortingPropertyChanged(CommerceUserData.PRICE_TRACKER_SORT_NAME, ListSortDirection.Ascending);
                break;

            case CommerceUserData.PRICE_TRACKER_SORT_BUY_PRICE:
                this.OnSortingPropertyChanged(CommerceUserData.PRICE_TRACKER_SORT_BUY_PRICE, ListSortDirection.Ascending);
                break;

            case CommerceUserData.PRICE_TRACKER_SORT_SALE_PRICE:
                this.OnSortingPropertyChanged(CommerceUserData.PRICE_TRACKER_SORT_SALE_PRICE, ListSortDirection.Ascending);
                break;

            case CommerceUserData.PRICE_TRACKER_SORT_PROFIT:
                this.OnSortingPropertyChanged(CommerceUserData.PRICE_TRACKER_SORT_PROFIT, ListSortDirection.Descending);
                break;

            default:
                this.OnSortingPropertyChanged(CommerceUserData.PRICE_TRACKER_SORT_NAME, ListSortDirection.Ascending);
                break;
            }
        }
Пример #3
0
        public TaskTrackerViewModel(
            IPlayerTasksController playerTasksController,
            CompositionContainer container)
        {
            this.controller = playerTasksController;
            this.container  = container;

            this.AddNewTaskCommand  = new Microsoft.Practices.Prism.Commands.DelegateCommand(this.AddNewTask);
            this.DeleteAllCommand   = new Microsoft.Practices.Prism.Commands.DelegateCommand(this.DeleteAllTasks);
            this.LoadTasksCommand   = new Microsoft.Practices.Prism.Commands.DelegateCommand(this.LoadTasks);
            this.ImportTasksCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(this.ImportTasks);
            this.ExportTasksCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(this.ExportTasks);

            var collectionViewSource = new AutoRefreshCollectionViewSource();

            collectionViewSource.Source = this.controller.PlayerTasks;
            this.PlayerTasks            = collectionViewSource;

            switch (this.UserData.TaskTrackerSortProperty)
            {
            case TasksUserData.TASK_TRACKER_SORT_NAME:
                this.OnSortingPropertyChanged(TasksUserData.TASK_TRACKER_SORT_NAME, ListSortDirection.Ascending);
                break;

            case TasksUserData.TASK_TRACKER_SORT_DISTANCE:
                this.OnSortingPropertyChanged(TasksUserData.TASK_TRACKER_SORT_DISTANCE, ListSortDirection.Ascending);
                break;

            default:
                this.OnSortingPropertyChanged(TasksUserData.TASK_TRACKER_SORT_NAME, ListSortDirection.Ascending);
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="channelData">The channel's data</param>
        public ChannelViewModel(Channel channelData, ITeamspeakService teamspeakService)
        {
            this.ID               = channelData.ID;
            this.ParentID         = channelData.ParentID;
            this.Name             = channelData.Name;
            this.OrderIndex       = channelData.Order;
            this.ClientsCount     = channelData.ClientsCount;
            this.teamspeakService = teamspeakService;
            this.Subchannels      = new ObservableCollection <ChannelViewModel>();

            var subChannelsSource = new AutoRefreshCollectionViewSource();

            subChannelsSource.Source = this.Subchannels;
            this.ChannelsSource      = subChannelsSource;
            this.ChannelsSource.SortDescriptions.Add(new SortDescription("OrderIndex", ListSortDirection.Ascending));
        }
Пример #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var collection = value as IList;

            if (collection != null)
            {
                var viewSource = new AutoRefreshCollectionViewSource();
                viewSource.Source = collection;
                //var view = new ListCollectionView(collection);
                var sortNames = parameter.ToString().Split('|');
                foreach (var sortName in sortNames)
                {
                    var sort = new SortDescription(sortName, ListSortDirection.Ascending);
                    viewSource.SortDescriptions.Add(sort);
                }
                return(viewSource.View);
            }
            return(null);
        }
Пример #6
0
        public WvWTrackerViewModel(IWvWController wvwController, IHasWvWMap wvwMapVM)
        {
            this.controller = wvwController;
            this.WvWMapVM   = wvwMapVM;

            var collectionViewSource = new AutoRefreshCollectionViewSource();

            collectionViewSource.Source = this.controller.CurrentObjectives;
            this.Objectives             = collectionViewSource;

            switch (this.UserData.ObjectivesSortProperty)
            {
            case "Type":
                this.OnSortingPropertyChanged("Type", ListSortDirection.Ascending);
                break;

            case "DistanceFromPlayer":
                this.OnSortingPropertyChanged("DistanceFromPlayer", ListSortDirection.Ascending);
                break;

            case "ShortName":
                this.OnSortingPropertyChanged("ShortName", ListSortDirection.Ascending);
                break;

            case "Location":
                this.OnSortingPropertyChanged("Location", ListSortDirection.Ascending);
                break;

            case "WorldOwner":
                this.OnSortingPropertyChanged("WorldOwner", ListSortDirection.Ascending);
                break;

            default:
                this.OnSortingPropertyChanged("Type", ListSortDirection.Ascending);
                break;
            }
        }