1 // Copyright (C) 2013, 2014, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>
\r
3 // Licensed under the Apache License, Version 2.0 (the "License");
\r
4 // you may not use this file except in compliance with the License.
\r
5 // You may obtain a copy of the License at
\r
7 // http://www.apache.org/licenses/LICENSE-2.0
\r
9 // Unless required by applicable law or agreed to in writing, software
\r
10 // distributed under the License is distributed on an "AS IS" BASIS,
\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 // See the License for the specific language governing permissions and
\r
13 // limitations under the License.
\r
16 using System.Collections.Generic;
\r
17 using System.ComponentModel;
\r
18 using System.Diagnostics;
\r
19 using System.Drawing;
\r
20 using System.Globalization;
\r
24 using System.Runtime.InteropServices;
\r
26 using System.Text.RegularExpressions;
\r
27 using System.Threading;
\r
28 using System.Threading.Tasks;
\r
29 using System.Windows.Forms;
\r
31 using KancolleSniffer.Log;
\r
32 using KancolleSniffer.Model;
\r
33 using KancolleSniffer.Net;
\r
34 using KancolleSniffer.Notification;
\r
35 using KancolleSniffer.Util;
\r
36 using KancolleSniffer.View;
\r
37 using Microsoft.CSharp.RuntimeBinder;
\r
38 using Clipboard = KancolleSniffer.Util.Clipboard;
\r
39 using Timer = System.Windows.Forms.Timer;
\r
41 namespace KancolleSniffer
\r
43 public partial class MainForm : Form
\r
45 private readonly ConfigDialog _configDialog;
\r
46 private readonly ProxyManager _proxyManager;
\r
47 private readonly ResizableToolTip _toolTip = new ResizableToolTip();
\r
48 private readonly ResizableToolTip _tooltipCopy = new ResizableToolTip {ShowAlways = false, AutomaticDelay = 0};
\r
49 private readonly ListFormGroup _listFormGroup;
\r
51 private readonly Notifier _notifier;
\r
52 private bool _started;
\r
53 private bool _timerEnabled;
\r
54 private string _debugLogFile;
\r
55 private IEnumerator<string> _playLog;
\r
56 private readonly TimeStep _step = new TimeStep();
\r
57 private IEnumerable<IUpdateContext> _updateable;
\r
58 private IEnumerable<IUpdateTimers> _timers;
\r
60 private readonly ErrorDialog _errorDialog = new ErrorDialog();
\r
61 private readonly ErrorLog _errorLog;
\r
63 public Sniffer Sniffer { get; } = new Sniffer();
\r
64 public Config Config { get; } = new Config();
\r
68 InitializeComponent();
\r
69 HttpProxy.AfterSessionComplete += HttpProxy_AfterSessionComplete;
\r
71 _configDialog = new ConfigDialog(this);
\r
72 _listFormGroup = new ListFormGroup(this);
\r
73 _notifier = new Notifier(FlashWindow, ShowTaster, PlaySound);
\r
75 _proxyManager = new ProxyManager(this);
\r
76 _proxyManager.UpdatePacFile();
\r
77 _errorLog = new ErrorLog(Sniffer);
\r
79 Sniffer.RepeatingTimerController = _notifier;
\r
82 private void SetupView()
\r
84 SetScaleFactorOfDpiScaling();
\r
87 shipInfoPanel.AkashiRepairTimer = labelAkashiRepairTimer;
\r
88 shipInfoPanel.ShowShipOnList = ShowShipOnShipList;
\r
89 panelRepairList.CreateLabels(panelRepairList_Click);
\r
90 ndockPanel.SetClickHandler(labelNDockCaption);
\r
91 missionPanel.SetClickHandler(labelMissionCaption);
\r
92 materialHistoryPanel.SetClickHandler(labelMaterialCaption, dropDownButtonMaterialHistory);
\r
97 private void SetupUpdateable()
\r
99 _updateable = new IUpdateContext[]
\r
101 hqPanel, missionPanel, kdockPanel, ndockPanel, materialHistoryPanel, shipInfoPanel, chargeStatus1,
\r
102 chargeStatus2, chargeStatus3, chargeStatus4, _notifier
\r
104 var context = new UpdateContext(Sniffer, Config, () => _step);
\r
105 foreach (var updateable in _updateable)
\r
106 updateable.Context = context;
\r
107 _timers = new IUpdateTimers[] {missionPanel, kdockPanel, ndockPanel, shipInfoPanel};
\r
110 private void SetScaleFactorOfDpiScaling()
\r
112 var autoScaleDimensions = new SizeF(6f, 12f); // AutoScaleDimensionの初期値
\r
113 Scaler.Factor = new SizeF(CurrentAutoScaleDimensions.Width / autoScaleDimensions.Width,
\r
114 CurrentAutoScaleDimensions.Height / autoScaleDimensions.Height);
\r
117 private void SetupQuestPanel()
\r
119 int prevHeight = questPanel.Height;
\r
120 questPanel.CreateLabels(Config.QuestLines, labelQuest_DoubleClick);
\r
121 Height += questPanel.Height - prevHeight;
\r
124 private readonly FileSystemWatcher _watcher = new FileSystemWatcher
\r
126 Path = AppDomain.CurrentDomain.BaseDirectory,
\r
127 NotifyFilter = NotifyFilters.LastWrite
\r
130 private readonly Timer _watcherTimer = new Timer {Interval = 1000};
\r
132 private void LoadData()
\r
135 Sniffer.LoadState();
\r
136 _watcher.SynchronizingObject = this;
\r
137 _watcherTimer.Tick += (sender, ev) =>
\r
139 _watcherTimer.Stop();
\r
143 Sniffer.LoadState();
\r
146 Sniffer.AdditionalData.LoadTpSpec();
\r
150 _watcher.Changed += (sender, ev) =>
\r
153 _watcherTimer.Stop();
\r
154 _watcherTimer.Start();
\r
156 _watcher.EnableRaisingEvents = true;
\r
159 private void HttpProxy_AfterSessionComplete(HttpProxy.Session session)
\r
161 BeginInvoke(new Action<HttpProxy.Session>(ProcessRequest), session);
\r
164 private void ProcessRequest(HttpProxy.Session session)
\r
166 var url = session.Request.PathAndQuery;
\r
167 if (!url.Contains("kcsapi/"))
\r
169 var request = session.Request.BodyAsString;
\r
170 var response = session.Response.BodyAsString;
\r
171 Privacy.Remove(ref url, ref request, ref response);
\r
172 if (response == null || !response.StartsWith("svdata="))
\r
174 WriteDebugLog(url, request, response);
\r
177 response = UnEscapeString(response.Remove(0, "svdata=".Length));
\r
178 WriteDebugLog(url, request, response);
\r
179 ProcessRequestMain(url, request, response);
\r
182 private void ProcessRequestMain(string url, string request, string response)
\r
186 UpdateInfo(Sniffer.Sniff(url, request, JsonObject.Parse(response)));
\r
187 _errorLog.CheckBattleApi(url, request, response);
\r
190 catch (RuntimeBinderException e)
\r
192 if (_errorDialog.ShowDialog(this,
\r
193 "艦これに仕様変更があったか、受信内容が壊れています。",
\r
194 _errorLog.GenerateErrorLog(url, request, response, e.ToString())) == DialogResult.Abort)
\r
197 catch (LogIOException e)
\r
199 // ReSharper disable once PossibleNullReferenceException
\r
200 if (_errorDialog.ShowDialog(this, e.Message, e.InnerException.ToString()) == DialogResult.Abort)
\r
203 catch (BattleResultError)
\r
205 if (_errorDialog.ShowDialog(this, "戦闘結果の計算に誤りがあります。",
\r
206 _errorLog.GenerateBattleErrorLog()) == DialogResult.Abort)
\r
209 catch (Exception e)
\r
211 if (_errorDialog.ShowDialog(this, "エラーが発生しました。",
\r
212 _errorLog.GenerateErrorLog(url, request, response, e.ToString())) == DialogResult.Abort)
\r
217 private void Exit()
\r
219 _proxyManager.Shutdown();
\r
220 Environment.Exit(1);
\r
223 private void WriteDebugLog(string url, string request, string response)
\r
225 if (_debugLogFile != null)
\r
227 File.AppendAllText(_debugLogFile,
\r
228 $"date: {DateTime.Now:g}\nurl: {url}\nrequest: {request}\nresponse: {response ?? "(null)"}\n");
\r
232 private string UnEscapeString(string s)
\r
236 var rx = new Regex(@"\\[uU]([0-9A-Fa-f]{4})");
\r
237 return rx.Replace(s,
\r
238 match => ((char)int.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString());
\r
240 catch (ArgumentException)
\r
246 private void UpdateInfo(Sniffer.Update update)
\r
248 if (update == Sniffer.Update.Start)
\r
250 hqPanel.Login.Visible = false;
\r
251 shipInfoPanel.Guide.Visible = false;
\r
253 _notifier.StopAllRepeat();
\r
258 if (_step.Now == DateTime.MinValue)
\r
260 if ((update & Sniffer.Update.Item) != 0)
\r
262 if ((update & Sniffer.Update.Timer) != 0)
\r
264 if ((update & Sniffer.Update.NDock) != 0)
\r
265 UpdateNDocLabels();
\r
266 if ((update & Sniffer.Update.Mission) != 0)
\r
267 UpdateMissionLabels();
\r
268 if ((update & Sniffer.Update.QuestList) != 0)
\r
270 if ((update & Sniffer.Update.Ship) != 0)
\r
272 if ((update & Sniffer.Update.Battle) != 0)
\r
273 UpdateBattleInfo();
\r
274 if ((update & Sniffer.Update.Cell) != 0)
\r
278 private void MainForm_Load(object sender, EventArgs e)
\r
280 SuppressActivate.Start();
\r
282 if (Config.HideOnMinimized && WindowState == FormWindowState.Minimized)
\r
283 ShowInTaskbar = false;
\r
284 if (Config.ShowHpInPercent)
\r
285 shipInfoPanel.ToggleHpPercent();
\r
286 if (Config.ShipList.Visible)
\r
287 _listFormGroup.Show();
\r
289 ApplyDebugLogSetting();
\r
291 ApplyProxySetting();
\r
292 CheckVersionUp((current, latest) =>
\r
294 if (latest == current)
\r
296 var guide = shipInfoPanel.Guide;
\r
297 guide.Text = $"バージョン{latest}があります。";
\r
298 guide.LinkArea = new LinkArea(0, guide.Text.Length);
\r
299 guide.Click += (obj, ev) =>
\r
301 Process.Start("https://ja.osdn.net/rel/kancollesniffer/" + latest);
\r
306 public async void CheckVersionUp(Action<string, string> action)
\r
308 var current = string.Join(".", Application.ProductVersion.Split('.').Take(2));
\r
311 var latest = (await new WebClient().DownloadStringTaskAsync("http://kancollesniffer.osdn.jp/version"))
\r
315 action(current, latest);
\r
317 catch (InvalidOperationException)
\r
321 catch (WebException)
\r
326 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
\r
328 if (!Config.ExitSilently)
\r
330 using var dialog = new ConfirmDialog();
\r
331 if (dialog.ShowDialog(this) != DialogResult.Yes)
\r
337 _listFormGroup.Close();
\r
338 Sniffer.FlashLog();
\r
339 Config.Location = (WindowState == FormWindowState.Normal ? Bounds : RestoreBounds).Location;
\r
340 Config.ShowHpInPercent = shipInfoPanel.ShowHpInPercent;
\r
342 Sniffer.SaveState();
\r
343 _proxyManager.Shutdown();
\r
346 private void MainForm_Resize(object sender, EventArgs e)
\r
348 if (_listFormGroup == null) // DPIが100%でないときにInitializeComponentから呼ばれるので
\r
350 SuppressActivate.Start();
\r
351 if (WindowState == FormWindowState.Minimized)
\r
353 if (Config.HideOnMinimized)
\r
354 ShowInTaskbar = false;
\r
356 _listFormGroup.Main.ChangeWindowState(WindowState);
\r
359 public readonly TimeOutChecker SuppressActivate = new TimeOutChecker();
\r
361 private void MainForm_Activated(object sender, EventArgs e)
\r
363 if (SuppressActivate.Check())
\r
366 RaiseBothWindows();
\r
369 private bool NeedRaise => _listFormGroup.Visible && WindowState != FormWindowState.Minimized;
\r
371 private void RaiseBothWindows()
\r
373 _listFormGroup.Main.Owner = null;
\r
374 Owner = _listFormGroup.Main;
\r
379 public class TimeOutChecker
\r
381 private DateTime _lastCheck;
\r
382 private readonly TimeSpan _timeout = TimeSpan.FromMilliseconds(500);
\r
384 public void Start()
\r
386 _lastCheck = DateTime.Now;
\r
389 public bool Check()
\r
391 var now = DateTime.Now;
\r
392 var last = _lastCheck;
\r
394 return now - last < _timeout;
\r
398 private void notifyIconMain_MouseDoubleClick(object sender, MouseEventArgs e)
\r
400 NotifyIconOpenToolStripMenuItem_Click(sender, e);
\r
403 private void NotifyIconOpenToolStripMenuItem_Click(object sender, EventArgs e)
\r
405 ShowInTaskbar = true;
\r
406 WindowState = FormWindowState.Normal;
\r
407 TopMost = _listFormGroup.TopMost = Config.TopMost; // 最前面に表示されなくなることがあるのを回避する
\r
410 private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
\r
415 private void ConfigToolStripMenuItem_Click(object sender, EventArgs e)
\r
417 if (_configDialog.ShowDialog(this) == DialogResult.OK)
\r
421 _notifier.StopRepeatingTimer(_configDialog.RepeatSettingsChanged);
\r
425 private void PerformZoom()
\r
427 if (Config.Zoom == 100)
\r
429 ShipLabel.Name.BaseFont = Font;
\r
430 ShipLabel.Name.LatinFont = LatinFont();
\r
433 var prev = CurrentAutoScaleDimensions;
\r
434 foreach (var control in new Control[]
\r
436 this, shipInfoPanel.Guide, hqPanel.Login,
\r
437 _configDialog, _configDialog.NotificationConfigDialog,
\r
438 contextMenuStripMain, _errorDialog
\r
441 control.Font = ZoomFont(control.Font);
\r
443 _listFormGroup.Font = ZoomFont(_listFormGroup.Font);
\r
444 foreach (var toolTip in new[] {_toolTip, _tooltipCopy})
\r
446 toolTip.Font = ZoomFont(toolTip.Font);
\r
448 ShipLabel.Name.BaseFont = Font;
\r
449 ShipLabel.Name.LatinFont = LatinFont();
\r
450 var cur = CurrentAutoScaleDimensions;
\r
451 Scaler.Factor = Scaler.Scale(cur.Width / prev.Width, cur.Height / prev.Height);
\r
454 private Font ZoomFont(Font font)
\r
456 return new Font(font.FontFamily, font.Size * Config.Zoom / 100);
\r
459 private Font LatinFont()
\r
461 return new Font("Tahoma", 8f * Config.Zoom / 100);
\r
464 private void RestoreLocation()
\r
466 if (Config.Location.X == int.MinValue)
\r
468 if (IsTitleBarOnAnyScreen(Config.Location))
\r
469 Location = Config.Location;
\r
472 private void ApplyConfig()
\r
474 if (TopMost != Config.TopMost)
\r
475 TopMost = _listFormGroup.TopMost = Config.TopMost;
\r
476 Sniffer.ShipCounter.Margin = Config.MarginShips;
\r
477 Sniffer.ItemCounter.Margin = Config.MarginEquips;
\r
479 _notifier.NotifyShipItemCount();
\r
480 Sniffer.Achievement.ResetHours = Config.ResetHours;
\r
481 labelAkashiRepair.Visible = labelAkashiRepairTimer.Visible = Config.UsePresetAkashi;
\r
482 Sniffer.WarnBadDamageWithDameCon = Config.WarnBadDamageWithDameCon;
\r
485 public void ApplyDebugLogSetting()
\r
487 _debugLogFile = Config.DebugLogging ? Config.DebugLogFile : null;
\r
490 public bool ApplyProxySetting()
\r
492 return _proxyManager.ApplyConfig();
\r
495 public void ApplyLogSetting()
\r
497 LogServer.OutputDir = Config.Log.OutputDir;
\r
498 LogServer.LogProcessor = new LogProcessor(Sniffer.Material.MaterialHistory, Sniffer.MapDictionary);
\r
499 Sniffer.EnableLog(Config.Log.On ? LogType.All : LogType.None);
\r
500 Sniffer.MaterialLogInterval = Config.Log.MaterialLogInterval;
\r
501 Sniffer.LogOutputDir = Config.Log.OutputDir;
\r
504 public static bool IsTitleBarOnAnyScreen(Point location)
\r
506 var rect = new Rectangle(
\r
507 new Point(location.X + SystemInformation.IconSize.Width + SystemInformation.HorizontalFocusThickness,
\r
508 location.Y + SystemInformation.CaptionHeight), new Size(60, 1));
\r
509 return Screen.AllScreens.Any(screen => screen.WorkingArea.Contains(rect));
\r
512 private void timerMain_Tick(object sender, EventArgs e)
\r
520 _notifier.NotifyTimers();
\r
523 catch (Exception ex)
\r
525 if (_errorDialog.ShowDialog(this, "エラーが発生しました。", ex.ToString()) == DialogResult.Abort)
\r
529 if (_playLog == null || _configDialog.Visible)
\r
531 hqPanel.PlayLog.Visible = false;
\r
537 public void SetPlayLog(string file)
\r
539 _playLog = File.ReadLines(file).GetEnumerator();
\r
542 private void PlayLog()
\r
544 var lines = new List<string>();
\r
545 foreach (var s in new[] {"url: ", "request: ", "response: "})
\r
549 if (!_playLog.MoveNext() || _playLog.Current == null)
\r
551 hqPanel.PlayLog.Visible = false;
\r
554 } while (!_playLog.Current.StartsWith(s));
\r
555 lines.Add(_playLog.Current.Substring(s.Length));
\r
557 hqPanel.PlayLog.Visible = !hqPanel.PlayLog.Visible;
\r
558 ProcessRequestMain(lines[0], lines[1], lines[2]);
\r
561 private void ShowShipOnShipList(int id)
\r
563 if (!_listFormGroup.Visible)
\r
565 _listFormGroup.ShowShip(id);
\r
568 private void UpdateItemInfo()
\r
571 _notifier.NotifyShipItemCount();
\r
572 materialHistoryPanel.Update();
\r
573 if (_listFormGroup.Visible)
\r
574 _listFormGroup.UpdateList();
\r
577 private void UpdateShipInfo()
\r
579 shipInfoPanel.SetCurrentFleet();
\r
580 shipInfoPanel.Update();
\r
581 _notifier.NotifyDamagedShip();
\r
582 UpdateChargeInfo();
\r
583 UpdateRepairList();
\r
584 UpdateMissionLabels();
\r
585 if (_listFormGroup.Visible)
\r
586 _listFormGroup.UpdateList();
\r
589 private void UpdatePanelShipInfo()
\r
591 shipInfoPanel.Update();
\r
592 ShowCurrentFleetNumber();
\r
593 labelFleet1.Text = shipInfoPanel.CombinedFleet ? CombinedName : "第一";
\r
596 private void ShowCurrentFleetNumber()
\r
598 var labels = new[] {triangleMark1, triangleMark2, triangleMark3, triangleMark4};
\r
599 for (var i = 0; i < labels.Length; i++)
\r
600 labels[i].Visible = shipInfoPanel.CurrentFleet == i;
\r
603 private string CombinedName
\r
607 switch (Sniffer.Fleets[0].CombinedType)
\r
609 case CombinedType.Carrier:
\r
611 case CombinedType.Surface:
\r
613 case CombinedType.Transport:
\r
621 private void UpdateBattleInfo()
\r
623 _listFormGroup.UpdateBattleResult();
\r
624 _listFormGroup.UpdateAirBattleResult();
\r
625 shipInfoPanel.UpdateBattleInfo();
\r
628 private void UpdateCellInfo()
\r
630 _listFormGroup.UpdateCellInfo();
\r
633 private void UpdateChargeInfo()
\r
635 foreach (var status in new[] {chargeStatus1, chargeStatus2, chargeStatus3, chargeStatus4})
\r
638 _toolTip.SetToolTip(status, status.Text);
\r
642 private void UpdateNDocLabels()
\r
644 ndockPanel.Update();
\r
647 private void UpdateMissionLabels()
\r
649 missionPanel.Update();
\r
652 private void UpdateTimers()
\r
654 foreach (var timer in _timers)
\r
655 timer.UpdateTimers();
\r
656 _timerEnabled = true;
\r
659 private void UpdateRepairList()
\r
661 panelRepairList.SetRepairList(Sniffer.RepairList);
\r
662 _toolTip.SetToolTip(label31, new RepairShipCount(Sniffer.RepairList).ToString());
\r
665 private void UpdateQuestList()
\r
667 questPanel.Update(Sniffer.Quests);
\r
668 labelQuestCount.Text = Sniffer.Quests.Length.ToString();
\r
669 _notifier.NotifyQuestComplete();
\r
672 private void FlashWindow()
\r
674 Win32API.FlashWindow(Handle);
\r
677 private void ShowTaster(string title, string message)
\r
679 notifyIconMain.ShowBalloonTip(20000, title, message, ToolTipIcon.Info);
\r
682 [DllImport("winmm.dll")]
\r
683 private static extern int mciSendString(String command,
\r
684 StringBuilder buffer, int bufferSize, IntPtr hWndCallback);
\r
686 // ReSharper disable InconsistentNaming
\r
687 // ReSharper disable once IdentifierTypo
\r
688 private const int MM_MCINOTIFY = 0x3B9;
\r
690 private const int MCI_NOTIFY_SUCCESSFUL = 1;
\r
691 // ReSharper restore InconsistentNaming
\r
693 public void PlaySound(string file, int volume)
\r
695 if (!File.Exists(file))
\r
697 mciSendString("close sound", null, 0, IntPtr.Zero);
\r
698 if (mciSendString("open \"" + file + "\" type mpegvideo alias sound", null, 0, IntPtr.Zero) != 0)
\r
700 mciSendString("setaudio sound volume to " + volume * 10, null, 0, IntPtr.Zero);
\r
701 mciSendString("play sound notify", null, 0, Handle);
\r
704 protected override void WndProc(ref Message m)
\r
706 if (m.Msg == MM_MCINOTIFY && (int)m.WParam == MCI_NOTIFY_SUCCESSFUL)
\r
707 mciSendString("close sound", null, 0, IntPtr.Zero);
\r
708 base.WndProc(ref m);
\r
711 private void SetupFleetClick()
\r
715 new Control[] {labelFleet1, labelFleet2, labelFleet3, labelFleet4},
\r
716 new Control[] {chargeStatus1, chargeStatus2, chargeStatus3, chargeStatus4}
\r
718 foreach (var a in labels)
\r
721 a[0].Click += labelFleet1_Click;
\r
722 a[0].DoubleClick += labelFleet1_DoubleClick;
\r
723 for (var fleet = 1; fleet < labels[0].Length; fleet++)
\r
725 a[fleet].Tag = fleet;
\r
726 a[fleet].Click += labelFleet_Click;
\r
727 a[fleet].DoubleClick += labelFleet_DoubleClick;
\r
732 private void labelFleet_Click(object sender, EventArgs e)
\r
736 var fleet = (int)((Control)sender).Tag;
\r
737 if (shipInfoPanel.CurrentFleet == fleet)
\r
739 shipInfoPanel.CombinedFleet = false;
\r
740 shipInfoPanel.CurrentFleet = fleet;
\r
741 UpdatePanelShipInfo();
\r
744 private readonly SemaphoreSlim _clickSemaphore = new SemaphoreSlim(1);
\r
745 private readonly SemaphoreSlim _doubleClickSemaphore = new SemaphoreSlim(0);
\r
747 private async void labelFleet1_Click(object sender, EventArgs e)
\r
751 if (shipInfoPanel.CurrentFleet != 0)
\r
753 labelFleet_Click(sender, e);
\r
756 if (!_clickSemaphore.Wait(0))
\r
760 if (await _doubleClickSemaphore.WaitAsync(SystemInformation.DoubleClickTime))
\r
765 _clickSemaphore.Release();
\r
767 shipInfoPanel.CombinedFleet = Sniffer.IsCombinedFleet && !shipInfoPanel.CombinedFleet;
\r
768 UpdatePanelShipInfo();
\r
771 private void labelFleet1_MouseHover(object sender, EventArgs e)
\r
773 labelFleet1.Text = shipInfoPanel.CurrentFleet == 0 && Sniffer.IsCombinedFleet && !shipInfoPanel.CombinedFleet ? "連合" : "第一";
\r
776 private void labelFleet1_MouseLeave(object sender, EventArgs e)
\r
778 labelFleet1.Text = shipInfoPanel.CombinedFleet ? CombinedName : "第一";
\r
781 private void labelFleet_DoubleClick(object sender, EventArgs e)
\r
785 var fleet = (int)((Control)sender).Tag;
\r
786 var text = TextGenerator.GenerateFleetData(Sniffer, fleet);
\r
787 CopyFleetText(text, (Control)sender);
\r
790 private void labelFleet1_DoubleClick(object sender, EventArgs e)
\r
794 _doubleClickSemaphore.Release();
\r
795 var text = TextGenerator.GenerateFleetData(Sniffer, 0);
\r
796 if (shipInfoPanel.CombinedFleet)
\r
797 text += TextGenerator.GenerateFleetData(Sniffer, 1);
\r
798 CopyFleetText(text, (Control)sender);
\r
801 private void CopyFleetText(string text, Control fleetButton)
\r
803 if (string.IsNullOrEmpty(text))
\r
805 Clipboard.SetText(text);
\r
806 _tooltipCopy.Active = true;
\r
807 _tooltipCopy.Show("コピーしました。", fleetButton);
\r
808 Task.Run(async () =>
\r
810 await Task.Delay(1000);
\r
811 _tooltipCopy.Active = false;
\r
815 public void ResetAchievement()
\r
817 Sniffer.Achievement.Reset();
\r
821 private void labelRepairListButton_Click(object sender, EventArgs e)
\r
823 if (panelRepairList.Visible)
\r
825 panelRepairList.Visible = false;
\r
826 dropDownButtonRepairList.BackColor = DefaultBackColor;
\r
830 panelRepairList.Visible = true;
\r
831 panelRepairList.BringToFront();
\r
832 dropDownButtonRepairList.BackColor = CustomColors.ActiveButtonColor;
\r
836 private void panelRepairList_Click(object sender, EventArgs e)
\r
838 panelRepairList.Visible = false;
\r
839 dropDownButtonRepairList.BackColor = DefaultBackColor;
\r
842 private void ShipListToolStripMenuItem_Click(object sender, EventArgs e)
\r
844 _listFormGroup.ShowOrCreate();
\r
847 private void LogToolStripMenuItem_Click(object sender, EventArgs e)
\r
849 Process.Start("http://localhost:" + Config.Proxy.Listen + "/");
\r
852 private void labelClearQuest_Click(object sender, EventArgs e)
\r
854 Sniffer.ClearQuests();
\r
858 private void labelClearQuest_MouseDown(object sender, MouseEventArgs e)
\r
860 labelClearQuest.BackColor = CustomColors.ActiveButtonColor;
\r
863 private void labelClearQuest_MouseUp(object sender, MouseEventArgs e)
\r
865 labelClearQuest.BackColor = DefaultBackColor;
\r
868 private void labelQuest_DoubleClick(object sender, EventArgs e)
\r
870 var label = (Label)sender;
\r
871 if (string.IsNullOrEmpty(label.Text))
\r
873 Clipboard.SetText(label.Text);
\r
874 _tooltipCopy.Active = true;
\r
875 _tooltipCopy.Show("コピーしました。", label);
\r
876 Task.Run(async () =>
\r
878 await Task.Delay(1000);
\r
879 _tooltipCopy.Active = false;
\r
883 private void CaptureToolStripMenuItem_Click(object sender, EventArgs e)
\r
887 var proc = new ProcessStartInfo("BurageSnap.exe") {WorkingDirectory = "Capture"};
\r
888 Process.Start(proc);
\r
890 catch (FileNotFoundException)
\r
893 catch (Win32Exception)
\r