Esempio n. 1
0
        private static void DoUpdatePatch(MTPatchModel objPatch)
        {
            double   dScore       = 0;
            DateTime dtLastTest   = objPatch.Created;
            double   dDecreaseDay = _iDecreaseDayNormal;

            //Testes
            foreach (MTStructTest objTest in objPatch.lstTest)
            {
                double dPartialScore = GetPoints(dtLastTest, objTest.Date, objTest.WasCorrect == true);
                dDecreaseDay = GetDecreaseDay(objPatch.lstTest.GetRange(0, objPatch.lstTest.IndexOf(objTest)));
                dScore      -= GetDecreaseByTime(objTest.Date.Subtract(dtLastTest), dDecreaseDay);
                //Low Limit
                dScore  = dScore < 0 ? 0 : dScore;
                dScore += dPartialScore;
                //Top Limit
                dScore     = dScore > 100 ? 100 : dScore;
                dtLastTest = objTest.Date;
            }
            //Top Limit
            dScore = dScore > 100 ? 100 : dScore;
            //Decrease by Time
            dScore -= GetDecreaseByTime(DateTime.Now.Subtract(dtLastTest), dDecreaseDay);
            objPatch.IsMemorized = dDecreaseDay == _iDecreaseDayLow;
            //Low Limit
            dScore = dScore < 0 ? 0 : dScore;

            //Final Score
            objPatch.Score = dScore;
        }
Esempio n. 2
0
        private static void DoUpdatePosition(MTPatchModel objPatch)
        {
            TimeSpan dtInterval   = DateTime.Now.Subtract(objPatch.LastDateTest);
            double   dPrePosition = 0;

            if (objPatch.IsMemorized)
            {
                dPrePosition = ((dtInterval.TotalSeconds / 2) / objPatch.Score) / 100;
            }
            else
            {
                dPrePosition = (dtInterval.TotalSeconds / objPatch.Score) / 100;
            }
            //Top Score
            if (dtInterval.TotalHours >= _iTopInterval)
            {
                objPatch.PositionBrain = dPrePosition * 1.2;
            }
            //Middle Score
            else if (dtInterval.TotalHours >= _iMidInterval)
            {
                objPatch.PositionBrain = dPrePosition;
            }
            //Low Score
            else if (dtInterval.TotalHours < _iMidInterval)
            {
                objPatch.PositionBrain = dPrePosition * 0.5;
            }
        }
Esempio n. 3
0
        //-------------DATA-----------------
        public static void WriteDataTest(MTPatchModel objPatch, MTTestModel objTest)
        {
            TextWriter tw = new StreamWriter(MTControler.UserPath + "DataTest.txt", true);

            WriteDataTest(tw, objPatch, objTest);
            tw.Close();
        }
