1 // Copyright (C) 2013, 2014, 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>
\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
183 TopMost = true; // 最前面に表示されなくなることがあるのを回避する
\r
187 private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
\r
192 private void ConfigToolStripMenuItem_Click(object sender, EventArgs e)
\r
194 if (_configDialog.ShowDialog(this) == DialogResult.OK)
\r
198 private void RestoreLocation()
\r
200 if (_config.Location.X == int.MinValue)
\r
202 var newBounds = Bounds;
\r
203 newBounds.Location = _config.Location;
\r
204 if (IsVisibleOnAnyScreen(newBounds))
\r
205 Location = _config.Location;
\r
208 private void ApplyConfig()
\r
210 _shipListForm.TopMost = TopMost = _config.TopMost;
\r
211 _sniffer.Item.MarginShips = _config.MarginShips;
\r
212 _sniffer.Item.MarginEquips = _config.MarginEquips;
\r
213 _sniffer.Achievement.ResetHours = _config.ResetHours;
\r
216 public void ApplyDebugLogSetting()
\r
218 _debugLogFile = _config.DebugLogging ? _config.DebugLogFile : null;
\r
221 public void ApplyProxySetting()
\r
223 if (_config.Proxy.Auto == _prevProxy.Auto && _config.Proxy.Listen == _prevProxy.Listen)
\r
229 public void ApplyLogSetting()
\r
231 if (_logServer != null && (!_config.Log.ServerOn || _config.Log.Listen != _logServer.Port))
\r
236 if (_logServer == null && _config.Log.ServerOn)
\r
238 _logServer = new LogServer(_config.Log.Listen);
\r
239 _logServer.Start();
\r
241 if (_logServer != null)
\r
242 _logServer.OutputDir = _config.Log.OutputDir;
\r
243 _sniffer.EnableLog(_config.Log.On ? LogType.All : LogType.None);
\r
244 _sniffer.MaterialLogInterval = _config.Log.MaterialLogInterval;
\r
245 _sniffer.LogOutputDir = _config.Log.OutputDir;
\r
248 public static bool IsVisibleOnAnyScreen(Rectangle rect)
\r
250 return Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(rect));
\r
253 private void timerMain_Tick(object sender, EventArgs e)
\r
257 if (_playLog == null || _configDialog.Visible)
\r
259 labelPlayLog.Visible = false;
\r
265 public void SetPlayLog(string file)
\r
267 _playLog = File.ReadLines(file).GetEnumerator();
\r
270 private void PlayLog()
\r
272 var lines = new List<string>();
\r
273 foreach (var s in new[] {"url: ", "request: ", "response: "})
\r
275 if (!_playLog.MoveNext() || !_playLog.Current.StartsWith(s))
\r
277 labelPlayLog.Visible = false;
\r
280 lines.Add(_playLog.Current.Substring(s.Count()));
\r
282 labelPlayLog.Visible = !labelPlayLog.Visible;
\r
283 var json = DynamicJson.Parse(lines[2]);
\r
284 UpdateInfo(_sniffer.Sniff(lines[0], lines[1], json));
\r
287 private void ShowShipOnShipList(object sender, EventArgs ev)
\r
289 if (!_shipListForm.Visible)
\r
291 var idx = (int)((Control)sender).Tag;
\r
292 var statuses = _sniffer.GetShipStatuses(_currentFleet);
\r
293 if (statuses.Length <= idx)
\r
295 _shipListForm.ShowShip(statuses[idx].Id);
\r
298 private void UpdateItemInfo()
\r
300 UpdateNumOfShips();
\r
301 UpdateNumOfEquips();
\r
302 labelNumOfBuckets.Text = _sniffer.Item.MaterialHistory[(int)Material.Bucket].Now.ToString("D");
\r
303 UpdateBucketHistory();
\r
304 var ac = _sniffer.Achievement.Value;
\r
307 labelAchievement.Text = ac >= 1000 ? ((int)ac).ToString("D") : ac.ToString("F1");
\r
308 toolTipAchievement.SetToolTip(labelAchievement, "今月 " + _sniffer.Achievement.ValueOfMonth.ToString("F1"));
\r
309 UpdateMaterialHistry();
\r
310 if (_shipListForm.Visible)
\r
311 _shipListForm.UpdateList();
\r
314 private void UpdateNumOfShips()
\r
316 var item = _sniffer.Item;
\r
317 labelNumOfShips.Text = string.Format("{0:D}/{1:D}", item.NowShips, item.MaxShips);
\r
318 labelNumOfShips.ForeColor = item.TooManyShips ? Color.Red : Color.Black;
\r
319 if (item.RingShips)
\r
321 var message = string.Format("残り{0:D}隻", _sniffer.Item.MaxShips - _sniffer.Item.NowShips);
\r
322 _noticeQueue.Enqueue("艦娘が多すぎます", message, _config.MaxShipsSoundFile);
\r
323 item.RingShips = false;
\r
327 private void UpdateNumOfEquips()
\r
329 var item = _sniffer.Item;
\r
330 labelNumOfEquips.Text = string.Format("{0:D}/{1:D}", item.NowEquips, item.MaxEquips);
\r
331 labelNumOfEquips.ForeColor = item.TooManyEquips ? Color.Red : Color.Black;
\r
332 if (item.RingEquips)
\r
334 var message = string.Format("残り{0:D}個", _sniffer.Item.MaxEquips - _sniffer.Item.NowEquips);
\r
335 _noticeQueue.Enqueue("装備が多すぎます", message, _config.MaxEquipsSoundFile);
\r
336 item.RingEquips = false;
\r
340 private void UpdateBucketHistory()
\r
342 var count = _sniffer.Item.MaterialHistory[(int)Material.Bucket];
\r
343 var day = count.Now - count.BegOfDay;
\r
344 var week = count.Now - count.BegOfWeek;
\r
349 labelBucketHistory.Text = string.Format("{0:+#;-#;±0} 今日\n{1:+#;-#;±0} 今週", day, week);
\r
352 private void UpdateMaterialHistry()
\r
354 var labels = new[] {labelFuelHistory, labelBulletHistory, labelSteelHistory, labelBouxiteHistory};
\r
355 var text = new[] {"燃料", "弾薬", "鋼材", "ボーキ"};
\r
356 for (var i = 0; i < labels.Length; i++)
\r
358 var count = _sniffer.Item.MaterialHistory[i];
\r
359 var day = count.Now - count.BegOfDay;
\r
362 var week = count.Now - count.BegOfWeek;
\r
363 if (week >= 100000)
\r
365 labels[i].Text = string.Format("{0}\n{1:+#;-#;±0}\n{2:+#;-#;±0}", text[i], day, week);
\r
369 private void UpdateShipInfo()
\r
371 UpdatePanelShipInfo();
\r
372 NotifyDamagedShip();
\r
373 UpdateChargeInfo();
\r
374 UpdateDamagedShipList();
\r
375 if (_shipListForm.Visible)
\r
376 _shipListForm.UpdateList();
\r
379 private void UpdatePanelShipInfo()
\r
381 var statuses = _sniffer.GetShipStatuses(_currentFleet);
\r
382 _shipLabels.SetShipInfo(statuses);
\r
383 labelFighterPower.Text = _sniffer.GetFighterPower(_currentFleet).ToString("D");
\r
384 UpdateAkashiTimer();
\r
386 UpdateCondTimers();
\r
389 private void NotifyDamagedShip()
\r
391 if (_sniffer.Battle.HasDamagedShip)
\r
392 _noticeQueue.Enqueue("大破した艦娘がいます", string.Join(" ", _sniffer.Battle.DamagedShipNames),
\r
393 _config.DamagedShipSoundFile);
\r
396 private void NotifyAkashiTimer()
\r
398 var msgs = _sniffer.GetAkashiTimerNotice();
\r
399 if (msgs.Length == 0)
\r
401 if (msgs[0] == "20分経過しました。")
\r
403 _noticeQueue.Enqueue("泊地修理", msgs[0], _config.Akashi20MinSoundFile);
\r
406 var fn = new[] {"第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊"};
\r
407 for (var i = 0; i < fn.Length; i++)
\r
411 _noticeQueue.Enqueue("泊地修理 " + fn[i], msgs[i], _config.AkashiProgressSoundFile);
\r
415 private void UpdateLoS()
\r
417 labelLoS.Text = _sniffer.GetFleetLineOfSights(_currentFleet).ToString("F1");
\r
420 private void UpdateBattleInfo()
\r
422 labelFormation.Text = "";
\r
423 labelEnemyFighterPower.Text = "";
\r
424 labelFighterPower.ForeColor = DefaultForeColor;
\r
425 labelResultRank.Text = "判定";
\r
426 panelBattleInfo.Visible = _sniffer.Battle.InBattle;
\r
427 if (!_sniffer.Battle.InBattle)
\r
429 panelBattleInfo.BringToFront();
\r
430 var battle = _sniffer.Battle;
\r
431 var color = new[] { DefaultForeColor, DefaultForeColor, Color.Blue, Color.Green, Color.Orange, Color.Red };
\r
432 labelFormation.Text = battle.Formation;
\r
433 labelEnemyFighterPower.Text = battle.EnemyFighterPower.ToString("D");
\r
434 labelFighterPower.ForeColor = color[battle.AirControlLevel + 1];
\r
435 if (_config.AlwaysShowResultRank)
\r
439 private void ShowResultRank()
\r
441 var result = new[] { "完全S", "勝利S", "勝利A", "勝利B", "敗北C", "敗北D", "敗北E" };
\r
442 labelResultRank.Text = result[(int)_sniffer.Battle.ResultRank];
\r
445 private void labelResultRank_Click(object sender, EventArgs e)
\r
450 private void UpdateChargeInfo()
\r
452 var fuelSq = new[] {labelFuelSq1, labelFuelSq2, labelFuelSq3, labelFuelSq4};
\r
453 var bullSq = new[] {labelBullSq1, labelBullSq2, labelBullSq3, labelBullSq4};
\r
455 for (var i = 0; i < fuelSq.Length; i++)
\r
457 var stat = _sniffer.ChargeStatuses[i];
\r
458 fuelSq[i].ImageIndex = stat.Fuel;
\r
459 bullSq[i].ImageIndex = stat.Bull;
\r
463 private void UpdateNDocLabels()
\r
465 _shipLabels.SetNDockLabels(_sniffer.NDock);
\r
468 private void UpdateMissionLabels()
\r
470 foreach (var entry in
\r
471 new[] {labelMissionName1, labelMissionName2, labelMissionName3}.Zip(_sniffer.Missions,
\r
472 (label, mission) => new {label, mission.Name}))
\r
473 entry.label.Text = entry.Name;
\r
476 private void UpdateTimers()
\r
478 foreach (var entry in
\r
479 new[] {labelMission1, labelMission2, labelMission3}.Zip(_sniffer.Missions,
\r
480 (label, mission) => new {label, mission.Name, mission.Timer}))
\r
482 entry.Timer.Update();
\r
483 SetTimerColor(entry.label, entry.Timer);
\r
484 var rest = entry.Timer.Rest;
\r
485 entry.label.Text = rest.Days == 0 ? rest.ToString(@"hh\:mm\:ss") : rest.ToString(@"d\.hh\:mm");
\r
486 if (!entry.Timer.NeedRing)
\r
488 _noticeQueue.Enqueue("遠征が終わりました", entry.Name, _config.MissionSoundFile);
\r
489 entry.Timer.NeedRing = false;
\r
491 for (var i = 0; i < _sniffer.NDock.Length; i++)
\r
493 var entry = _sniffer.NDock[i];
\r
494 entry.Timer.Update();
\r
495 _shipLabels.SetNDockTimer(i, entry.Timer);
\r
496 if (!entry.Timer.NeedRing)
\r
498 _noticeQueue.Enqueue("入渠が終わりました", entry.Name, _config.NDockSoundFile);
\r
499 entry.Timer.NeedRing = false;
\r
501 var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4};
\r
502 for (var i = 0; i < kdock.Length; i++)
\r
504 var timer = _sniffer.KDock[i];
\r
506 SetTimerColor(kdock[i], timer);
\r
507 kdock[i].Text = timer.Rest.ToString(@"hh\:mm\:ss");
\r
508 if (!timer.NeedRing)
\r
510 _noticeQueue.Enqueue("建造が終わりました", string.Format("第{0:D}ドック", i + 1), _config.KDockSoundFile);
\r
511 timer.NeedRing = false;
\r
513 UpdateCondTimers();
\r
514 UpdateAkashiTimer();
\r
517 private void SetTimerColor(Label label, RingTimer timer)
\r
519 label.ForeColor = timer.IsFinished ? Color.Red : Color.Black;
\r
522 private void UpdateCondTimers()
\r
524 var timer = _sniffer.GetConditionTimer(_currentFleet);
\r
525 var now = DateTime.Now;
\r
526 if (timer == DateTime.MinValue)
\r
528 labelCondTimerTitle.Text = "";
\r
529 labelCondTimer.Text = "";
\r
532 var span = TimeSpan.FromSeconds(Math.Ceiling((timer - now).TotalSeconds));
\r
533 if (span >= TimeSpan.FromMinutes(9))
\r
535 labelCondTimerTitle.Text = "cond40まで";
\r
536 labelCondTimer.Text = (span - TimeSpan.FromMinutes(9)).ToString(@"mm\:ss");
\r
540 labelCondTimerTitle.Text = "cond49まで";
\r
541 labelCondTimer.Text = (span >= TimeSpan.Zero ? span : TimeSpan.Zero).ToString(@"mm\:ss");
\r
543 var notice = _sniffer.GetConditionNotice();
\r
544 if (notice == null)
\r
546 var fn = new[] {"第一艦隊", "第二艦隊", "第三艦隊", "第四艦隊"};
\r
547 for (var i = 0; i < fn.Length; i++)
\r
549 if (!_config.NotifyConditions.Contains(notice[i]))
\r
551 _noticeQueue.Enqueue("疲労が回復しました", fn[i] + " cond" + notice[i].ToString("D"), _config.ConditionSoundFile);
\r
555 private void UpdateAkashiTimer()
\r
557 _shipLabels.SetAkashiTimer(_sniffer.GetShipStatuses(_currentFleet),
\r
558 _sniffer.GetAkashiTimers(_currentFleet));
\r
559 NotifyAkashiTimer();
\r
562 private void UpdateDamagedShipList()
\r
564 _shipLabels.SetDamagedShipList(_sniffer.DamagedShipList);
\r
567 private void UpdateQuestList()
\r
569 var category = new[]
\r
571 labelQuestColor1, labelQuestColor2, labelQuestColor3, labelQuestColor4, labelQuestColor5, labelQuestColor6
\r
573 var name = new[] {labelQuest1, labelQuest2, labelQuest3, labelQuest4, labelQuest5, labelQuest6};
\r
574 var progress = new[] {labelProgress1, labelProgress2, labelProgress3, labelProgress4, labelProgress5, labelProgress6};
\r
577 Color.FromArgb(60, 141, 76), Color.FromArgb(232, 57, 41), Color.FromArgb(136, 204, 120),
\r
578 Color.FromArgb(52, 147, 185), Color.FromArgb(220, 198, 126), Color.FromArgb(168, 111, 76),
\r
579 Color.FromArgb(200, 148, 231)
\r
582 var quests = _sniffer.Quests;
\r
583 for (var i = 0; i < name.Length; i++)
\r
585 if (i < quests.Length)
\r
587 category[i].BackColor = color[quests[i].Category - 1];
\r
588 name[i].Text = quests[i].Name;
\r
589 progress[i].Text = string.Format("{0:D}%", quests[i].Progress);
\r
593 category[i].BackColor = DefaultBackColor;
\r
594 name[i].Text = progress[i].Text = "";
\r
599 private class NoticeQueue
\r
601 private readonly Action<string, string, string> _ring;
\r
602 private readonly Queue<Tuple<string, string, string>> _queue = new Queue<Tuple<string, string, string>>();
\r
603 private readonly Timer _timer = new Timer {Interval = 2000};
\r
605 public NoticeQueue(Action<string, string, string> ring)
\r
608 _timer.Tick += TimerOnTick;
\r
611 private void TimerOnTick(object obj, EventArgs e)
\r
613 if (_queue.Count == 0)
\r
618 var notice = _queue.Dequeue();
\r
619 _ring(notice.Item1, notice.Item2, notice.Item3);
\r
622 public void Enqueue(string title, string message, string soundFile)
\r
624 if (_timer.Enabled)
\r
626 _queue.Enqueue(new Tuple<string, string, string>(title, message, soundFile));
\r
630 _ring(title, message, soundFile);
\r
636 private void Ring(string baloonTitle, string baloonMessage, string soundFile)
\r
638 if (_config.FlashWindow)
\r
639 Win32API.FlashWindow(Handle);
\r
640 if (_config.ShowBaloonTip)
\r
641 notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info);
\r
642 if (_config.PlaySound)
\r
643 PlaySound(soundFile, _config.SoundVolume);
\r
646 [DllImport("winmm.dll")]
\r
647 private static extern int mciSendString(String command,
\r
648 StringBuilder buffer, int bufferSize, IntPtr hwndCallback);
\r
650 // ReSharper disable InconsistentNaming
\r
651 private const int MM_MCINOTIFY = 0x3B9;
\r
652 private const int MCI_NOTIFY_SUCCESSFUL = 1;
\r
653 // ReSharper restore InconsistentNaming
\r
655 public void PlaySound(string file, int volume)
\r
657 if (!File.Exists(file))
\r
659 mciSendString("close sound", null, 0, IntPtr.Zero);
\r
660 if (mciSendString("open \"" + file + "\" type mpegvideo alias sound", null, 0, IntPtr.Zero) != 0)
\r
662 mciSendString("setaudio sound volume to " + volume * 10, null, 0, IntPtr.Zero);
\r
663 mciSendString("play sound notify", null, 0, Handle);
\r
666 protected override void WndProc(ref Message m)
\r
668 if (m.Msg == MM_MCINOTIFY && (int)m.WParam == MCI_NOTIFY_SUCCESSFUL)
\r
669 mciSendString("close sound", null, 0, IntPtr.Zero);
\r
670 base.WndProc(ref m);
\r
673 private void SetupFleetClick()
\r
677 new[] {labelFleet1, labelFleet2, labelFleet3, labelFleet4},
\r
678 new[] {labelFuelSq1, labelFuelSq2, labelFuelSq3, labelFuelSq4},
\r
679 new[] {labelBullSq1, labelBullSq2, labelBullSq3, labelBullSq4}
\r
681 foreach (var a in labels)
\r
683 for (var fleet = 0; fleet < labels[0].Length; fleet++)
\r
685 a[fleet].Tag = fleet;
\r
686 a[fleet].Click += labelFleet_Click;
\r
691 private void labelFleet_Click(object sender, EventArgs e)
\r
693 var fleet = (int)((Label)sender).Tag;
\r
694 if (_currentFleet == fleet)
\r
696 _currentFleet = fleet;
\r
697 foreach (var label in _labelCheckFleets)
\r
698 label.Visible = false;
\r
699 _labelCheckFleets[fleet].Visible = true;
\r
702 UpdatePanelShipInfo();
\r
705 private void labelBucketHistoryButton_Click(object sender, EventArgs e)
\r
707 if (labelBucketHistory.Visible)
\r
709 labelBucketHistory.Visible = false;
\r
710 labelBucketHistoryButton.BackColor = DefaultBackColor;
\r
714 labelBucketHistory.Visible = true;
\r
715 labelBucketHistory.BringToFront();
\r
716 labelBucketHistoryButton.BackColor = SystemColors.ActiveCaption;
\r
720 private void labelMaterialHistoryButton_Click(object sender, EventArgs e)
\r
722 if (panelMaterialHistory.Visible)
\r
724 panelMaterialHistory.Visible = false;
\r
725 labelMaterialHistoryButton.BackColor = DefaultBackColor;
\r
729 panelMaterialHistory.Visible = true;
\r
730 panelMaterialHistory.BringToFront();
\r
731 labelMaterialHistoryButton.BackColor = SystemColors.ActiveCaption;
\r
735 public void ResetAchievemnt()
\r
737 _sniffer.Achievement.Reset();
\r
741 private void labelDamgedShipListButton_Click(object sender, EventArgs e)
\r
743 if (panelDamagedShipList.Visible)
\r
745 panelDamagedShipList.Visible = false;
\r
746 labelDamgedShipListButton.BackColor = DefaultBackColor;
\r
750 panelDamagedShipList.Visible = true;
\r
751 panelDamagedShipList.BringToFront();
\r
752 labelDamgedShipListButton.BackColor = SystemColors.ActiveCaption;
\r
756 private void ShipListToolStripMenuItem_Click(object sender, EventArgs e)
\r
758 _shipListForm.UpdateList();
\r
759 _shipListForm.Show();
\r
760 if (_shipListForm.WindowState == FormWindowState.Minimized)
\r
761 _shipListForm.WindowState = FormWindowState.Normal;
\r
762 _shipListForm.Activate();
\r
765 private void LogToolStripMenuItem_Click(object sender, EventArgs e)
\r
767 Process.Start("http://localhost:" + _config.Log.Listen + "/");
\r