protected TreeViewItemViewModel(TreeViewItemViewModel parent, bool lazyLoadChildren)
 {
     this.parent = parent;
     this.children = new SafeObservableCollection<TreeViewItemViewModel>();
     if (lazyLoadChildren)
         this.children.Add(placeholderChild);
 }
Exemplo n.º 2
0
        void bwTrackList_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                //ObservableCollection<TrackListItem> items = e.Result as ObservableCollection<TrackListItem>;
                SafeObservableCollection <TrackListItem> items = e.Result as SafeObservableCollection <TrackListItem>;

                ListCollectionView lcv = new ListCollectionView(items);
                lcv.Filter           = FilterRow;
                dataGrid.ItemsSource = lcv;

                if (dataGrid.Items.Count > 0)
                {
                    dataGrid.UpdateLayout();
                    dataGrid.ScrollIntoView(dataGrid.Items[0]);
                }
            }
            finally
            {
                if (FillListCompleted != null)
                {
                    FillListCompleted(this, new EventArgs());
                }
            }
            //UpdateStatusBar();
        }
Exemplo n.º 3
0
        private async void SavePerson()
        {
            if (SelectedPerson == null)
            {
                return;
            }

            _logger.Write($"Saving {SelectedPerson.ID} ({SelectedPerson.FirstName} {SelectedPerson.LastName})", enLogType.Info);

            var currentPerson = SelectedPerson;

            await _personApi.Save(SelectedPerson);

            _logger.Write("Reloading current search...", enLogType.Info);
            var list = await _personApi.List(SearchFilter);

            People = new SafeObservableCollection <IPersonEntity>(list);

            // Restore the current selected / new person
            if (SelectedPerson != null && SelectedPerson.ID > 0)
            {
                SelectedPerson = People.FirstOrDefault(p => p.ID == currentPerson.ID);
            }
            else
            {
                // Best effort. There could be duplicates in this schema
                if (currentPerson != null)
                {
                    SelectedPerson = People.FirstOrDefault(p => p.FirstName == currentPerson.FirstName && p.LastName == currentPerson.LastName && p.Age == currentPerson.Age);
                }
            }
        }
Exemplo n.º 4
0
        void bwCDList_DoWork(object sender, DoWorkEventArgs e)
        {
            SafeObservableCollection <AlbumItem> items = new SafeObservableCollection <AlbumItem>();

            int count = 0;

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = AlbumView.CreateView(this.DataBase, this.CdListFields.GetFields(), new SortFieldCollection(), 0, searchCondition))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    AlbumItem newItem = new AlbumItem();
                    newItem.ID = (int)values[0];

                    newItem.Items = new object[values.Length - 1];
                    FillRowValues(newItem, values);
                    items.AddItemFromThread(newItem);

                    count++;
                }
            }

            e.Result = items;
        }
Exemplo n.º 5
0
 public PushViewModel() : base(Messages.PushDialogResult)
 {
     applicationServices    = new SafeObservableCollection <ProvisionedService>();
     ManageCloudsCommand    = new RelayCommand(ManageClouds);
     AddAppServiceCommand   = new RelayCommand(AddAppService, CanAddAppService);
     ChooseDirectoryCommand = new RelayCommand(ChooseDirectory, CanChooseDirectory);
     SelectedMemory         = MemoryLimits[0];
 }
Exemplo n.º 6
0
 public PushViewModel()
     : base(Messages.PushDialogResult)
 {
     this.applicationServices = new SafeObservableCollection<ProvisionedService>();
     ManageCloudsCommand = new RelayCommand(ManageClouds);
     AddAppServiceCommand = new RelayCommand(AddAppService, CanAddAppService);
     ChooseDirectoryCommand = new RelayCommand(ChooseDirectory, CanChooseDirectory);
     SelectedMemory = MemoryLimits[0];
 }
 protected TreeViewItemViewModel(TreeViewItemViewModel parent, bool lazyLoadChildren)
 {
     this.parent   = parent;
     this.children = new SafeObservableCollection <TreeViewItemViewModel>();
     if (lazyLoadChildren)
     {
         this.children.Add(placeholderChild);
     }
 }
