PageRenderTime 65ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/BombEistiv2WPF/View/Menu/KeyConfigMenu.cs

https://github.com/SsSanzo/BombEISTIv2
C# | 241 lines | 204 code | 31 blank | 6 comment | 37 complexity | 68268ff80f7ca599cff3adc26f6fabc0 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Timers;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Threading;
  11. using BombEistiv2WPF.Control;
  12. using BombEistiv2WPF.Environment;
  13. using Timer = System.Timers.Timer;
  14. namespace BombEistiv2WPF.View.Menu
  15. {
  16. class KeyConfigMenu : Screenv2
  17. {
  18. private Wizard _wizard;
  19. private Dictionary<string, Image> _menuDataList;
  20. private Dictionary<string, Label> _menuLabelList;
  21. private String OptionSelected;
  22. private Dictionary<String, int> OptionZommed;
  23. private bool thisistheend;
  24. public Dictionary<string, Image> MenuDataList
  25. {
  26. get { return _menuDataList; }
  27. }
  28. public Dictionary<string, Label> MenuLabelList
  29. {
  30. get { return _menuLabelList; }
  31. }
  32. public override void Show(Control.Wizard w, Screenv2 oldscreen)
  33. {
  34. thisistheend = false;
  35. var pressstart = (OptionMenu)oldscreen;
  36. _wizard = w;
  37. OptionZommed = new Dictionary<string, int>();
  38. OptionSelected = "BoxGeneral";
  39. if (_menuDataList == null)
  40. {
  41. _menuDataList = new Dictionary<string, Image>();
  42. _menuLabelList = new Dictionary<string, Label>();
  43. _wizard.WindowDispatcher.Invoke(DispatcherPriority.Normal, new Action(() => LoadMenuImagePrevious(pressstart)));
  44. //_wizard.WindowDispatcher.Invoke(DispatcherPriority.Normal, new Action(LoadMenuLabel));
  45. }
  46. for (var i = w.Grid.Children.Count - 1; i > -1; i--)
  47. {
  48. if (!(w.Grid.Children[i] is Grid))
  49. {
  50. w.Grid.Children.RemoveAt(i);
  51. }
  52. }
  53. foreach (var img in MenuDataList)
  54. {
  55. _wizard.Grid.Children.Add(img.Value);
  56. }
  57. foreach (var lab in MenuLabelList)
  58. {
  59. _wizard.Grid.Children.Add(lab.Value);
  60. }
  61. //var lt = new ScaleTransform { ScaleX = 1.1, ScaleY = 1.1, CenterX = 134, CenterY = 50 };
  62. //MenuDataList[OptionSelected].Margin = new Thickness(MenuDataList[OptionSelected].Margin.Left - 10, MenuDataList[OptionSelected].Margin.Top - 10, 0,0);
  63. //MenuDataList[OptionSelected].LayoutTransform = lt;
  64. //MenuDataList[OptionSelected].Opacity = 1;
  65. TimerManager._.AddNewTimer(true, 15, true, null, ActionDefil);
  66. TimerManager._.AddNewTimer(true, 15, true, null, FadeIn);
  67. }
  68. public void SwitchOption(String s)
  69. {
  70. OptionSelected = s;
  71. MenuDataList[s].Opacity = 1;
  72. Canvas.SetZIndex(MenuDataList[s], 2);
  73. Canvas.SetZIndex(MenuLabelList[s], 3);
  74. OptionZommed[s] = 1;
  75. }
  76. public override void KeyUp(Key k) { }
  77. public override void KeyDown(Key k)
  78. {
  79. if (KeyAction._.KeysMenu.ContainsKey(k) && KeyAction._.KeysMenu[k] == "Down")
  80. {
  81. }
  82. else if (KeyAction._.KeysMenu.ContainsKey(k) && KeyAction._.KeysMenu[k] == "Up")
  83. {
  84. }
  85. else if (KeyAction._.KeysMenu.ContainsKey(k) && KeyAction._.KeysMenu[k] == "Enter")
  86. {
  87. }
  88. }
  89. public override void Hide()
  90. {
  91. }
  92. public void LoadMenuImagePrevious(OptionMenu old)
  93. {
  94. MenuDataList.Add("Sky", old.MenuDataList["Sky"]);
  95. MenuDataList.Add("Black", old.MenuDataList["Black"]);
  96. MenuDataList.Add("Bomb", old.MenuDataList["Bomb"]);
  97. MenuDataList.Add("Eisti", old.MenuDataList["Eisti"]);
  98. MenuDataList.Add("2", old.MenuDataList["2"]);
  99. MenuDataList.Add("BoxOption", old.MenuDataList["BoxOption"]);
  100. MenuLabelList.Add("BoxOption", old.MenuLabelList["BoxOption"]);
  101. MenuDataList.Add("BoxTouche", old.MenuDataList["BoxTouche"]);
  102. MenuLabelList.Add("BoxTouche", old.MenuLabelList["BoxTouche"]);
  103. }
  104. public void LoadMenuImage()
  105. {
  106. }
  107. public void LoadMenuLabel()
  108. {
  109. }
  110. private void ActionDefil(object sender, ElapsedEventArgs e)
  111. {
  112. if (!thisistheend)
  113. {
  114. _wizard.WindowDispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(defileSky));
  115. _wizard.WindowDispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(zoomin));
  116. }
  117. else
  118. {
  119. var t = (Timer)sender;
  120. t.AutoReset = false;
  121. }
  122. }
  123. private void FadeIn(object sender, ElapsedEventArgs e)
  124. {
  125. _wizard.WindowDispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => FadeInOption((Timer)sender)));
  126. }
  127. public void FadeInOption(Timer t)
  128. {
  129. MenuDataList["BoxTouche"].Opacity = 1;
  130. var lt = (ScaleTransform)MenuDataList["BoxTouche"].LayoutTransform;
  131. if (lt.ScaleX > 0.81)
  132. {
  133. MenuDataList["BoxTouche"].Margin = new Thickness(MenuDataList["BoxTouche"].Margin.Left - 165.0 / 20.0, MenuDataList["BoxTouche"].Margin.Top - 245.0 / 20.0, 0, 0);
  134. lt.ScaleX = lt.ScaleX - 0.4 / 20.0;
  135. lt.ScaleY = lt.ScaleY - 0.4 / 20.0;
  136. MenuLabelList["BoxTouche"].Margin = new Thickness(MenuLabelList["BoxTouche"].Margin.Left - 175.0 / 20.0, MenuLabelList["BoxTouche"].Margin.Top - 255.0 / 20.0, 0, 0);
  137. MenuLabelList["BoxTouche"].FontSize -= 0.7;
  138. }
  139. else
  140. {
  141. t.AutoReset = false;
  142. _wizard.WindowDispatcher.Invoke(DispatcherPriority.Normal, new Action(LoadMenuImage));
  143. _wizard.WindowDispatcher.Invoke(DispatcherPriority.Normal, new Action(LoadMenuLabel));
  144. for (var i = _wizard.Grid.Children.Count - 1; i > -1; i--)
  145. {
  146. if (!(_wizard.Grid.Children[i] is Grid))
  147. {
  148. _wizard.Grid.Children.RemoveAt(i);
  149. }
  150. }
  151. foreach (var img in MenuDataList)
  152. {
  153. _wizard.Grid.Children.Add(img.Value);
  154. }
  155. foreach (var lab in MenuLabelList)
  156. {
  157. _wizard.Grid.Children.Add(lab.Value);
  158. }
  159. //SwitchOption("BoxGeneral");
  160. }
  161. }
  162. public void defileSky()
  163. {
  164. if (MenuDataList["Sky"].Margin.Left == -(MenuDataList["Sky"].Width / 2.0))
  165. {
  166. MenuDataList["Sky"].Margin = new Thickness(0.0, 0.0, 0.0, 0.0);
  167. }
  168. MenuDataList["Sky"].Margin = new Thickness(MenuDataList["Sky"].Margin.Left - 1, 0.0, 0.0, 0.0);
  169. }
  170. public void zoomin()
  171. {
  172. var copy = OptionZommed.Where(c => c.Value != 0);
  173. for (var i = 0; i < copy.Count(); i++)
  174. {
  175. if (copy.ElementAt(i).Value == 1)
  176. {
  177. var lt = (ScaleTransform)MenuDataList[copy.ElementAt(i).Key].LayoutTransform;
  178. if (((copy.ElementAt(i).Key != "BoxCancel") && lt.ScaleX >= 1.2) || ((copy.ElementAt(i).Key == "BoxCancel") && lt.ScaleX >= 0.9))
  179. {
  180. OptionZommed[copy.ElementAt(i).Key] = 0;
  181. }
  182. else
  183. {
  184. MenuDataList[copy.ElementAt(i).Key].Margin = new Thickness(MenuDataList[copy.ElementAt(i).Key].Margin.Left - 2, MenuDataList[copy.ElementAt(i).Key].Margin.Top - 2, 0, 0);
  185. MenuLabelList[copy.ElementAt(i).Key].FontSize += 1;
  186. MenuLabelList[copy.ElementAt(i).Key].Margin = new Thickness(MenuLabelList[copy.ElementAt(i).Key].Margin.Left - 2, MenuLabelList[copy.ElementAt(i).Key].Margin.Top - 2, 0, 0);
  187. lt.ScaleX += 0.02;
  188. lt.ScaleY += 0.02;
  189. }
  190. }
  191. else
  192. {
  193. var lt = (ScaleTransform)MenuDataList[copy.ElementAt(i).Key].LayoutTransform;
  194. if (((copy.ElementAt(i).Key != "BoxCancel") && lt.ScaleX <= 1.0) || ((copy.ElementAt(i).Key == "BoxCancel") && lt.ScaleX <= 0.7))
  195. {
  196. OptionZommed[copy.ElementAt(i).Key] = 0;
  197. }
  198. else
  199. {
  200. MenuDataList[copy.ElementAt(i).Key].Margin = new Thickness(MenuDataList[copy.ElementAt(i).Key].Margin.Left + 2, MenuDataList[copy.ElementAt(i).Key].Margin.Top + 2, 0, 0);
  201. MenuLabelList[copy.ElementAt(i).Key].FontSize -= 1;
  202. MenuLabelList[copy.ElementAt(i).Key].Margin = new Thickness(MenuLabelList[copy.ElementAt(i).Key].Margin.Left + 2, MenuLabelList[copy.ElementAt(i).Key].Margin.Top + 2, 0, 0);
  203. lt.ScaleX -= 0.02;
  204. lt.ScaleY -= 0.02;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }