Пример #1
0
        private void UpdateMyMusicList(MyMusicListItem myMusicListItem)
        {
            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);

            DataBaseView view = TrackView.CreateView(DataBase, fc, trackListSort, myMusicListItem.ID);

            object[] values = view.Read();

            FillRowValues(myMusicListItem, values, soundFileIndex, internalFieldsCount);

            ListCollectionView lcv = this.dataGrid.ItemsSource as ListCollectionView;

            lcv.Refresh();
        }
Пример #2
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;
        }
Пример #3
0
        public ServerCtrl(string filePath)
        {
            players       = new Dictionary <long, Tank>();
            playerSockets = new Dictionary <long, SocketState>();
            wallsSent     = false;
            SetDefaults();
            rand            = new Random();
            randPowerupTime = rand.Next(0, maxPowerupSpawnTime);
            projectileCount = 0;
            beamCount       = 0;
            powerUpTracker  = 0;
            powerUpID       = 0;
            projectileDelay = 0;
            turretAimx      = 0;
            turretAimy      = 0;
            working         = false;
            world           = new TheWorld(worldSize, 0);


            Load(filePath);
            Networking.StartServer(NewPlayer, 11000);
            Console.WriteLine("Server started");

            dataBaseView = new DataBaseView();


            Thread thread = new Thread(() => SendData());

            thread.Start();
        }
Пример #4
0
        private void UpdateAlbumItem(AlbumItem albumItem)
        {
            DataBaseView view = AlbumView.CreateView(DataBase, CdListFields.GetFields(), CdListSort, albumItem.ID);

            object[] values = view.Read();

            FillRowValues(albumItem, values);

            ListCollectionView lcv = this.dataGrid.ItemsSource as ListCollectionView;

            lcv.Refresh();
        }
Пример #5
0
        void UpdateTrackListItem(TrackListItem item)
        {
            string sql = GetSql(item.ID);

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

                values = view.Read();

                if (values != null)
                {
                    ReadValues(values, item);
                }
            }
        }
Пример #6
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;
        }
Пример #7
0
        void bwTrackList_DoWork(object sender, DoWorkEventArgs e)
        {
            string sql = "";

            switch (CurrentViewMode)
            {
            case MainControls.CurrentViewMode.MediumTable:
                sql = "SELECT Medium.Name, COUNT(*) AS TotalCount " +
                      "FROM CD LEFT JOIN " +
                      "Medium ON CD.MediumID = Medium.MediumID " +
                      "GROUP BY Medium.Name";
                if (Condition != null && Condition.Count > 0)
                {
                    sql += " HAVING Medium.Name LIKE '" + Condition[0].Value + "%'";
                }
                break;
            }

            List <AlbumListItem> items = new List <AlbumListItem>();

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

                while ((values = view.Read()) != null)
                {
                    AlbumListItem trackListItem = new AlbumListItem();
                    trackListItem.Title = values[0].ToString();
                    trackListItem.Count = (int)values[1];

                    items.Add(trackListItem);
                }
            }

            e.Result = items;
        }
Пример #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Shell shell              = new Shell("АИК");
            var   LogWindow          = new LogginWindowView();
            var   LogWindowViewModel = new LoggingWindowViewModel(shell);
            var   InstrumentalView   = new InstrumentalView();
            var   SettingsView       = new SettingsView();
            var   MeasurementsView   = new MeasurementsView();
            var   DataBaseView       = new DataBaseView();
            var   LogsView           = new LogsView();
            var   CalibrationView    = new CalibrationView();
            var   WizardView         = new WizardView();
            var   ContextMediator    = new ContextMediator();

            LogWindow.DataContext = LogWindowViewModel;
            LogWindow.Show();
            //LogWindow



            var SubStep1 = new ExecutableWizardStepBuilder()
                           .SetName("SubStep1.1")
                           .SetDescription("description for substep 1.1")
                           .SetReadOnly(false)
                           .SetSelectable(true)
                           .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                           .Build();

            var SubStep2 = new ExecutableWizardStepBuilder()
                           .SetName("SubStep1.2")
                           .SetDescription("description for substep 1.2")
                           .SetReadOnly(false)
                           .SetSelectable(true)
                           .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                           .Build();

            var SubSubStep1 = new ExecutableWizardStepBuilder()
                              .SetName("SubSubStep1.3.1")
                              .SetDescription("description for subsubstep 1.3.1")
                              .SetReadOnly(false)
                              .SetSelectable(true)
                              .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                              .Build();

            var SubSubStep2 = new ExecutableWizardStepBuilder()
                              .SetName("SubSubStep1.3.2")
                              .SetDescription("description for subsubstep 1.3.2")
                              .SetReadOnly(false)
                              .SetSelectable(true)
                              .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                              .Build();

            var GrouppedStep1_3 = new WizardStepGroupBuilder()
                                  .SetName("SubGruop1.3")
                                  .SetDescription("description for subgroup 1.3")
                                  .AddChildren(SubSubStep1)
                                  .AddChildren(SubSubStep2)
                                  .Build();

            var GrouppedStep1 = new WizardStepGroupBuilder()
                                .SetName("Group1")
                                .SetDescription("description for subgroup 1")
                                .AddChildren(SubStep1)
                                .AddChildren(SubStep2)
                                .AddChildren(GrouppedStep1_3)
                                .Build();

            var Step2 = new ExecutableWizardStepBuilder()
                        .SetName("Step2")
                        .SetIconName("Settings")
                        .SetDescription("description for step 2")
                        .SetReadOnly(false)
                        .SetSelectable(true)
                        .AddBoundedStep(SubSubStep1)
                        .AddBoundedStep(GrouppedStep1)
                        .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                        .Build();

            var SubStep3_1 = new ExecutableWizardStepBuilder()
                             .SetName("SubStep3.1")
                             .SetDescription("description for substep 3.1")
                             .SetReadOnly(false)
                             .SetSelectable(true)
                             .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                             .Build();

            var GrouppedStep3 = new WizardStepGroupBuilder()
                                .SetName("Group3")
                                .SetDescription("description for group 3")
                                .AddChildren(SubStep3_1)
                                .Build();
            var Step4 = new ExecutableWizardStepBuilder()
                        .SetName("Step4")
                        .SetIconName("Settings")
                        .SetDescription("description for step 2")
                        .SetReadOnly(false)
                        .SetSelectable(true)
                        .AddAction((s, c, o) =>
            {
                try
                {
                }
                catch (System.Exception)
                {
                    throw;
                }
                finally
                {
                }
            })
                        .Last(true)
                        .Build();

            var TestData = new TestData();
            var SettingsGroupsContainer = new SettingsGroupsContainer(
                new SettingsGroup("Group 1",
                                  new DoubleSetting()
            {
                Name = "Setting1.1", Dimention = "Hz", Visible = true
            },
                                  new IntSetting()
            {
                Name = "Setting1.2", Dimention = "Ohm", Visible = true
            }),
                new SettingsGroup("Group 2",
                                  new DoubleSetting()
            {
                Name = "Setting2.1", Dimention = "dB", Visible = true
            },
                                  new IntSetting()
            {
                Name = "Setting2.2", Dimention = "Sec", Visible = true
            }),
                new SettingsGroup("Group 3",
                                  new DoubleSetting()
            {
                Name = "Setting3.1", Dimention = "mV", Visible = true
            },
                                  new IntSetting()
            {
                Name = "Setting3.2", Dimention = "Rad", Visible = true
            }));

            var InstrumentalViewModel = new InstrumentalViewModel("Модуль приборов", "appbar_power", ContextMediator, new SignalAnalyzer(), new SignalGenerator());
            var SettingsViewModel     = new SettingsViewModel("Модуль настроек", "appbar_settings", ContextMediator, SettingsGroupsContainer.SettingsGroups);
            var MeasurementsViewModel = new MeasurementsViewModel("Автоматический режим", "appbar_axis_x", ContextMediator, TestData)
            {
                SettingsList = SettingsGroupsContainer.SettingsGroups
            };
            var DataBaseViewModel = new DataBaseViewModel("База данных", "appbar_database", ContextMediator);
            var LogsViewModel     = new LogsViewModel("Лог", "appbar_disk", ContextMediator);

            var SetupWizard = new SetupWizardBuilder()
                              .AddStep(GrouppedStep1)
                              .AddStep(Step2)
                              .AddStep(GrouppedStep3)
                              .AddStep(Step4)
                              .ConfigureWizard()
                              .Build();

            LogWindow.DataContext        = LogWindowViewModel;
            InstrumentalView.DataContext = InstrumentalViewModel;
            SettingsView.DataContext     = SettingsViewModel;
            MeasurementsView.DataContext = MeasurementsViewModel;
            DataBaseView.DataContext     = DataBaseViewModel;
            LogsView.DataContext         = LogsViewModel;
            WizardView.DataContext       = SetupWizard;

            var CalibrationViewModel = new CalibrationViewModel("Модуль калибровки", "appbar_scale", ContextMediator, WizardView, SetupWizard);

            CalibrationView.DataContext = CalibrationViewModel;

            ContextMediator
            .AddModuleReference(InstrumentalViewModel)
            .AddModuleReference(SettingsViewModel)
            .AddModuleReference(CalibrationViewModel)
            .AddModuleReference(MeasurementsViewModel)
            .AddModuleReference(DataBaseViewModel)
            .AddModuleReference(LogsViewModel);

            shell
            .AddView(InstrumentalView)
            .AddView(SettingsView)
            .AddView(CalibrationView)
            .AddView(MeasurementsView)
            .AddView(DataBaseView)
            .AddView(LogsView);


            //var mainWindow = new MainWindow();
            //mainWindow.DataContext = shell;
        }
Пример #9
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;
        }
Пример #10
0
        /// <summary>
        ///     Класс для создания дочерних окон(костыль чтобы не использовать сторониих библиотек)
        /// </summary>
        /// <param name="viewIndex">
        ///     Индекс View(окна) которое нужно создать(см. switch)
        /// </param>
        /// <param name="dataContext">
        ///     Контекст данных для выбранного View
        /// </param>
        /// <param name="isModal">
        ///     true - дочернее окно будет модальным, false - окно будет не модальным
        /// </param>
        /// <param name="closeAction">
        ///     Метод который надо вызвать по закрытию окна
        /// </param>
        public static void Show(int viewIndex, object dataContext, bool isModal, Action <bool?> closeAction)
        {
            //UserControl для дочернего окна
            UserControl control = null;

            //switch для выбора нужного view
            switch (viewIndex)
            {
            case 0:
                control = new DataBaseView();    //UserControl для отображения данных в бд
                break;

            default:
                //Вбрасывание исключения в случае не правильного индекса
                throw new ArgumentOutOfRangeException(nameof(viewIndex), "Такого индекса View не существует");
            }


            var wnd = new Window {
                SizeToContent = SizeToContent.WidthAndHeight
            };                                 //Созданиие окна, установка размеров окна

            control.DataContext = dataContext; //ViewModel для view
            var sp = new StackPanel();         //StackPanel для размещения елементов в UserControl

            sp.Children.Add(control);

            var applyButton = new Button//кнопка выбора
            {
                Content  = "Принять",
                FontSize = 20,
                Margin   = new Thickness(0, 10, 10, 0),
                Padding  = new Thickness(5)
            };

            applyButton.Click += (sender, args) =>//Событие которое происходит при нажатии на кнопку выбра
            {
                if (isModal)
                {
                    wnd.DialogResult = true;
                }
                else
                {
                    wnd.Close();
                }
            };

            var buttonPanel = new StackPanel//StackPanel для размещения кнопок выбора и выхода
            {
                //Настройки StackPanel
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            buttonPanel.Children.Add(applyButton);                 //Добавление кнопки выбора в StackPanel
            sp.Children.Add(buttonPanel);
            wnd.Content = sp;                                      //Присваиваем окну контролы
            wnd.Closed += (s, e) => closeAction(wnd.DialogResult); //Событие которое происходит при закрытии окна

            if (isModal)
            {
                var cancelButton = new Button//Создание кнопки выходи из модального окна
                {
                    //Инициализация кнопки
                    Content  = "Отмена",
                    FontSize = 20,
                    Margin   = new Thickness(10, 10, 0, 0),
                    Padding  = new Thickness(5)
                };
                cancelButton.Click += (s, e) => { wnd.DialogResult = false; }; //Событие которое происходит при нажатии на кнопку выхода
                buttonPanel.Children.Add(cancelButton);                        //Добавление кнопки к контейнеру
                wnd.ShowDialog();                                              //показ окна
            }
            else
            {
                wnd.Show();
            }
        }
Пример #11
0
        private void Search()
        {
            Big3.Hitbase.DataBaseEngine.Condition sel = new Big3.Hitbase.DataBaseEngine.Condition();

            // Diese Sachen direkt speichern, wenn einmal gesucht wurde.
            Settings.SetValue("LinkSameNumber", checkBoxSameTrackCount.IsChecked == true ? (int)1 : (int)0);
            Settings.SetValue("LinkNotLinked", checkBoxNotAssigned.IsChecked == true ? (int)1 : (int)0);

            // Nur CDs.
            sel.Add(Field.AlbumType, Operator.Equal, 0);

            if (this.checkBoxNotAssigned.IsChecked == true)
            {
                sel.Add(Field.Identity, Operator.Empty, 0);
            }

            if (this.checkBoxSameTrackCount.IsChecked == true)
            {
                sel.Add(Field.NumberOfTracks, Operator.Equal, cdInDrive.NumberOfTracks);
            }

            if (textBoxArtist.Text != "")
            {
                sel.Add(Field.ArtistCDName, Operator.Contains, textBoxArtist.Text);
            }

            if (textBoxTitle.Text != "")
            {
                sel.Add(Field.Title, Operator.Contains, textBoxTitle.Text);
            }

            SortFieldCollection sortKeys = new SortFieldCollection();

            sortKeys.Add(Field.ArtistCDName);
            sortKeys.Add(Field.Title);

            FieldCollection fc = new FieldCollection();

            fc.Add(Field.ArtistCDName);
            fc.Add(Field.Title);
            fc.Add(Field.TotalLength);
            fc.Add(Field.NumberOfTracks);

            List <CDItemResult> items = new List <CDItemResult>();

            using (DataBaseView albumView = AlbumView.CreateView(dataBase, fc, sortKeys, 0, sel))
            {
                object[] values;

                while ((values = albumView.Read()) != null)
                {
                    CDItemResult newItem = new CDItemResult();
                    newItem.CDID           = (int)values[0];
                    newItem.Artist         = (string)values[1];
                    newItem.Title          = values[2] is DBNull ? "" : (string)values[2];
                    newItem.Length         = (int)values[3];
                    newItem.NumberOfTracks = (int)values[4];

                    items.Add(newItem);
                }
            }

            DataGridResult.ItemsSource = items;

            return;
        }
Пример #12
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;
        }
Пример #13
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;
        }