Exemplo n.º 8
0
 public AddCloudViewModel() : base(Messages.AddCloudDialogResult)
 {
     Cloud                  = new Types.Cloud();
     this.dispatcher        = Dispatcher.CurrentDispatcher;
     ValidateAccountCommand = new RelayCommand(ValidateAccount, CanValidate);
     RegisterAccountCommand = new RelayCommand(RegisterAccount, CanRegister);
     ManageCloudUrlsCommand = new RelayCommand(ManageCloudUrls);
     this.cloudUrls         = provider.CloudUrls;
     this.SelectedCloudUrl  = cloudUrls.SingleOrDefault((i) => i.IsDefault);
 }
Exemplo n.º 9
0
        private async void Search()
        {
            _logger.Write("Searching ...", enLogType.Info);

            var list = await _personApi.List(SearchFilter);

            People = new SafeObservableCollection <IPersonEntity>(list);

            _logger.Write($"Search complete: {list.Count()} matches found", enLogType.Info);
        }
Exemplo n.º 10
0
 public AddCloudViewModel()
     : base(Messages.AddCloudDialogResult)
 {
     Cloud = new Types.Cloud();
     this.dispatcher = Dispatcher.CurrentDispatcher;
     ValidateAccountCommand = new RelayCommand(ValidateAccount, CanValidate);
     RegisterAccountCommand = new RelayCommand(RegisterAccount, CanRegister);
     ManageCloudUrlsCommand = new RelayCommand(ManageCloudUrls);
     this.cloudUrls = provider.CloudUrls;
     this.SelectedCloudUrl = cloudUrls.SingleOrDefault((i) => i.IsDefault);
 }
        public ApplicationViewModel(IZuneDatabaseReader dbReader,
                                    SafeObservableCollection<AlbumDetailsViewModel> albums,
                                    ViewLocator locator,
                                    IKernel kernel,
                                    ApplicationView av)
        {
            _dbReader = dbReader;
            _albums = albums;
            _viewLocator = locator;
            _kernel = kernel;

            //register for notification messages
            Messenger.Default.Register<ErrorMessage>(this, Notifications.Add);
            Messenger.Default.Register<UserControl>(this, (view) => { CurrentPage = view; });
        }
Exemplo n.º 12
0
        public ApplicationViewModel(IZuneDatabaseReader dbReader,
                                    SafeObservableCollection <AlbumDetailsViewModel> albums,
                                    ViewLocator locator)
        {
            _dbReader    = dbReader;
            _albums      = albums;
            _viewLocator = locator;

            //register for notification messages
            Messenger.Default.Register <ErrorMessage>(this, Notifications.Add);

            locator.SwitchToViewRequested += (view, viewModel) => {
                CurrentPage = view;
            };
        }
        public ApplicationViewModel(IZuneDatabaseReader dbReader,
                                    SafeObservableCollection<AlbumDetailsViewModel> albums,
                                    ViewLocator locator)
        {
            _dbReader = dbReader;
            _albums = albums;
            _viewLocator = locator;

            //register for notification messages
            Messenger.Default.Register<ErrorMessage>(this, Notifications.Add);

            locator.SwitchToViewRequested += (view, viewModel) => {
                CurrentPage = view;
            };
        }
Exemplo n.º 14
0
        void bwAlbumView_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //GridLoadingCircle.Visibility = System.Windows.Visibility.Collapsed;

            SafeObservableCollection <AlbumViewItemBase> items = e.Result as SafeObservableCollection <AlbumViewItemBase>;
            ListCollectionView lcv = new ListCollectionView(items);

            lcv.Filter = FilterRow;
            itemsControl.ItemsSource = lcv;

            if (FillListCompleted != null)
            {
                FillListCompleted(this, new EventArgs());
            }
        }
