/// <summary>
 /// Initializes a new instance of the <see cref="ServerConnectorPage"/> class.
 /// </summary>
 /// <param name="learnLogic">The learn logic.</param>
 /// <remarks>Documented by Dev02, 2008-07-23</remarks>
 public ServerConnectorPage(LearnLogic learnLogic)
 {
     InitializeComponent();
     #if DEBUG
     if (File.Exists(connectionstringfile))
         textBoxConnectionString.Text = File.ReadAllText(connectionstringfile);
     #endif
     m_learnLogic = learnLogic;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="LMSelectionPage"/> class.
        /// </summary>
        /// <param name="learnLogic">The learn logic.</param>
        /// <param name="localLMDirectory">The local file open dialog start directory.</param>
        /// <param name="localLMOpenFilter">The local file open dialog filter mask.</param>
        /// <param name="localLMSaveFilter">The local LM save filter.</param>
        /// <remarks>Documented by Dev02, 2008-09-22</remarks>
        public LMSelectionPage(LearnLogic learnLogic, string localLMDirectory, string localLMOpenFilter, string localLMSaveFilter)
        {
            InitializeComponent();
            listViewLMs_SelectedIndexChanged(listViewLMs, EventArgs.Empty);
            m_learnLogic = learnLogic;

            this.localLMDirectory = localLMDirectory;
            this.localLMOpenFilter = localLMOpenFilter;
            this.localLMSaveFilter = localLMSaveFilter;
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="User"/> class.
 /// </summary>
 /// <param name="learnLogic">The learn logic.</param>
 /// <remarks>Documented by Dev09, 2009-04-10</remarks>
 public User(LearnLogic learnLogic)
 {
     CurrentLearnLogic = learnLogic;
 }
Example #4
0
 public Mainform(string[] args)
 {
     InitializeComponent();
     m_learnLogic = new LearnLogic(GetUser, DataAccessError);
 }
Example #5
0
        public void GradeCardTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext);
                LearnLogic llogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                //llogic.User.Authenticate((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser,
                //    connectionString, (DataAccessErrorDelegate)delegate { return; });

                try
                {
                    llogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString));
                }
                catch (IsOdxFormatException)
                {
                    if (TestInfrastructure.ConnectionType(TestContext) == "File")
                        return;
                    else
                        throw;
                }

                llogic.OnLearningModuleOptionsChanged();

                Card card = llogic.Dictionary.Cards.GetCardByID(llogic.CurrentCardID);
                int oldBox = card.BaseCard.Box = 5;

                UserInputSubmitEventArgs e = new UserInputSubmitTextEventArgs(0, card.CurrentAnswer.Words.Count, card.CurrentAnswer.Words.Count, true, card.CurrentAnswer.Words.ToString());
                llogic.OnUserInputSubmit(this, e);

                Assert.AreEqual<int>(oldBox + 1, card.BaseCard.Box, "Card was not correctly promoted!");

                card.BaseCard.Box = oldBox;

                e = new UserInputSubmitTextEventArgs(5, 0, 5, false, string.Empty);
                llogic.OnUserInputSubmit(this, e);

                Assert.AreEqual<int>(1, card.BaseCard.Box, "Card was not demoted!");
            }
        }
 /// <summary>
 /// Registers the learn logic.
 /// </summary>
 /// <param name="learnlogic">The learnlogic.</param>
 /// <remarks>Documented by Dev02, 2008-04-22</remarks>
 public void RegisterLearnLogic(LearnLogic learnlogic)
 {
     this.learnlogic = learnlogic;
     this.learnlogic.CardStateChanged += new LearnLogic.CardStateChangedEventHandler(learnlogic_CardStateChanged);
     this.learnlogic.CardStack.StackChanged += new EventHandler(CardStack_StackChanged);
 }
Example #7
0
 /// <summary>
 /// Registers the learn logic.
 /// </summary>
 /// <param name="learnlogic">The learnlogic.</param>
 /// <remarks>Documented by Dev02, 2008-04-22</remarks>
 public void RegisterLearnLogic(LearnLogic learnlogic)
 {
     this.learnlogic = learnlogic;
     this.oldCardStackVisibleValue = learnlogic.CardStack.VisibleStack.Count;
     this.learnlogic.CardStack.StackChanged += new EventHandler(CardStack_StackChanged);
 }
