Пример #1
0
        /// <summary>
        /// Filter by Media
        /// </summary>
        /// <param name="card">The card.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev08, 2009-07-16</remarks>
        private bool CardSearchFilterMedia(CardTreeViewItem card)
        {
            //If all checkboxes are unchecked, return true;
            if (!checkBoxFilterPicture.IsChecked.Value && !checkBoxFilterAudio.IsChecked.Value && !checkBoxFilterVideo.IsChecked.Value)
            {
                return(true);
            }

            if (card.HasAudio != checkBoxFilterAudio.IsChecked.Value)
            {
                return(false);
            }

            if (card.HasImage != checkBoxFilterPicture.IsChecked.Value)
            {
                return(false);
            }

            if (card.HasVideo != checkBoxFilterVideo.IsChecked.Value)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Filters by Example Sentence
        /// </summary>
        /// <param name="card">The card.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev08, 2009-07-16</remarks>
        private bool CardSearchExampleSentence(CardTreeViewItem card)
        {
            if (!checkBoxFilterExampleSentence.IsChecked.Value)
            {
                return(true);
            }

            return(card.HasExampleSentence);
        }
Пример #3
0
        /// <summary>
        /// Inits the text search filter.
        /// </summary>
        /// <remarks>Documented by Dev08, 2009-07-15</remarks>
        private void InitCardSearchFilter()
        {
            foreach (ICollectionView cardView in CardFilterViewList)
            {
                cardView.Filter = delegate(object obj)
                {
                    CardTreeViewItem cardTreeViewItem = obj as CardTreeViewItem;

                    if (cardTreeViewItem == null)
                    {
                        return(false);
                    }

                    if (!CardSearchFilterText(cardFilter, new List <string>()
                    {
                        cardTreeViewItem.Question, cardTreeViewItem.Answer, cardTreeViewItem.QuestionExample, cardTreeViewItem.AnswerExample
                    }))
                    {
                        return(false);
                    }

                    if (!CardSearchFilterLearningMode(cardTreeViewItem.Settings.QueryTypes))
                    {
                        return(false);
                    }

                    if (!CardSearchFilterDirection(cardTreeViewItem.Settings.QueryDirections))
                    {
                        return(false);
                    }

                    if (!CardSearchFilterMCOptions(cardTreeViewItem.Settings.MultipleChoiceOptions))
                    {
                        return(false);
                    }

                    if (!CardSearchFilterMedia(cardTreeViewItem))
                    {
                        return(false);
                    }

                    if (!CardSearchExampleSentence(cardTreeViewItem))
                    {
                        return(false);
                    }

                    return(true);
                };
            }
        }
Пример #4
0
        /// <summary>
        /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="x">The first object to compare.</param>
        /// <param name="y">The second object to compare.</param>
        /// <returns>
        /// Value
        /// Condition
        /// Less than zero
        /// <paramref name="x"/> is less than <paramref name="y"/>.
        /// Zero
        /// <paramref name="x"/> equals <paramref name="y"/>.
        /// Greater than zero
        /// <paramref name="x"/> is greater than <paramref name="y"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">
        /// Neither <paramref name="x"/> nor <paramref name="y"/> implements the <see cref="T:System.IComparable"/> interface.
        /// -or-
        /// <paramref name="x"/> and <paramref name="y"/> are of different types and neither one can handle comparisons with the other.
        /// </exception>
        /// <remarks>Documented by Dev08, 2009-07-16</remarks>
        public int Compare(object x, object y)
        {
            if (!(x is CardTreeViewItem) || !(y is CardTreeViewItem))
            {
                return(-1);
            }

            CardTreeViewItem card1 = x as CardTreeViewItem;
            CardTreeViewItem card2 = y as CardTreeViewItem;

            if (column == CardSortColumn.Id)
            {
                if (card1.Id == card2.Id)
                {
                    return(0);
                }
                else if (card1.Id < card2.Id)
                {
                    return(-1);
                }
                else if (card1.Id > card2.Id)
                {
                    return(1);
                }
            }

            if (column == CardSortColumn.Question)
            {
                return(string.Compare(card1.Question, card2.Question));
            }

            if (column == CardSortColumn.Answer)
            {
                return(string.Compare(card1.Answer, card2.Answer));
            }

            return(-1);
        }
Пример #5
0
        /// <summary>
        /// Handles the SelectedItemChanged event of the treeViewLearningModule control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedPropertyChangedEventArgs&lt;System.Object&gt;"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev08, 2009-07-20</remarks>
        private void treeViewLearningModule_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (!(sender is TreeView))
            {
                return;
            }

            if ((sender as TreeView).SelectedItem is LearningModuleTreeViewItem)
            {
                LearningModuleTreeViewItem learningModuleTreeViewItem = (sender as TreeView).SelectedItem as LearningModuleTreeViewItem;
                settingsControlMain.SetSettings(learningModuleTreeViewItem.Settings);
            }
            else if ((sender as TreeView).SelectedItem is ChapterTreeViewItem)
            {
                ChapterTreeViewItem chapterTreeViewItem = (sender as TreeView).SelectedItem as ChapterTreeViewItem;
                settingsControlMain.SetSettings(chapterTreeViewItem.Settings);
            }
            else if ((sender as TreeView).SelectedItem is CardTreeViewItem)
            {
                CardTreeViewItem cardTreeViewItem = (sender as TreeView).SelectedItem as CardTreeViewItem;
                settingsControlMain.SetSettings(cardTreeViewItem.Settings);
            }
        }
        /// <summary>
        /// Filter by Media
        /// </summary>
        /// <param name="card">The card.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev08, 2009-07-16</remarks>
        private bool CardSearchFilterMedia(CardTreeViewItem card)
        {
            //If all checkboxes are unchecked, return true;
            if (!checkBoxFilterPicture.IsChecked.Value && !checkBoxFilterAudio.IsChecked.Value && !checkBoxFilterVideo.IsChecked.Value)
                return true;

            if (card.HasAudio != checkBoxFilterAudio.IsChecked.Value)
                return false;

            if (card.HasImage != checkBoxFilterPicture.IsChecked.Value)
                return false;

            if (card.HasVideo != checkBoxFilterVideo.IsChecked.Value)
                return false;

            return true;
        }
        /// <summary>
        /// Filters by Example Sentence
        /// </summary>
        /// <param name="card">The card.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev08, 2009-07-16</remarks>
        private bool CardSearchExampleSentence(CardTreeViewItem card)
        {
            if (!checkBoxFilterExampleSentence.IsChecked.Value)
                return true;

            return card.HasExampleSentence;
        }