Exemplo n.º 15
0
        public CloudFoundryProvider(PreferencesProvider preferencesProvider)
        {
            this.preferencesProvider = preferencesProvider;
            var preferences = preferencesProvider.Load();

            this.Clouds    = preferences.Clouds.DeepCopy();
            this.CloudUrls = preferences.CloudUrls.DeepCopy();

            this.Clouds.CollectionChanged += Clouds_CollectionChanged;
            foreach (var cloud in Clouds)
            {
                cloud.PropertyChanged += CloudChanged;
            }

            Messenger.Default.Register <NotificationMessageAction <ICloudFoundryProvider> >(this, ProcessCloudFoundryProviderMessage);
        }
        public WebAlbumListViewModel(SafeObservableCollection<AlbumDetailsViewModel> albums,
                                     ViewLocator locator)
        {
            _albums = albums;
            _albums.CollectionChanged += AlbumsCollectionChanged;
            _cvs = new CollectionViewSource();
            _cvs.Source = albums;
            _cvs.Filter += CvsFilter;

            _locator = locator;

            this.LoadFromZuneWebsiteCommand = new RelayCommand(LoadFromZuneWebsite);
            this.SwitchToClassicModeCommand = new RelayCommand(SwitchToClassicMode);
            this.SortCommand = new RelayCommand(Sort);
            this.SearchCommand = new RelayCommand<string>(Search);
            this.SortOrder = Settings.Default.SortOrder;
        }
Exemplo n.º 17
0
        void bwCDList_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SafeObservableCollection <AlbumViewItem> items = e.Result as SafeObservableCollection <AlbumViewItem>;

            ListCollectionView lcv = new ListCollectionView(items);

            lcv.Filter = FilterRow;

            listBox.ItemsSource = lcv;

            if (FillListCompleted != null)
            {
                FillListCompleted(this, new EventArgs());
            }

            //UpdateStatusBar();
        }
Exemplo n.º 18
0
        public ProviderResponse <IEnumerable <Instance> > GetInstances(Cloud cloud, Application app)
        {
            var response = new ProviderResponse <IEnumerable <Instance> >();

            try
            {
                IVcapClient client    = new VcapClient(cloud);
                var         stats     = client.GetStats(app);
                var         instances = new SafeObservableCollection <Instance>();
                if (stats != null)
                {
                    foreach (var stat in stats)
                    {
                        var instance = new Instance()
                        {
                            ID    = stat.ID,
                            State = stat.State
                        };
                        if (stat.Stats != null)
                        {
                            instance.Cores       = stat.Stats.Cores;
                            instance.MemoryQuota = stat.Stats.MemQuota / 1048576;
                            instance.DiskQuota   = stat.Stats.DiskQuota / 1048576;
                            instance.Host        = stat.Stats.Host;
                            instance.Parent      = app;
                            instance.Uptime      = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime));

                            if (stat.Stats.Usage != null)
                            {
                                instance.Cpu    = stat.Stats.Usage.CpuTime / 100;
                                instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage) / 1024;
                                instance.Disk   = Convert.ToInt32(stat.Stats.Usage.DiskUsage) / 1048576;
                            }
                        }
                        instances.Add(instance);
                    }
                }
                response.Response = instances;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
Exemplo n.º 19
0
        private async void PopulatePeopleList()
        {
            _logger.Write("Initialising ... ", enLogType.Info);

            _personApi = new PersonApi();
            var list = await _personApi.List();

            People = new SafeObservableCollection <IPersonEntity>(list);

            if (list.Count() == 0)
            {
                _logger.Write("No people loaded. Did you remember to rebuid the solution?", enLogType.Error);
            }
            else
            {
                _logger.Write($"Complete. {list.Count()} people loaded.", enLogType.Info);
            }
        }
        public WebAlbumListViewModel(SafeObservableCollection<AlbumDetailsViewModel> albums,
                                     ViewLocator locator)
        {
            _albums = albums;
            _albums.CollectionChanged += AlbumsCollectionChanged;
            _cvs = new CollectionViewSource();
            _cvs.Source = albums;
            _cvs.Filter += CvsFilter;

            _locator = locator;
            _isTaskbarSupported = TaskbarManager.IsPlatformSupported;

            this.LoadFromZuneWebsiteCommand = new RelayCommand(LoadFromZuneWebsite);
            this.SwitchToClassicModeCommand = new RelayCommand(SwitchToClassicMode);
            this.SortCommand = new RelayCommand(Sort);
            this.SearchCommand = new RelayCommand<string>(Search);
            this.CanShowScanAllButton = true;
            this.SortOrder = Settings.Default.SortOrder;
        }
        public WebAlbumListViewModel(SafeObservableCollection <AlbumDetailsViewModel> albums,
                                     ViewLocator locator)
        {
            _albums = albums;
            _albums.CollectionChanged += AlbumsCollectionChanged;
            _cvs         = new CollectionViewSource();
            _cvs.Source  = albums;
            _cvs.Filter += CvsFilter;

            _locator            = locator;
            _isTaskbarSupported = TaskbarManager.IsPlatformSupported;

            this.LoadFromZuneWebsiteCommand = new RelayCommand(LoadFromZuneWebsite);
            this.SwitchToClassicModeCommand = new RelayCommand(SwitchToClassicMode);
            this.SortCommand          = new RelayCommand(Sort);
            this.SearchCommand        = new RelayCommand <string>(Search);
            this.CanShowScanAllButton = true;
            this.SortOrder            = Settings.Default.SortOrder;
        }
Exemplo n.º 22
0
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            SafeObservableCollection <MyMusicListItem> items = new SafeObservableCollection <MyMusicListItem>();

            int count = 0;

            FieldCollection fc = new FieldCollection();

            int internalFieldsCount = 0;

            foreach (Field field in internalFields)
            {
                if (this.trackListFields.SingleOrDefault(x => x.Field == field) == null)
                {
                    fc.Add(field);
                    internalFieldsCount++;
                }
            }

            fc.AddRange(this.trackListFields.GetFields());

            int soundFileIndex = fc.IndexOf(Field.TrackSoundFile);

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = TrackView.CreateView(this.DataBase, fc, this.trackListSort, 0, searchCondition))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    MyMusicListItem newItem = new MyMusicListItem();

                    FillRowValues(newItem, values, soundFileIndex, internalFieldsCount);
                    items.AddItemFromThread(newItem);

                    count++;
                }
            }

            e.Result = items;
        }
Exemplo n.º 23
0
        protected override bool Load()
        {
            _safeLogRows = new SafeObservableCollection <ViewModelLogItem>(System.Windows.Threading.Dispatcher.CurrentDispatcher);// = new ObservableList<DataModelLogItem>();
            //using (_safeLogRows.AcquireLock())
            //{
            //    ViewModelLogItem log1 = new ViewModelLogItem(EnumLogType.Info, "how", "when");
            //    _safeLogRows.Add(log1);
            //}
            OnPropertyChanged("LogUI");
            //using (_safeLogRows.AcquireLock())
            //{
            //    ViewModelLogItem log1 = new ViewModelLogItem(EnumLogType.Info, "how1", "when1");
            //    _safeLogRows.Add(log1);
            //}
            if (xvThreadLog == null)
            {
                xvThreadLog = new Thread(new ThreadStart(ThreadProc));
                //       xvThreadSequencer.Priority = ThreadPriority.Highest;
                xvThreadLog.Start();
            }

            return(base.Load());
        }
Exemplo n.º 24
0
        void bwCDList_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SafeObservableCollection <AlbumItem> items = e.Result as SafeObservableCollection <AlbumItem>;

            ListCollectionView lcv = new ListCollectionView(items);

            lcv.Filter = FilterRow;

            if (GroupBy != null && GroupBy.Count > 0)
            {
            }

            dataGrid.ItemsSource = lcv;

            LoadSorting();

            MySort mySort = new MySort(DataBase, dataGrid, this.cdListFields, this.CdListSort);

            lcv.CustomSort = mySort;    // provide our own sort

            if (dataGrid.Items.Count > 0)
            {
                dataGrid.UpdateLayout();
                dataGrid.ScrollIntoView(dataGrid.Items[0]);
            }

            if (FillListCompleted != null)
            {
                FillListCompleted(this, new EventArgs());
            }

            SaveDataGridColumnWidths();


            //UpdateStatusBar();
        }
Exemplo n.º 25
0
        public ProviderResponse<IEnumerable<Instance>> GetInstances(Cloud cloud, Application app)
        {
            var response = new ProviderResponse<IEnumerable<Instance>>();
            try
            {
                IVcapClient client = new VcapClient(cloud);
                var stats = client.GetStats(app);
                var instances = new SafeObservableCollection<Instance>();
                if (stats != null)
                {

                    foreach (var stat in stats)
                    {
                        var instance = new Instance()
                                       {
                                           ID = stat.ID,
                                           State = stat.State
                                       };
                        if (stat.Stats != null)
                        {
                            instance.Cores = stat.Stats.Cores;
                            instance.MemoryQuota = stat.Stats.MemQuota/1048576;
                            instance.DiskQuota = stat.Stats.DiskQuota/1048576;
                            instance.Host = stat.Stats.Host;
                            instance.Parent = app;
                            instance.Uptime = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime));

                            if (stat.Stats.Usage != null)
                            {
                                instance.Cpu = stat.Stats.Usage.CpuTime/100;
                                instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage)/1024;
                                instance.Disk = Convert.ToInt32(stat.Stats.Usage.DiskUsage)/1048576;
                            }
                        }
                        instances.Add(instance);
                    }
                }
                response.Response = instances;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return response;
        }