Example #8
0
 /// <summary>
 /// Registers the learn logic to this control.
 /// </summary>
 /// <param name="learnlogic">The learnlogic.</param>
 /// <remarks>Documented by Dev02, 2008-04-22</remarks>
 /// <remarks>Documented by Dev02, 2008-04-29</remarks>
 public void RegisterLearnLogic(MLifter.BusinessLayer.LearnLogic learnlogic)
 {
     this.learnlogic             = learnlogic;
     this.learnlogic.UserDialog += new LearnLogic.UserDialogEventHandler(learnlogic_UserDialog);
 }
Example #9
0
        public void GetCurrentStatsTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext);
                LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                try
                {
                    learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString));
                }
                catch (IsOdxFormatException)
                {
                    if (TestInfrastructure.ConnectionType(TestContext) == "File")
                        return;
                    else
                        throw;
                }

                learnLogic.OnLearningModuleOptionsChanged();
                learnLogic.Dictionary.ResetLearningProgress();

                //Answer Card correct
                Card currentCard = learnLogic.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID);
                UserInputSubmitEventArgs e = new UserInputSubmitTextEventArgs(0, currentCard.CurrentAnswer.Words.Count,
                    currentCard.CurrentAnswer.Words.Count, true, currentCard.CurrentAnswer.Words.ToString());
                learnLogic.OnUserInputSubmit(this, e);
                learnLogic.OnUserInputSubmit(this, new UserInputSubmitEventArgs());

                //Answer Card wrong
                currentCard = learnLogic.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID);
                e = new UserInputSubmitTextEventArgs(0, 0, currentCard.CurrentAnswer.Words.Count, false, string.Empty);
                learnLogic.OnUserInputSubmit(this, e);
                learnLogic.OnUserInputSubmit(this, new UserInputSubmitEventArgs());

                LearnStats stats = learnLogic.Dictionary.Statistics.GetCurrentStats();
                Assert.AreEqual<int>(1, stats.NumberOfRights, "GetCurrentStats() did not return the correct LearnStats.NumberOfRights");
                Assert.AreEqual<int>(1, stats.NumberOfWrongs, "GetCurrentStats() did not return the correct LearnStats.NumberOfWrongs");
            }
        }
Example #10
0
 public void OpenLearningModuleNullTest()
 {
     LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate)delegate { return; });
     llogic.OpenLearningModule(null);
 }
Example #11
0
        /// <summary>
        /// Runs a test for opening file types that throw exceptions.
        /// </summary>
        /// <param name="ext">The ext.</param>
        /// <remarks>Documented by Dev09, 2009-03-05</remarks>
        private void FileExtTestHelper(String ext)
        {
            // create temp file with desired extension
            String filename = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + "." + ext);
            File.Create(filename);

            LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate)delegate { return; });
            LearningModulesIndexEntry module = new LearningModulesIndexEntry();
            module.ConnectionString = new ConnectionStringStruct(DatabaseType.Xml, filename);
            llogic.OpenLearningModule(module);
        }
Example #12
0
 public void OpenLearningModuleFileNotFoundTest()
 {
     LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate)delegate { return; });
     LearningModulesIndexEntry module = new LearningModulesIndexEntry();
     module.ConnectionString = new ConnectionStringStruct(DatabaseType.Xml, "invalid");
     llogic.OpenLearningModule(module);
 }
Example #13
0
        public void OpenLearningModuleCannotCloseTest()
        {
            if (TestInfrastructure.IsActive(TestContext) && TestInfrastructure.ConnectionType(TestContext).ToLower() != "file")
            {
                LearnLogic llogic = new LearnLogic((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser, (DataAccessErrorDelegate)delegate { return; });
                LearningModulesIndexEntry module = new LearningModulesIndexEntry();
                module.ConnectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext);

                llogic.LearningModuleClosing += new LearnLogic.LearningModuleClosingEventHandler(llogic_LearningModuleClosing);
                llogic.OpenLearningModule(module);
                llogic.OpenLearningModule(module);
            }
            else
                throw new CouldNotCloseLearningModuleException();
        }
Example #14
0
        public void LearnLogicLearnModeTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext);
                LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                //learnLogic.User.Authenticate(OpenUserProfileTests.GetUserAdmin, connectionString, (DataAccessErrorDelegate)delegate { return; });
                try
                {
                    learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString));
                }
                catch (IsOdxFormatException)
                {
                    if (TestInfrastructure.ConnectionType(TestContext) == "File")     //success
                        return;
                    else
                        throw;
                }

                learnLogic.User.Dictionary.Settings.QueryTypes.ImageRecognition = true;
                learnLogic.User.Dictionary.Settings.QueryTypes.ListeningComprehension = true;
                learnLogic.User.Dictionary.Settings.QueryTypes.Sentence = true;
                for (int i = 0; i < TestInfrastructure.LoopCount; i++)
                {
                    learnLogic.OnLearningModuleOptionsChanged();
                    Card card = learnLogic.User.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID);
                    switch (learnLogic.User.Dictionary.LearnMode)
                    {
                        case LearnModes.ImageRecognition:
                            Assert.IsTrue(card.ContainsImage(Side.Question.ToString()), "Card must contain image for ImageRecognition mode.");
                            break;
                        case LearnModes.ListeningComprehension:
                            Assert.IsTrue(card.ContainsAudio(Side.Question.ToString()), "Card must contain audio for ListeningComprehension mode.");
                            break;
                        case LearnModes.Sentence:
                            Assert.IsTrue(card.CurrentQuestionExample.Words.Count > 0, "Card must contain example for Sentence mode.");
                            break;
                        default:
                            continue;
                    }
                }
            }
        }
Example #15
0
 /// <summary>
 /// Registers the learn logic.
 /// </summary>
 /// <param name="learnlogic">The learnlogic.</param>
 /// <remarks>Documented by Dev02, 2008-04-22</remarks>
 public void RegisterLearnLogic(LearnLogic learnlogic)
 {
     this.learnlogic = learnlogic;
     this.learnlogic.CardStateChanged += new LearnLogic.CardStateChangedEventHandler(learnlogic_CardStateChanged);
     this.learnlogic.LearningModuleClosed += new EventHandler(learnlogic_LearningModuleClosed);
 }
Example #16
0
        public void GetKnownTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext);
                LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                //learnLogic.User.Authenticate((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser,
                //    connectionString, (DataAccessErrorDelegate)delegate { return; });
                try
                {
                    learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString));
                }
                catch (IsOdxFormatException)
                {
                    if (TestInfrastructure.ConnectionType(TestContext) == "File")
                        return;
                    else
                        throw;
                }

                learnLogic.OnLearningModuleOptionsChanged();
                learnLogic.ResetLearningProgress();

                //Answer 5 cards correct
                for (int i = 0; i < 5; i++)
                {
                    Card currentCard = learnLogic.Dictionary.Cards.GetCardByID(learnLogic.CurrentCardID);

                    //Answer Card correct
                    UserInputSubmitEventArgs e = new UserInputSubmitTextEventArgs(0, currentCard.CurrentAnswer.Words.Count,
                        currentCard.CurrentAnswer.Words.Count, true, currentCard.CurrentAnswer.Words.ToString());

                    learnLogic.OnUserInputSubmit(this, e);
                    learnLogic.OnUserInputSubmit(this, new UserInputSubmitEventArgs());
                }

                int known = learnLogic.Dictionary.Statistics.GetKnown(DateTime.Now.AddDays(1));
                Assert.AreEqual<int>(5, known, "GetKnown() did not return the correct number of known cards");
            }
        }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dictionary"/> class.
 /// </summary>
 /// <param name="dictionary">The dictionary.</param>
 /// <param name="answerStyleSheet">The answer style sheet.</param>
 /// <param name="questionStyleSheet">The question style sheet.</param>
 /// <remarks>Documented by Dev05, 2007-09-03</remarks>
 public Dictionary(IDictionary dictionary, LearnLogic learnLogic)
 {
     CurrentLearnLogic = learnLogic;
     LoadDictionary(dictionary);
     m_Random = new Random((int)DateTime.Now.Ticks);
 }
