OSDN Git Service

ShipListPanel関連のクラスを名前空間でまとめる
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / ListForm.cs
index 41f4dfb..3b2df6d 100644 (file)
@@ -17,7 +17,8 @@ using System.Collections.Generic;
 using System.Drawing;\r
 using System.Linq;\r
 using System.Windows.Forms;\r
-using static System.Math;\r
+using KancolleSniffer.View;\r
+using KancolleSniffer.View.ShipListPanel;\r
 \r
 namespace KancolleSniffer\r
 {\r
@@ -25,423 +26,176 @@ namespace KancolleSniffer
     {\r
         private readonly Sniffer _sniffer;\r
         private readonly Config _config;\r
-        private const int LabelHeight = 12;\r
-        private const int LineHeight = 16;\r
+        private readonly MainForm _main;\r
+        private readonly MainForm.TimeOutChecker _suppressActivate;\r
+        private readonly CheckBox[] _shipTypeCheckBoxes;\r
         public const int PanelWidth = 217;\r
-        private ShipStatus[] _shipList;\r
-        private readonly List<ShipLabel[]> _labelList = new List<ShipLabel[]>();\r
-        private readonly List<Panel> _labelPanelList = new List<Panel>();\r
-        private readonly List<CheckBox[]> _checkBoxesList = new List<CheckBox[]>();\r
-        private readonly List<ShipLabel[]> _configLabelList = new List<ShipLabel[]>();\r
-        private readonly List<Panel> _checkBoxPanelList = new List<Panel>();\r
-        private readonly List<ShipLabel[]> _repairLabelList = new List<ShipLabel[]>();\r
-        private readonly List<Panel> _repairPanelList = new List<Panel>();\r
-        public const int GroupCount = 4;\r
-        private readonly HashSet<int>[] _groupSettings = new HashSet<int>[GroupCount];\r
 \r
         public enum SortOrder\r
         {\r
             None,\r
             Cond,\r
+            CondAscend = Cond,\r
+            CondDescend,\r
             ExpToNext,\r
+            ExpToNextAscend = ExpToNext,\r
+            ExpToNextDescend,\r
             Repair\r
         }\r
 \r
-        public ListForm(Sniffer sniffer, Config config)\r
+        public ListForm(MainForm main)\r
         {\r
             InitializeComponent();\r
-            _sniffer = sniffer;\r
-            _config = config;\r
+            _main = main;\r
+            _sniffer = main.Sniffer;\r
+            _config = main.Config;\r
+            _suppressActivate = main.SuppressActivate;\r
+            _shipTypeCheckBoxes = new[]\r
+            {\r
+                checkBoxSTypeBattleShip,\r
+                checkBoxSTypeAircraftCarrier,\r
+                checkBoxSTypeHeavyCruiser,\r
+                checkBoxSTypeLightCruiser,\r
+                checkBoxSTypeDestroyer,\r
+                checkBoxSTypeEscort,\r
+                checkBoxSTypeSubmarine,\r
+                checkBoxSTypeAuxiliary\r
+            };\r
+            battleResultPanel.HpLabelClick += ToggleHpPercent;\r
+            shipListPanel.HpLabelClick += ToggleHpPercent;\r
             var swipe = new SwipeScrollify();\r
-            swipe.AddPanel(panelShipList);\r
+            swipe.AddShipListPanel(shipListPanel);\r
             swipe.AddTreeView(itemTreeView);\r
-            swipe.AddPanel(equipPanel);\r
+            swipe.AddPanel(fleetPanel);\r
         }\r
 \r
         public void UpdateList()\r
         {\r
-            panelItemHeader.Visible = InItemList || InEquip || InMiscText;\r
-            panelGroupHeader.Visible = InGroupConfig;\r
-            panelRepairHeader.Visible = InRepairList;\r
-            // SwipeScrollifyが誤作動するのでEnabledも切り替える\r
-            panelShipList.Visible = panelShipList.Enabled = InShipStatus || InGroupConfig || InRepairList;\r
-            itemTreeView.Visible = itemTreeView.Enabled = InItemList;\r
-            equipPanel.Visible = equipPanel.Enabled = InEquip;\r
-            richTextBoxMiscText.Visible = InMiscText;\r
+            SetHeaderVisibility();\r
+            SetPanelVisibility();\r
             if (InItemList)\r
             {\r
                 itemTreeView.SetNodes(_sniffer.ItemList);\r
             }\r
-            else if (InEquip)\r
+            else if (InFleetInfo)\r
+            {\r
+                fleetPanel.Update(_sniffer);\r
+            }\r
+            else if (InAntiAir)\r
             {\r
-                equipPanel.UpdateEquip(_sniffer);\r
+                antiAirPanel.Update(_sniffer);\r
             }\r
             else if (InMiscText)\r
             {\r
                 richTextBoxMiscText.Text = _sniffer.MiscText;\r
             }\r
-            else\r
+            else if (InShipStatus || InGroupConfig || InRepairList)\r
             {\r
                 SetHeaderSortOrder();\r
-                CreateShipList();\r
-                CreateListLabels();\r
-                SetShipLabels();\r
+                shipListPanel.Update(_sniffer, comboBoxGroup.Text, _config.ShipList);\r
             }\r
-        }\r
-\r
-        private void SetHeaderSortOrder()\r
-        {\r
-            switch (_config.ShipList.SortOrder)\r
+            if (shipListPanel.GroupUpdated)\r
             {\r
-                case SortOrder.None:\r
-                    labelHeaderCond.Text = "cond";\r
-                    labelHeaderExp.Text = "Exp";\r
-                    break;\r
-                case SortOrder.Cond:\r
-                    labelHeaderCond.Text = "cond▴";\r
-                    labelHeaderExp.Text = "Exp";\r
-                    break;\r
-                case SortOrder.ExpToNext:\r
-                    labelHeaderCond.Text = "cond";\r
-                    labelHeaderExp.Text = "Exp▴";\r
-                    break;\r
+                StoreShipGroupToConfig();\r
+                _config.Save();\r
+                shipListPanel.GroupUpdated = false;\r
             }\r
         }\r
 \r
-        private void CreateShipList()\r
+        private class Visibility\r
         {\r
-            var ships = InRepairList ? _sniffer.RepairList : FilterByGroup(_sniffer.ShipList).ToArray();\r
-            var order = InRepairList ? SortOrder.Repair : _config.ShipList.SortOrder;\r
-            if (!_config.ShipList.ShipType)\r
-            {\r
-                _shipList = ships.OrderBy(s => s, new CompareShip(false, order)).ToArray();\r
-                return;\r
-            }\r
-            var types = ships.Select(s => new {Id = s.Spec.ShipType, Name = s.Spec.ShipTypeName}).Distinct().\r
-                Select(stype =>\r
-                    new ShipStatus\r
-                    {\r
-                        Spec = new ShipSpec {Name = stype.Name, ShipType = stype.Id},\r
-                        Level = 1000,\r
-                        NowHp = -1000,\r
-                        Cond = -1000\r
-                    });\r
-            _shipList = ships.Concat(types).OrderBy(s => s, new CompareShip(true, order)).ToArray();\r
-        }\r
+            public Control Control { get; }\r
+            public bool Visible { get; }\r
 \r
-        private IEnumerable<ShipStatus> FilterByGroup(IEnumerable<ShipStatus> ships)\r
-        {\r
-            var g = Array.FindIndex(new[] {"A", "B", "C", "D"}, x => x == comboBoxGroup.Text);\r
-            if (g == -1)\r
-                return ships;\r
-            return from s in ships where _groupSettings[g].Contains(s.Id) select s;\r
-        }\r
-\r
-        private class CompareShip : IComparer<ShipStatus>\r
-        {\r
-            private readonly bool _type;\r
-            private readonly SortOrder _order;\r
-\r
-            public CompareShip(bool type, SortOrder order)\r
+            public Visibility(Control control, bool visible)\r
             {\r
-                _type = type;\r
-                _order = order;\r
-            }\r
-\r
-            public int Compare(ShipStatus a, ShipStatus b)\r
-            {\r
-                if (_type && a.Spec.ShipType != b.Spec.ShipType)\r
-                    return a.Spec.ShipType - b.Spec.ShipType;\r
-                switch (_order)\r
-                {\r
-                    case SortOrder.None:\r
-                    case SortOrder.ExpToNext:\r
-                        break;\r
-                    case SortOrder.Cond:\r
-                        if (a.Cond != b.Cond)\r
-                            return a.Cond - b.Cond;\r
-                        break;\r
-                    case SortOrder.Repair:\r
-                        if (a.RepairTime != b.RepairTime)\r
-                            return (int)(b.RepairTime - a.RepairTime).TotalSeconds;\r
-                        break;\r
-                }\r
-                if ((!_type || _order == SortOrder.ExpToNext) && a.Level != b.Level)\r
-                    return b.Level - a.Level;\r
-                if (_order == SortOrder.ExpToNext && a.ExpToNext != b.ExpToNext)\r
-                    return a.ExpToNext - b.ExpToNext;\r
-                if (a.Spec.SortNo != b.Spec.SortNo)\r
-                    return a.Spec.SortNo - b.Spec.SortNo;\r
-                return a.Id - b.Id;\r
+                Control = control;\r
+                Visible = visible;\r
             }\r
         }\r
 \r
-        private void CreateListLabels()\r
+        private void SetHeaderVisibility()\r
         {\r
-            panelShipList.SuspendLayout();\r
-            for (var i = _labelList.Count; i < _shipList.Length; i++)\r
+            var headers = new[]\r
             {\r
-                CreateConfigComponents(i);\r
-                CreateRepairLabels(i);\r
-                CreateShipLabels(i);\r
-            }\r
-            panelShipList.ResumeLayout();\r
-        }\r
-\r
-        private void CreateConfigComponents(int i)\r
-        {\r
-            var y = 3 + LineHeight * i;\r
-            var cfgp = new Panel\r
-            {\r
-                Location = new Point(0, y - 2),\r
-                Size = new Size(PanelWidth, LineHeight - 1),\r
-                BackColor = ShipLabels.ColumnColors[(i + 1) % 2],\r
-                Visible = false\r
+                new Visibility(panelItemHeader, InItemList || InAntiAir || InBattleResult || InMiscText),\r
+                new Visibility(panelGroupHeader, InGroupConfig),\r
+                new Visibility(panelRepairHeader, InRepairList),\r
+                new Visibility(panelFleetHeader, InFleetInfo)\r
             };\r
-            cfgp.Scale(ShipLabel.ScaleFactor);\r
-            cfgp.Tag = cfgp.Location.Y;\r
-            var cfgl = new[]\r
-            {\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(91, 2),\r
-                    Size = new Size(23, LabelHeight),\r
-                    TextAlign = ContentAlignment.MiddleRight,\r
-                },\r
-                new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
-            };\r
-\r
-            var cb = new CheckBox[GroupCount];\r
-            for (var j = 0; j < cb.Length; j++)\r
-            {\r
-                cb[j] = new CheckBox\r
-                {\r
-                    Location = new Point(125 + j * 24, 2),\r
-                    FlatStyle = FlatStyle.Flat,\r
-                    Size = new Size(12, 11),\r
-                    Tag = i * 10 + j\r
-                };\r
-                cb[j].Scale(ShipLabel.ScaleFactor);\r
-                cb[j].CheckedChanged += checkboxGroup_CheckedChanged;\r
-            }\r
-            _configLabelList.Add(cfgl);\r
-            _checkBoxesList.Add(cb);\r
-            _checkBoxPanelList.Add(cfgp);\r
-            // ReSharper disable CoVariantArrayConversion\r
-            cfgp.Controls.AddRange(cfgl);\r
-            cfgp.Controls.AddRange(cb);\r
-            // ReSharper restore CoVariantArrayConversion\r
-            panelShipList.Controls.Add(cfgp);\r
-            foreach (var label in cfgl)\r
+            foreach (var header in headers)\r
             {\r
-                label.Scale();\r
-                label.PresetColor =\r
-                    label.BackColor = ShipLabels.ColumnColors[(i + 1) % 2];\r
+                header.Control.Visible = header.Visible;\r
+                if (header.Visible)\r
+                    header.Control.BringToFront();\r
             }\r
         }\r
 \r
-        private void CreateRepairLabels(int i)\r
+        private void SetPanelVisibility()\r
         {\r
-            var y = 3 + LineHeight * i;\r
-            const int height = LabelHeight;\r
-            var rpp = new Panel\r
+            var panels = new[]\r
             {\r
-                Location = new Point(0, y - 2),\r
-                Size = new Size(PanelWidth, LineHeight - 1),\r
-                BackColor = ShipLabels.ColumnColors[(i + 1) % 2],\r
-                Visible = false\r
+                new Visibility(shipListPanel, InShipStatus || InGroupConfig || InRepairList),\r
+                new Visibility(itemTreeView, InItemList),\r
+                new Visibility(fleetPanel, InFleetInfo),\r
+                new Visibility(antiAirPanel, InAntiAir),\r
+                new Visibility(airBattleResultPanel, InBattleResult),\r
+                new Visibility(battleResultPanel, InBattleResult),\r
+                new Visibility(richTextBoxMiscText, InMiscText)\r
             };\r
-            rpp.Scale(ShipLabel.ScaleFactor);\r
-            rpp.Tag = rpp.Location.Y;\r
-            var rpl = new[]\r
+            foreach (var panel in panels)\r
             {\r
-                new ShipLabel {Location = new Point(118, 2), AutoSize = true, AnchorRight = true},\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(117, 2),\r
-                    Size = new Size(23, height),\r
-                    TextAlign = ContentAlignment.MiddleRight\r
-                },\r
-                new ShipLabel {Location = new Point(141, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(186, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
-            };\r
-            _repairLabelList.Add(rpl);\r
-            _repairPanelList.Add(rpp);\r
-// ReSharper disable once CoVariantArrayConversion\r
-            rpp.Controls.AddRange(rpl);\r
-            panelShipList.Controls.Add(rpp);\r
-            foreach (var label in rpl)\r
-            {\r
-                label.Scale();\r
-                label.PresetColor =\r
-                    label.BackColor = ShipLabels.ColumnColors[(i + 1) % 2];\r
+                // SwipeScrollifyが誤作動するのでEnabledも切り替える\r
+                panel.Control.Visible = panel.Control.Enabled = panel.Visible;\r
             }\r
         }\r
 \r
-        private void CreateShipLabels(int i)\r
+        public void UpdateAirBattleResult()\r
         {\r
-            var y = 3 + LineHeight * i;\r
-            const int height = LabelHeight;\r
-            var lbp = new Panel\r
-            {\r
-                Location = new Point(0, y - 2),\r
-                Size = new Size(PanelWidth, LineHeight - 1),\r
-                BackColor = ShipLabels.ColumnColors[(i + 1) % 2],\r
-                Visible = false\r
-            };\r
-            lbp.Scale(ShipLabel.ScaleFactor);\r
-            lbp.Tag = lbp.Location.Y;\r
-            var labels = new[]\r
-            {\r
-                new ShipLabel {Location = new Point(126, 2), AutoSize = true, AnchorRight = true},\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(129, 2),\r
-                    Size = new Size(23, height),\r
-                    TextAlign = ContentAlignment.MiddleRight\r
-                },\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(155, 2),\r
-                    Size = new Size(23, height),\r
-                    TextAlign = ContentAlignment.MiddleRight\r
-                },\r
-                new ShipLabel\r
-                {\r
-                    Location = new Point(176, 2),\r
-                    Size = new Size(41, height),\r
-                    TextAlign = ContentAlignment.MiddleRight\r
-                },\r
-                new ShipLabel {Location = new Point(10, 2), AutoSize = true},\r
-                new ShipLabel {Location = new Point(1, 2), AutoSize = true}\r
-            };\r
-            _labelList.Add(labels);\r
-            _labelPanelList.Add(lbp);\r
-// ReSharper disable once CoVariantArrayConversion\r
-            lbp.Controls.AddRange(labels);\r
-            panelShipList.Controls.Add(lbp);\r
-            foreach (var label in labels)\r
-            {\r
-                label.Scale();\r
-                label.PresetColor =\r
-                    label.BackColor = ShipLabels.ColumnColors[(i + 1) % 2];\r
-            }\r
+            airBattleResultPanel.ShowResultAutomatic = (_config.Spoilers & Spoiler.AirBattleResult) != 0;\r
+            airBattleResultPanel.SetResult(_sniffer);\r
         }\r
 \r
-        private void SetShipLabels()\r
+        public void UpdateBattleResult()\r
         {\r
-            panelShipList.SuspendLayout();\r
-            for (var i = 0; i < _shipList.Length; i++)\r
-            {\r
-                if (!InShipStatus)\r
-                    _labelPanelList[i].Visible = false;\r
-                if (!InGroupConfig)\r
-                    _checkBoxPanelList[i].Visible = false;\r
-                if (!InRepairList)\r
-                    _repairPanelList[i].Visible = false;\r
-            }\r
-            for (var i = 0; i < _shipList.Length; i++)\r
-            {\r
-                if (InShipStatus)\r
-                    SetShipStatus(i);\r
-                if (InGroupConfig)\r
-                    SetGroupConfig(i);\r
-                if (InRepairList)\r
-                    SetRepairList(i);\r
-            }\r
-            for (var i = _shipList.Length; i < _labelPanelList.Count; i++)\r
-            {\r
-                _labelPanelList[i].Visible = _checkBoxPanelList[i].Visible = _repairPanelList[i].Visible = false;\r
-            }\r
-            panelShipList.ResumeLayout();\r
+            battleResultPanel.Spoilers = _config.Spoilers;\r
+            battleResultPanel.Update(_sniffer);\r
         }\r
 \r
-        private void SetShipStatus(int i)\r
+        public void UpdateCellInfo()\r
         {\r
-            var lbp = _labelPanelList[i];\r
-            if (!lbp.Visible)\r
-                lbp.Location = new Point(lbp.Left, (int)lbp.Tag + panelShipList.AutoScrollPosition.Y);\r
-            var s = _shipList[i];\r
-            var labels = _labelList[i];\r
-            if (s.Level == 1000) // 艦種の表示\r
-            {\r
-                SetShipType(i);\r
-                return;\r
-            }\r
-            labels[0].SetHp(s);\r
-            labels[1].SetCond(s);\r
-            labels[2].SetLevel(s);\r
-            labels[3].SetExpToNext(s);\r
-            labels[4].SetName(s, ShipNameWidth.ShipList);\r
-            labels[5].SetFleet(s);\r
-            lbp.Visible = true;\r
-        }\r
-\r
-        private void SetShipType(int i)\r
-        {\r
-            var lbp = _labelPanelList[i];\r
-            if (!lbp.Visible)\r
-                lbp.Location = new Point(lbp.Left, (int)lbp.Tag + panelShipList.AutoScrollPosition.Y);\r
-            var s = _shipList[i];\r
-            var labels = _labelList[i];\r
-            for (var c = 0; c < 4; c++)\r
-            {\r
-                labels[c].Text = "";\r
-                labels[c].BackColor = labels[c].PresetColor;\r
-            }\r
-            labels[4].SetName("");\r
-            labels[5].Text = s.Name;\r
-            lbp.Visible = true;\r
+            battleResultPanel.Spoilers = _config.Spoilers;\r
+            battleResultPanel.UpdateCellInfo(_sniffer.CellInfo);\r
         }\r
 \r
-        private void SetGroupConfig(int i)\r
+        private void SetHeaderSortOrder()\r
         {\r
-            var cbp = _checkBoxPanelList[i];\r
-            var s = _shipList[i];\r
-            if (s.Level == 1000)\r
-            {\r
-                SetShipType(i);\r
-                cbp.Visible = false;\r
-                return;\r
-            }\r
-            if (!cbp.Visible)\r
-                cbp.Location = new Point(cbp.Left, (int)cbp.Tag + panelShipList.AutoScrollPosition.Y);\r
-            var cfgl = _configLabelList[i];\r
-            cfgl[0].SetLevel(s);\r
-            cfgl[1].SetName(s, ShipNameWidth.GroupConfig);\r
-            cfgl[2].SetFleet(s);\r
-            var cb = _checkBoxesList[i];\r
-            for (var j = 0; j < cb.Length; j++)\r
-                cb[j].Checked = _groupSettings[j].Contains(s.Id);\r
-            cbp.Visible = true;\r
-        }\r
-\r
-        private void SetRepairList(int i)\r
-        {\r
-            var rpp = _repairPanelList[i];\r
-            var s = _shipList[i];\r
-            if (s.Level == 1000)\r
+            switch (_config.ShipList.SortOrder)\r
             {\r
-                SetShipType(i);\r
-                rpp.Visible = false;\r
-                return;\r
+                case SortOrder.None:\r
+                    labelHeaderCond.Text = "cond";\r
+                    labelHeaderExp.Text = "Exp";\r
+                    break;\r
+                case SortOrder.CondAscend:\r
+                    labelHeaderCond.Text = "cond▴";\r
+                    labelHeaderExp.Text = "Exp";\r
+                    break;\r
+                case SortOrder.CondDescend:\r
+                    labelHeaderCond.Text = "cond▾";\r
+                    labelHeaderExp.Text = "Exp";\r
+                    break;\r
+                case SortOrder.ExpToNextAscend:\r
+                    labelHeaderCond.Text = "cond";\r
+                    labelHeaderExp.Text = "Exp▴";\r
+                    break;\r
+                case SortOrder.ExpToNextDescend:\r
+                    labelHeaderCond.Text = "cond";\r
+                    labelHeaderExp.Text = "Exp▾";\r
+                    break;\r
             }\r
-            if (!rpp.Visible)\r
-                rpp.Location = new Point(rpp.Left, (int)rpp.Tag + panelShipList.AutoScrollPosition.Y);\r
-            var rpl = _repairLabelList[i];\r
-            rpl[0].SetHp(s);\r
-            rpl[1].SetLevel(s);\r
-            rpl[2].SetRepairTime(s);\r
-            rpl[3].Text = TimeSpan.FromSeconds(s.RepairSecPerHp).ToString(@"mm\:ss");\r
-            rpl[4].SetName(s, ShipNameWidth.RepairListFull);\r
-            rpl[5].SetFleet(s);\r
-            rpp.Visible = true;\r
         }\r
 \r
-        private bool InShipStatus => Array.Exists(new[] {"全", "A", "B", "C", "D"}, x => comboBoxGroup.Text == x);\r
+        private bool InShipStatus => Array.Exists(new[] {"全", "A", "B", "C", "D"}, x => comboBoxGroup.Text == x);\r
 \r
         private bool InGroupConfig => comboBoxGroup.Text == "分類";\r
 \r
@@ -449,85 +203,135 @@ namespace KancolleSniffer
 \r
         private bool InItemList => comboBoxGroup.Text == "装備";\r
 \r
-        private bool InEquip => comboBoxGroup.Text == "艦隊";\r
+        private bool InFleetInfo => comboBoxGroup.Text == "艦隊";\r
+\r
+        private bool InAntiAir => comboBoxGroup.Text == "対空";\r
+\r
+        private bool InBattleResult => comboBoxGroup.Text == "戦況";\r
 \r
         private bool InMiscText => comboBoxGroup.Text == "情報";\r
 \r
-        private void ShipListForm_Load(object sender, EventArgs e)\r
+        private void ListForm_Load(object sender, EventArgs e)\r
         {\r
-            panelShipList.Width = itemTreeView.Width = equipPanel.Width =\r
-                (int)Round(PanelWidth * ShipLabel.ScaleFactor.Width) + 3 + SystemInformation.VerticalScrollBarWidth;\r
-            Width = panelShipList.Width + 12 + (Width - ClientSize.Width);\r
+            /* DPIではなくズームしたときにパネルは大きくなるがScrollBarはそのままなので隙間ができる。\r
+               そこでScrollBarの幅に合わせて全体の横幅を設定し直す。*/\r
+            Width = Scaler.ScaleWidth(PanelWidth + 12 /* PanelとFrameの内側 */) +\r
+                    SystemInformation.VerticalScrollBarWidth + 2 /* 縁の幅 */ + Width - ClientSize.Width;\r
             MinimumSize = new Size(Width, 0);\r
             MaximumSize = new Size(Width, int.MaxValue);\r
             var config = _config.ShipList;\r
-            checkBoxShipType.Checked = config.ShipType;\r
-            ActiveControl = panelShipList;\r
-            for (var i = 0; i < GroupCount; i++)\r
-                _groupSettings[i] = i < config.ShipGroup.Count\r
-                    ? new HashSet<int>(config.ShipGroup[i])\r
-                    : new HashSet<int>();\r
-            comboBoxGroup.SelectedIndex = 0;\r
+            if (config.ShowHpInPercent)\r
+            {\r
+                shipListPanel.ToggleHpPercent();\r
+                battleResultPanel.ToggleHpPercent();\r
+            }\r
+            LoadShipGroupFromConfig();\r
+            comboBoxGroup.SelectedItem = config.Mode ?? "全艦";\r
+            SetCheckBoxSTypeSate();\r
             if (config.Location.X == int.MinValue)\r
                 return;\r
             var bounds = new Rectangle(config.Location, config.Size);\r
-            if (MainForm.IsVisibleOnAnyScreen(bounds))\r
+            if (MainForm.IsTitleBarOnAnyScreen(bounds.Location))\r
                 Location = bounds.Location;\r
             Height = bounds.Height;\r
         }\r
 \r
-        private void ShipListForm_FormClosing(object sender, FormClosingEventArgs e)\r
+        private void LoadShipGroupFromConfig()\r
+        {\r
+            var group = _config.ShipList.ShipGroup;\r
+            for (var i = 0; i < GroupConfigLabels.GroupCount; i++)\r
+                shipListPanel.GroupSettings[i] = i < group.Count ? new HashSet<int>(group[i]) : new HashSet<int>();\r
+        }\r
+\r
+        private void SetCheckBoxSTypeSate()\r
+        {\r
+            for (var type = 0; type < _shipTypeCheckBoxes.Length; type++)\r
+                _shipTypeCheckBoxes[type].Checked = ((int)_config.ShipList.ShipCategories & (1 << type)) != 0;\r
+            checkBoxSTypeAll.Checked = _config.ShipList.ShipCategories == ShipCategory.All;\r
+            checkBoxSTypeDetails.Checked = _config.ShipList.ShipType;\r
+        }\r
+\r
+        private void ListForm_FormClosing(object sender, FormClosingEventArgs e)\r
         {\r
             e.Cancel = true;\r
-            if (!Visible)\r
+            if (!Visible) // 非表示のときは保存すべき情報がないのでスキップする\r
                 return;\r
             var config = _config.ShipList;\r
-            var all = _sniffer.ShipList.Select(s => s.Id).ToArray();\r
-            config.ShipGroup.Clear();\r
-            for (var i = 0; i < GroupCount; i++)\r
-            {\r
-                if (all.Length > 0)\r
-                    _groupSettings[i].IntersectWith(all);\r
-                config.ShipGroup.Add(_groupSettings[i].ToList());\r
-            }\r
+            StoreShipGroupToConfig();\r
             var bounds = WindowState == FormWindowState.Normal ? Bounds : RestoreBounds;\r
             config.Location = bounds.Location;\r
             config.Size = bounds.Size;\r
+            config.Mode = (string)comboBoxGroup.SelectedItem;\r
             Hide();\r
         }\r
 \r
-        public void ShowShip(int id)\r
+        public void ChangeWindowState(FormWindowState newState)\r
         {\r
-            if (InShipStatus)\r
+            if (!Visible)\r
+                return;\r
+            if (newState == FormWindowState.Minimized)\r
             {\r
-                var i = Array.FindIndex(_shipList, s => s.Id == id);\r
-                if (i == -1)\r
-                    return;\r
-                var y = (int)Round(ShipLabel.ScaleFactor.Height * LineHeight * i);\r
-                panelShipList.AutoScrollPosition = new Point(0, y);\r
+                if (WindowState == FormWindowState.Normal)\r
+                    WindowState = FormWindowState.Minimized;\r
+                if (_config.HideOnMinimized)\r
+                    ShowInTaskbar = false;\r
             }\r
-            else if (InEquip)\r
+            else\r
             {\r
-                equipPanel.ShowShip(id);\r
+                if (WindowState == FormWindowState.Minimized)\r
+                {\r
+                    Application.DoEvents();\r
+                    if (_config.HideOnMinimized)\r
+                        ShowInTaskbar = true;\r
+                    WindowState = FormWindowState.Normal;\r
+                }\r
             }\r
         }\r
 \r
-        private void checkBoxShipType_CheckedChanged(object sender, EventArgs e)\r
+        private void ListForm_Activated(object sender, EventArgs e)\r
         {\r
-            _config.ShipList.ShipType = checkBoxShipType.Checked;\r
-            UpdateList();\r
-            SetActiveControl();\r
+            if (_suppressActivate.Check())\r
+                return;\r
+            if (WindowState == FormWindowState.Minimized)\r
+                return;\r
+            RaiseBothWindows();\r
         }\r
 \r
-        private void checkboxGroup_CheckedChanged(object sender, EventArgs e)\r
+        private void RaiseBothWindows()\r
         {\r
-            var cb = (CheckBox)sender;\r
-            var group = (int)cb.Tag % 10;\r
-            var idx = (int)cb.Tag / 10;\r
-            if (cb.Checked)\r
-                _groupSettings[group].Add(_shipList[idx].Id);\r
-            else\r
-                _groupSettings[group].Remove(_shipList[idx].Id);\r
+            _main.Owner = null;\r
+            Owner = _main;\r
+            BringToFront();\r
+            Owner = null;\r
+        }\r
+\r
+        private void StoreShipGroupToConfig()\r
+        {\r
+            var all = _sniffer.ShipList.Select(s => s.Id).ToArray();\r
+            var group = _config.ShipList.ShipGroup;\r
+            group.Clear();\r
+            for (var i = 0; i < GroupConfigLabels.GroupCount; i++)\r
+            {\r
+                if (all.Length > 0)\r
+                    shipListPanel.GroupSettings[i].IntersectWith(all);\r
+                group.Add(shipListPanel.GroupSettings[i].ToList());\r
+            }\r
+        }\r
+\r
+        public void ShowShip(int id)\r
+        {\r
+            if (InShipStatus)\r
+            {\r
+                shipListPanel.ShowShip(id);\r
+            }\r
+            else if (InFleetInfo)\r
+            {\r
+                fleetPanel.ShowShip(id);\r
+            }\r
+            else if (InAntiAir)\r
+            {\r
+                antiAirPanel.ShowShip(id);\r
+            }\r
         }\r
 \r
         private void comboBoxGroup_DropDownClosed(object sender, EventArgs e)\r
@@ -540,11 +344,13 @@ namespace KancolleSniffer
             UpdateList();\r
             SetActiveControl();\r
             copyToolStripMenuItem.Enabled = InShipStatus | InItemList;\r
+            if (!(InShipStatus || InGroupConfig || InRepairList))\r
+                SetPanelSTypeState(false);\r
         }\r
 \r