Exemplo n.º 26
0
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            string sql = "";

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.ArtistTable:
                sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ArtistID = PersonGroup.PersonGroupID " +
                      "GROUP BY PersonGroup.Name, PersonGroup.SaveAs";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    if (searchCondition[0].Value.ToString() == "?")
                    {
                        sql += " HAVING PersonGroup.SaveAs < 'A' OR PersonGroup.SaveAs > 'ZZZZZ'";
                    }
                    else
                    {
                        sql += " HAVING PersonGroup.SaveAs >= '" + searchCondition[0].Value + "' AND PersonGroup.SaveAs < '" + searchCondition[0].Value + "ZZZZZ'";
                    }
                }

                sql += " ORDER BY PersonGroup.SaveAs";

                break;

            case MainControls.CurrentViewMode.ComposerTable:
                sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " +
                      "GROUP BY PersonGroup.Name, PersonGroup.SaveAs ";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    if (searchCondition[0].Value.ToString() == "?")
                    {
                        sql += " HAVING PersonGroup.SaveAs < 'A' OR PersonGroup.SaveAs > 'ZZZZZ'";
                    }
                    else
                    {
                        sql += " HAVING PersonGroup.SaveAs >= '" + searchCondition[0].Value + "' AND PersonGroup.SaveAs < '" + searchCondition[0].Value + "ZZZZZ'";
                    }
                }

                sql += " ORDER BY PersonGroup.SaveAs";

                break;

            case MainControls.CurrentViewMode.GenreTable:
                sql = "SELECT Category.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track LEFT JOIN " +
                      "CD ON Track.CDID = CD.CDID LEFT JOIN " +
                      "Category ON Track.CategoryID = Category.CategoryID OR CD.CategoryID = Category.CategoryID " +
                      "GROUP BY Category.Name";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    sql += " HAVING Category.Name LIKE '" + searchCondition[0].Value + "%'";
                }
                break;

            case MainControls.CurrentViewMode.MediumTable:
                sql = "SELECT Medium.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track INNER JOIN " +
                      "CD ON Track.CDID = CD.CDID LEFT JOIN " +
                      "Medium ON CD.MediumID = Medium.MediumID " +
                      "GROUP BY Medium.Name";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    sql += " HAVING Medium.Name LIKE '" + searchCondition[0].Value + "%'";
                }
                break;

            case MainControls.CurrentViewMode.YearTable:
                sql = "SELECT Track.YearRecorded, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track " +
                      "GROUP BY Track.YearRecorded";
                if (searchCondition != null && searchCondition.Count > 0)
                {
                    if (searchCondition.Count > 1)
                    {
                        sql += " HAVING Track.YearRecorded >= " + searchCondition[0].Value + " AND Track.YearRecorded < " + searchCondition[1].Value;
                    }
                    else
                    {
                        sql += " HAVING Track.YearRecorded=" + searchCondition[0].Value + "";
                    }
                }
                break;

            case MainControls.CurrentViewMode.RatingTable:
                sql = "SELECT Track.Rating, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                      "FROM Track " +
                      "GROUP BY Track.Rating";
                if (searchCondition != null && searchCondition.Count > 0 && searchCondition[0].Value != null)
                {
                    sql += " HAVING Track.Rating = " + searchCondition[0].Value + "";
                }
                break;
            }

            SafeObservableCollection <TrackListItem> items     = new SafeObservableCollection <TrackListItem>();
            Dictionary <string, TrackListItem>       dictItems = new Dictionary <string, TrackListItem>(); // Für schnelleren Zugriff

            using (DataBaseView view = DataBaseView.Create(this.DataBase, sql))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    TrackListItem trackListItem = new TrackListItem();
                    trackListItem.Title = values[0].ToString();
                    if (CurrentViewMode == MainControls.CurrentViewMode.YearTable && trackListItem.Title == "0")
                    {
                        trackListItem.Title = StringTable.Undefined;
                    }

                    trackListItem.Count  = (int)values[1];
                    trackListItem.Length = (long)values[2];
                    trackListItem.Rating = 0;
                    dictItems.Add(trackListItem.Title, trackListItem);
                    items.AddItemFromThread(trackListItem);
                }
            }

            // Rating ermitteln
            sql = "";
            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.ArtistTable:
            {
                sql = "SELECT PersonGroup.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3, PersonGroup.SaveAs " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ArtistID = PersonGroup.PersonGroupID " +
                      "WHERE (Track.Rating > 0) " +
                      "GROUP BY PersonGroup.Name, PersonGroup.SaveAs";
                break;
            }

            case MainControls.CurrentViewMode.ComposerTable:
            {
                sql = "SELECT PersonGroup.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " +
                      "FROM Track INNER JOIN " +
                      "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " +
                      "WHERE (Track.Rating > 0) " +
                      "GROUP BY PersonGroup.Name";
                break;
            }

            case MainControls.CurrentViewMode.GenreTable:
            {
                sql = "SELECT category.Name, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " +
                      "FROM Track LEFT JOIN " +
                      "CD ON Track.CDID = CD.CDID LEFT JOIN " +
                      "Category AS Category ON Track.CategoryID = Category.CategoryID OR CD.CategoryID = Category.CategoryID " +
                      "WHERE        (Track.Rating > 0) " +
                      "GROUP BY Category.Name";

                break;
            }

            case MainControls.CurrentViewMode.YearTable:
            {
                sql = "SELECT Track.YearRecorded, AVG(CAST(Track.Rating AS decimal)) AS Expr3 " +
                      "FROM Track " +
                      "WHERE        (Track.Rating > 0) " +
                      "GROUP BY Track.YearRecorded";

                break;
            }
            }

            if (sql != "")
            {
                using (DataBaseView view = DataBaseView.Create(this.DataBase, sql))
                {
                    object[] values;

                    while ((values = view.Read()) != null)
                    {
                        string key = values[0].ToString();

                        if (CurrentViewMode == MainControls.CurrentViewMode.YearTable && key == "0")
                        {
                            key = StringTable.Undefined;
                        }

                        if (dictItems.ContainsKey(key))
                        {
                            TrackListItem trackListItem = dictItems[key];
                            trackListItem.Rating = (double)(decimal)values[1];
                        }
                    }
                }
            }

            e.Result = items;
        }
Exemplo n.º 27
0
 protected override void InitializeData()
 {
     Messenger.Default.Send(
         new NotificationMessageAction <SafeObservableCollection <string> >(Messages.SetManageApplicationUrlsData,
                                                                            urls => Urls = urls.DeepCopy()));
 }
 protected override void InitializeData()
 {
     Messenger.Default.Send(new NotificationMessageAction<SafeObservableCollection<string>>(Messages.SetManageApplicationUrlsData, urls => this.Urls = urls.DeepCopy()));
 }