Esempio n. 4
0
        private void btRemove_Click(object sender, RoutedEventArgs e)
        {
            CloseCurrentPopup();
            if (this.lvTexts.SelectedIndex > -1)
            {
                MTPatchModel objText = this.lvTexts.SelectedItem as MTPatchModel;
                //Ask to user
                MessageBoxResult result = MessageBox.Show("Você tem certeza que deseja deletar este exto?\n\"" + objText.Adrees + "\"", "Deletar Texto", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (result == MessageBoxResult.No)
                {
                    return;
                }

                MTControler.TextManager.LstPatch.Remove(objText);

                //Remove from Map Occurrence
                foreach (MTMapModel objMap in objText.LstAdress)
                {
                    objMap.RemoveOccurrence(1);
                }

                if (File.Exists(objText.FilePatch))
                {
                    File.Delete(objText.FilePatch);
                }

                lbPatchCount.Content = "Número de textos: " + MTControler.TextManager.LstPatch.Count().ToString();
            }
            else
            {
                MessageBox.Show("Selecione pelomenos im item na lista.", "Selecione um item", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Esempio n. 5
0
        public object Convert(object value,
                              Type targetType, object parameter,
                              System.Globalization.CultureInfo culture)
        {
            MTPatchModel objPatch = parameter as MTPatchModel;

            if (objPatch == null)
            {
                return(value);
            }
            else
            {
                if (objPatch.Score < MTControler.Settings.Stg1to2)
                {
                    if ((value as SolidColorBrush).Color.Equals(Colors.Khaki))
                    {
                        return(value);
                    }
                    else
                    {
                        return(new SolidColorBrush(Colors.PowderBlue));
                    }
                }
                else
                {
                    return(new SolidColorBrush(Colors.PowderBlue));
                }
            }
        }
Esempio n. 6
0
 public static void WriteDataTest(TextWriter tw, MTPatchModel objPatch, MTTestModel objTest)
 {
     tw.WriteLine(objPatch.GUID);
     tw.WriteLine(objPatch.Adrees);
     tw.WriteLine(objTest.Date);
     tw.WriteLine(objTest.Type.ToString());
     tw.WriteLine(objTest.WasCorrect.ToString());
     tw.WriteLine("##################");
 }
 public MTAddEditTextView()
 {
     InitializeComponent();
     _Map.MapMode  = TestType.AskAdrees;
     _Map.Action   = new DoSomeThing(Action);
     _objText      = new MTPatchModel();
     _bIsAdd       = true;
     btAdd.Content = "Adicionar";
     this.Title    = "Adicionar Texto";
 }
 public MTAddEditTextView(ref MTPatchModel objText)
 {
     InitializeComponent();
     _Map.MapMode = TestType.AskAdrees;
     _Map.Action  = new DoSomeThing(Action);
     _Map.SetSelectedVersesList(objText.LstAdress);
     _objText      = objText;
     _bIsAdd       = false;
     btAdd.Content = "Editar";
     this.Title    = "Editar Texto";
 }
Esempio n. 9
0
        public static void WritePatch(MTPatchModel objPatch)
        {
            try
            {
                string sPatchPath = objPatch.FilePatch;

                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Encoding = Encoding.GetEncoding("iso8859-1");
                settings.Indent   = true;

                using (XmlWriter writer = XmlWriter.Create(sPatchPath, settings))
                {
                    writer.WriteStartDocument();
                    writer.WriteStartElement("MaindText");
                    writer.WriteStartElement("Patches");

                    CultureInfo provider = new CultureInfo("pt-PT");
                    writer.WriteStartElement("Patch");
                    writer.WriteAttributeString("Adress", objPatch.ShortAdrees);
                    writer.WriteAttributeString("Created", objPatch.Created.ToString(provider));
                    writer.WriteAttributeString("GUID", objPatch.GUID);
                    writer.WriteAttributeString("TestIsEnabled", objPatch.TestIsEnabled.ToString());

                    foreach (MTStructTest iTest in objPatch.lstTest)
                    {
                        writer.WriteStartElement("Test");
                        writer.WriteAttributeString("Date", iTest.Date.ToString(provider));
                        writer.WriteAttributeString("Type", iTest.Type.ToString());
                        writer.WriteAttributeString("WasCorrect", iTest.WasCorrect.ToString());
                        writer.WriteEndElement();
                    }

                    foreach (String iText in objPatch.MgrApply.LstApply)
                    {
                        writer.WriteStartElement("Applycation");
                        writer.WriteAttributeString("Text", iText);
                        writer.WriteEndElement();
                    }

                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(string.Format("O seguinte erro foi encontrado no arquivo selecionado: \n{0}", ex.Message), "Arquivo invalido", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 10
0
 public static double LastPoints(MTPatchModel objPatch)
 {
     if (objPatch.lstTest.Count == 0)
     {
         return(0);
     }
     else if (objPatch.lstTest.Count == 1)
     {
         return(MTClassificator.GetPoints(objPatch.Created, objPatch.LastDateTest, true));
     }
     else //if (_lstTest.Count > 1)
     {
         return(MTClassificator.GetPoints(objPatch.lstTest[objPatch.lstTest.Count - 2].Date, objPatch.LastDateTest, true));
     }
 }
Esempio n. 11
0
 private void btEdit_Click(object sender, RoutedEventArgs e)
 {
     CloseCurrentPopup();
     if (this.lvTexts.SelectedIndex > -1)
     {
         MTPatchModel      objText = this.lvTexts.SelectedItem as MTPatchModel;
         MTAddEditTextView dlgAdd  = new MTAddEditTextView(ref objText);
         dlgAdd.Owner = this;
         dlgAdd.Show();
     }
     else
     {
         MessageBox.Show("Selecione pelomenos im item na lista.", "Selecione um item", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Esempio n. 12
0
 static public void UpdatePatch(MTPatchModel objPatch)
 {
     DoUpdatePatch(objPatch);
     UpdateAllPositions();
 }
Esempio n. 13
0
        private static void ReadTestes(XmlReader objReader)
        {
            //Create MTPatchModel
            string      input    = objReader.GetAttribute("Created");
            CultureInfo provider = new CultureInfo("pt-PT");
            DateTime    dateTime;

            try
            {
                dateTime = Convert.ToDateTime(input, provider);
            }
            catch (System.Exception ex)
            {
                string e = ex.Message;
                dateTime = Convert.ToDateTime(input);
            }

            MTPatchModel objPatch = new MTPatchModel(objReader.GetAttribute("Adress"), dateTime, objReader.GetAttribute("GUID"), Convert.ToBoolean(objReader.GetAttribute("TestIsEnabled")));

            MTControler.TextManager.AddPatch(objPatch);

            if (!objReader.IsEmptyElement)
            {
                while (objReader.Read())
                {
                    //if it's the end Element
                    if (objReader.NodeType == XmlNodeType.EndElement && objReader.Name.Equals("Patch", StringComparison.CurrentCultureIgnoreCase))
                    {
                        break;
                    }

                    switch (objReader.Name)
                    {
                    case "Test":
                        //Create MTTestModel
                        input = objReader.GetAttribute("Date");
                        try
                        {
                            dateTime = Convert.ToDateTime(input, provider);
                        }
                        catch (System.Exception ex)
                        {
                            string e = ex.Message;
                            dateTime = Convert.ToDateTime(input);
                        }

                        TestType enType = TestType.AskAdrees;
                        string   sType  = objReader.GetAttribute("Type");
                        if (sType != null)
                        {
                            enType = (TestType)Enum.Parse(typeof(TestType), sType, true);
                        }
                        MTStructTest strTest;
                        strTest.Date       = dateTime;
                        strTest.WasCorrect = Convert.ToBoolean(objReader.GetAttribute("WasCorrect"));
                        strTest.Type       = enType;
                        //MTTestModel objTest = new MTTestModel(dateTime, Convert.ToBoolean(objReader.GetAttribute("WasCorrect")), enType);
                        objPatch.lstTest.Add(strTest);
                        break;

                    case "Applycation":
                        //Create MTPatchModel
                        objPatch.MgrApply.LstApply.Add(objReader.GetAttribute("Text"));
                        if (objPatch.MgrApply.SelIndex == -1)
                        {
                            objPatch.MgrApply.SelIndex = 0;
                        }
                        break;

                    default:
                        throw new Exception("Unexpected element: '" + objReader.Name + "'");
                    }
                }
            }
        }