-        private void ShipListForm_KeyPress(object sender, KeyPressEventArgs e)\r
+        private void ListForm_KeyPress(object sender, KeyPressEventArgs e)\r
         {\r
-            var g = Array.FindIndex(new[] {'Z', 'A', 'B', 'C', 'D', 'G', 'R', 'W', 'X', 'I'},\r
+            var g = Array.FindIndex(new[] {'Z', 'A', 'B', 'C', 'D', 'G', 'R', 'W', 'X', 'Y', 'S', 'I'},\r
                 x => x == char.ToUpper(e.KeyChar));\r
             if (g == -1)\r
                 return;\r
@@ -556,11 +362,21 @@ namespace KancolleSniffer
         private void SetActiveControl()\r
         {\r
             if (InItemList)\r
+            {\r
                 ActiveControl = itemTreeView;\r
-            else if (InEquip)\r
-                ActiveControl = equipPanel;\r
+            }\r
+            else if (InFleetInfo)\r
+            {\r
+                ActiveControl = fleetPanel;\r
+            }\r
+            else if (InAntiAir)\r
+            {\r
+                ActiveControl = antiAirPanel;\r
+            }\r
             else\r
-                ActiveControl = panelShipList;\r
+            {\r
+                ActiveControl = shipListPanel;\r
+            }\r
         }\r
 \r
         private void copyToolStripMenuItem_Click(object sender, EventArgs e)\r
@@ -580,24 +396,107 @@ namespace KancolleSniffer
 \r
         private void labelHeaderCond_Click(object sender, EventArgs e)\r
         {\r
-            _config.ShipList.SortOrder = _config.ShipList.SortOrder == SortOrder.Cond ? SortOrder.None : SortOrder.Cond;\r
+            var sl = _config.ShipList;\r
+            switch (sl.SortOrder)\r
+            {\r
+                case SortOrder.CondAscend:\r
+                    sl.SortOrder = SortOrder.CondDescend;\r
+                    break;\r
+                case SortOrder.CondDescend:\r
+                    sl.SortOrder = SortOrder.None;\r
+                    break;\r
+                default:\r
+                    sl.SortOrder = SortOrder.CondAscend;\r
+                    break;\r
+            }\r
             UpdateList();\r
         }\r
 \r
         private void labelHeaderExp_Click(object sender, EventArgs e)\r
         {\r
-            _config.ShipList.SortOrder = _config.ShipList.SortOrder == SortOrder.ExpToNext ? SortOrder.None : SortOrder.ExpToNext;\r
+            var sl = _config.ShipList;\r
+            switch (sl.SortOrder)\r
+            {\r
+                case SortOrder.ExpToNextAscend:\r
+                    sl.SortOrder = SortOrder.ExpToNextDescend;\r
+                    break;\r
+                case SortOrder.ExpToNextDescend:\r
+                    sl.SortOrder = SortOrder.None;\r
+                    break;\r
+                default:\r
+                    sl.SortOrder = SortOrder.ExpToNextAscend;\r
+                    break;\r
+            }\r
             UpdateList();\r
         }\r
 \r
         private void csvToolStripMenuItem_Click(object sender, EventArgs e)\r
         {\r
-            Clipboard.SetText(TextGenerator.GenerateShipList(FilterByGroup(_sniffer.ShipList)));\r
+            Clipboard.SetText(TextGenerator.GenerateShipList(shipListPanel.CurrentShipList));\r
         }\r
 \r
+        // ReSharper disable IdentifierTypo\r
         private void kantaiSarashiToolStripMenuItem_Click(object sender, EventArgs e)\r
         {\r
-            Clipboard.SetText(TextGenerator.GenerateKantaiSarashiData(FilterByGroup(_sniffer.ShipList)));\r
+            Clipboard.SetText(TextGenerator.GenerateKantaiSarashiData(shipListPanel.CurrentShipList));\r
+        }\r
+        // ReSharper enable IdentifierTypo\r
+\r
+        private void labelFleet_Click(object sender, EventArgs e)\r
+        {\r
+            fleetPanel.ShowFleet(((Label)sender).Text);\r
+        }\r
+\r
+        private void labelHeaderHp_Click(object sender, EventArgs e)\r
+        {\r
+            ToggleHpPercent();\r
+        }\r
+\r
+        private void ToggleHpPercent()\r
+        {\r
+            _config.ShipList.ShowHpInPercent = !_config.ShipList.ShowHpInPercent;\r
+            shipListPanel.ToggleHpPercent();\r
+            battleResultPanel.ToggleHpPercent();\r
+        }\r
+\r
+        private void labelSTypeButton_Click(object sender, EventArgs e)\r
+        {\r
+            SetPanelSTypeState(!panelSType.Visible);\r
+        }\r
+\r
+        private void checkBoxSType_Click(object sender, EventArgs e)\r
+        {\r
+            _config.ShipList.ShipCategories = SelectedShipTypes;\r
+            UpdateList();\r
+            SetActiveControl();\r
+        }\r
+\r
+        private ShipCategory SelectedShipTypes =>\r
+            (ShipCategory)_shipTypeCheckBoxes.Select((cb, type) => cb.Checked ? 1 << type : 0).Sum();\r
+\r
+        private void checkBoxSTypeAll_Click(object sender, EventArgs e)\r
+        {\r
+            foreach (var checkBox in _shipTypeCheckBoxes)\r
+                checkBox.Checked = checkBoxSTypeAll.Checked;\r
+            checkBoxSType_Click(sender, e);\r
+        }\r
+\r
+        private void panelSType_Click(object sender, EventArgs e)\r
+        {\r
+            SetPanelSTypeState(false);\r
+        }\r
+\r
+        private void SetPanelSTypeState(bool visible)\r
+        {\r
+            panelSType.Visible = visible;\r
+            labelSTypeButton.BackColor = visible ? CustomColors.ActiveButtonColor : DefaultBackColor;\r
+        }\r
+\r
+        private void checkBoxSTypeDetails_Click(object sender, EventArgs e)\r
+        {\r
+            _config.ShipList.ShipType = checkBoxSTypeDetails.Checked;\r
+            UpdateList();\r
+            SetActiveControl();\r
         }\r
     }\r
 }
\ No newline at end of file