Exemplo n.º 29
0
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            string sql = "";

            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.ArtistDetails:
            case MainControls.CurrentViewMode.ComposerDetails:
                sql = GetArtistDetailsSql();
                if (Condition != null && Condition.Count > 0 && Condition[0].Value != null)
                {
                    sql += " HAVING PersonGroup.Name LIKE '" + Condition[0].Value + "%'";
                }
                break;

                //case MainControls.CurrentViewMode.ComposerTable:
                //    sql = "SELECT PersonGroup.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track INNER JOIN " +
                //        "PersonGroup ON Track.ComposerID = PersonGroup.PersonGroupID " +
                //        "GROUP BY PersonGroup.Name";
                //    if (Condition != null && Condition.Count > 0)
                //    {
                //        sql += " HAVING PersonGroup.Name LIKE '" + Condition[0].Value + "%'";
                //    }
                //    break;

                //case MainControls.CurrentViewMode.GenreTable:
                //    sql = "SELECT Category.Name, COUNT(*) AS TotalCount, SUM(Cast(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track INNER JOIN " +
                //        "Category ON Track.CategoryID = Category.CategoryID " +
                //        "GROUP BY Category.Name";
                //    if (Condition != null && Condition.Count > 0)
                //    {
                //        sql += " HAVING Category.Name LIKE '" + Condition[0].Value + "%'";
                //    }
                //    break;
                //case MainControls.CurrentViewMode.YearTable:
                //    sql = "SELECT Track.YearRecorded, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track " +
                //        "GROUP BY Track.YearRecorded";
                //    break;
                //case MainControls.CurrentViewMode.RatingTable:
                //    sql = "SELECT Track.Rating, COUNT(*) AS TotalCount, SUM(CAST(Track.Length as bigint)) AS TotalLength " +
                //        "FROM Track " +
                //        "GROUP BY Track.Rating";
                //    if (Condition != null && Condition.Count > 0)
                //    {
                //        sql += " HAVING Track.Rating = " + Condition[0].Value + "";
                //    }
                //    break;
            }

            SafeObservableCollection <TrackListItem> items = new SafeObservableCollection <TrackListItem>();

            using (DataBaseView view = DataBaseView.Create(this.DataBase, sql))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    TrackListItem trackListItem = new TrackListItem();

                    ReadValues(values, trackListItem);

                    items.AddItemFromThread(trackListItem);
                }
            }

            e.Result = items;
        }
