1 // Copyright (C) 2013, 2014, 2015 Kazuhiro Fujieda <fujieda@users.sourceforge.jp>
\r
3 // This program is part of KancolleSniffer.
\r
5 // KancolleSniffer is free software: you can redistribute it and/or modify
\r
6 // it under the terms of the GNU General Public License as published by
\r
7 // the Free Software Foundation, either version 3 of the License, or
\r
8 // (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, see <http://www.gnu.org/licenses/>.
\r
19 using System.Collections.Generic;
\r
20 using System.Diagnostics;
\r
21 using System.Drawing;
\r
24 using System.Runtime.InteropServices;
\r
26 using System.Windows.Forms;
\r
27 using Codeplex.Data;
\r
30 namespace KancolleSniffer
\r
32 public partial class MainForm : Form
\r
34 private readonly Sniffer _sniffer = new Sniffer();
\r
35 private readonly Config _config = new Config();
\r
36 private readonly ConfigDialog _configDialog;
\r
37 private int _currentFleet;
\r
38 private readonly Label[] _labelCheckFleets;
\r
39 private readonly ShipLabels _shipLabels;
\r
40 private readonly ShipListForm _shipListForm;
\r
41 private readonly NoticeQueue _noticeQueue;
\r
42 private bool _started;
\r
43 private string _debugLogFile;
\r
44 private IEnumerator<string> _playLog;
\r
45 private LogServer _logServer;
\r
46 private readonly ProxyConfig _prevProxy = new ProxyConfig();
\r
50 InitializeComponent();
\r
51 FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
\r
52 FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
\r
53 _configDialog = new ConfigDialog(_config, this);
\r
54 _labelCheckFleets = new[] {labelCheckFleet1, labelCheckFleet2, labelCheckFleet3, labelCheckFleet4};
\r
56 // この時点でAutoScaleDimensions == CurrentAutoScaleDimensionsなので、
\r
57 // MainForm.Designer.csのAutoScaleDimensionsの6f,12fを使う。
\r
58 ShipLabel.ScaleFactor = new SizeF(CurrentAutoScaleDimensions.Width / 6f, CurrentAutoScaleDimensions.Height / 12f);
\r
61 _shipLabels = new ShipLabels();
\r
62 _shipLabels.CreateAkashiTimers(panelShipInfo);
\r
63 _shipLabels.CreateLabels(panelShipInfo, ShowShipOnShipList);
\r
64 _shipLabels.CreateDamagedShipList(panelDamagedShipList);
\r
65 _shipLabels.CreateNDockLabels(panelDock);
\r
66 _shipListForm = new ShipListForm(_sniffer, _config) {Owner = this};
\r
67 _noticeQueue = new NoticeQueue(Ring);
\r
70 private void FiddlerApplication_BeforeRequest(Session oSession)
\r
72 var path = oSession.PathAndQuery;
\r
73 var proxy = _config.Proxy;
\r
74 if (proxy.UseUpstream && (path.StartsWith("/kcsapi/api_") ||
\r
75 // この二つはMyFleetGirlsに必要
\r
76 path.StartsWith("/kcs/resources/") || path.StartsWith("/kcs/sound/")))
\r
77 oSession["x-overrideGateway"] = string.Format("localhost:{0:D}", proxy.UpstreamPort); // 上流プロキシを設定する
\r
78 if (!path.StartsWith("/kcsapi/api_")) // 艦これのAPI以外は無視する
\r
82 private void FiddlerApplication_AfterSessionComplete(Session oSession)
\r
84 if (!oSession.bHasResponse || !oSession.uriContains("/kcsapi/api_"))
\r
86 Invoke(new Action<Session>(ProcessRequest), oSession);
\r
89 private void ProcessRequest(Session session)
\r
91 var response = session.GetResponseBodyAsString();
\r
92 if (!response.StartsWith("svdata="))
\r
94 response = response.Remove(0, "svdata=".Length);
\r
95 var json = DynamicJson.Parse(response);
\r
96 var request = session.GetRequestBodyAsString();
\r
97 if (_debugLogFile != null)
\r
99 File.AppendAllText(_debugLogFile,
\r
100 string.Format("url: {0}\nrequest: {1}\nresponse: {2}\n", session.url, request, json.ToString()));
\r
102 UpdateInfo(_sniffer.Sniff(session.url, request, json));
\r
105 private void UpdateInfo(Sniffer.Update update)
\r
107 if (update == Sniffer.Update.Start)
\r
109 labelLogin.Visible = false;
\r
115 if ((update & Sniffer.Update.Item) != 0)
\r
117 if ((update & Sniffer.Update.Timer) != 0)
\r
119 if ((update & Sniffer.Update.NDock) != 0)
\r
120 UpdateNDocLabels();
\r
121 if ((update & Sniffer.Update.Mission) != 0)
\r
122 UpdateMissionLabels();
\r
123 if ((update & Sniffer.Update.QuestList) != 0)
\r
125 if ((update & Sniffer.Update.Ship) != 0)
\r
127 if ((update & Sniffer.Update.Battle) != 0)
\r
128 UpdateBattleInfo();
\r
131 private void MainForm_Load(object sender, EventArgs e)
\r
135 if (_config.HideOnMinimized && WindowState == FormWindowState.Minimized)
\r
136 ShowInTaskbar = false;
\r
138 ApplyDebugLogSetting();
\r
140 _sniffer.LoadState();
\r
144 private void StartProxy()
\r
146 if (_config.Proxy.Auto)
\r
147 FiddlerApplication.Startup(0, FiddlerCoreStartupFlags.RegisterAsSystemProxy);
\r
149 FiddlerApplication.Startup(_config.Proxy.Listen, FiddlerCoreStartupFlags.None);
\r
150 _prevProxy.Auto = _config.Proxy.Auto;
\r
151 _prevProxy.Listen = _config.Proxy.Listen;
\r
154 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
\r
157 _config.Location = (WindowState == FormWindowState.Normal ? Bounds : RestoreBounds).Location;
\r
160 if (_logServer != null)
\r
164 private void ShutdownProxy()
\r
166 FiddlerApplication.Shutdown();
\r
169 private void MainForm_Resize(object sender, EventArgs e)
\r
171 ShowInTaskbar = !(_config.HideOnMinimized && WindowState == FormWindowState.Minimized);
\r
174 private void notifyIconMain_MouseDoubleClick(object sender, MouseEventArgs e)
\r
176 NotifyIconOpenToolStripMenuItem_Click(sender, e);
\r
179 private void NotifyIconOpenToolStripMenuItem_Click(object sender, EventArgs e)
\r
181 ShowInTaskbar = true;
\r
182 WindowState = FormWindowState.Normal;
\r
186 private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
\r
191 private void ConfigToolStripMenuItem_Click(object sender, EventArgs e)
\r
193 if (_configDialog.ShowDialog(this) == DialogResult.OK)
\r
197 private void RestoreLocation()
\r
199 if (_config.Location.X == int.MinValue)
\r
201 var newBounds = Bounds;
\r
202 newBounds.Location = _config.Location;
\r
203 if (IsVisibleOnAnyScreen(newBounds))
\r
204 Location = _config.Location;
\r
207 private void ApplyConfig()
\r
209 _shipListForm.TopMost = TopMost = _config.TopMost;
\r
210 _sniffer.Item.MarginShips = _config.MarginShips;
\r
211 _sniffer.Item.MarginEquips = _config.MarginEquips;
\r
212 _sniffer.Achievement.ResetHours = _config.ResetHours;
\r
215 public void ApplyDebugLogSetting()
\r
217 _debugLogFile = _config.DebugLogging ? _config.DebugLogFile : null;
\r
220 public void ApplyProxySetting()
\r
222 if (_config.Proxy.Auto == _prevProxy.Auto && _config.Proxy.Listen == _prevProxy.Listen)
\r
228 public void ApplyLogSetting()
\r
230 if (_logServer != null && (!_config.Log.ServerOn || _config.Log.Listen != _logServer.Port))
\r
235 if (_logServer == null && _config.Log.ServerOn)
\r
237 _logServer = new LogServer(_config.Log.Listen);
\r
238 _logServer.Start();
\r
240 if (_logServer != null)
\r
241 _logServer.OutputDir = _config.Log.OutputDir;
\r
242 _sniffer.EnableLog(_config.Log.On ? LogType.All : LogType.None);
\r
243 _sniffer.MaterialLogInterval = _config.Log.MaterialLogInterval;
\r
244 _sniffer.LogOutputDir = _config.Log.OutputDir;
\r
247 public static bool IsVisibleOnAnyScreen(Rectangle rect)
\r
249 return Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(rect));
\r
252 private void timerMain_Tick(object sender, EventArgs e)
\r
256 if (_playLog == null || _configDialog.Visible)
\r
258 labelPlayLog.Visible = false;
\r
264 public void SetPlayLog(string file)
\r
266 _playLog = File.ReadLines(file).GetEnumerator();
\r
269 private void PlayLog()
\r
271 var lines = new List<string>();
\r
272 foreach (var s in new[] {"url: ", "request: ", "response: "})
\r
274 if (!_playLog.MoveNext() || !_playLog.Current.StartsWith(s))
\r
276 labelPlayLog.Visible = false;
\r
279 lines.Add(_playLog.Current.Substring(s.Count()));
\r
281 labelPlayLog.Visible = !labelPlayLog.Visible;
\r
282 var json = DynamicJson.Parse(lines[2]);
\r
283 UpdateInfo(_sniffer.Sniff(lines[0], lines[1], json));
\r
286 private void ShowShipOnShipList(object sender, EventArgs ev)
\r
288 if (!_shipListForm.Visible)
\r
290 var idx = (int)((Control)sender).Tag;
\r
291 var statuses = _sniffer.GetShipStatuses(_currentFleet);
\r
292 if (statuses.Length <= idx)
\r
294 _shipListForm.ShowShip(statuses[idx].Id);
\r
297 private void UpdateItemInfo()
\r
299 UpdateNumOfShips();
\r
300 UpdateNumOfEquips();
\r
301 labelNumOfBuckets.Text = _sniffer.Item.MaterialHistory[(int)Material.Bucket].Now.ToString("D");
\r
302 UpdateBucketHistory();
\r
303 var ac = _sniffer.Achievement.Value;
\r
306 labelAchievement.Text = ac >= 1000 ? ((int)ac).ToString("D") : ac.ToString("F1");
\r
307 toolTipAchievement.SetToolTip(labelAchievement, "今月 " + _sniffer.Achievement.ValueOfMonth.ToString("F1"));
\r
308 UpdateMaterialHistry();
\r
309 if (_shipListForm.Visible)
\r
310 _shipListForm.UpdateList();
\r
313 private void UpdateNumOfShips()
\r
315 var item = _sniffer.Item;
\r
316 labelNumOfShips.Text = string.Format("{0:D}/{1:D}", item.NowShips, item.MaxShips);
\r
317 labelNumOfShips.ForeColor = item.TooManyShips ? Color.Red : Color.Black;
\r
318 if (item.RingShips)
\r
320 var message = string.Format("残り{0:D}隻", _sniffer.Item.MaxShips - _sniffer.Item.NowShips);
\r
321 _noticeQueue.Enqueue("艦娘が多すぎます", message, _config.MaxShipsSoundFile);
\r
322 item.RingShips = false;
\r
326 private void UpdateNumOfEquips()
\r
328 var item = _sniffer.Item;
\r
329 labelNumOfEquips.Text = string.Format("{0:D}/{1:D}", item.NowEquips, item.MaxEquips);
\r
330 labelNumOfEquips.ForeColor = item.TooManyEquips ? Color.Red : Color.Black;
\r
331 if (item.RingEquips)
\r
333 var message = string.Format("残り{0:D}個", _sniffer.Item.MaxEquips - _sniffer.Item.NowEquips);
\r
334 _noticeQueue.Enqueue("装備が多すぎます", message, _config.MaxEquipsSoundFile);
\r
335 item.RingEquips = false;
\r
339 private void UpdateBucketHistory()
\r
341 var count = _sniffer.Item.MaterialHistory[(int)Material.Bucket];
\r
342 var day = count.Now - count.BegOfDay;
\r
343 var week = count.Now - count.BegOfWeek;
\r
348 labelBucketHistory.Text = string.Format("{0:+#;-#;±0} 今日\n{1:+#;-#;±0} 今週", day, week);
\r
351 private void UpdateMaterialHistry()
\r
353 var labels = new[] {labelFuelHistory, labelBulletHistory, labelSteelHistory, labelBouxiteHistory};
\r
354 var text = new[] {"燃料", "弾薬", "鋼材", "ボーキ"};
\r
355 for (var i = 0; i < labels.Length; i++)
\r
357 var count = _sniffer.Item.MaterialHistory[i];
\r
358 var day = count.Now - count.BegOfDay;
\r
361 var week = count.Now - count.BegOfWeek;
\r
362 if (week >= 100000)
\r
364 labels[i].Text = string.Format("{0}\n{1:+#;-#;±0}\n{2:+#;-#;±0}", text[i], day, week);
\r
368 private void UpdateShipInfo()
\r
370 UpdatePanelShipInfo();
\r
371 NotifyDamagedShip();
\r
372 UpdateChargeInfo();
\r
373 UpdateDamagedShipList();
\r
374 if (_shipListForm.Visible)
\r
375 _shipListForm.UpdateList();
\r
378 private void UpdatePanelShipInfo()
\r
380 var statuses = _sniffer.GetShipStatuses(_currentFleet);
\r
381 _shipLabels.SetShipInfo(statuses);
\r
382 labelFighterPower.Text = _sniffer.GetFighterPower(_currentFleet).ToString("D");
\r
383 UpdateAkashiTimer();
\r
385 UpdateCondTimers();
\r
388 private void NotifyDamagedShip()
\r
390 if (_sniffer.Battle.HasDamagedShip)
\r
391 _noticeQueue.Enqueue("大破した艦娘がいます", string.Join(" ", _sniffer.Battle.DamagedShipNames),
\r
392 _config.DamagedShipSoundFile);
\r
395 private void NotifyAkashiTimer()
\r
397 var msgs = _sniffer.GetAkashiTimerNotice();
\r
398 if (msgs.Length == 0)
\r
400 if (msgs[0] == "20分経過しました。")
\r
402 _noticeQueue.Enqueue("泊地修理", msgs[0], _config.Akashi20MinSoundFile);
\r
405 var fn = new[] {"第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊"};
\r
406 for (var i = 0; i < fn.Length; i++)
\r
410 _noticeQueue.Enqueue("泊地修理 " + fn[i], msgs[i], _config.AkashiProgressSoundFile);
\r
414 private void UpdateLoS()
\r
416 labelLoS.Text = _sniffer.GetFleetLineOfSights(_currentFleet).ToString("F1");
\r
419 private void UpdateBattleInfo()
\r
421 labelFormation.Text = "";
\r
422 labelEnemyFighterPower.Text = "";
\r
423 labelFighterPower.ForeColor = DefaultForeColor;
\r
424 labelResultRank.Text = "判定";
\r
425 panelBattleInfo.Visible = _sniffer.Battle.InBattle;
\r
426 if (!_sniffer.Battle.InBattle)
\r
428 panelBattleInfo.BringToFront();
\r
429 var battle = _sniffer.Battle;
\r
430 var color = new[] { DefaultForeColor, DefaultForeColor, Color.Blue, Color.Green, Color.Orange, Color.Red };
\r
431 labelFormation.Text = battle.Formation;
\r
432 labelEnemyFighterPower.Text = battle.EnemyFighterPower.ToString("D");
\r
433 labelFighterPower.ForeColor = color[battle.AirControlLevel + 1];
\r
434 if (_config.AlwaysShowResultRank)
\r
438 private void ShowResultRank()
\r
440 var result = new[] { "完全S", "勝利S", "勝利A", "勝利B", "敗北C", "敗北D", "敗北E" };
\r
441 labelResultRank.Text = result[(int)_sniffer.Battle.ResultRank];
\r
444 private void labelResultRank_Click(object sender, EventArgs e)
\r
449 private void UpdateChargeInfo()
\r
451 var fuelSq = new[] {labelFuelSq1, labelFuelSq2, labelFuelSq3, labelFuelSq4};
\r
452 var bullSq = new[] {labelBullSq1, labelBullSq2, labelBullSq3, labelBullSq4};
\r
454 for (var i = 0; i < fuelSq.Length; i++)
\r
456 var stat = _sniffer.ChargeStatuses[i];
\r
457 fuelSq[i].ImageIndex = stat.Fuel;
\r
458 bullSq[i].ImageIndex = stat.Bull;
\r
462 private void UpdateNDocLabels()
\r
464 _shipLabels.SetNDockLabels(_sniffer.NDock);
\r
467 private void UpdateMissionLabels()
\r
469 foreach (var entry in
\r
470 new[] {labelMissionName1, labelMissionName2, labelMissionName3}.Zip(_sniffer.Missions,
\r
471 (label, mission) => new {label, mission.Name}))
\r
472 entry.label.Text = entry.Name;
\r
475 private void UpdateTimers()
\r
477 foreach (var entry in
\r
478 new[] {labelMission1, labelMission2, labelMission3}.Zip(_sniffer.Missions,
\r
479 (label, mission) => new {label, mission.Name, mission.Timer}))
\r
481 entry.Timer.Update();
\r
482 SetTimerColor(entry.label, entry.Timer);
\r
483 var rest = entry.Timer.Rest;
\r
484 entry.label.Text = rest.Days == 0 ? rest.ToString(@"hh\:mm\:ss") : rest.ToString(@"d\.hh\:mm");
\r
485 if (!entry.Timer.NeedRing)
\r
487 _noticeQueue.Enqueue("遠征が終わりました", entry.Name, _config.MissionSoundFile);
\r
488 entry.Timer.NeedRing = false;
\r
490 for (var i = 0; i < _sniffer.NDock.Length; i++)
\r
492 var entry = _sniffer.NDock[i];
\r
493 entry.Timer.Update();
\r
494 _shipLabels.SetNDockTimer(i, entry.Timer);
\r
495 if (!entry.Timer.NeedRing)
\r
497 _noticeQueue.Enqueue("入渠が終わりました", entry.Name, _config.NDockSoundFile);
\r
498 entry.Timer.NeedRing = false;
\r
500 var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4};
\r
501 for (var i = 0; i < kdock.Length; i++)
\r
503 var timer = _sniffer.KDock[i];
\r
505 SetTimerColor(kdock[i], timer);
\r
506 kdock[i].Text = timer.Rest.ToString(@"hh\:mm\:ss");
\r
507 if (!timer.NeedRing)
\r
509 _noticeQueue.Enqueue("建造が終わりました", string.Format("第{0:D}ドック", i + 1), _config.KDockSoundFile);
\r
510 timer.NeedRing = false;
\r
512 UpdateCondTimers();
\r
513 UpdateAkashiTimer();
\r
516 private void SetTimerColor(Label label, RingTimer timer)
\r
518 label.ForeColor = timer.IsFinished ? Color.Red : Color.Black;
\r
521 private void UpdateCondTimers()
\r
523 var timer = _sniffer.GetConditionTimer(_currentFleet);
\r
524 var now = DateTime.Now;
\r
525 if (timer == DateTime.MinValue)
\r
527 labelCondTimerTitle.Text = "";
\r
528 labelCondTimer.Text = "";
\r
531 var span = TimeSpan.FromSeconds(Math.Ceiling((timer - now).TotalSeconds));
\r
532 if (span >= TimeSpan.FromMinutes(9))
\r
534 labelCondTimerTitle.Text = "cond40まで";
\r
535 labelCondTimer.Text = (span - TimeSpan.FromMinutes(9)).ToString(@"mm\:ss");
\r
539 labelCondTimerTitle.Text = "cond49まで";
\r
540 labelCondTimer.Text = (span >= TimeSpan.Zero ? span : TimeSpan.Zero).ToString(@"mm\:ss");
\r
542 var notice = _sniffer.GetConditionNotice();
\r
543 if (notice == null)
\r
545 var fn = new[] {"第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊"};
\r
546 for (var i = 0; i < fn.Length; i++)
\r
548 if (!_config.NotifyConditions.Contains(notice[i]))
\r
550 _noticeQueue.Enqueue("疲労が回復しました", fn[i] + " cond" + notice[i].ToString("D"), _config.ConditionSoundFile);
\r
554 private void UpdateAkashiTimer()
\r
556 _shipLabels.SetAkashiTimer(_sniffer.GetShipStatuses(_currentFleet),
\r
557 _sniffer.GetAkashiTimers(_currentFleet));
\r
558 NotifyAkashiTimer();
\r
561 private void UpdateDamagedShipList()
\r
563 _shipLabels.SetDamagedShipList(_sniffer.DamagedShipList);
\r
566 private void UpdateQuestList()
\r
568 var category = new[]
\r
570 labelQuestColor1, labelQuestColor2, labelQuestColor3, labelQuestColor4, labelQuestColor5, labelQuestColor6
\r
572 var name = new[] {labelQuest1, labelQuest2, labelQuest3, labelQuest4, labelQuest5, labelQuest6};
\r
573 var progress = new[] {labelProgress1, labelProgress2, labelProgress3, labelProgress4, labelProgress5, labelProgress6};
\r
576 Color.FromArgb(60, 141, 76), Color.FromArgb(232, 57, 41), Color.FromArgb(136, 204, 120),
\r
577 Color.FromArgb(52, 147, 185), Color.FromArgb(220, 198, 126), Color.FromArgb(168, 111, 76),
\r
578 Color.FromArgb(200, 148, 231)
\r
581 var quests = _sniffer.Quests;
\r
582 for (var i = 0; i < name.Length; i++)
\r
584 if (i < quests.Length)
\r
586 category[i].BackColor = color[quests[i].Category - 1];
\r
587 name[i].Text = quests[i].Name;
\r
588 progress[i].Text = string.Format("{0:D}%", quests[i].Progress);
\r
592 category[i].BackColor = DefaultBackColor;
\r
593 name[i].Text = progress[i].Text = "";
\r
598 private class NoticeQueue
\r
600 private readonly Action<string, string, string> _ring;
\r
601 private readonly Queue<Tuple<string, string, string>> _queue = new Queue<Tuple<string, string, string>>();
\r
602 private readonly Timer _timer = new Timer {Interval = 2000};
\r
604 public NoticeQueue(Action<string, string, string> ring)
\r
607 _timer.Tick += TimerOnTick;
\r
610 private void TimerOnTick(object obj, EventArgs e)
\r
612 if (_queue.Count == 0)
\r
617 var notice = _queue.Dequeue();
\r
618 _ring(notice.Item1, notice.Item2, notice.Item3);
\r
621 public void Enqueue(string title, string message, string soundFile)
\r
623 if (_timer.Enabled)
\r
625 _queue.Enqueue(new Tuple<string, string, string>(title, message, soundFile));
\r
629 _ring(title, message, soundFile);
\r
635 private void Ring(string baloonTitle, string baloonMessage, string soundFile)
\r
637 if (_config.FlashWindow)
\r
638 Win32API.FlashWindow(Handle);
\r
639 if (_config.ShowBaloonTip)
\r
640 notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info);
\r
641 if (_config.PlaySound)
\r
642 PlaySound(soundFile, _config.SoundVolume);
\r
645 [DllImport("winmm.dll")]
\r
646 private static extern int mciSendString(String command,
\r
647 StringBuilder buffer, int bufferSize, IntPtr hwndCallback);
\r
649 // ReSharper disable InconsistentNaming
\r
650 private const int MM_MCINOTIFY = 0x3B9;
\r
651 private const int MCI_NOTIFY_SUCCESSFUL = 1;
\r
652 // ReSharper restore InconsistentNaming
\r
654 public void PlaySound(string file, int volume)
\r
656 if (!File.Exists(file))
\r
658 mciSendString("close sound", null, 0, IntPtr.Zero);
\r
659 if (mciSendString("open \"" + file + "\" type mpegvideo alias sound", null, 0, IntPtr.Zero) != 0)
\r
661 mciSendString("setaudio sound volume to " + volume * 10, null, 0, IntPtr.Zero);
\r
662 mciSendString("play sound notify", null, 0, Handle);
\r
665 protected override void WndProc(ref Message m)
\r
667 if (m.Msg == MM_MCINOTIFY && (int)m.WParam == MCI_NOTIFY_SUCCESSFUL)
\r
668 mciSendString("close sound", null, 0, IntPtr.Zero);
\r
669 base.WndProc(ref m);
\r
672 private void SetupFleetClick()
\r
676 new[] {labelFleet1, labelFleet2, labelFleet3, labelFleet4},
\r
677 new[] {labelFuelSq1, labelFuelSq2, labelFuelSq3, labelFuelSq4},
\r
678 new[] {labelBullSq1, labelBullSq2, labelBullSq3, labelBullSq4}
\r
680 foreach (var a in labels)
\r
682 for (var fleet = 0; fleet < labels[0].Length; fleet++)
\r
684 a[fleet].Tag = fleet;
\r
685 a[fleet].Click += labelFleet_Click;
\r
690 private void labelFleet_Click(object sender, EventArgs e)
\r
692 var fleet = (int)((Label)sender).Tag;
\r
693 if (_currentFleet == fleet)
\r
695 _currentFleet = fleet;
\r
696 foreach (var label in _labelCheckFleets)
\r
697 label.Visible = false;
\r
698 _labelCheckFleets[fleet].Visible = true;
\r
701 UpdatePanelShipInfo();
\r
704 private void labelBucketHistoryButton_Click(object sender, EventArgs e)
\r
706 if (labelBucketHistory.Visible)
\r
708 labelBucketHistory.Visible = false;
\r
709 labelBucketHistoryButton.BackColor = DefaultBackColor;
\r
713 labelBucketHistory.Visible = true;
\r
714 labelBucketHistory.BringToFront();
\r
715 labelBucketHistoryButton.BackColor = SystemColors.ActiveCaption;
\r
719 private void labelMaterialHistoryButton_Click(object sender, EventArgs e)
\r
721 if (panelMaterialHistory.Visible)
\r
723 panelMaterialHistory.Visible = false;
\r
724 labelMaterialHistoryButton.BackColor = DefaultBackColor;
\r
728 panelMaterialHistory.Visible = true;
\r
729 panelMaterialHistory.BringToFront();
\r
730 labelMaterialHistoryButton.BackColor = SystemColors.ActiveCaption;
\r
734 public void ResetAchievemnt()
\r
736 _sniffer.Achievement.Reset();
\r
740 private void labelDamgedShipListButton_Click(object sender, EventArgs e)
\r
742 if (panelDamagedShipList.Visible)
\r
744 panelDamagedShipList.Visible = false;
\r
745 labelDamgedShipListButton.BackColor = DefaultBackColor;
\r
749 panelDamagedShipList.Visible = true;
\r
750 panelDamagedShipList.BringToFront();
\r
751 labelDamgedShipListButton.BackColor = SystemColors.ActiveCaption;
\r
755 private void ShipListToolStripMenuItem_Click(object sender, EventArgs e)
\r
757 _shipListForm.UpdateList();
\r
758 _shipListForm.Show();
\r
759 if (_shipListForm.WindowState == FormWindowState.Minimized)
\r
760 _shipListForm.WindowState = FormWindowState.Normal;
\r
761 _shipListForm.Activate();
\r
764 private void LogToolStripMenuItem_Click(object sender, EventArgs e)
\r
766 Process.Start("http://localhost:" + _config.Log.Listen + "/");
\r