Ejemplo n.º 1
0
 public static void FillDummyDic(Dictionary dictionary)
 {
     List<int> chapters = new List<int>();
     for (int k = 0; k < 10; k++)
     {
         int chapterId = dictionary.Chapters.AddChapter("Chapter " + Convert.ToString(k + 1), "Chapter Description" + Convert.ToString(k + 1));
         chapters.Add(chapterId);
         dictionary.QueryChapters.Add(chapterId);
     }
     for (int i = 0; i < TestInfrastructure.LoopCount; i++)
     {
         bool hasQImage = TestInfrastructure.RandomBool, hasAImage = TestInfrastructure.RandomBool;
         bool hasQAudio = TestInfrastructure.RandomBool, hasAAudio = TestInfrastructure.RandomBool;
         bool hasQEAudio = TestInfrastructure.RandomBool, hasAEAudio = TestInfrastructure.RandomBool;
         bool hasQVideo = TestInfrastructure.RandomBool, hasAVideo = TestInfrastructure.RandomBool;
         bool hasQExample = TestInfrastructure.RandomBool, hasAExample = TestInfrastructure.RandomBool;
         int cardId = dictionary.Cards.AddCard("question " + i, "answer " + i, (hasQExample) ? "question example " + i : String.Empty, (hasAExample) ? "answer example " + i : String.Empty, String.Empty, String.Empty, chapters[TestInfrastructure.Random.Next(0, chapters.Count)]);
         if (hasQImage)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestImage(), EMedia.Image, Side.Question, true, true, false);
         if (hasAImage)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestImage(), EMedia.Image, Side.Answer, true, true, false);
         if (hasQAudio)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Question, true, true, false);
         if (hasAAudio)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Answer, true, true, false);
         if (hasQEAudio)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Question, true, false, true);
         if (hasAEAudio)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestAudio(), EMedia.Audio, Side.Answer, true, false, true);
         if (hasQVideo)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestVideo(), EMedia.Video, Side.Question, true, true, false);
         if (hasAVideo)
             dictionary.Cards.AddMedia(cardId, TestInfrastructure.GetTestVideo(), EMedia.Video, Side.Answer, true, true, false);
     }
 }
Ejemplo n.º 2
0
        public CardPreview(Card cardToDisplay, Dictionary dictionary)
        {
            card = cardToDisplay;
            dic = dictionary;

            InitializeComponent();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the specified actual card.
        /// </summary>
        /// <param name="actualCard">The actual card.</param>
        /// <param name="actualDictionary">The actual dictionary.</param>
        /// <remarks>Documented by Dev05, 2007-10-31</remarks>
        public void Initialize(ICard actualCard, ICardStyle actualStyle, Dictionary actualDictionary, object elementToStyle)
        {
            styleParent = elementToStyle;
            dictionary = actualDictionary;
            style = actualStyle;
            backupStyle = style.Clone();
            card = actualCard;

            textStyleEditAnswer.Style = style.Answer;
            textStyleEditAnswerExample.Style = style.AnswerExample;
            textStyleEditCorrect.Style = style.AnswerCorrect;
            textStyleEditQuestion.Style = style.Question;
            textStyleEditQuestionExample.Style = style.QuestionExample;
            textStyleEditWrong.Style = style.AnswerWrong;

            ShowPreview();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectorForm"/> class.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-09-27</remarks>
        public CollectorForm()
        {
            InitializeComponent();
            cardEdit.HelpNamespace = this.HelpFile;

            OpenFileDialog openDlg = new OpenFileDialog();
            openDlg.Filter = "Dictionary|*.odx";
            if (openDlg.ShowDialog() == DialogResult.OK)
            {
                if (dictionary != null) dictionary.Dispose();
                MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation)MLifter.Controls.LoginForm.OpenLoginForm,
                    new ConnectionStringStruct(DatabaseType.Xml, openDlg.FileName, true),
                    (DataAccessErrorDelegate)delegate(object sender, Exception e) { MessageBox.Show(e.ToString()); }, this);
                dictionary = new Dictionary(user.Open(), null);
            }
            else
                Close();

            tableCards.NoItemsText = Properties.Resources.TABLECARDS_NOITEMSTEXT;
        }
