Esempio n. 1
0
        void lbFilterConditions_Editing_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            GroupFilterVM gf = this.DataContext as GroupFilterVM;

            if (gf == null)
            {
                return;
            }

            GroupFilterConditionVM gfc = lbFilterConditions_Editing.SelectedItem as GroupFilterConditionVM;

            if (gfc == null)
            {
                return;
            }

            try
            {
                GroupFilterConditionForm frm = new GroupFilterConditionForm();
                frm.Owner = Window.GetWindow(this);
                frm.Init(gf, gfc);
                bool?result = frm.ShowDialog();
                if (result.HasValue && result.Value == true)
                {
                    Window     win  = Window.GetWindow(this);
                    MainWindow main = win as MainWindow;
                    //gf.FilterConditions.Add(gfc);

                    MainListHelperVM.Instance.ViewGroupsForms.Filter = main.GroupFilter_GroupSearch;
                    MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        public void Init(GroupFilterVM gf, GroupFilterConditionVM gfc)
        {
            groupFilter          = gf;
            groupFilterCondition = gfc;


            try
            {
                cboConditionType.Items.Clear();
                foreach (string cond in GroupFilterHelper.GetAllConditionTypes())
                {
                    cboConditionType.Items.Add(cond);
                }

                PopulateAnimeGroups();
                PopulateTags();
                PopulateCustomTags();
                PopulateVideoQuality();
                PopulateAnimeTypes();
                PopulateLanguages();

                // find the right condition
                int idx = 0;
                for (int i = 0; i < cboConditionType.Items.Count; i++)
                {
                    GroupFilterConditionType conditionTypeTemp = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.Items[i].ToString());
                    if (conditionTypeTemp == gfc.ConditionTypeEnum)
                    {
                        idx = i;
                        break;
                    }
                }
                cboConditionType.SelectedIndex = idx;
                GroupFilterConditionType conditionType = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.SelectedItem.ToString());

                cboConditionOperator.Items.Clear();
                foreach (string op in GroupFilterHelper.GetAllowedOperators(conditionType))
                {
                    cboConditionOperator.Items.Add(op);
                }

                cboConditionType.SelectionChanged     += new SelectionChangedEventHandler(cboConditionType_SelectionChanged);
                cboConditionOperator.SelectionChanged += new SelectionChangedEventHandler(cboConditionOperator_SelectionChanged);

                // find the right operator
                idx = 0;
                for (int i = 0; i < cboConditionOperator.Items.Count; i++)
                {
                    GroupFilterOperator opTypeTemp = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[i].ToString());
                    if (opTypeTemp == gfc.ConditionOperatorEnum)
                    {
                        idx = i;
                        break;
                    }
                }
                cboConditionOperator.SelectedIndex = idx;
                GroupFilterOperator opType = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[idx].ToString());

                // display the selected filter value
                switch (conditionType)
                {
                case GroupFilterConditionType.AirDate:
                case GroupFilterConditionType.SeriesCreatedDate:
                case GroupFilterConditionType.EpisodeAddedDate:
                case GroupFilterConditionType.EpisodeWatchedDate:
                case GroupFilterConditionType.LatestEpisodeAirDate:

                    if (opType == GroupFilterOperator.LastXDays)
                    {
                        txtParameter.Text = gfc.ConditionParameter;
                    }
                    else
                    {
                        DateTime airDate = GroupFilterHelper.GetDateFromString(gfc.ConditionParameter);
                        dpDate.SelectedDate = airDate;
                    }
                    break;

                case GroupFilterConditionType.AnimeGroup:

                    // don't display anything
                    break;

                case GroupFilterConditionType.AnimeType:
                case GroupFilterConditionType.Tag:
                case GroupFilterConditionType.CustomTags:
                case GroupFilterConditionType.ReleaseGroup:
                case GroupFilterConditionType.Studio:
                case GroupFilterConditionType.VideoQuality:
                case GroupFilterConditionType.AniDBRating:
                case GroupFilterConditionType.UserRating:
                case GroupFilterConditionType.AudioLanguage:
                case GroupFilterConditionType.SubtitleLanguage:
                case GroupFilterConditionType.Year:
                    txtParameter.Text = gfc.ConditionParameter;
                    break;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Esempio n. 3
0
        private void CommandBinding_Cancel(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;
            if (obj == null) return;

            try
            {
                if (obj.GetType() == typeof(AnimeGroupVM))
                {
                    AnimeGroupVM grp = (AnimeGroupVM)obj;
                    grp.IsReadOnly = true;
                    grp.IsBeingEdited = false;

                    // copy all editable properties
                    if (grp.AnimeGroupID.HasValue) // an existing group
                    {
                        grp.GroupName = groupBeforeChanges.GroupName;
                        grp.IsFave = groupBeforeChanges.IsFave;

                        //grp.AnimeGroupParentID = groupBeforeChanges.AnimeGroupParentID;
                        grp.Description = groupBeforeChanges.Description;
                        grp.SortName = groupBeforeChanges.SortName;

                        MainListHelperVM.Instance.ViewGroups.Refresh();
                        EnableDisableGroupControls(true);
                        //MainListHelperVM.Instance.LastAnimeGroupID = grp.AnimeGroupID.Value;
                        HighlightMainListItem();
                    }
                    else
                    {
                        HighlightMainListItem();
                        SetDetailBinding(null);
                    }

                }

                if (obj.GetType() == typeof(GroupFilterVM))
                {
                    GroupFilterVM gf = (GroupFilterVM)obj;
                    gf.IsLocked = true;
                    gf.IsBeingEdited = false;

                    // copy all editable properties
                    if (gf.GroupFilterID.HasValue && gf.GroupFilterID.Value!=0) // an existing group filter
                    {
                        gf.FilterName = groupFilterBeforeChanges.FilterName;
                        gf.ApplyToSeries = groupFilterBeforeChanges.ApplyToSeries;
                        gf.BaseCondition = groupFilterBeforeChanges.BaseCondition;
                        gf.FilterConditions.Clear();
                        gf.SortCriteriaList.Clear();

                        foreach (GroupFilterConditionVM gfc_old in groupFilterBeforeChanges.FilterConditions)
                        {
                            GroupFilterConditionVM gfc = new GroupFilterConditionVM();
                            gfc.ConditionOperator = gfc_old.ConditionOperator;
                            gfc.ConditionParameter = gfc_old.ConditionParameter;
                            gfc.ConditionType = gfc_old.ConditionType;
                            gfc.GroupFilterConditionID = gfc_old.GroupFilterConditionID;
                            gfc.GroupFilterID = gfc_old.GroupFilterID;
                            gf.FilterConditions.Add(gfc);
                        }

                        foreach (GroupFilterSortingCriteria gfsc_old in groupFilterBeforeChanges.SortCriteriaList)
                        {
                            GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria();
                            gfsc.GroupFilterID = gfsc_old.GroupFilterID;
                            gfsc.SortDirection = gfsc_old.SortDirection;
                            gfsc.SortType = gfsc_old.SortType;
                            gf.SortCriteriaList.Add(gfsc);
                        }

                        //MainListHelperVM.Instance.LastGroupFilterID = gf.GroupFilterID.Value;
                    }
                    else
                    {
                        SetDetailBinding(null);
                    }
                    EnableDisableGroupControls(true);
                    HighlightMainListItem();
                }

                if (obj.GetType() == typeof(AnimeSeriesVM))
                {

                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Esempio n. 4
0
        private void CommandBinding_NewFilterCondition(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                object obj = e.Parameter;
                if (obj == null) return;

                GroupFilterVM gf = (GroupFilterVM)obj;
                GroupFilterConditionVM gfc = new GroupFilterConditionVM();

                GroupFilterConditionForm frm = new GroupFilterConditionForm();
                frm.Owner = this;
                frm.Init(gf, gfc);
                bool? result = frm.ShowDialog();
                if (result.HasValue && result.Value == true)
                {
                    gf.FilterConditions.Add(gfc);

                    groupFilterVM = gf;
                    MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch;
                    MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Esempio n. 5
0
        private void CommandBinding_Edit(object sender, ExecutedRoutedEventArgs e)
        {
            //object obj = lbGroupsSeries.SelectedItem;
            object obj = e.Parameter;
            if (obj == null) return;

            try
            {
                if (obj.GetType() == typeof(AnimeGroupVM))
                {
                    AnimeGroupVM grp = (AnimeGroupVM)obj;

                    if (grp.AnimeGroupID.HasValue)
                    {
                        groupBeforeChanges = new AnimeGroupVM();
                        Cloner.Clone(grp, groupBeforeChanges);
                    }

                    grp.IsReadOnly = false;
                    grp.IsBeingEdited = true;

                }

                if (obj.GetType() == typeof(GroupFilterVM))
                {
                    GroupFilterVM gf = (GroupFilterVM)obj;

                    if (gf.GroupFilterID.HasValue && gf.GroupFilterID.Value!=0)
                    {
                        groupFilterBeforeChanges = new GroupFilterVM();
                        groupFilterBeforeChanges.FilterName = gf.FilterName;
                        groupFilterBeforeChanges.BaseCondition = gf.BaseCondition;
                        groupFilterBeforeChanges.ApplyToSeries = gf.ApplyToSeries;
                        groupFilterBeforeChanges.FilterConditions = new ObservableCollection<GroupFilterConditionVM>();
                        groupFilterBeforeChanges.SortCriteriaList = new ObservableCollection<GroupFilterSortingCriteria>();

                        foreach (GroupFilterConditionVM gfc_cur in gf.FilterConditions)
                        {
                            GroupFilterConditionVM gfc = new GroupFilterConditionVM();
                            gfc.ConditionOperator = gfc_cur.ConditionOperator;
                            gfc.ConditionParameter = gfc_cur.ConditionParameter;
                            gfc.ConditionType = gfc_cur.ConditionType;
                            gfc.GroupFilterConditionID = gfc_cur.GroupFilterConditionID;
                            gfc.GroupFilterID = gfc_cur.GroupFilterID;
                            groupFilterBeforeChanges.FilterConditions.Add(gfc);
                        }

                        foreach (GroupFilterSortingCriteria gfcs_cur in gf.SortCriteriaList)
                        {
                            GroupFilterSortingCriteria gfsc = new GroupFilterSortingCriteria();
                            gfsc.GroupFilterID = gfcs_cur.GroupFilterID;
                            gfsc.SortDirection = gfcs_cur.SortDirection;
                            gfsc.SortType = gfcs_cur.SortType;
                            groupFilterBeforeChanges.SortCriteriaList.Add(gfsc);
                        }
                        //Cloner.Clone(gf, groupFilterBeforeChanges);
                    }

                    gf.IsLocked = false;
                    gf.IsBeingEdited = true;

                    groupFilterVM = gf;
                    MainListHelperVM.Instance.ViewGroupsForms.Filter = GroupFilter_GroupSearch;
                    MainListHelperVM.Instance.SetGroupFilterSortingOnForms(gf);
                }

                if (obj.GetType() == typeof(AnimeSeriesVM))
                {

                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            EnableDisableGroupControls(false);
        }
        public void Init(GroupFilterVM gf, GroupFilterConditionVM gfc)
        {
            groupFilter = gf;
            groupFilterCondition = gfc;

            try
            {
                cboConditionType.Items.Clear();
                foreach (string cond in GroupFilterHelper.GetAllConditionTypes())
                    cboConditionType.Items.Add(cond);

                PopulateAnimeGroups();
                PopulateTags();
                PopulateCustomTags();
                PopulateVideoQuality();
                PopulateAnimeTypes();
                PopulateLanguages();

                // find the right condition
                int idx = 0;
                for (int i = 0; i < cboConditionType.Items.Count; i++)
                {
                    GroupFilterConditionType conditionTypeTemp = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.Items[i].ToString());
                    if (conditionTypeTemp == gfc.ConditionTypeEnum)
                    {
                        idx = i;
                        break;
                    }
                }
                cboConditionType.SelectedIndex = idx;
                GroupFilterConditionType conditionType = GroupFilterHelper.GetEnumForText_ConditionType(cboConditionType.SelectedItem.ToString());

                cboConditionOperator.Items.Clear();
                foreach (string op in GroupFilterHelper.GetAllowedOperators(conditionType))
                    cboConditionOperator.Items.Add(op);

                cboConditionType.SelectionChanged += new SelectionChangedEventHandler(cboConditionType_SelectionChanged);
                cboConditionOperator.SelectionChanged += new SelectionChangedEventHandler(cboConditionOperator_SelectionChanged);

                // find the right operator
                idx = 0;
                for (int i = 0; i < cboConditionOperator.Items.Count; i++)
                {
                    GroupFilterOperator opTypeTemp = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[i].ToString());
                    if (opTypeTemp == gfc.ConditionOperatorEnum)
                    {
                        idx = i;
                        break;
                    }
                }
                cboConditionOperator.SelectedIndex = idx;
                GroupFilterOperator opType = GroupFilterHelper.GetEnumForText_Operator(cboConditionOperator.Items[idx].ToString());

                // display the selected filter value
                switch (conditionType)
                {
                    case GroupFilterConditionType.AirDate:
                    case GroupFilterConditionType.SeriesCreatedDate:
                    case GroupFilterConditionType.EpisodeAddedDate:
                    case GroupFilterConditionType.EpisodeWatchedDate:
                    case GroupFilterConditionType.LatestEpisodeAirDate:

                        if (opType == GroupFilterOperator.LastXDays)
                            txtParameter.Text = gfc.ConditionParameter;
                        else
                        {
                            DateTime airDate = GroupFilterHelper.GetDateFromString(gfc.ConditionParameter);
                            dpDate.SelectedDate = airDate;
                        }
                        break;

                    case GroupFilterConditionType.AnimeGroup:

                        // don't display anything
                        break;

                    case GroupFilterConditionType.AnimeType:
                    case GroupFilterConditionType.Tag:
                    case GroupFilterConditionType.CustomTags:
                    case GroupFilterConditionType.ReleaseGroup:
                    case GroupFilterConditionType.Studio:
                    case GroupFilterConditionType.VideoQuality:
                    case GroupFilterConditionType.AniDBRating:
                    case GroupFilterConditionType.UserRating:
                    case GroupFilterConditionType.AudioLanguage:
                    case GroupFilterConditionType.SubtitleLanguage:
                    case GroupFilterConditionType.Year:
                        txtParameter.Text = gfc.ConditionParameter;
                        break;
                }

            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }