Exemple #1
0
        private void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            MixEntry nestedEntry = new MixEntry(this, Depth + 1);

            nestedEntry.TextBotGotFocus  += HandleTextBoxGotFocus;
            nestedEntry.TextBotLostFocus += HandleTextBoxLostFocus;

            NestedList.Children.Add(nestedEntry);
        }
Exemple #2
0
        public MixEntry(MixEntry parent, int depth)
        {
            this.InitializeComponent();

            ParentMixEntry = parent;

            if (depth < MAX_DEPTH)
            {
                AllMixTypes.Add(new SelectableOption<MixType>(Strings.GetResource("MixEntryMixTypeAll"), MixType.And));
                AllMixTypes.Add(new SelectableOption<MixType>(Strings.GetResource("MixEntryMixTypeAny"), MixType.Or));
                AllMixTypes.Add(new SelectableOption<MixType>(Strings.GetResource("MixEntryMixTypeNot"), MixType.Not));
            }

            MixEntryType.ItemsSource = AllMixTypes;
            MixEntryType.SelectedIndex = 0;

            StringPicker.ItemsSource = StringInfo;
            StringPicker.SelectedIndex = 0;

            NumericPicker.ItemsSource = NumericInfo;
            NumericPicker.SelectedIndex = 0;

            PlaylistMemberPicker.ItemsSource = LibraryViewModel.Current.PlaylistCollection;
            if (LibraryViewModel.Current.PlaylistCollection.Count > 0)
            {
                PlaylistMemberPicker.SelectedIndex = 0;
            }

            MixMemberPicker.ItemsSource = LibraryViewModel.Current.MixCollection;
            MixMemberPicker.SelectedIndex = 0;

            NumericValue.Text = "0";

            Depth = depth;

            if (Depth > 0)
            {
                VisualStateManager.GoToState(this, "MixIsChild", false);
            }
            else
            {
                VisualStateManager.GoToState(this, "MixIsRoot", false);
            }
        }
Exemple #3
0
        public MixEntry(MixEntry parent, int depth)
        {
            this.InitializeComponent();

            ParentMixEntry = parent;

            if (depth < MAX_DEPTH)
            {
                AllMixTypes.Add(new SelectableOption <MixType>(Strings.GetResource("MixEntryMixTypeAll"), MixType.And));
                AllMixTypes.Add(new SelectableOption <MixType>(Strings.GetResource("MixEntryMixTypeAny"), MixType.Or));
                AllMixTypes.Add(new SelectableOption <MixType>(Strings.GetResource("MixEntryMixTypeNot"), MixType.Not));
            }

            MixEntryType.ItemsSource   = AllMixTypes;
            MixEntryType.SelectedIndex = 0;

            StringPicker.ItemsSource   = StringInfo;
            StringPicker.SelectedIndex = 0;

            NumericPicker.ItemsSource   = NumericInfo;
            NumericPicker.SelectedIndex = 0;

            PlaylistMemberPicker.ItemsSource = LibraryViewModel.Current.PlaylistCollection;
            if (LibraryViewModel.Current.PlaylistCollection.Count > 0)
            {
                PlaylistMemberPicker.SelectedIndex = 0;
            }

            MixMemberPicker.ItemsSource   = LibraryViewModel.Current.MixCollection;
            MixMemberPicker.SelectedIndex = 0;

            NumericValue.Text = "0";

            Depth = depth;

            if (Depth > 0)
            {
                VisualStateManager.GoToState(this, "MixIsChild", false);
            }
            else
            {
                VisualStateManager.GoToState(this, "MixIsRoot", false);
            }
        }
Exemple #4
0
 private void RemoveEntry(MixEntry mixEntry)
 {
     NestedList.Children.Remove(mixEntry);
 }
Exemple #5
0
        private void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            MixEntry nestedEntry = new MixEntry(this, Depth + 1);

            nestedEntry.TextBotGotFocus += HandleTextBoxGotFocus;
            nestedEntry.TextBotLostFocus += HandleTextBoxLostFocus;

            NestedList.Children.Add(nestedEntry);
        }
Exemple #6
0
        public void LoadEvaluator(IMixEvaluator evaluator)
        {
            MixType mixType = evaluator.MixType;

            SelectableOption<MixType> selectedMixTypeEntry = AllMixTypes.Where((m) => { return (m.Type == (mixType & MixType.SUBTYPE_MASK) || m.Type == mixType); }).FirstOrDefault();
            MixEntryType.SelectedItem = selectedMixTypeEntry;

            switch (mixType & MixType.TYPE_MASK)
            {
                case MixType.NUMBER_TYPE:
                    NumericMixEvaluator<IComparable> numericEvaluator = DebugHelper.CastAndAssert<NumericMixEvaluator<IComparable>>(evaluator);

                    SelectableOption<NumericEvalType> selectedNumericTypeEntry = NumericInfo.Where((m) => { return (m.Type == numericEvaluator.EvalType); }).FirstOrDefault();
                    NumericPicker.SelectedItem = selectedNumericTypeEntry;

                    UpdateNumericStartingValue(mixType, numericEvaluator.Target);
                    return;
                case MixType.STRING_TYPE:
                    StringMixEvaluator stringEvaluator = DebugHelper.CastAndAssert<StringMixEvaluator>(evaluator);

                    SelectableOption<StringEvalType> selectedStringTypeEntry = StringInfo.Where((m) => { return (m.Type == stringEvaluator.EvalType); }).FirstOrDefault();
                    StringPicker.SelectedItem = selectedStringTypeEntry;

                    StringValue.Text = stringEvaluator.Target;
                    return;
                case MixType.NESTED_TYPE:
                    NestedMixEvaluator nestedEvaluator = DebugHelper.CastAndAssert<NestedMixEvaluator>(evaluator);

                    foreach (IMixEvaluator mixEvaluator in nestedEvaluator.Mixes)
                    {
                        MixEntry nestedEntry = new MixEntry(this, Depth + 1);
                        nestedEntry.LoadEvaluator(mixEvaluator);
                        NestedList.Children.Add(nestedEntry);
                        nestedEntry.TextBotGotFocus += HandleTextBoxGotFocus;
                        nestedEntry.TextBotLostFocus += HandleTextBoxLostFocus;
                    }

                    return;
                case MixType.MEMBER_TYPE:
                    MemberMixEvaluator memberEvaluator = DebugHelper.CastAndAssert<MemberMixEvaluator>(evaluator);

                    if ((mixType & MixType.SUBTYPE_MASK) == MixType.PLAYLISTMEMBER_SUBTYPE)
                    {
                        PlaylistViewModel playlist = LibraryViewModel.Current.LookupPlaylistById(memberEvaluator.Target);

                        PlaylistMemberPicker.SelectedItem = playlist;
                    }
                    else if ((mixType & MixType.SUBTYPE_MASK) == MixType.MIXMEMBER_SUBTYPE)
                    {
                        MixViewModel mix = LibraryViewModel.Current.LookupMixById(memberEvaluator.Target);

                        MixMemberPicker.SelectedItem = mix;
                    }
                    else
                    {
                        DebugHelper.Alert(new CallerInfo(), "Unexpected member type: {0}", mixType);
                        return;
                    }

                    return;
                case MixType.RANGE_TYPE:
                    RangeMixEvaluator rangeEvaluator = DebugHelper.CastAndAssert<RangeMixEvaluator>(evaluator);

                    RangeValue.Text = rangeEvaluator.Target.ToString();

                    return;
                default:
                    DebugHelper.Assert(new CallerInfo(), mixType == MixType.None, "Unexpected mix type: {0}", mixType);
                    VisualStateManager.GoToState(this, "UnknownSelected", false);
                    return;
            }
        }
Exemple #7
0
 private void RemoveEntry(MixEntry mixEntry)
 {
     NestedList.Children.Remove(mixEntry);
 }
Exemple #8
0
        public IMixEvaluator ConvertToEvaluator()
        {
            if (MixEntryType.SelectedItem == null)
            {
                return(new NoneMixEvaluator());
            }

            SelectableOption <MixType> selectedType = DebugHelper.CastAndAssert <SelectableOption <MixType> >(MixEntryType.SelectedItem);

            switch (selectedType.Type & MixType.TYPE_MASK)
            {
            case MixType.NUMBER_TYPE:
                if (NumericPicker.SelectedItem == null)
                {
                    return(new NoneMixEvaluator());
                }

                SelectableOption <NumericEvalType> selectedNumericType = DebugHelper.CastAndAssert <SelectableOption <NumericEvalType> >(NumericPicker.SelectedItem);

                string newTarget = ConvertNumericValueToString(selectedType.Type);

                return(MixViewModel.NumericMixEntryModelToMixEvaluator(selectedType.Type | NumericMixEvaluator <int> .NumericEvalTypeToMixTypeVariant(selectedNumericType.Type), newTarget));

            case MixType.STRING_TYPE:
                if (StringPicker.SelectedItem == null)
                {
                    return(new NoneMixEvaluator());
                }

                SelectableOption <StringEvalType> selectedStringType = DebugHelper.CastAndAssert <SelectableOption <StringEvalType> >(StringPicker.SelectedItem);

                return(MixViewModel.StringMixEntryModelToMixEvaluator(selectedType.Type | StringMixEvaluator.StringEvalTypeToMixTypeVariant(selectedStringType.Type), StringValue.Text));

            case MixType.NESTED_TYPE:
                List <IMixEvaluator> mixes = new List <IMixEvaluator>();

                foreach (object listItem in NestedList.Children)
                {
                    MixEntry listItemAsMixEntry = DebugHelper.CastAndAssert <MixEntry>(listItem);

                    mixes.Add(listItemAsMixEntry.ConvertToEvaluator());
                }

                return(MixViewModel.NestedMixEntryModelToMixEvaluator(selectedType.Type, mixes));

            case MixType.RANGE_TYPE:
                return(MixViewModel.RangeMixEntryModelToMixEvaluator(selectedType.Type | RangeMixEvaluator.RangeEvalTypeToMixTypeVariant(RangeEvalType.Days), RangeValue.Text));

            case MixType.MEMBER_TYPE:
                if (selectedType.Type == MixType.PLAYLISTMEMBER_SUBTYPE)
                {
                    if (PlaylistMemberPicker.SelectedItem == null)
                    {
                        return(new NoneMixEvaluator());
                    }

                    PlaylistViewModel selectedPlaylist = DebugHelper.CastAndAssert <PlaylistViewModel>(PlaylistMemberPicker.SelectedItem);

                    return(MixViewModel.MemberMixEntryModelToMixEvaluator(MixType.PlaylistMemberContains, selectedPlaylist.PlaylistId.ToString()));
                }
                else if (selectedType.Type == MixType.MIXMEMBER_SUBTYPE)
                {
                    if (MixMemberPicker.SelectedItem == null)
                    {
                        return(new NoneMixEvaluator());
                    }

                    MixViewModel selectedMix = DebugHelper.CastAndAssert <MixViewModel>(MixMemberPicker.SelectedItem);

                    return(MixViewModel.MemberMixEntryModelToMixEvaluator(MixType.MixMemberContains, selectedMix.MixId.ToString()));
                }
                else
                {
                    DebugHelper.Alert(new CallerInfo(), "Unexpected member type: {0}", selectedType);
                    return(new NoneMixEvaluator());
                }

            default:
                DebugHelper.Assert(new CallerInfo(), selectedType.Type == MixType.None, "Unexpected mix type: {0}", selectedType.Type);
                return(new NoneMixEvaluator());
            }
        }
Exemple #9
0
        public void LoadEvaluator(IMixEvaluator evaluator)
        {
            MixType mixType = evaluator.MixType;

            SelectableOption <MixType> selectedMixTypeEntry = AllMixTypes.Where((m) => { return(m.Type == (mixType & MixType.SUBTYPE_MASK) || m.Type == mixType); }).FirstOrDefault();

            MixEntryType.SelectedItem = selectedMixTypeEntry;

            switch (mixType & MixType.TYPE_MASK)
            {
            case MixType.NUMBER_TYPE:
                NumericMixEvaluator <IComparable> numericEvaluator = DebugHelper.CastAndAssert <NumericMixEvaluator <IComparable> >(evaluator);

                SelectableOption <NumericEvalType> selectedNumericTypeEntry = NumericInfo.Where((m) => { return(m.Type == numericEvaluator.EvalType); }).FirstOrDefault();
                NumericPicker.SelectedItem = selectedNumericTypeEntry;

                UpdateNumericStartingValue(mixType, numericEvaluator.Target);
                return;

            case MixType.STRING_TYPE:
                StringMixEvaluator stringEvaluator = DebugHelper.CastAndAssert <StringMixEvaluator>(evaluator);

                SelectableOption <StringEvalType> selectedStringTypeEntry = StringInfo.Where((m) => { return(m.Type == stringEvaluator.EvalType); }).FirstOrDefault();
                StringPicker.SelectedItem = selectedStringTypeEntry;

                StringValue.Text = stringEvaluator.Target;
                return;

            case MixType.NESTED_TYPE:
                NestedMixEvaluator nestedEvaluator = DebugHelper.CastAndAssert <NestedMixEvaluator>(evaluator);

                foreach (IMixEvaluator mixEvaluator in nestedEvaluator.Mixes)
                {
                    MixEntry nestedEntry = new MixEntry(this, Depth + 1);
                    nestedEntry.LoadEvaluator(mixEvaluator);
                    NestedList.Children.Add(nestedEntry);
                    nestedEntry.TextBotGotFocus  += HandleTextBoxGotFocus;
                    nestedEntry.TextBotLostFocus += HandleTextBoxLostFocus;
                }

                return;

            case MixType.MEMBER_TYPE:
                MemberMixEvaluator memberEvaluator = DebugHelper.CastAndAssert <MemberMixEvaluator>(evaluator);

                if ((mixType & MixType.SUBTYPE_MASK) == MixType.PLAYLISTMEMBER_SUBTYPE)
                {
                    PlaylistViewModel playlist = LibraryViewModel.Current.LookupPlaylistById(memberEvaluator.Target);

                    PlaylistMemberPicker.SelectedItem = playlist;
                }
                else if ((mixType & MixType.SUBTYPE_MASK) == MixType.MIXMEMBER_SUBTYPE)
                {
                    MixViewModel mix = LibraryViewModel.Current.LookupMixById(memberEvaluator.Target);

                    MixMemberPicker.SelectedItem = mix;
                }
                else
                {
                    DebugHelper.Alert(new CallerInfo(), "Unexpected member type: {0}", mixType);
                    return;
                }

                return;

            case MixType.RANGE_TYPE:
                RangeMixEvaluator rangeEvaluator = DebugHelper.CastAndAssert <RangeMixEvaluator>(evaluator);

                RangeValue.Text = rangeEvaluator.Target.ToString();

                return;

            default:
                DebugHelper.Assert(new CallerInfo(), mixType == MixType.None, "Unexpected mix type: {0}", mixType);
                VisualStateManager.GoToState(this, "UnknownSelected", false);
                return;
            }
        }