Ejemplo n.º 5
0
 internal CopyToEventArgs(Dictionary source, Dictionary target, User sourceUser, User targetUser, bool success, Exception excepion)
 {
     this.source = source;
     this.target = target;
     this.sourceUser = sourceUser;
     this.targetUser = targetUser;
     this.success = success;
     this.Exception = excepion;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CardDictionary"/> class.
 /// </summary>
 /// <param name="cards">The cards.</param>
 /// <remarks>Documented by Dev05, 2007-09-03</remarks>
 public CardDictionary(Dictionary dict, ICards Cards)
 {
     dictionary = dict;
     this.cards = Cards;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Modifies the multiple cards.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-10-12</remarks>
        private void ModifyMultipleCards()
        {
            if (!Multiselect)
                return;

            Cursor = Cursors.WaitCursor;
            LoadStatusMessage statusMessage = new LoadStatusMessage(string.Format(Properties.Resources.CARDEDIT_STATUS_SAVING, cards.Length), cards.Length, true);
            statusMessage.Show();

            string[] question = GetWord(Side.Question).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            string[] answer = GetWord(Side.Answer).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            string questionExample = textBoxQuestionExample.Text;
            string answerExample = textBoxAnswerExample.Text;

            foreach (int id in cards)
            {
                Dictionary.Cards.ChangeCardOnDifference(id, question, answer, questionExample, answerExample,
                    (comboBoxChapter.SelectedItem is IChapter ? ((IChapter)comboBoxChapter.SelectedItem).Id : -1), Resources.MAINTAIN_UNCHANGED);

                ICard card = Dictionary.Cards.GetCardByID(id).BaseCard;
                if (checkBoxActive.CheckState != CheckState.Indeterminate)
                    if (card.Active != checkBoxActive.Checked)
                        card.Active = checkBoxActive.Checked;

                if (comboBoxCardBox.SelectedIndex != -1 && card.Active)
                {
                    card.Box = comboBoxCardBox.SelectedIndex;
                }

                //Save old Media objects
                Dictionary<string, IMedia> oldMedia = new Dictionary<string, IMedia>();
                IMedia media = null;
                if ((media = Dictionary.Cards.GetImageObject(card, Side.Answer, true)) != null)
                    oldMedia.Add("answerImage", media);
                if ((media = Dictionary.Cards.GetImageObject(card, Side.Question, true)) != null)
                    oldMedia.Add("questionImage", media);
                if ((media = Dictionary.Cards.GetAudioObject(card, Side.Answer, true, false, true)) != null)
                    oldMedia.Add("answerAudio", media);
                if ((media = Dictionary.Cards.GetAudioObject(card, Side.Question, true, false, true)) != null)
                    oldMedia.Add("questionAudio", media);
                if ((media = Dictionary.Cards.GetAudioObject(card, Side.Answer, false, true, true)) != null)
                    oldMedia.Add("answerExample", media);
                if ((media = Dictionary.Cards.GetAudioObject(card, Side.Question, false, true, true)) != null)
                    oldMedia.Add("questionExample", media);
                if ((media = Dictionary.Cards.GetVideoObject(card, Side.Answer, true)) != null)
                    oldMedia.Add("answerVideo", media);
                if ((media = Dictionary.Cards.GetVideoObject(card, Side.Question, true)) != null)
                    oldMedia.Add("questionVideo", media);

                card.ClearAllMedia(false);

                //Image
                if (pictureBoxAnswer.Tag as IImage != null && checkBoxSamePicture.CheckState != CheckState.Unchecked)
                    card.AddMedia(pictureBoxAnswer.Tag as IMedia, Side.Answer);
                else if (pictureBoxAnswer.Tag is PreviousValueDummy && oldMedia.ContainsKey("answerImage") && checkBoxSamePicture.CheckState != CheckState.Unchecked)
                    card.AddMedia(oldMedia["answerImage"], Side.Answer);
                if (pictureBoxQuestion.Tag as IImage != null)
                {
                    IMedia image = pictureBoxQuestion.Tag as IMedia;
                    card.AddMedia(image, Side.Question);
                    if (checkBoxSamePicture.CheckState == CheckState.Checked)
                        card.AddMedia(image, Side.Answer);
                }
                else if (pictureBoxQuestion.Tag is PreviousValueDummy && oldMedia.ContainsKey("questionImage"))
                {
                    IMedia image = oldMedia["questionImage"];
                    card.AddMedia(image, Side.Question);
                    if (checkBoxSamePicture.CheckState == CheckState.Checked)
                        card.AddMedia(image, Side.Answer);
                }

                //Audio
                if (buttonAnswerAudio.Tag as IAudio != null)
                    card.AddMedia(buttonAnswerAudio.Tag as IMedia, Side.Answer);
                else if (buttonAnswerAudio.Tag is PreviousValueDummy && oldMedia.ContainsKey("answerAudio"))
                    card.AddMedia(oldMedia["answerAudio"], Side.Answer);
                if (buttonAnswerExampleAudio.Tag as IAudio != null)
                    card.AddMedia(buttonAnswerExampleAudio.Tag as IMedia, Side.Answer);
                else if (buttonAnswerExampleAudio.Tag is PreviousValueDummy && oldMedia.ContainsKey("answerExample"))
                    card.AddMedia(oldMedia["answerExample"], Side.Answer);
                if (buttonQuestionAudio.Tag as IAudio != null)
                    card.AddMedia(buttonQuestionAudio.Tag as IMedia, Side.Question);
                else if (buttonQuestionAudio.Tag is PreviousValueDummy && oldMedia.ContainsKey("questionAudio"))
                    card.AddMedia(oldMedia["questionAudio"], Side.Question);
                if (buttonQuestionExampleAudio.Tag as IAudio != null)
                    card.AddMedia(buttonQuestionExampleAudio.Tag as IMedia, Side.Question);
                else if (buttonQuestionExampleAudio.Tag is PreviousValueDummy && oldMedia.ContainsKey("questionExample"))
                    card.AddMedia(oldMedia["questionExample"], Side.Question);

                //Video
                if (buttonAnswerVideo.Tag as IVideo != null)
                    card.AddMedia(buttonAnswerVideo.Tag as IMedia, Side.Answer);
                else if (buttonAnswerVideo.Tag is PreviousValueDummy && oldMedia.ContainsKey("answerVideo"))
                    card.AddMedia(oldMedia["answerVideo"], Side.Answer);
                if (buttonQuestionVideo.Tag as IVideo != null)
                    card.AddMedia(buttonQuestionVideo.Tag as IMedia, Side.Question);
                else if (buttonQuestionVideo.Tag is PreviousValueDummy && oldMedia.ContainsKey("questionVideo"))
                    card.AddMedia(oldMedia["questionVideo"], Side.Question);

                statusMessage.ProgressStep();
            }

            statusMessage.Close();

            Modified = false;
            OnMultiEdit(EventArgs.Empty);
            Cursor = Cursors.Default;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Copies the contents of a dictionary to another one.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 /// <remarks>Documented by Dev02, 2008-09-24</remarks>
 public void CopyTo(Dictionary dictionary, CopyToProgress progressDelegate)
 {
     this.DictionaryDAL.CopyTo(dictionary.DictionaryDAL, progressDelegate);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes the dictionary form for the currently loaded dictionary
        /// </summary>
        /// <returns>True if OK</returns>
        /// <remarks>Documented by Dev03, 2007-07-19</remarks>
        public static bool LoadDictionary(Dictionary dict, string helpfile)
        {
            dictionary = dict;
            PropertiesForm propertiesForm = new PropertiesForm(helpfile);

            //learning modules cultures and captions
            propertiesForm.tabControlProperties.SelectedIndex = 0;
            propertiesForm.dictionaryCaptions.QuestionTitle = dictionary.DefaultSettings.QuestionCaption;
            propertiesForm.dictionaryCaptions.AnswerTitle = dictionary.DefaultSettings.AnswerCaption;
            propertiesForm.dictionaryCaptions.QuestionCulture = dictionary.DefaultSettings.QuestionCulture;
            propertiesForm.dictionaryCaptions.AnswerCulture = dictionary.DefaultSettings.AnswerCulture;

            propertiesForm.groupBoxQuestion.Text = dictionary.QuestionCaption;
            propertiesForm.groupBoxAnswer.Text = dictionary.AnswerCaption;

            //commentary sounds
            propertiesForm.commentarySounds.Clear();
            foreach (KeyValuePair<CommentarySoundIdentifier, IMedia> commentarySound in dictionary.DefaultSettings.CommentarySounds)
                propertiesForm.commentarySounds.Add(commentarySound.Key, commentarySound.Value);

            //Learning Module LearnModes
            propertiesForm.learnModes.MultipleDirections = true;
            propertiesForm.learnModes.QuestionCaption = dictionary.DefaultSettings.QuestionCaption;
            propertiesForm.learnModes.AnswerCaption = dictionary.DefaultSettings.AnswerCaption;
            propertiesForm.learnModes.SetQueryDirections(dictionary.AllowedQueryDirections);
            propertiesForm.learnModes.SetQueryTypes(dictionary.AllowedQueryTypes);

            //Learning Module Properties
            propertiesForm.dictionaryProperties.Title = dictionary.DictionaryTitle;
            propertiesForm.dictionaryProperties.DictionaryName = dictionary.DictionaryTitle;
            propertiesForm.dictionaryProperties.DictionaryAuthor = dictionary.Author;
            propertiesForm.dictionaryProperties.DictionaryCategory = dictionary.Category;
            propertiesForm.dictionaryProperties.DictionaryDescription = dictionary.Description;

            propertiesForm.dictionaryInfos.SetInfo(dictionary);

            //Load dictionary logos
            if (dictionary.Logo != null && dictionary.Logo is Stream)
            {
                Image logo = Bitmap.FromStream(dictionary.Logo);
                propertiesForm.dictionaryProperties.LeftImageSizeMode = propertiesForm.dictionaryInfos.LeftImageSizeMode = PictureBoxSizeMode.Zoom;
                propertiesForm.dictionaryProperties.LeftImage = propertiesForm.dictionaryInfos.LeftImage = logo;
            }

            propertiesForm.buttonCancel.Enabled = true;
            propertiesForm.listboxCommentaryAnswer.SelectedIndex = 0;

            //[ML-2317]  Properties / Add/edit styles crashes
            propertiesForm.buttonAddEditStyle.Visible = dictionary.CurrentLearnLogic != null;

            //[ML-1837] - disable the allowed learning options for protected content
            if (dictionary.DictionaryContentProtected)
            {
                propertiesForm.learnModes.EditableControlsEnabled = false;
            }

            //Enable/Disable controls depending on current permission-role:
            if (!dictionary.CanModify)
            {
                propertiesForm.dictionaryProperties.EditableControlsEnabled = false;
                propertiesForm.dictionaryCaptions.EditableControlsEnabled = false;
                propertiesForm.learnModes.EditableControlsEnabled = false;
                propertiesForm.buttonChange.Enabled = false;
                propertiesForm.buttonAddEditStyle.Enabled = false;
            }

            return propertiesForm.ShowDialog() == DialogResult.OK ? true : false;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectorForm"/> class.
        /// </summary>
        /// <param name="Dictionary">The dictionary.</param>
        /// <remarks>Documented by Dev05, 2007-10-02</remarks>
        public CollectorForm(string Dictionary)
        {
            ShowInTaskbar = false;
            InitializeComponent();
            cardEdit.HelpNamespace = this.HelpFile;

            if (dictionary != null) dictionary.Dispose();
            MLifter.DAL.Interfaces.IUser user = UserFactory.Create((GetLoginInformation)MLifter.Controls.LoginForm.OpenLoginForm,
                 new ConnectionStringStruct(DatabaseType.Xml, Dictionary, true),
                    (DataAccessErrorDelegate)delegate(object sender, Exception e) { MessageBox.Show(e.ToString()); }, this);
            dictionary = new Dictionary(user.Open(), null);

            tableCards.NoItemsText = Properties.Resources.TABLECARDS_NOITEMSTEXT;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Loads the new card.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-10-11</remarks>
        public void LoadNewCard(Dictionary currentDictionary)
        {
            buttonStyle.Enabled = false;

            CheckModified();
            Multiselect = false;
            Dictionary = currentDictionary;

            StopPlayingVideos();

            buttonAddEdit.Image = Properties.Resources.newDoc;
            buttonAddEdit.Text = Properties.Resources.EDITCARD_NEW;

            SetWord(Side.Question, string.Empty);
            SetWord(Side.Answer, string.Empty);

            textBoxQuestionExample.Text = string.Empty;
            textBoxAnswerExample.Text = string.Empty;

            checkBoxActive.Checked = true;
            checkBoxActive.CheckState = CheckState.Checked;
            comboBoxCardBox.SelectedIndex = 0;
            comboBoxCardBox.DropDownStyle = ComboBoxStyle.DropDownList;

            if (comboBoxChapter.Items.Contains(Properties.Resources.MAINTAIN_UNCHANGED))
            {
                comboBoxChapter.Items.Remove(Properties.Resources.MAINTAIN_UNCHANGED);
                if (!(comboBoxChapter.SelectedItem is IChapter) && comboBoxChapter.Items.Count > 0)
                    comboBoxChapter.SelectedIndex = 0;
            }

            pictureBoxAnswer.Image = null;
            pictureBoxAnswer.Tag = null;
            pictureBoxQuestion.Image = null;
            pictureBoxQuestion.Tag = null;

            buttonQuestionAudio.Image = Properties.Resources.Audio;
            buttonQuestionAudio.Tag = null;
            buttonQuestionExampleAudio.Image = Properties.Resources.Audio;
            buttonQuestionExampleAudio.Tag = null;
            buttonQuestionVideo.Image = Properties.Resources.Video;
            buttonQuestionVideo.Tag = null;
            buttonAnswerAudio.Image = Properties.Resources.Audio;
            buttonAnswerAudio.Tag = null;
            buttonAnswerExampleAudio.Image = Properties.Resources.Audio;
            buttonAnswerExampleAudio.Tag = null;
            buttonAnswerVideo.Image = Properties.Resources.Video;
            buttonAnswerVideo.Tag = null;

            checkBoxSamePicture.Checked = false;

            CardLoaded();

            newCard = true;
            preloadedCard = false;
            Modified = false;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Loads the card for editing.
 /// </summary>
 /// <param name="cardID">The card ID.</param>
 /// <remarks>Documented by Dev05, 2007-10-11</remarks>
 public void LoadCardForEditing(Dictionary currentDictionary, int cardID)
 {
     Card card = currentDictionary.Cards.GetCardByID(cardID);
     LoadCardForEditing(currentDictionary, card.BaseCard);
     ApplyPermissions(card);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets a persistent LM connection according chosen connectionType e.g. file or pgsql.
        /// </summary>
        /// <param name="testContext">The test context.</param>
        /// <param name="connectionType">Type of the connection.</param>
        /// <param name="standAlone">if set to <c>true</c> a stand alone user will be created.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev10, 2008-26-09</remarks>
        public static Dictionary GetPersistentLMConnection(TestContext testContext, string connectionType, bool standAlone)
        {
            MLifterTest.DAL.LMConnectionParameter param = new MLifterTest.DAL.LMConnectionParameter(testContext);
            param.Callback = MLifterTest.DAL.TestInfrastructure.GetAdminUser;
            param.ConnectionType = connectionType;
            param.IsProtected = false;
            param.LearningModuleId = -1;
            param.Password = string.Empty;
            param.RepositoryName = string.Empty;
            param.standAlone = standAlone;

            IDictionary targetDAL = MLifterTest.DAL.TestInfrastructure.GetLMConnection(param);
            Dictionary target = new Dictionary(targetDAL, null);
            return target;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Loads the content of the web.
        /// </summary>
        /// <remarks>Documented by Dev05, 2009-06-26</remarks>
        public void LoadWebContent(object path)
        {
            IsListLoaded = false;
            IsLoaded = false;

            string configPath = path as string;

            nodes = new Dictionary<int, FeedCategoryTreeNode>();
            if (TreeView.InvokeRequired)
                TreeView.Invoke((MethodInvoker)delegate { Nodes.Clear(); });
            else
                Nodes.Clear();

            try
            {
                if (TreeView.InvokeRequired)
                    TreeView.Invoke((MethodInvoker)delegate
                    {
                        Text = String.IsNullOrWhiteSpace(Feed.Name) ? Resources.FeedTreeNode_Name : Feed.Name;
                    });
                else
                    Text = String.IsNullOrWhiteSpace(Feed.Name) ? Resources.FeedTreeNode_Name : Feed.Name;

                #region read categories

                XmlReader categoryFeedReader = XmlReader.Create(Feed.CategoriesUri);
                SyndicationFeed categoryFeed = SyndicationFeed.Load(categoryFeedReader);

                List<ModuleCategory> categoriesToAdd = new List<ModuleCategory>();
                foreach (SyndicationItem item in categoryFeed.Items)
                {
                    ModuleCategory category = new ModuleCategory()
                    {
                        Id = Convert.ToInt32(item.Id),
                        Title = item.Title.Text,
                        ParentCategory = Convert.ToInt32(item.Links[0].Title)
                    };
                    categoriesToAdd.Add(category);
                }
                categoriesToAdd.Sort((a, b) => a.Id.CompareTo(b.Id));
                categoriesToAdd.ForEach(c => AddCategoryNode(c));

                #endregion

                #region read modules

                XmlReader moduleFeedReader = XmlReader.Create(Feed.ModulesUri);
                SyndicationFeed moduleFeed = SyndicationFeed.Load(moduleFeedReader);

                List<ModuleInfo> modules = new List<ModuleInfo>();
                XmlSerializer infoSerializer = new XmlSerializer(typeof(ModuleInfo));
                Dictionary<string, SyndicationItem> items = new Dictionary<string, SyndicationItem>();
                foreach (SyndicationItem item in moduleFeed.Items)
                {
                    ModuleInfo info;
                    if (item.Summary != null)
                        info = (ModuleInfo)infoSerializer.Deserialize(XmlReader.Create(new StringReader(WebUtility.HtmlDecode(item.Summary.Text))));
                    else
                        info = new ModuleInfo();
                    info.Id = item.Id;
                    info.Title = item.Title.Text;
                    info.EditDate = item.LastUpdatedTime.ToString();
                    if (item.Contributors.Count > 0)
                    {
                        info.Author = item.Contributors[0].Name;
                        info.AuthorMail = item.Contributors[0].Email;
                        info.AuthorUrl = item.Contributors[0].Uri;
                    }
                    if (item.Content is TextSyndicationContent)
                        info.Description = (item.Content as TextSyndicationContent).Text;
                    info.Categories = new SerializableList<string>();
                    foreach (SyndicationCategory cat in item.Categories)
                        info.Categories.Add(cat.Label);
                    foreach (SyndicationLink link in item.Links)
                    {
                        if (link.RelationshipType == AtomLinkRelationshipType.Module.ToString())
                        {
                            info.Size = link.Length;
                            info.DownloadUrl = link.Uri.AbsoluteUri;
                        }
                    }
                    modules.Add(info);
                    items.Add(info.Id, item);
                }

                categories.ForEach(c => nodes[c.Id].SetModuleList(modules.FindAll(p => p.Categories.Contains(c.Id.ToString()))));

                #endregion

                if (TreeView.InvokeRequired)
                    TreeView.Invoke((MethodInvoker)delegate { Expand(); });
                else
                    Expand();
                IsListLoaded = true;

                OnContentLoaded(EventArgs.Empty);

                #region read images

                using (PersistentMemoryCache<ModuleInfoCacheItem> cache = new PersistentMemoryCache<ModuleInfoCacheItem>("Feed_" + moduleFeed.Id))
                {
                    WebClient webClient = new WebClient();
                    foreach (ModuleInfo basicInfo in modules)
                    {
                        try
                        {
                            ModuleInfo info = basicInfo;
                            SyndicationItem item = items[basicInfo.Id];
                            string cacheKey = String.Format("{0}##{1}##{2}", moduleFeed.Id, item.Id, item.LastUpdatedTime);

                            if (cache.Contains(cacheKey))
                            {
                                ModuleInfoCacheItem cacheItem = (ModuleInfoCacheItem)cache[cacheKey];
                                info.IconSmall = Convert.FromBase64String(cacheItem.IconSmall);
                                info.IconBig = Convert.FromBase64String(cacheItem.IconBig);
                                info.Preview = Convert.FromBase64String(cacheItem.Preview);
                            }
                            else
                            {
                                ModuleInfoCacheItem cacheItem = new ModuleInfoCacheItem(info.Id);
                                foreach (SyndicationLink link in item.Links)
                                {
                                    if (link.RelationshipType == AtomLinkRelationshipType.IconSmall.ToString())
                                        cacheItem.IconSmall = Convert.ToBase64String(info.IconSmall = webClient.DownloadData(link.Uri));
                                    if (link.RelationshipType == AtomLinkRelationshipType.IconBig.ToString())
                                        cacheItem.IconBig = Convert.ToBase64String(info.IconBig = webClient.DownloadData(link.Uri));
                                    if (link.RelationshipType == AtomLinkRelationshipType.Preview.ToString())
                                        cacheItem.Preview = Convert.ToBase64String(info.Preview = webClient.DownloadData(link.Uri));
                                }
                                cache.Set(cacheKey, cacheItem, DateTime.Now.AddYears(1));
                            }

                            if (TreeView.InvokeRequired)
                                TreeView.Invoke((MethodInvoker)delegate { LoadDetails(info); });
                            else
                                LoadDetails(info);
                        }
                        catch (Exception exp) { Trace.WriteLine(exp.ToString()); }
                    }
                    cache.Dispose();
                }

                #endregion

                IsLoaded = true;
            }
            catch (Exception)
            {
                try
                {
                    if (TreeView.InvokeRequired)
                        TreeView.Invoke((MethodInvoker)delegate { Text = Resources.FeedTreeNode_Text_Offline; });
                    else
                        Text = Resources.FeedTreeNode_Text_Offline;
                }
                catch (ObjectDisposedException) { }
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Loads the style.
 /// </summary>
 /// <param name="actualCard">The actual card.</param>
 /// <param name="styleToEdit">The style to edit.</param>
 /// <remarks>Documented by Dev05, 2007-10-31</remarks>
 public void LoadStyle(ICard actualCard, ICardStyle styleToEdit, Dictionary dictionary, object elementToStyle)
 {
     cardStyleEdit.Initialize(actualCard, styleToEdit, dictionary, elementToStyle);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Opens the learning module.
        /// </summary>
        /// <returns></returns>
        /// <remarks>Documented by Dev03, 2008-08-28</remarks>
        internal bool OpenLearningModule()
        {
            if (user == null) return false;
            try
            {
                dictionary = new Dictionary(user.Open(), CurrentLearnLogic);
            }
            catch (DatabaseVersionNotSupported) { throw; }
            catch (DictionaryFormatNotSupported) { throw; }
            catch (DictionaryFormatOldVersion) { throw; }
            catch (DictionaryNotDecryptedException) { throw; }
            catch (System.Xml.XmlException) { throw new InvalidDictionaryException(); }
            catch (System.IO.IOException) { throw; }
            catch (UserSessionInvalidException) { throw; }
            catch (NotEnoughtDiskSpaceException) { throw; }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.ToString());
                return false;
            }

            return true;
        }
        private PostgreSqlConnectionStringBuilder PreparePostgreSqlConnectionStringBuilder(out Dictionary<string, string> referenceValues)
        {
            referenceValues = new Dictionary<string, string>();
            referenceValues.Add("Name", "Test ConnectionString");
            referenceValues.Add("Database", "db");
            referenceValues.Add("Server", "server");
            referenceValues.Add("Port", "1234");
            referenceValues.Add("SSL", false.ToString());
            referenceValues.Add("UserId", "username");
            referenceValues.Add("Password", "password");

            PostgreSqlConnectionStringBuilder csb = new PostgreSqlConnectionStringBuilder();
            csb.Name = referenceValues["Name"];
            csb.Database = referenceValues["Database"];
            csb.Server = referenceValues["Server"];
            csb.Port = int.Parse(referenceValues["Port"]);
            csb.SSL = bool.Parse(referenceValues["SSL"]);
            csb.UserId = referenceValues["UserId"];
            csb.Password = referenceValues["Password"];
            return csb;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Plays the commentary sound.
        /// </summary>
        /// <param name="soundid">The commentary sound id: 0 -> correct, 1 -> wrong, 2 -> almost.</param>
        /// <param name="standalone">if set to <c>true</c>, the [standalone commentary sound gets played].</param>
        /// <remarks>Documented by Dev02, 2008-03-17</remarks>
        private void PlayCommentarySound(Dictionary dictionary, AnswerResult result, bool standalone)
        {
            if (dictionary.Settings.EnableCommentary.Value)
            {
                Side side = dictionary.CurrentQueryDirection == EQueryDirection.Question2Answer ? Side.Answer : Side.Question;
                ECommentarySoundType type;
                switch (result)
                {
                    case AnswerResult.Correct:
                        type = standalone ? ECommentarySoundType.RightStandAlone : ECommentarySoundType.Right;
                        break;
                    case AnswerResult.Wrong:
                        type = standalone ? ECommentarySoundType.WrongStandAlone : ECommentarySoundType.Wrong;
                        break;
                    case AnswerResult.Almost:
                        type = standalone ? ECommentarySoundType.AlmostStandAlone : ECommentarySoundType.Almost;
                        break;
                    default:
                        return;
                }
                CommentarySoundIdentifier identifier = CommentarySoundIdentifier.Create(side, type);

                if (dictionary.CommentarySound.ContainsKey(identifier))
                    PlayMediaFile(dictionary.CommentarySound[identifier].Filename, result != AnswerResult.Correct);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Deserializes the specified stream.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <remarks>Documented by Dev02, 2008-12-04</remarks>
 private static void Deserialize(Stream stream)
 {
     IFormatter formatter = new BinaryFormatter();
     executedActions = (Dictionary<Guid, List<ExtensionAction>>)formatter.Deserialize(stream);
     extensionVersions = (Dictionary<Guid, Version>)formatter.Deserialize(stream);
     extensionListsDirty = false;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Deserializes the specified stream.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <remarks>Documented by Dev02, 2008-12-04</remarks>
 private static void Deserialize(Stream stream)
 {
     IFormatter formatter = new BinaryFormatter();
     syncedModules = (Dictionary<string, List<LearningModulesIndexEntry>>)formatter.Deserialize(stream);
 }
Ejemplo n.º 21
0
        ///<summary>
        ///Initializes a new instance of the <see cref="CollectorForm"/> class.
        ///</summary>
        ///<param name="Dictionary">The dictionary.</param>
        ///<remarks>Documented by Dev05, 2007-10-02</remarks>
        public CollectorForm(Dictionary Dictionary)
        {
            ShowInTaskbar = false;
            finallyClose = false;
            InitializeComponent();
            cardEdit.HelpNamespace = this.HelpFile;
            dictionary = Dictionary;
            cardEdit.CardCollector = true;

            tableCards.NoItemsText = Properties.Resources.TABLECARDS_NOITEMSTEXT;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Loads the card for editing.
        /// </summary>
        /// <remarks>Documented by Dev05, 2007-09-27</remarks>
        public void LoadCardForEditing(Dictionary currentDictionary, ICard card)
        {
            buttonStyle.Enabled = true;

            CheckModified();
            Multiselect = false;

            Dictionary = currentDictionary;

            StopPlayingVideos();

            checkBoxSamePicture.Checked = false;

            pictureBoxQuestion.Tag = null;
            pictureBoxQuestion.Image = null;
            pictureBoxAnswer.Tag = null;
            pictureBoxAnswer.Image = null;

            buttonAnswerAudio.Tag = null;
            buttonAnswerExampleAudio.Tag = null;
            buttonQuestionAudio.Tag = null;
            buttonQuestionExampleAudio.Tag = null;

            buttonAnswerVideo.Tag = null;
            buttonQuestionVideo.Tag = null;

            CardID = card.Id;
            buttonAddEdit.Text = Properties.Resources.EDITCARD_EDIT;
            buttonAddEdit.Image = Properties.Resources.texteditor;

            buttonQuestionAudio.Image = Properties.Resources.Audio;
            buttonQuestionExampleAudio.Image = Properties.Resources.Audio;
            buttonQuestionVideo.Image = Properties.Resources.Video;
            buttonAnswerAudio.Image = Properties.Resources.Audio;
            buttonAnswerExampleAudio.Image = Properties.Resources.Audio;
            buttonAnswerVideo.Image = Properties.Resources.Video;

            SetWord(Side.Question, card.Question.ToNewlineString());
            SetWord(Side.Answer, card.Answer.ToNewlineString());
            SetDistractors(Side.Question, DistractorsToStringList(card.QuestionDistractors.Words));
            SetDistractors(Side.Answer, DistractorsToStringList(card.AnswerDistractors.Words));

            textBoxQuestionExample.Text = card.QuestionExample.ToString();
            textBoxAnswerExample.Text = card.AnswerExample.ToString();

            if (comboBoxChapter.Items.Contains(Properties.Resources.MAINTAIN_UNCHANGED))
                comboBoxChapter.Items.Remove(Properties.Resources.MAINTAIN_UNCHANGED);
            comboBoxChapter.SelectedItem = Dictionary.Chapters.GetChapterByID(card.Chapter);

            checkBoxActive.CheckState = card.Active ? CheckState.Checked : CheckState.Unchecked;
            comboBoxCardBox.SelectedIndex = card.Box != -1 ? card.Box : 0;
            comboBoxCardBox.DropDownStyle = ComboBoxStyle.DropDownList;

            //Images
            IImage image = Dictionary.Cards.GetImageObject(card, Side.Question, true) as IImage;
            if (image != null && image.Filename != string.Empty)
            {
                Image picture = Bitmap.FromStream(image.Stream);
                CheckAndRestoreGIF(ref picture);
                pictureBoxQuestion.Image = picture;
                pictureBoxQuestion.Tag = image;
            }

            image = Dictionary.Cards.GetImageObject(card, Side.Answer, true) as IImage;
            if (image != null && image.Filename != string.Empty)
            {
                if ((pictureBoxQuestion.Tag as IImage) != null && image.Filename == ((IMedia)pictureBoxQuestion.Tag).Filename)
                {
                    checkBoxSamePicture.Checked = true;
                    pictureBoxAnswer.Image = pictureBoxQuestion.Image;
                }
                else
                {
                    Image picture = Bitmap.FromStream(image.Stream);
                    CheckAndRestoreGIF(ref picture);
                    pictureBoxAnswer.Image = picture;
                    pictureBoxAnswer.Tag = image;
                }
            }

            //Audio
            IAudio audio = Dictionary.Cards.GetAudioObject(card, Side.Question, true, false, true) as IAudio;
            if (audio != null && audio.Filename != string.Empty)
            {
                buttonQuestionAudio.Tag = audio;
                buttonQuestionAudio.Image = Properties.Resources.AudioAvailable;
            }
            audio = Dictionary.Cards.GetAudioObject(card, Side.Question, false, true, true) as IAudio;
            if (audio != null && audio.Filename != string.Empty)
            {
                buttonQuestionExampleAudio.Tag = audio;
                buttonQuestionExampleAudio.Image = Properties.Resources.AudioAvailable;
            }
            audio = Dictionary.Cards.GetAudioObject(card, Side.Answer, true, false, true) as IAudio;
            if (audio != null && audio.Filename != string.Empty)
            {
                buttonAnswerAudio.Tag = audio;
                buttonAnswerAudio.Image = Properties.Resources.AudioAvailable;
            }
            audio = Dictionary.Cards.GetAudioObject(card, Side.Answer, false, true, true) as IAudio;
            if (audio != null && audio.Filename != string.Empty)
            {
                buttonAnswerExampleAudio.Tag = audio;
                buttonAnswerExampleAudio.Image = Properties.Resources.AudioAvailable;
            }

            //Video
            IVideo video = Dictionary.Cards.GetVideoObject(card, Side.Question, true) as IVideo;
            if (video != null && video.Filename != string.Empty)
            {
                buttonQuestionVideo.Tag = video;
                buttonQuestionVideo.Image = Properties.Resources.VideoAvailable;
            }
            video = Dictionary.Cards.GetVideoObject(card, Side.Answer, true) as IVideo;
            if (video != null && video.Filename != string.Empty)
            {
                buttonAnswerVideo.Tag = video;
                buttonAnswerVideo.Image = Properties.Resources.VideoAvailable;
            }

            CardLoaded();

            newCard = false;
            preloadedCard = false;
            Modified = false;
        }
        private UncConnectionStringBuilder PrepareUncConnectionStringBuilder(out Dictionary<string, string> referenceValues)
        {
            referenceValues = new Dictionary<string, string>();
            referenceValues.Add("ConnectionString", @"c:\lms");
            referenceValues.Add("Name", "Test ConnectionString");

            UncConnectionStringBuilder csb = new UncConnectionStringBuilder(referenceValues["ConnectionString"]);
            csb.Name = referenceValues["Name"];
            return csb;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Loads the new card.
        /// </summary>
        /// <param name="question">The question.</param>
        /// <param name="questionExample">The question example.</param>
        /// <param name="answer">The answer.</param>
        /// <param name="answerExample">The answer example.</param>
        /// <param name="questionImage">The question image.</param>
        /// <param name="answerImage">The answer image.</param>
        /// <param name="questionAudio">The question audio.</param>
        /// <param name="questionExampleAudio">The question example audio.</param>
        /// <param name="questionVideo">The question video.</param>
        /// <param name="answerAudio">The answer audio.</param>
        /// <param name="answerExampleAudio">The answer example audio.</param>
        /// <param name="answerVideo">The answer video.</param>
        /// <remarks>Documented by Dev05, 2007-10-15</remarks>
        /// <remarks>Documented by Dev08, 2008-09-25</remarks>
        public void LoadNewCard(Dictionary currentDictionary, string question, string questionExample, string answer, string answerExample, string questionImage, string answerImage,
            string questionAudio, string questionExampleAudio, string questionVideo, string answerAudio, string answerExampleAudio, string answerVideo)
        {
            CheckModified();
            Multiselect = false;
            Dictionary = currentDictionary;

            StopPlayingVideos();

            buttonAddEdit.Image = Properties.Resources.newDoc;
            buttonAddEdit.Text = Properties.Resources.EDITCARD_NEW;

            pictureBoxAnswer.Image = null;
            pictureBoxAnswer.Tag = null;
            pictureBoxQuestion.Image = null;
            pictureBoxQuestion.Tag = null;

            buttonQuestionAudio.Image = Properties.Resources.Audio;
            buttonQuestionAudio.Tag = null;
            buttonQuestionExampleAudio.Image = Properties.Resources.Audio;
            buttonQuestionExampleAudio.Tag = null;
            buttonQuestionVideo.Image = Properties.Resources.Video;
            buttonQuestionVideo.Tag = null;
            buttonAnswerAudio.Image = Properties.Resources.Audio;
            buttonAnswerAudio.Tag = null;
            buttonAnswerExampleAudio.Image = Properties.Resources.Audio;
            buttonAnswerExampleAudio.Tag = null;
            buttonAnswerVideo.Image = Properties.Resources.Video;
            buttonAnswerVideo.Tag = null;

            //BugFix: Trim Synonyms by FabThe
            string[] splitchars = new string[] { " ,", " ;", ", ", "; ", ",", ";" };

            foreach (string splitchar in splitchars)
            {
                question = question.Replace(splitchar, Environment.NewLine);
                answer = answer.Replace(splitchar, Environment.NewLine);
            }

            SetWord(Side.Question, question);
            SetWord(Side.Answer, answer);

            textBoxQuestionExample.Text = questionExample;
            textBoxAnswerExample.Text = answerExample;

            checkBoxSamePicture.Checked = false;

            if (comboBoxChapter.Items.Count == 0)
            {
                IChapter[] chapterArray = new IChapter[Dictionary.Chapters.Chapters.Count];
                Dictionary.Chapters.Chapters.CopyTo(chapterArray, 0);
                comboBoxChapter.Items.AddRange(chapterArray);
                comboBoxChapter.SelectedIndex = 0;
                checkBoxActive.Checked = true;
            }
            if (comboBoxChapter.Items.Contains(Properties.Resources.MAINTAIN_UNCHANGED))
            {
                comboBoxChapter.Items.Remove(Properties.Resources.MAINTAIN_UNCHANGED);
                if (!(comboBoxChapter.SelectedItem is IChapter) && comboBoxChapter.Items.Count > 0)
                    comboBoxChapter.SelectedIndex = 0;
            }

            comboBoxCardBox.SelectedIndex = 0;
            comboBoxCardBox.DropDownStyle = ComboBoxStyle.DropDownList;

            try
            {
                pictureBoxQuestion.Load(questionImage);
                pictureBoxQuestion.Tag = CreateMedia(EMedia.Image, questionImage, true, true, false);
            }
            catch { }
            try
            {
                pictureBoxAnswer.Load(answerImage);
                pictureBoxAnswer.Tag = CreateMedia(EMedia.Image, answerImage, true, true, false);
            }
            catch { }
            try
            {
                string path = questionAudio;
                if (Helper.GetMediaType(path) == EMedia.Audio)
                {
                    buttonQuestionAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, false);
                    buttonQuestionAudio.Image = Properties.Resources.AudioAvailable;
                }
            }
            catch { }
            try
            {
                string path = questionExampleAudio;
                if (Helper.GetMediaType(path) == EMedia.Audio)
                {
                    buttonQuestionExampleAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, true);
                    buttonQuestionExampleAudio.Image = Properties.Resources.AudioAvailable;
                }
            }
            catch { }
            try
            {
                string path = answerAudio;
                if (Helper.GetMediaType(path) == EMedia.Audio)
                {
                    buttonAnswerAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, false);
                    buttonAnswerAudio.Image = Properties.Resources.AudioAvailable;
                }
            }
            catch { }
            try
            {
                string path = answerExampleAudio;
                if (Helper.GetMediaType(path) == EMedia.Audio)
                {
                    buttonAnswerExampleAudio.Tag = CreateMedia(EMedia.Audio, path, true, true, true);
                    buttonAnswerExampleAudio.Image = Properties.Resources.AudioAvailable;
                }
            }
            catch { }
            try
            {
                string path = questionVideo;
                if (Helper.GetMediaType(path) == EMedia.Video)
                {
                    buttonQuestionVideo.Tag = CreateMedia(EMedia.Video, path, true, true, false);
                    buttonQuestionVideo.Image = Properties.Resources.VideoAvailable;
                }
            }
            catch { }
            try
            {
                string path = answerVideo;
                if (Helper.GetMediaType(path) == EMedia.Video)
                {
                    buttonAnswerVideo.Tag = CreateMedia(EMedia.Video, path, true, true, false);
                    buttonAnswerVideo.Image = Properties.Resources.VideoAvailable;
                }
            }
            catch { }

            CardLoaded();

            newCard = true;
            preloadedCard = true;
            Modified = false;
        }
Ejemplo n.º 25
0
        public void CopyToBasicTest()
        {
            //Perform Test only if we use a db connection otherwise test case makes no sense
            if (TestInfrastructure.IsActive(TestContext) && TestInfrastructure.ConnectionType(TestContext) != "File")
            {
                IUser sourceUser = null;
                IUser targetUser = null;
                try
                {
                    string repositoryNameFinal = "finalTargetForCopyTest" + System.Environment.MachineName.ToLower();

                    //Do we have a target to copy from
                    Assert.IsTrue(File.Exists(TestDic), "Test Learning Module file cannot be found.");
                    ConnectionStringStruct sourceConnection = new ConnectionStringStruct(DatabaseType.Xml, CopyToTest.TestDic, false);
                    sourceUser = UserFactory.Create((GetLoginInformation)delegate(UserStruct u, ConnectionStringStruct c) { return u; },
                        sourceConnection, (DataAccessErrorDelegate)delegate { return; }, this);
                    if (!authenticationUsers.ContainsKey(sourceConnection.ConnectionString))
                        authenticationUsers.Add(sourceConnection.ConnectionString, sourceUser.AuthenticationStruct);

                    //Copy the reference LM to the new persistent LM
                    ConnectionStringStruct dbConnection;
                    using (Dictionary dbTarget = TestInfrastructure.GetConnection(TestContext))
                    {
                        IUser dbUser = dbTarget.DictionaryDAL.Parent.CurrentUser;
                        dbConnection = dbUser.ConnectionString;
                        if (!authenticationUsers.ContainsKey(dbConnection.ConnectionString))
                            authenticationUsers.Add(dbConnection.ConnectionString, dbUser.AuthenticationStruct);
                        dbTarget.Dispose();

                        finished = false;
                        LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished);
                        LearnLogic.CopyLearningModule(sourceConnection, dbConnection,
                            GetUser, (MLifter.DAL.Tools.CopyToProgress)delegate(string m, double p) { return; }, (DataAccessErrorDelegate)delegate { return; }, null);
                        while (!finished) { System.Threading.Thread.Sleep(100); };
                        LearnLogic.CopyToFinished -= new EventHandler(LearnLogic_CopyToFinished);
                    }

                    //copy to another persistent LM where we use Save to store as odx again
                    ConnectionStringStruct targetConnection;
                    using (Dictionary target = TestInfrastructure.GetPersistentLMConnection(TestContext, "sqlce"))
                    {
                        targetUser = target.DictionaryDAL.Parent.CurrentUser;
                        targetConnection = targetUser.ConnectionString;
                        if (!authenticationUsers.ContainsKey(targetConnection.ConnectionString))
                            authenticationUsers.Add(targetConnection.ConnectionString, targetUser.AuthenticationStruct);
                        target.Dispose();

                        finished = false;
                        LearnLogic.CopyToFinished += new EventHandler(LearnLogic_CopyToFinished);
                        LearnLogic.CopyLearningModule(dbConnection, targetConnection,
                            GetUser, (MLifter.DAL.Tools.CopyToProgress)delegate(string m, double p) { return; }, (DataAccessErrorDelegate)delegate { return; }, null);
                        while (!finished) { System.Threading.Thread.Sleep(100); };
                        LearnLogic.CopyToFinished -= new EventHandler(LearnLogic_CopyToFinished);
                    }

                    using (Dictionary source = new Dictionary(sourceUser.Open(), null))
                    using (Dictionary target = new Dictionary(targetUser.Open(), null))
                    {
                        CompareChapters(source.Chapters.Chapters, target.Chapters.Chapters);

                        //Verification Code compare finalTarget with the reference target
                        CompareCards(source.Cards.Cards, target.Cards.Cards, source, target);

                        //Compare Settings
                        CompareSettings(source.Settings, target.Settings);
                        if ((source.Settings != null) && (target.Settings != null))
                        {
                            //Compare Styles
                            CompareStyles(source.Settings.Style, target.Settings.Style);
                        }
                    }
                }
                finally
                {
                    if (sourceUser != null)
                        sourceUser.Logout();
                    if (targetUser != null)
                        targetUser.Logout();
                }
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Sets the stack card back colors.
 /// </summary>
 /// <param name="styleHandler">The style handler.</param>
 /// <remarks>Documented by Dev02, 2008-05-09</remarks>
 public void SetStackCardBackColors(MLifter.Components.StyleHandler styleHandler)
 {
     Dictionary<AnswerResult, Color> stackColors = new Dictionary<AnswerResult, Color>();
     foreach (AnswerResult result in Enum.GetValues(typeof(AnswerResult)))
     {
         string stylename = string.Format("{0}_{1}", this.Name, result.ToString());
         if (styleHandler.CurrentStyle.StyledControls.ContainsKey(stylename) && styleHandler.CurrentStyle.StyledControls[stylename].BackColor != Color.Empty)
         {
             Color color = styleHandler.CurrentStyle.StyledControls[stylename].BackColor;
             stackColors.Add(result, color);
         }
     }
     this.StackCardBackColors = stackColors;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Checks the commentary sounds.
        /// </summary>
        /// <param name="one">The one.</param>
        /// <param name="two">The two.</param>
        /// <remarks>Documented by Dev10, 2008-29-09</remarks>
        private void checkCommentarySounds(Dictionary<CommentarySoundIdentifier, IMedia> one, Dictionary<CommentarySoundIdentifier, IMedia> two)
        {
            Assert.AreEqual<int>(one.Count, two.Count, "Number of commentary Sounds do not match");
            foreach (KeyValuePair<CommentarySoundIdentifier, IMedia> kvp in one)
            {
                if (two.ContainsKey(kvp.Key))
                {
                    Assert.IsTrue(checkMedia(two[kvp.Key], kvp.Value), "Media do not match");
                }
                else
                    Assert.Fail("Key is missing in one directory, in commentary Sounds");

            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Compares the cards.
        /// </summary>
        /// <param name="reference">The reference.</param>
        /// <param name="copy">The copy.</param>
        /// <remarks>Documented by Dev03, 2008-09-26</remarks>
        private void CompareCards(IList<ICard> reference, IList<ICard> copy, Dictionary referenceDic, Dictionary copyDic)
        {
            Assert.AreEqual<int>(reference.Count, copy.Count, "Numbers of cards are not equal");

            //create Lists to work on
            List<ICard> referenceList = new List<ICard>();
            List<ICard> copyList = new List<ICard>();
            referenceList.AddRange(reference);
            copyList.AddRange(copy);

            //compare the cards
            foreach (ICard card in reference)
            {
                ICard match = copyList.Find(
                    delegate(ICard cardCopy)
                    {
                        bool isMatch = true;
                        isMatch = isMatch && (card.Active == cardCopy.Active);
                        isMatch = isMatch && (card.Answer.ToString() == cardCopy.Answer.ToString());
                        isMatch = isMatch && (card.Question.ToString() == cardCopy.Question.ToString());
                        isMatch = isMatch && (card.AnswerExample.ToString() == cardCopy.AnswerExample.ToString());
                        isMatch = isMatch && (card.QuestionExample.ToString() == cardCopy.QuestionExample.ToString());
                        isMatch = isMatch && (card.AnswerDistractors.ToString() == cardCopy.AnswerDistractors.ToString());
                        isMatch = isMatch && (card.QuestionDistractors.ToString() == cardCopy.QuestionDistractors.ToString());
                        isMatch = isMatch && (card.Box == cardCopy.Box);
                        IChapter chapter2search = FindChapter(referenceDic.Chapters.Chapters, card.Chapter);
                        isMatch = isMatch && (FindChapter(copyDic.Chapters.Chapters, chapter2search) != null);

                        Debug.WriteLine("#####" + card.Id);
                        Debug.WriteLine("########" + card.Answer);
                        Debug.WriteLine("########" + cardCopy.Answer);
                        Debug.WriteLine("########" + isMatch);

                        return isMatch;
                    }
                );

                Assert.IsTrue(match != null, String.Format("Card not found:\n{0}", card.ToString()));
                //CompareMedia(card, match);

                //AAB_MBR not implemented for XML# CompareSettings(card.Settings, match.Settings);
                if ((card.Settings != null) && (match.Settings != null))
                {
                    CompareStyles(card.Settings.Style, match.Settings.Style);
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Begins the copy to.
        /// </summary>
        /// <param name="dictionary">The dictionary.</param>
        /// <param name="progressDelegate">The progress delegate.</param>
        /// <param name="sourceUser">The source user.</param>
        /// <param name="targetUser">The target user.</param>
        /// <param name="resetAfterCopy">if set to <c>true</c> to reset after copy.</param>
        /// <remarks>Documented by Dev08, 2008-09-26</remarks>
        public void BeginCopyTo(Dictionary dictionary, CopyToProgress progressDelegate, User sourceUser, User targetUser, bool resetAfterCopy)
        {
            Thread copyToThread = new Thread(delegate()
            {
                bool success = false;
                Exception exp = null;
                try
                {
                    CopyTo(dictionary, progressDelegate);

                    if (resetAfterCopy)
                        dictionary.DictionaryDAL.ResetLearningProgress();

                    success = true;
                }
                catch (Exception e)
                {
                    exp = e;
                    Trace.WriteLine("CopyTo(dictionary) failed: " + e.Message);
                }
                finally
                {
                    OnCopyToFinished(new CopyToEventArgs(this, dictionary, sourceUser, targetUser, success, exp));
                }
            });
            copyToThread.Name = "Dictionary CopyTo Thread";
            copyToThread.IsBackground = true;
            copyToThread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            copyToThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
            copyToThread.Start();
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChapterDictionary"/> class.
 /// </summary>
 /// <param name="dict">The dict.</param>
 /// <remarks>Documented by Dev05, 2007-09-04</remarks>
 public ChapterDictionary(Dictionary dict, IChapters Chapters)
 {
     dictionary = dict;
     this.chapters = Chapters;
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Initializes the dictionary form for the currently loaded dictionary
        /// </summary>
        /// <returns>True if OK</returns>
        /// <remarks>Documented by Dev03, 2007-07-19</remarks>
        public static bool LoadDictionary(Dictionary dict, string helpfile)
        {
            dictionary = dict;
            PropertiesForm propertiesForm = new PropertiesForm(helpfile);

            //learning modules cultures and captions
            propertiesForm.tabControlProperties.SelectedIndex = 0;
            propertiesForm.dictionaryCaptions.QuestionTitle   = dictionary.DefaultSettings.QuestionCaption;
            propertiesForm.dictionaryCaptions.AnswerTitle     = dictionary.DefaultSettings.AnswerCaption;
            propertiesForm.dictionaryCaptions.QuestionCulture = dictionary.DefaultSettings.QuestionCulture;
            propertiesForm.dictionaryCaptions.AnswerCulture   = dictionary.DefaultSettings.AnswerCulture;

            propertiesForm.groupBoxQuestion.Text = dictionary.QuestionCaption;
            propertiesForm.groupBoxAnswer.Text   = dictionary.AnswerCaption;

            //commentary sounds
            propertiesForm.commentarySounds.Clear();
            foreach (KeyValuePair <CommentarySoundIdentifier, IMedia> commentarySound in dictionary.DefaultSettings.CommentarySounds)
            {
                propertiesForm.commentarySounds.Add(commentarySound.Key, commentarySound.Value);
            }

            //Learning Module LearnModes
            propertiesForm.learnModes.MultipleDirections = true;
            propertiesForm.learnModes.QuestionCaption    = dictionary.DefaultSettings.QuestionCaption;
            propertiesForm.learnModes.AnswerCaption      = dictionary.DefaultSettings.AnswerCaption;
            propertiesForm.learnModes.SetQueryDirections(dictionary.AllowedQueryDirections);
            propertiesForm.learnModes.SetQueryTypes(dictionary.AllowedQueryTypes);

            //Learning Module Properties
            propertiesForm.dictionaryProperties.Title                 = dictionary.DictionaryTitle;
            propertiesForm.dictionaryProperties.DictionaryName        = dictionary.DictionaryTitle;
            propertiesForm.dictionaryProperties.DictionaryAuthor      = dictionary.Author;
            propertiesForm.dictionaryProperties.DictionaryCategory    = dictionary.Category;
            propertiesForm.dictionaryProperties.DictionaryDescription = dictionary.Description;

            propertiesForm.dictionaryInfos.SetInfo(dictionary);

            //Load dictionary logos
            if (dictionary.Logo != null && dictionary.Logo is Stream)
            {
                Image logo = Bitmap.FromStream(dictionary.Logo);
                propertiesForm.dictionaryProperties.LeftImageSizeMode = propertiesForm.dictionaryInfos.LeftImageSizeMode = PictureBoxSizeMode.Zoom;
                propertiesForm.dictionaryProperties.LeftImage         = propertiesForm.dictionaryInfos.LeftImage = logo;
            }

            propertiesForm.buttonCancel.Enabled = true;
            propertiesForm.listboxCommentaryAnswer.SelectedIndex = 0;

            //[ML-2317]  Properties / Add/edit styles crashes
            propertiesForm.buttonAddEditStyle.Visible = dictionary.CurrentLearnLogic != null;

            //[ML-1837] - disable the allowed learning options for protected content
            if (dictionary.DictionaryContentProtected)
            {
                propertiesForm.learnModes.EditableControlsEnabled = false;
            }

            //Enable/Disable controls depending on current permission-role:
            if (!dictionary.CanModify)
            {
                propertiesForm.dictionaryProperties.EditableControlsEnabled = false;
                propertiesForm.dictionaryCaptions.EditableControlsEnabled   = false;
                propertiesForm.learnModes.EditableControlsEnabled           = false;
                propertiesForm.buttonChange.Enabled       = false;
                propertiesForm.buttonAddEditStyle.Enabled = false;
            }

            return(propertiesForm.ShowDialog() == DialogResult.OK ? true : false);
        }