Ejemplo n.º 1
0
        private void OnMushroomNameLostFocus(object sender, RoutedEventArgs e)
        {
            if (MushroomInfoList.Count > 0 && MushroomInfoList.Count < MaxMushroomRows)
            {
                if (MushroomInfoList[MushroomInfoList.Count - 1].Name.Length > 0)
                {
                    MushroomInfoList.Add(new MushroomInfo(Dispatcher, string.Empty, string.Empty, null, null));
                }
                else
                {
                    bool Continue = true;

                    while (Continue)
                    {
                        Continue = false;

                        for (int i = 0; i + 1 < MushroomInfoList.Count; i++)
                        {
                            MushroomInfo Item = MushroomInfoList[i];
                            if (Item.Name.Length == 0 && Item.SelectedMoonPhase1 < 0 && Item.SelectedMoonPhase2 < 0)
                            {
                                MushroomInfoList.Remove(Item);
                                Continue = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void ResetMushroomListToDefault(bool keepComment)
        {
            List <MushroomInfo> NewList = new List <MushroomInfo>();

            AddMushroomToList(NewList, MoonPhase.ParasolMushroomLongName, MoonPhase.FullMoon, MoonPhase.WaningCrescentMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.MycenaMushroomLongName, MoonPhase.WaxingCrescentMoon, MoonPhase.FirstQuarterMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.BoletusMushroomLongName, MoonPhase.NewMoon, MoonPhase.WaningGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.FieldMushroomLongName, MoonPhase.WaxingGibbousMoon, MoonPhase.LastQuarterMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.BlusherMushroomLongName, MoonPhase.NewMoon, MoonPhase.WaningGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.GoblinPuffballLongName, MoonPhase.NewMoon, MoonPhase.WaxingGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.MilkCapMushroomLongName, MoonPhase.FullMoon, MoonPhase.WaningCrescentMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.BloodMushroomLongName, MoonPhase.WaxingCrescentMoon, MoonPhase.LastQuarterMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.CoralMushroomLongName, MoonPhase.FirstQuarterMoon, MoonPhase.WaxingGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.IocaineMushroomLongName, MoonPhase.WaxingCrescentMoon, MoonPhase.FirstQuarterMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.GroxmakMushroomLongName, MoonPhase.WaxingGibbousMoon, MoonPhase.LastQuarterMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.PorciniMushroomLongName, MoonPhase.FullMoon, MoonPhase.WaningGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.BlackFootMorelLongName, MoonPhase.NewMoon, MoonPhase.WaningCrescentMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.PixiesParasolLongName, MoonPhase.FirstQuarterMoon, MoonPhase.WaxingGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.FlyAmanitaLongName, MoonPhase.WaxingCrescentMoon, MoonPhase.FullMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.BlastcapMushroomLongName, MoonPhase.FullMoon, MoonPhase.WaningGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.ChargedMyceliumLongName, MoonPhase.NewMoon, MoonPhase.WaningGibbousMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.FalseAgaricLongName, MoonPhase.WaningCrescentMoon, MoonPhase.LastQuarterMoon, keepComment);
            AddMushroomToList(NewList, MoonPhase.WizardsMushroomLongName, MoonPhase.WaxingCrescentMoon, MoonPhase.FirstQuarterMoon, keepComment);

            MushroomInfoList.Clear();
            foreach (MushroomInfo Item in NewList)
            {
                MushroomInfoList.Add(Item);
            }
        }
Ejemplo n.º 3
0
        private void InitMushroomFarming()
        {
            ShowMushroomFarmingInternal = Settings.GetBool(ShowMushroomFarmingSettingName, true);
            IsMushroomListLargeInternal = false;
            IsLockedInternal            = Settings.GetBool(IsLockedSettingName, false);

            LoadMushroomInfoList();

            bool IsMushroomListInitialized = Settings.IsValueSet(MushroomListInitializedName);

            Settings.SetBool(MushroomListInitializedName, true);

            if (MushroomInfoList.Count == 0 && !IsMushroomListInitialized)
            {
                ResetMushroomListToDefault(false);
            }

            MushroomInfoList.Add(new MushroomInfo(Dispatcher, string.Empty, string.Empty, null, null));
            MushroomInfoList.CollectionChanged += OnMushroomInfoListChanged;

            string ApplicationFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PgJsonParse");

            MushroomNameFile            = Path.Combine(ApplicationFolder, "Mushrooms.txt");
            UpdateMushroomNameListTimer = new Timer(new TimerCallback(UpdateMushroomNameListTimerCallback));
            UpdateMushroomNameListTimer.Change(TimeSpan.Zero, Timeout.InfiniteTimeSpan);
        }
Ejemplo n.º 4
0
        private void LoadMushroomInfoList()
        {
            MushroomInfoList.Clear();

            string MushroomListSetting = Settings.GetString(MushroomListSettingName, string.Empty);

            if (MushroomListSetting != null)
            {
                string[] SplitMushroomListSetting = MushroomListSetting.Split(MushroomListSeparator);
                foreach (string s in SplitMushroomListSetting)
                {
                    string[] Line = s.Split(MushroomSeparator);
                    if (Line.Length >= 1)
                    {
                        string Name = Line[0].Trim();
                        if (Name.Length > 0)
                        {
                            int SelectedPhase1, SelectedPhase2;
                            if (Line.Length >= 3)
                            {
                                int PhaseIndex1;
                                int PhaseIndex2;

                                if (int.TryParse(Line[1].Trim(), out PhaseIndex1) && PhaseIndex1 >= 0 && PhaseIndex1 + 1 < MoonPhase.MoonPhaseList.Count)
                                {
                                    SelectedPhase1 = PhaseIndex1;
                                }
                                else
                                {
                                    SelectedPhase1 = -1;
                                }

                                if (int.TryParse(Line[2].Trim(), out PhaseIndex2) && PhaseIndex2 >= 0 && PhaseIndex2 + 1 < MoonPhase.MoonPhaseList.Count)
                                {
                                    SelectedPhase2 = PhaseIndex2;
                                }
                                else
                                {
                                    SelectedPhase2 = -1;
                                }
                            }
                            else
                            {
                                SelectedPhase1 = -1;
                                SelectedPhase2 = -1;
                            }

                            string Comment = (Line.Length > 3) ? Line[3] : string.Empty;

                            MoonPhase?RobustGrowthPhase1 = SelectedPhase1 >= 0 ? MoonPhase.MoonPhaseList[SelectedPhase1] : null;
                            MoonPhase?RobustGrowthPhase2 = SelectedPhase2 >= 0 ? MoonPhase.MoonPhaseList[SelectedPhase2] : null;
                            MushroomInfoList.Add(new MushroomInfo(Dispatcher, Name, Comment, RobustGrowthPhase1, RobustGrowthPhase2));
                        }
                    }
                }
            }
        }