Example #18
0
        public void DeleteAllStatisticsTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionStringWithDummyData(TestContext);
                LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                try
                {
                    learnLogic.OpenLearningModule(new LearningModulesIndexEntry(connectionString));
                }
                catch (IsOdxFormatException)
                {
                    if (TestInfrastructure.ConnectionType(TestContext) == "File")
                        return;
                    else
                        throw;
                }

                learnLogic.OnLearningModuleOptionsChanged();
                learnLogic.ResetLearningProgress();

                LearnStats learnStats = learnLogic.Dictionary.Statistics.GetCurrentStats();
                Assert.AreEqual<int>(0, learnStats.NumberOfRights, "DeleteAllStatistics() did not delete all Stats!");
                Assert.AreEqual<int>(0, learnStats.NumberOfWrongs, "DeleteAllStatistics() did not delete all Stats!");
                Assert.IsTrue(learnLogic.Dictionary.Statistics.GetNewestStatistic().StartTimestamp == learnLogic.Dictionary.Statistics.GetOldestStatistic().StartTimestamp, "GetNewestStatistic() and GetOldestStatistic seems to be not equal. There should be only ONE stat in the restarted LM");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TestDataGenerator"/> class.
 /// </summary>
 /// <param name="connectionString">The connection string.</param>
 /// <remarks>Documented by Dev03, 2008-11-28</remarks>
 internal TestDataGenerator(LearnLogic learnLogic)
 {
     m_learnLogic = learnLogic;
 }
Example #20
0
		/// <summary>
		/// Constructor of class. Opens/Creates registry key, creates "learn particular box" menu, VocEdit, character box, stacks
		/// </summary>
		/// <returns>No return value</returns>
		/// <exception cref="ex"></exceptions>
		/// <remarks>Documented by Dev00, 2007-07-26</remarks>
		public MainForm()
		{
			//check stick and load settings (must be first as all following code depends on settings)
			OnStickMode = Setup.RunningFromStick();

			if (OnStickMode)
				Setup.LoadSettingsFromStick();

			Setup.UpgradeFromEarlierVersion();

			//load language and culture
			try
			{
				CultureInfo currentCulture = new CultureInfo(Settings.Default.CurrentLanguage);
				Thread.CurrentThread.CurrentUICulture = currentCulture;
				if (!currentCulture.IsNeutralCulture) //neutral cultures cannot be used for the thread culture
					Thread.CurrentThread.CurrentCulture = currentCulture;
			}
			catch (Exception e)
			{
				Trace.WriteLine("Culture appliance failed: " + e.ToString());
			}
			Thread.CurrentThread.Name = "MLifter Main-Thread";

			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			// take care of the closing event of the dropdown menu for changing the learningmodi
			this.toolStripDropDownButtonChangeLearnModus.DropDown.Closing += new ToolStripDropDownClosingEventHandler(toolStripDropDownButtonChangeLearnModus_Closing);

			//set up character map
			characterMapComponent.RegisterControl(this);
			characterMapComponent.VisibleChanged += new EventHandler(characterMapComponent_VisibleChanged);
			Application.EnterThreadModal += new EventHandler(Application_EnterThreadModal);
			Application.LeaveThreadModal += new EventHandler(Application_LeaveThreadModal);

			//set up recent files list event
			RecentLearningModules.Restore(Setup.RecentLearningModulesPath);
			UpdateRecentFiles();
			RecentLearningModules.ListChanged += new EventHandler(RecentFiles_ListChanged);

			//initialize learnlogic
			if (LearnLogic == null)
			{
				LearnLogic = new LearnLogic(LoginForm.OpenLoginForm, DataAccessError);
				learnLogic.SyncedLearningModulesPath = Setup.SyncedModulesPath;
				LearnLogic.LearningModuleSyncRequest += new EventHandler(LearnLogic_LearningModuleSyncRequest);
			}

			//set up business logic events
			LearnLogic.LearningModuleOptionsChanged += new EventHandler(learnLogic_LearningModuleOptionsChanged);
			LearnLogic.LearningModuleOpened += new EventHandler(learnLogic_LearningModuleOpened);
			LearnLogic.LearningModuleConnectionLost += new EventHandler(LearnLogic_LearningModuleConnectionLost);
			LearnLogic.LearningModuleClosed += new EventHandler(learnLogic_LearningModuleClosed);
			LearnLogic.LearningModuleClosing += new LearnLogic.LearningModuleClosingEventHandler(learnLogic_LearningModuleClosing);
			LearnLogic.CardStack.StackChanged += new EventHandler(learnLogic_CardStack_StackChanged);
			LearnLogic.SnoozeModeQuitProgram += new EventHandler(LearnLogic_SnoozeModeQuitProgram);
			LearnLogic.UserSessionClosed += new EventHandler(LearnLogic_UserSessionClosed);

			//register the LearnLogic to the LearningWindow
			learningWindow.RegisterLearnLogic(MainForm.LearnLogic);

			//trayicon title
			TrayIcon.Text = AssemblyData.Title;

			//set up drive detector to react properly when a memory stick gets unplugged
			driveDetector_WatchDevice(Setup.ApplicationRoot);
			MLifter.Classes.Help.SetHelpNameSpace(MainHelp);
		}
 /// <summary>
 /// Registers the learn logic to this control.
 /// </summary>
 /// <param name="learnlogic">The learnlogic.</param>
 /// <remarks>Documented by Dev02, 2008-04-22</remarks>
 /// <remarks>Documented by Dev02, 2008-04-29</remarks>
 public void RegisterLearnLogic(MLifter.BusinessLayer.LearnLogic learnlogic)
 {
     this.learnlogic = learnlogic;
     this.learnlogic.UserDialog += new LearnLogic.UserDialogEventHandler(learnlogic_UserDialog);
 }