Exemplo n.º 30
0
        void bwAlbumView_DoWork(object sender, DoWorkEventArgs e)
        {
            FieldCollection fc = new FieldCollection();

            fc.AddRange(new Field[] { Field.CDID, Field.Title, Field.ArchiveNumber, Field.CDCoverFront, Field.YearRecorded,
                                      Field.TrackNumber, Field.TrackTitle, Field.TrackLength, Field.TrackRating, Field.TrackSoundFile,
                                      Field.ArtistCDName, Field.ArtistCDSaveAs, Field.ArtistTrackName, Field.Category, Field.ComposerTrackName });

            int count = 0;

            SortFieldCollection sfc = new SortFieldCollection();

            sfc.Add(Field.ArtistCDSaveAs);
            sfc.Add(Field.Title);
            sfc.Add(Field.CDID);
            // Die Verzeichnisansicht immer sortiert nach Dateiname
            if (this.ShowItemType == ShowItemType.Directory)
            {
                sfc.Add(Field.TrackSoundFile);
            }
            else
            {
                sfc.Add(Field.TrackNumber);
            }

            SafeObservableCollection <AlbumViewItemBase> items = new SafeObservableCollection <AlbumViewItemBase>();

            AlbumViewItem newItem         = null;
            string        lastArtist      = "";
            string        lastArtistTitle = "";
            string        lastTitle       = "";
            int           lastcdid        = 0;

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = TrackView.CreateView(DataBase, fc, sfc, 0, searchCondition))
            {
                // Überall auf die Indizes 1 addieren, da die erste Spalte die TrackID ist.
                int colArtistName     = fc.IndexOf(Field.ArtistCDName) + 1;
                int colArtistSaveAs   = fc.IndexOf(Field.ArtistCDSaveAs) + 1;
                int colTitle          = fc.IndexOf(Field.Title) + 1;
                int colCDID           = fc.IndexOf(Field.CDID) + 1;
                int colFrontCover     = fc.IndexOf(Field.CDCoverFront) + 1;
                int colCategory       = fc.IndexOf(Field.Category) + 1;
                int colArchiveNumber  = fc.IndexOf(Field.ArchiveNumber) + 1;
                int colYearRecorded   = fc.IndexOf(Field.YearRecorded) + 1;
                int colTrackNumber    = fc.IndexOf(Field.TrackNumber) + 1;
                int colTrackTitle     = fc.IndexOf(Field.TrackTitle) + 1;
                int colTrackLength    = fc.IndexOf(Field.TrackLength) + 1;
                int colTrackRating    = fc.IndexOf(Field.TrackRating) + 1;
                int colTrackArtist    = fc.IndexOf(Field.ArtistTrackName) + 1;
                int colTrackComposer  = fc.IndexOf(Field.ComposerTrackName) + 1;
                int colTrackSoundFile = fc.IndexOf(Field.TrackSoundFile) + 1;
                int colTrackID        = 0;

                object[] values;

                while ((values = view.Read()) != null)
                {
                    string artistDisplay = values[colArtistName] is DBNull ? "" : (string)values[colArtistName];
                    string artist        = values[colArtistSaveAs] is DBNull ? "" : (string)values[colArtistSaveAs];
                    string title         = values[colTitle] is DBNull ? "" : (string)values[colTitle];
                    int    cdid          = (int)values[colCDID];

                    if (cdid != lastcdid)
                    {
                        if (newItem != null)
                        {
                            if (newItem.Artist != lastArtistTitle)
                            {
                                AlbumViewTitle albumTitle = new AlbumViewTitle();
                                albumTitle.Title = newItem.Artist;
                                items.Add(albumTitle);

                                lastArtistTitle = newItem.Artist;
                            }

                            items.Add(newItem);
                        }

                        newItem               = new AlbumViewItem();
                        newItem.ID            = cdid;
                        newItem.Artist        = artistDisplay;
                        newItem.Title         = title;
                        newItem.ImageFilename = values[colFrontCover] is DBNull ? "" : (string)values[colFrontCover];
                        newItem.Genre         = values[colCategory] is DBNull ? "" : (string)values[colCategory];
                        newItem.ArchiveNumber = values[colArchiveNumber] is DBNull ? "" : (string)values[colArchiveNumber];
                        int yearRecorded = values[colYearRecorded] is DBNull ? 0 : (int)values[colYearRecorded];
                        if (yearRecorded > 0)
                        {
                            newItem.Year = yearRecorded.ToString();
                        }

                        newItem.Tracks = new SafeObservableCollection <Track>();
                        lastArtist     = artist;
                        lastTitle      = title;
                    }

                    if (newItem != null)
                    {
                        Track track = new Track();
                        track.TrackNumber = (int)values[colTrackNumber];
                        track.Title       = values[colTrackTitle] is DBNull ? "" : (string)values[colTrackTitle];
                        track.Length      = (int)values[colTrackLength];
                        track.Rating      = values[colTrackRating] is DBNull ? 0 : (int)values[colTrackRating];
                        track.Artist      = values[colTrackArtist] is DBNull ? "" : (string)values[colTrackArtist];
                        track.Composer    = values[colTrackComposer] is DBNull ? "" : (string)values[colTrackComposer];
                        track.Soundfile   = values[colTrackSoundFile] is DBNull ? "" : (string)values[colTrackSoundFile];
                        track.CDID        = cdid;
                        track.ID          = (int)values[colTrackID];

                        newItem.Tracks.Add(track);
                    }

                    //toolStripStatusProgressBar.Value = (int)(100.0 / TrackView.Rows.Count * count);

                    count++;

                    lastcdid = cdid;
                }
            }


            if (newItem != null)
            {
                if (newItem.Artist != lastArtistTitle)
                {
                    AlbumViewTitle albumTitle = new AlbumViewTitle();
                    albumTitle.Title = newItem.Artist;
                    items.Add(albumTitle);
                }

                items.Add(newItem);
            }

            e.Result = items;
        }