Пример #1
0
        /// <summary>
        /// Ask the woman for her password.
        /// </summary>
        /// <param name="woman">The woman to ask. Also stores credentials.</param>
        /// <returns>True if authetification succeded.</returns>
        public static bool AskPassword(Woman woman)
        {
            LoginForm form = new LoginForm();

            form.Text = woman.Name + ", " + form.Text;
            while (true)
            {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    break;
                }

                if (form.Password != woman.Password)
                {
                    if (!MsgBox.YesNo(TEXT.Get["Wrong_password_question"], TEXT.Get["Error"]))
                    {
                        break;
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        private void setLastPregnancyDay_Click(object sender, EventArgs e)
        {
            var period = Program.CurrentWoman.Conceptions.GetConceptionByDate(FocusDate);

            if (period != null)
            {
                if (MsgBox.YesNo(TEXT.Get["Shorten_pregn_question"],
                                 TEXT.Get["Are_you_sure"]))
                {
                    period.LastDay = FocusDate;
                    ((MainForm)ParentForm).RedrawCalendar();
                }
            }
        }
Пример #3
0
        private static void CallbackDoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                var s   = GetFileStream("http://ovulyashki.dp.ua/lastversion/");
                var doc = new XmlDocument();
                doc.Load(s);
                XmlNode rootNode = doc.ChildNodes[1];
                var     release  = new Release()
                {
                    Date      = rootNode["dateadd"].InnerText,
                    FileName  = rootNode["filename"].InnerText,
                    Version   = rootNode["version"].InnerText,
                    ChangeLog = rootNode["changelog"].InnerText,
                    FileSize  = rootNode["filesize"].InnerText,
                    Downloads = rootNode["downloads"].InnerText,
                    Url       = rootNode["url"].InnerText
                };
                s.Close();

                if (release.IsItNewVersion())
                {
                    bool updateUs = false;
                    Program.ApplicationForm.Invoke(new MethodInvoker(() =>
                    {
                        updateUs = MsgBox.YesNo(release.GetFormattedText(), TEXT.Get["Ovulyashki"]);
                    }));
                    if (updateUs)
                    {
                        DownloadUpdate(release);
                    }
                }
                else
                {
                    Program.ApplicationForm.BeginInvoke(new MethodInvoker(() =>
                    {
                        MsgBox.Show(TEXT.Get["Latest_application"], TEXT.Get["Ovulyashki"]);
                    }));
                }
            }
            catch (Exception ex)
            {
                Program.ApplicationForm.BeginInvoke(new MethodInvoker(() =>
                {
                    MsgBox.Error(TEXT.Get.Format("Unable_to_update", ex.Message), TEXT.Get["Error"]);
                }));
            }
        }
Пример #4
0
        private void numMenstruationPeriod_ValueChanged(object sender, EventArgs e)
        {
            int newValue = (int)numMenstruationPeriod.Value;

            if (Program.CurrentWoman.ManualPeriodLength <= MenstruationPeriod.NormalMaximalPeriod &&
                newValue > MenstruationPeriod.NormalMaximalPeriod)
            {
                if (!MsgBox.YesNo(
                        TEXT.Get.Format("Cycle_more_than", MenstruationPeriod.NormalMaximalPeriod),
                        TEXT.Get["What_a_cycle"]))
                {
                    numMenstruationPeriod.Value = Program.CurrentWoman.ManualPeriodLength;
                    lblMyCycle2.Text            = TEXT.GetDaysString(Program.CurrentWoman.ManualPeriodLength);
                    return;
                }
            }

            Program.CurrentWoman.ManualPeriodLength = newValue;
            lblMyCycle2.Text = TEXT.GetDaysString(newValue);
            RedrawCalendar();
        }
Пример #5
0
        /// <summary>
        /// Adds one more cycle to the collection. Interacts with user if something.
        /// </summary>
        /// <param name="date">The red days start.</param>
        /// <param name="length">The egesting number of days.</param>
        /// <returns>True if sucsessfully added.</returns>
        public bool Add(DateTime date, int length)
        {
            MenstruationPeriod newPeriod     = new MenstruationPeriod(date, length);
            MenstruationPeriod closestPeriod = this.GetClosestPeriodAfterDay(date);

            if (closestPeriod != null)
            {
                if (!MsgBox.YesNo(
                        TEXT.Get["Menstr_after_day"] + TEXT.Get["Are_you_sure_capital"],
                        TEXT.Get["Are_you_crazy"]))
                {
                    return(false);
                }

                int distance = (closestPeriod.StartDay - date).Days;
                if (distance < length)
                {
                    newPeriod.SetLength(distance);
                }

                this.Insert(IndexOf(closestPeriod), newPeriod); // we must always keep the collection sorted.
            }
            else
            {
                string askMessage = string.Empty;
                closestPeriod = this.GetClosestPeriodBeforeDay(date);
                if (closestPeriod != null)
                {
                    int distance = (date - closestPeriod.StartDay).Days;
                    if (distance < MenstruationPeriod.NormalMinimalPeriod)
                    {
                        askMessage += TEXT.Get.Format(
                            "Msg_short_menstr_period",
                            MenstruationPeriod.NormalMinimalPeriod,
                            TEXT.GetDaysString(MenstruationPeriod.NormalMinimalPeriod));
                    }
                    else if (distance > MenstruationPeriod.NormalMaximalPeriod)
                    {
                        askMessage += TEXT.Get.Format(
                            "Msg_large_menstr_period",
                            MenstruationPeriod.NormalMaximalPeriod,
                            TEXT.GetDaysString(MenstruationPeriod.NormalMaximalPeriod));
                    }
                }

                if (date > DateTime.Today)
                {
                    askMessage += "\n" + TEXT.Get["Future_day_question"];
                }

                if (!string.IsNullOrEmpty(askMessage) &&
                    !MsgBox.YesNo(
                        askMessage + TEXT.Get["Are_you_sure_capital"],
                        TEXT.Get["What_a_situation"]))
                {
                    return(false);
                }

                this.Add(newPeriod);
            }

            return(true);
        }
Пример #6
0
        /// <summary>
        /// Try to add pregnancy. Asks user any questions he has to be asked.
        /// </summary>
        /// <param name="date">The clicked day.</param>
        /// <returns>True if added. Otherwise false.</returns>
        public bool AddConceptionDay(DateTime date)
        {
            if (!this.Conceptions.IsPregnancyDay(date))
            {
                if (date > DateTime.Today)
                {
                    if (!MsgBox.YesNo(
                            TEXT.Get["Future_pregnancy_day"] + TEXT.Get["Are_you_sure_capital"],
                            TEXT.Get["What_a_situation"]))
                    {
                        return(false);
                    }
                }

                ConceptionPeriod concPeriod = this.Conceptions.GetConceptionAfterDate(date);
                if (concPeriod != null && (concPeriod.StartDay - date).Days <= ConceptionPeriod.StandardLength)
                {
                    MsgBox.YesNo(
                        TEXT.Get.Format("Already_pregnant_after", (concPeriod.StartDay - date).Days.ToString()),
                        TEXT.Get["No_no_no"]);
                    return(false);
                }

                MenstruationPeriod nextMenses = this.Menstruations.GetClosestPeriodAfterDay(date);
                if (nextMenses != null)
                {
                    if (!MsgBox.YesNo(
                            TEXT.Get["Have_menses_after_pregn"] + TEXT.Get["Are_you_sure_capital"],
                            TEXT.Get["What_a_situation"]))
                    {
                        return(false);
                    }
                }

                MenstruationPeriod prevMenses = this.Menstruations.GetPeriodByDate(date);
                if (prevMenses != null)
                {
                    if (!MsgBox.YesNo(
                            TEXT.Get["Pregn_on_menses"] + TEXT.Get["Are_you_sure_capital"],
                            TEXT.Get["What_a_situation"]))
                    {
                        return(false);
                    }
                }
                else
                {
                    prevMenses = this.Menstruations.GetClosestPeriodBeforeDay(date);
                }

                if (prevMenses != null && Math.Abs((date - prevMenses.LastDay).Days) <= this.ManualPeriodLength)
                { // The pregnancy must start from last cycle start.
                  // Also we must be sure is was not so long time ago since last cycle.
                    prevMenses.HasPregnancy = true;
                    return(this.Conceptions.Add(prevMenses.StartDay));
                }
                else
                {
                    return(this.Conceptions.Add(date));
                }
            }

            return(false);
        }