Example #22
0
 /// <summary>
 /// Registers the learn logic.
 /// </summary>
 /// <param name="learnlogic">The learnlogic.</param>
 /// <remarks>Documented by Dev02, 2008-04-22</remarks>
 public void RegisterLearnLogic(LearnLogic learnlogic)
 {
     if (this.learnlogic == null || this.learnlogic != learnlogic)
     {
         this.learnlogic = learnlogic;
         RegisterLearnLogicAllControls(this.Controls);
         RegisterLearnLogicAllComponents(this.components.Components);
         this.Visible = learnlogic.DictionaryReadyForLearning;
         this.learnlogic.LearningModuleClosed += new EventHandler(learnlogic_LearningModuleClosed);
         this.learnlogic.LearningModuleOptionsChanged += new EventHandler(learnlogic_LearningModuleOptionsChanged);
         this.learnlogic.UserDialog += new LearnLogic.UserDialogEventHandler(learnlogic_UserDialog);
         this.learnlogic.OnLearningModuleOptionsChanged();
     }
 }
Example #23
0
 void ILearnUserControl.RegisterLearnLogic(LearnLogic learnlogic)
 {
     this.learnlogic = learnlogic;
     this.learnlogic.CardStateChanged += new LearnLogic.CardStateChangedEventHandler(learnlogic_CardStateChanged);
 }
Example #24
0
        public void DoubleLoginTest()
        {
            if (TestInfrastructure.IsActive(TestContext))
            {
                switch (TestInfrastructure.ConnectionType(TestContext))
                {
                    case "File":
                    case "sqlce":
                        throw new DoubleLoginException();
                    default:
                        break;
                }

                ConnectionStringStruct connectionString = TestInfrastructure.GetConnectionString(TestContext);
                LearnLogic learnLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                learnLogic.User.Authenticate((GetLoginInformation)MLifterTest.DAL.TestInfrastructure.GetTestUser,
                    connectionString, (DataAccessErrorDelegate)delegate { return; });

                //Doesn't throw the Exception because the UserFactory logs out the previous user
                LearnLogic lLogic = new LearnLogic(OpenUserProfileTests.GetUserAdmin, (DataAccessErrorDelegate)delegate { return; });
                lLogic.User.Authenticate((GetLoginInformation)GetLoginErrorMethod, connectionString, (DataAccessErrorDelegate)delegate { return; });

                //Check instead if old user is logged out properly
                if (!learnLogic.UserSessionAlive)
                    throw new DoubleLoginException();
            }
            else
            {
                throw new DoubleLoginException();
            }
        }