private WeekDayFlag WeekDaySetter(int weekint)
        {
            if (weekint.ToString().Count() == 7)
            {
                return(WeekDayFlag.All);
            }

            int var = weekint;
            int len = 1;
            int div;

            while (true)
            {
                div = var / 10;
                if (div == 0)
                {
                    break;
                }
                len++;
                var = div;
            }
            WeekDayFlag weekday = new WeekDayFlag();

            for (int i = 0; i < len; i++)
            {
                var temp    = weekint.ToString();
                int inttemp = Convert.ToInt32(temp[i].ToString());
                switch (inttemp)
                {
                case 1:
                    weekday |= WeekDayFlag.Sunday;
                    break;

                case 2:
                    weekday |= WeekDayFlag.Monday;
                    break;

                case 3:
                    weekday |= WeekDayFlag.Tuesday;
                    break;

                case 4:
                    weekday |= WeekDayFlag.Wednesday;
                    break;

                case 5:
                    weekday |= WeekDayFlag.Thursday;
                    break;

                case 6:
                    weekday |= WeekDayFlag.Friday;
                    break;

                case 7:
                    weekday |= WeekDayFlag.Saturday;
                    break;
                }
            }
            return(weekday);
        }
Beispiel #2
0
        private WeekDayFlag WeekDaySetter(int weekint)
        {
            var temp = weekint.ToString();
            int len  = temp.Length;

            if (len == 7)
            {
                return(WeekDayFlag.All);
            }

            WeekDayFlag weekday = new WeekDayFlag();

            for (int i = 0; i < len; i++)
            {
                int inttemp = int.Parse(temp[i].ToString());
                weekday |= (WeekDayFlag)(1 << (inttemp - 1));
            }
            return(weekday);
        }
        private List <RemodelItemList> MakeUpList(IEnumerable <XElement> remodellist, WeekDayFlag today)
        {
            List <RemodelItemList> templist = new List <RemodelItemList>();

            foreach (var item in remodellist)
            {
                var temp = new RemodelItemList();
                temp.Ships = new List <ShipInfo>();

                if (WeekDaySetter(Convert.ToInt32(item.Element("AllWeekdays").Value)).HasFlag(today))
                {
                    if (item.Element("SlotItemName") != null)
                    {
                        temp.ItemName = KanColleClient.Current.Translations.GetTranslation(item.Element("SlotItemName").Value, TranslationType.Equipment);
                        foreach (var slotitem in KanColleClient.Current.Master.SlotItems)
                        {
                            if (slotitem.Value.Name == temp.ItemName)
                            {
                                temp.IconType = slotitem.Value.IconType;
                            }
                        }
                    }
                    int  shipCount = 1;
                    bool Checker   = true;
                    try
                    {
                        List <ShipInfo> ShipList = new List <ShipInfo>();
                        while (Checker)
                        {
                            string shipname = "ShipName" + shipCount.ToString();
                            string weekdays = "WeekDays" + shipCount.ToString();
                            string upgrade  = "Upgrade" + shipCount.ToString();

                            ShipInfo ship = new ShipInfo();

                            if (item.Element(shipname) != null)
                            {
                                ship.ShipName = KanColleClient.Current.Translations.GetTranslation(item.Element(shipname).Value, TranslationType.Ships);
                                ship.Weekday  = WeekDaySetter(Convert.ToInt32(item.Element(weekdays).Value));
                            }
                            if (item.Element(upgrade) != null)
                            {
                                ship.Upgrade = KanColleClient.Current.Translations.GetTranslation(item.Element(upgrade).Value, TranslationType.Equipment);

                                foreach (var slotitem in KanColleClient.Current.Master.SlotItems)
                                {
                                    if (slotitem.Value.Name == ship.Upgrade)
                                    {
                                        ship.UpgradeIconType = slotitem.Value.IconType;
                                    }
                                }
                            }
                            shipCount++;
                            if (ship.ShipName == null && ship.Upgrade != null)
                            {
                                ship.Weekday |= WeekDayFlag.NotNeedShip;
                            }
                            if (ship != null)
                            {
                                if (ship.Weekday.HasFlag(today) || ship.Weekday.HasFlag(WeekDayFlag.NotNeedShip))
                                {
                                    ShipList.Add(ship);
                                }
                                if (ship.ShipName == null && ship.Upgrade == null && ship.UpgradeIconType == null && ship.Weekday.HasFlag(WeekDayFlag.None))
                                {
                                    Checker = false;
                                }
                            }
                            else
                            {
                                Checker = false;
                            }
                        }
                        if (ShipList != null)
                        {
                            foreach (var shipinfo in ShipList)
                            {
                                temp.Ships.Add(shipinfo);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                    }
                    if (item.Element("AllWeekdays") != null)
                    {
                        temp.TotalWeekday = WeekDaySetter(Convert.ToInt32(item.Element("AllWeekdays").Value));
                    }
                    if (item.Element("ToolTip") != null)
                    {
                        temp.ToolTipString = item.Element("ToolTip").Value;
                    }
                    else
                    {
                        temp.ToolTipString = "특이사항 없음";
                    }
                    StringBuilder equipCombine = new StringBuilder();
                    if (item.Element("StartEquip") != null)
                    {
                        equipCombine.Append(item.Element("StartEquip").Value);
                    }
                    if (item.Element("MidEquip") != null)
                    {
                        equipCombine.Append("/");
                        equipCombine.Append(item.Element("MidEquip").Value);
                    }
                    if (item.Element("LastEquip") != null)
                    {
                        equipCombine.Append("/");
                        equipCombine.Append(item.Element("LastEquip").Value);
                    }
                    if (equipCombine != null)
                    {
                        temp.UseEquip = equipCombine.ToString();
                    }

                    if (temp.TotalWeekday.HasFlag(today))
                    {
                        templist.Add(temp);
                        if (temp.Ships != null)
                        {
                            foreach (var context in temp.Ships)
                            {
                                if (context.Upgrade != null)
                                {
                                    tempimp.Add(temp);
                                    break;
                                }
                            }
                        }
                        if (temp.UseEquip != null)
                        {
                            tempUse.Add(temp);
                        }
                    }
                }
            }
            return(templist);
        }
        private void Update(bool IsStart = true)
        {
            if (File.Exists(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml")))
            {
                if (IsStart)
                {
                    WeekDayView = (int)DateTime.Today.DayOfWeek + 1;
                }
                else
                {
                    WeekDayView = WeekDayTable[SelectedDay];
                }
                WeekDayFlag today = new WeekDayFlag();
                switch (WeekDayView)
                {
                case 1:
                    today |= WeekDayFlag.Sunday;
                    if (IsStart)
                    {
                        SelectedDay = "일요일";
                    }
                    break;

                case 2:
                    today |= WeekDayFlag.Monday;
                    if (IsStart)
                    {
                        SelectedDay = "월요일";
                    }
                    break;

                case 3:
                    today |= WeekDayFlag.Tuesday;
                    if (IsStart)
                    {
                        SelectedDay = "화요일";
                    }
                    break;

                case 4:
                    today |= WeekDayFlag.Wednesday;
                    if (IsStart)
                    {
                        SelectedDay = "수요일";
                    }
                    break;

                case 5:
                    today |= WeekDayFlag.Thursday;
                    if (IsStart)
                    {
                        SelectedDay = "목요일";
                    }
                    break;

                case 6:
                    today |= WeekDayFlag.Friday;
                    if (IsStart)
                    {
                        SelectedDay = "금요일";
                    }
                    break;

                case 7:
                    today |= WeekDayFlag.Saturday;
                    if (IsStart)
                    {
                        SelectedDay = "토요일";
                    }
                    break;
                }
                this.RemodelXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml"));
                IEnumerable <XElement> RemodelList = GetRemodelList();
                var Position = "Position";

                IEnumerable <XElement> First  = RemodelList.Where(f => f.Element(Position).Value.Equals("1")).ToList();
                IEnumerable <XElement> Second = RemodelList.Where(f => f.Element(Position).Value.Equals("2")).ToList();
                IEnumerable <XElement> Third  = RemodelList.Where(f => f.Element(Position).Value.Equals("3")).ToList();

                this.tempimp     = new List <RemodelItemList>();
                this.tempUse     = new List <RemodelItemList>();
                this.FirstList   = new List <RemodelItemList>(MakeUpList(First, today));
                this.SecondList  = new List <RemodelItemList>(MakeUpList(Second, today));
                this.ThirdList   = new List <RemodelItemList>(MakeUpList(Third, today));
                this.Improvement = new List <RemodelItemList>(tempimp);
                this.UseItemList = new List <RemodelItemList>(tempUse);
            }
        }
        private WeekDayFlag WeekDaySetter(int weekint)
        {
            if (weekint.ToString().Count() == 7)
            {
                return WeekDayFlag.All;
            }

            int var = weekint;
            int len = 1;
            int div;

            while (true)
            {
                div = var / 10;
                if (div == 0) break;
                len++;
                var = div;
            }
            WeekDayFlag weekday = new WeekDayFlag();
            for (int i = 0; i < len; i++)
            {
                var temp = weekint.ToString();
                int inttemp = Convert.ToInt32(temp[i].ToString());
                switch (inttemp)
                {
                    case 1:
                        weekday |= WeekDayFlag.Sunday;
                        break;
                    case 2:
                        weekday |= WeekDayFlag.Monday;
                        break;
                    case 3:
                        weekday |= WeekDayFlag.Tuesday;
                        break;
                    case 4:
                        weekday |= WeekDayFlag.Wednesday;
                        break;
                    case 5:
                        weekday |= WeekDayFlag.Thursday;
                        break;
                    case 6:
                        weekday |= WeekDayFlag.Friday;
                        break;
                    case 7:
                        weekday |= WeekDayFlag.Saturday;
                        break;
                }
            }
            return weekday;
        }
        private void Update(bool IsStart = true)
        {
            if (File.Exists(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml")))
            {
                if (IsStart) WeekDayView = (int)DateTime.Today.DayOfWeek + 1;
                else WeekDayView = WeekDayTable[SelectedDay];
                today = new WeekDayFlag();
                switch (WeekDayView)
                {
                    case 1:
                        today |= WeekDayFlag.Sunday;
                        if (IsStart) SelectedDay = "일요일";
                        break;
                    case 2:
                        today |= WeekDayFlag.Monday;
                        if (IsStart) SelectedDay = "월요일";
                        break;
                    case 3:
                        today |= WeekDayFlag.Tuesday;
                        if (IsStart) SelectedDay = "화요일";
                        break;
                    case 4:
                        today |= WeekDayFlag.Wednesday;
                        if (IsStart) SelectedDay = "수요일";
                        break;
                    case 5:
                        today |= WeekDayFlag.Thursday;
                        if (IsStart) SelectedDay = "목요일";
                        break;
                    case 6:
                        today |= WeekDayFlag.Friday;
                        if (IsStart) SelectedDay = "금요일";
                        break;
                    case 7:
                        today |= WeekDayFlag.Saturday;
                        if (IsStart) SelectedDay = "토요일";
                        break;
                }
                this.RemodelXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml"));
                IEnumerable<XElement> RemodelList = GetRemodelList();

                var Weekday = "AllWeekdays";
                //RemodelList에서 오늘 개수공창 목록에 들어갈것들을 선별한다.
                RemodelList = RemodelList.Where(f => WeekDaySetter(Convert.ToInt32(f.Element(Weekday).Value)).HasFlag(today));
                //상중하 리스트를 작성
                this.FirstList = MakeDefaultList(RemodelList, 1);
                this.SecondList = MakeDefaultList(RemodelList, 2);
                this.ThirdList = MakeDefaultList(RemodelList, 3);
                //소모아이템 리스트를 작성
                this.UseItemList = MakeUseItemList(RemodelList);
                //개조 목록을 작성
                this.Improvement = MakeUpgradeList(RemodelList);
            }
        }
Beispiel #7
0
        private void Update(bool IsStart = true)
        {
            if (File.Exists(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml")))
            {
                this.IsLoading = true;

                new System.Threading.Thread(() =>
                {
                    if (IsStart)
                    {
                        WeekDayView = (int)DateTime.Today.DayOfWeek + 1;
                    }
                    else
                    {
                        WeekDayView = WeekDayTable[SelectedDay];
                    }
                    today = new WeekDayFlag();
                    switch (WeekDayView)
                    {
                    case 1:
                        today |= WeekDayFlag.Sunday;
                        if (IsStart)
                        {
                            SelectedDay = "일요일";
                        }
                        break;

                    case 2:
                        today |= WeekDayFlag.Monday;
                        if (IsStart)
                        {
                            SelectedDay = "월요일";
                        }
                        break;

                    case 3:
                        today |= WeekDayFlag.Tuesday;
                        if (IsStart)
                        {
                            SelectedDay = "화요일";
                        }
                        break;

                    case 4:
                        today |= WeekDayFlag.Wednesday;
                        if (IsStart)
                        {
                            SelectedDay = "수요일";
                        }
                        break;

                    case 5:
                        today |= WeekDayFlag.Thursday;
                        if (IsStart)
                        {
                            SelectedDay = "목요일";
                        }
                        break;

                    case 6:
                        today |= WeekDayFlag.Friday;
                        if (IsStart)
                        {
                            SelectedDay = "금요일";
                        }
                        break;

                    case 7:
                        today |= WeekDayFlag.Saturday;
                        if (IsStart)
                        {
                            SelectedDay = "토요일";
                        }
                        break;
                    }
                    this.RemodelXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml"));
                    IEnumerable <XElement> RemodelList = GetRemodelList();

                    var Weekday = "AllWeekdays";
                    //RemodelList에서 오늘 개수공창 목록에 들어갈것들을 선별한다.
                    RemodelList = RemodelList.Where(f => WeekDaySetter(Convert.ToInt32(f.Element(Weekday).Value)).HasFlag(today));
                    //상중하 리스트를 작성->상중하의 구분을 제거
                    var list       = MakeDefaultList(RemodelList).ToList();
                    var _FirstList = SortList(list);

                    //소모아이템 리스트를 작성
                    var use          = MakeUseItemList(RemodelList);
                    var _UseItemList = SortList(use.ToList());
                    //개조 목록을 작성
                    var im           = MakeUpgradeList(RemodelList);
                    var _Improvement = SortList(im.ToList());

                    Grabacr07.KanColleViewer.Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.FirstList   = _FirstList;
                        this.UseItemList = _UseItemList;
                        this.Improvement = _Improvement;
                        this.IsLoading   = false;
                    });
                }).Start();
            }
        }
        private void Update(bool IsStart = true)
        {
            if (File.Exists(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml")))
            {
                if (IsStart)
                {
                    WeekDayView = (int)DateTime.Today.DayOfWeek + 1;
                }
                else
                {
                    WeekDayView = WeekDayTable[SelectedDay];
                }
                today = new WeekDayFlag();
                switch (WeekDayView)
                {
                case 1:
                    today |= WeekDayFlag.Sunday;
                    if (IsStart)
                    {
                        SelectedDay = "일요일";
                    }
                    break;

                case 2:
                    today |= WeekDayFlag.Monday;
                    if (IsStart)
                    {
                        SelectedDay = "월요일";
                    }
                    break;

                case 3:
                    today |= WeekDayFlag.Tuesday;
                    if (IsStart)
                    {
                        SelectedDay = "화요일";
                    }
                    break;

                case 4:
                    today |= WeekDayFlag.Wednesday;
                    if (IsStart)
                    {
                        SelectedDay = "수요일";
                    }
                    break;

                case 5:
                    today |= WeekDayFlag.Thursday;
                    if (IsStart)
                    {
                        SelectedDay = "목요일";
                    }
                    break;

                case 6:
                    today |= WeekDayFlag.Friday;
                    if (IsStart)
                    {
                        SelectedDay = "금요일";
                    }
                    break;

                case 7:
                    today |= WeekDayFlag.Saturday;
                    if (IsStart)
                    {
                        SelectedDay = "토요일";
                    }
                    break;
                }
                this.RemodelXML = XDocument.Load(Path.Combine(MainFolder, "Translations", "RemodelSlots.xml"));
                IEnumerable <XElement> RemodelList = GetRemodelList();

                var Weekday = "AllWeekdays";
                //RemodelList에서 오늘 개수공창 목록에 들어갈것들을 선별한다.
                RemodelList = RemodelList.Where(f => WeekDaySetter(Convert.ToInt32(f.Element(Weekday).Value)).HasFlag(today));
                //상중하 리스트를 작성
                this.FirstList  = MakeDefaultList(RemodelList, 1);
                this.SecondList = MakeDefaultList(RemodelList, 2);
                this.ThirdList  = MakeDefaultList(RemodelList, 3);
                //소모아이템 리스트를 작성
                this.UseItemList = MakeUseItemList(RemodelList);
                //개조 목록을 작성
                this.Improvement = MakeUpgradeList(RemodelList);
            }
        }