/branches/ReworkEnhancedWatchedHandling/MyFilms/MyFilmsGUI/MFView.cs

http://my-films.googlecode.com/ · C# · 605 lines · 527 code · 76 blank · 2 comment · 0 complexity · 5e4169ea1412554a16bf2f270f934331 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using GUILocalizeStrings = MyFilmsPlugin.MyFilms.Utils.GUILocalizeStrings;
  6. namespace MyFilmsPlugin.MyFilmsGUI
  7. {
  8. using MediaPortal.GUI.Library;
  9. using MyFilmsPlugin.MyFilms.MyFilmsGUI;
  10. public class MFView
  11. {
  12. private static NLog.Logger LogMyFilms = NLog.LogManager.GetCurrentClassLogger(); //log
  13. public MFView() { }
  14. public MyFilms.ViewContext CurrentContext // "Boolselect" - or Films, Views, Persons, Herarchies ... GetSelectFromDivX or GetFilmList ...
  15. {
  16. get { return currentContext; }
  17. set { currentContext = value; }
  18. }
  19. private MyFilms.ViewContext currentContext = MyFilms.ViewContext.Menu;
  20. public int ID // to access a state via "PrevID"
  21. {
  22. get { return _ID; }
  23. set { _ID = value; }
  24. }
  25. private int _ID;
  26. public int PrevID // to access a state via "PrevID"
  27. {
  28. get { return prevID; }
  29. set { prevID = value; }
  30. }
  31. private int prevID;
  32. public View StartSettings
  33. {
  34. get { return startSettings; }
  35. set { startSettings = value; }
  36. }
  37. private View startSettings;
  38. public View CurrentSettings
  39. {
  40. get { return currentSettings; }
  41. set { currentSettings = value; }
  42. }
  43. private View currentSettings;
  44. }
  45. public class View
  46. {
  47. public View() { }
  48. private static NLog.Logger LogMyFilms = NLog.LogManager.GetCurrentClassLogger(); //log
  49. #region public vars
  50. public int ID
  51. {
  52. get { return _ID; }
  53. set { _ID = value; }
  54. }
  55. private int _ID = -1;
  56. public MyFilms.ViewContext ViewContext
  57. {
  58. get { return viewContext; }
  59. set { viewContext = value; }
  60. }
  61. private MyFilms.ViewContext viewContext = MyFilms.ViewContext.Menu;
  62. public string ViewDisplayName
  63. {
  64. get { return viewDisplayName; }
  65. set { viewDisplayName = value; }
  66. }
  67. private string viewDisplayName = string.Empty;
  68. public string ViewDBItem
  69. {
  70. get { return viewDBItem; }
  71. set { viewDBItem = value; }
  72. }
  73. private string viewDBItem = string.Empty;
  74. public string ViewDBItemValue
  75. {
  76. get { return viewDBItemValue; }
  77. set { viewDBItemValue = value; }
  78. }
  79. private string viewDBItemValue = string.Empty;
  80. public MyFilms.Layout ViewLayout
  81. {
  82. get { return viewLayout; }
  83. set { viewLayout = value; }
  84. }
  85. private MyFilms.Layout viewLayout = 0;
  86. public MyFilms.ViewSortType ViewSortType // Name or Occurencies
  87. {
  88. get { return viewSortType; }
  89. set { viewSortType = value; }
  90. }
  91. private MyFilms.ViewSortType viewSortType = MyFilms.ViewSortType.Name;
  92. public string ViewSortDirection
  93. {
  94. get { return viewSortDirection; }
  95. set { viewSortDirection = value; }
  96. }
  97. private string viewSortDirection = string.Empty;
  98. public string ViewFilter // to e.g. apply userdefined or global filters on view !
  99. {
  100. get { return viewFilter; }
  101. set { viewFilter = value; }
  102. }
  103. private string viewFilter = string.Empty;
  104. public MyFilms.Layout PersonsLayout
  105. {
  106. get { return personsLayout; }
  107. set { personsLayout = value; }
  108. }
  109. private MyFilms.Layout personsLayout = 0;
  110. public MyFilms.ViewSortType PersonsSortType // Name or Occurencies
  111. {
  112. get { return personsSortType; }
  113. set { personsSortType = value; }
  114. }
  115. private MyFilms.ViewSortType personsSortType = MyFilms.ViewSortType.Name;
  116. public string PersonsSortItemFriendlyName
  117. {
  118. get { return personsSortItemFriendlyName; }
  119. set { personsSortItemFriendlyName = value; }
  120. }
  121. private string personsSortItemFriendlyName = string.Empty;
  122. public string PersonsSortDirection
  123. {
  124. get { return personsSortDirection; }
  125. set { personsSortDirection = value; }
  126. }
  127. private string personsSortDirection = string.Empty;
  128. public MyFilms.Layout HierarchyLayout
  129. {
  130. get { return hierarchyLayout; }
  131. set { hierarchyLayout = value; }
  132. }
  133. private MyFilms.Layout hierarchyLayout = 0;
  134. public string HierarchySortItem
  135. {
  136. get { return hierarchySortItem; }
  137. set { hierarchySortItem = value; }
  138. }
  139. private string hierarchySortItem = string.Empty;
  140. public string HierarchySortItemFriendlyName
  141. {
  142. get { return hierarchySortItemFriendlyName; }
  143. set { hierarchySortItemFriendlyName = value; }
  144. }
  145. private string hierarchySortItemFriendlyName = string.Empty;
  146. public string HierarchySortDirection
  147. {
  148. get { return hierarchySortDirection; }
  149. set { hierarchySortDirection = value; }
  150. }
  151. private string hierarchySortDirection = string.Empty;
  152. public MyFilms.Layout FilmsLayout
  153. {
  154. get { return filmsLayout; }
  155. set { filmsLayout = value; }
  156. }
  157. private MyFilms.Layout filmsLayout = 0;
  158. public string FilmsSortItem
  159. {
  160. get { return filmsSortItem; }
  161. set { filmsSortItem = value; }
  162. }
  163. private string filmsSortItem = string.Empty;
  164. public string FilmsSortItemFriendlyName
  165. {
  166. get { return filmsSortItemFriendlyName; }
  167. set { filmsSortItemFriendlyName = value; }
  168. }
  169. private string filmsSortItemFriendlyName = string.Empty;
  170. public string FilmsSortDirection
  171. {
  172. get { return filmsSortDirection; }
  173. set { filmsSortDirection = value; }
  174. }
  175. private string filmsSortDirection = string.Empty;
  176. public void InitDefaults()
  177. {
  178. _ID = -1;
  179. viewContext = MyFilms.ViewContext.Menu;
  180. viewDisplayName = "Films";
  181. viewDBItem = "OriginalTitle";
  182. viewDBItemValue = "";
  183. viewLayout = MyFilms.Layout.List;
  184. viewSortType = MyFilms.ViewSortType.Name;
  185. viewSortDirection = " ASC";
  186. viewFilter = string.Empty;
  187. personsLayout = MyFilms.Layout.List;
  188. personsSortType = MyFilms.ViewSortType.Name;
  189. personsSortItemFriendlyName = string.Empty;
  190. personsSortDirection = " ASC";
  191. hierarchyLayout = MyFilms.Layout.List;
  192. hierarchySortItem = "OriginalTitle";
  193. hierarchySortItemFriendlyName = string.Empty;
  194. hierarchySortDirection = " ASC";
  195. filmsLayout = MyFilms.Layout.List;
  196. filmsSortItem = "SortTitle";
  197. filmsSortItemFriendlyName = string.Empty;
  198. filmsSortDirection = " ASC";
  199. }
  200. public string SaveToString()
  201. {
  202. string savestring = "";
  203. savestring = ID + "|" + ViewDisplayName + "|" + ViewDBItem + "|" + ViewDBItemValue + "|" +
  204. Enum.GetName(typeof(MyFilms.Layout), ViewLayout) + "|" + Enum.GetName(typeof(MyFilms.ViewSortType), ViewSortType) + "|" + ViewSortDirection + "|" + ViewFilter + "|" +
  205. Enum.GetName(typeof(MyFilms.Layout), PersonsLayout) + "|" + Enum.GetName(typeof(MyFilms.ViewSortType), PersonsSortType) + "|" + PersonsSortItemFriendlyName + "|" + PersonsSortDirection + "|" +
  206. Enum.GetName(typeof(MyFilms.Layout), HierarchyLayout) + "|" + HierarchySortItem + "|" + HierarchySortItemFriendlyName + "|" + HierarchySortDirection + "|" +
  207. Enum.GetName(typeof(MyFilms.Layout), FilmsLayout) + "|" + FilmsSortItem + "|" + FilmsSortItemFriendlyName + "|" + FilmsSortDirection;
  208. LogMyFilms.Debug("SaveToString() - output = '" + savestring + "'");
  209. return savestring;
  210. }
  211. public void LoadFromString(string inputstring)
  212. {
  213. int i = 0;
  214. string[] split = inputstring.Split(new char[] { '|' }, StringSplitOptions.None);
  215. LogMyFilms.Debug("LoadFromString() - parsed '" + split.Length + "' elements from inputstring = '" + inputstring + "'");
  216. foreach (string s in split)
  217. {
  218. LogMyFilms.Debug("LoadFromString() - Parsed Value [" + i + "] = '" + s + "'");
  219. i++;
  220. }
  221. ID = int.Parse(split[0]);
  222. // viewContext = (MyFilms.ViewContext)Enum.Parse(typeof(MyFilms.ViewContext), split[2], true);
  223. ViewDisplayName = split[1];
  224. ViewDBItem = split[2];
  225. ViewDBItemValue = split[3];
  226. ViewLayout = (MyFilms.Layout)Enum.Parse(typeof(MyFilms.Layout), split[4], true);
  227. ViewSortType = (MyFilms.ViewSortType)Enum.Parse(typeof(MyFilms.ViewSortType), split[5], true);
  228. ViewSortDirection = split[6];
  229. ViewFilter = split[7];
  230. PersonsLayout = (MyFilms.Layout)Enum.Parse(typeof(MyFilms.Layout), split[8], true);
  231. PersonsSortType = (MyFilms.ViewSortType)Enum.Parse(typeof(MyFilms.ViewSortType), split[9], true);
  232. PersonsSortItemFriendlyName = split[10];
  233. PersonsSortDirection = split[11];
  234. HierarchyLayout = (MyFilms.Layout)Enum.Parse(typeof(MyFilms.Layout), split[12], true);
  235. HierarchySortItem = split[13];
  236. HierarchySortItemFriendlyName = split[14];
  237. HierarchySortDirection = split[15];
  238. FilmsLayout = (MyFilms.Layout)Enum.Parse(typeof(MyFilms.Layout), split[16], true);
  239. FilmsSortItem = split[17];
  240. FilmsSortItemFriendlyName = split[18];
  241. FilmsSortDirection = split[19];
  242. }
  243. #endregion
  244. }
  245. public class CoverState
  246. {
  247. public CoverState(){}
  248. public CoverState(string menucover, string filmcover, string viewcover, string personcover, string groupcover)
  249. {
  250. MenuCover = menucover;
  251. FilmCover = filmcover;
  252. ViewCover = viewcover;
  253. PersonCover = personcover;
  254. GroupCover = groupcover;
  255. }
  256. #region public vars
  257. public string MenuCover { get; set; }
  258. public string FilmCover { get; set; }
  259. public string ViewCover { get; set; }
  260. public string PersonCover { get; set; }
  261. public string GroupCover { get; set; }
  262. #endregion
  263. }
  264. public class ViewState
  265. {
  266. public ViewState() { }
  267. private static NLog.Logger LogMyFilms = NLog.LogManager.GetCurrentClassLogger(); //log
  268. #region public vars
  269. private string strSelect = string.Empty;
  270. public string StrSelect
  271. {
  272. get { return strSelect; }
  273. set { strSelect = value; }
  274. }
  275. private string strPersons = string.Empty;
  276. public string StrPersons
  277. {
  278. get { return strPersons; }
  279. set { strPersons = value; }
  280. }
  281. private string strTitleSelect = string.Empty;
  282. public string StrTitleSelect
  283. {
  284. get { return strTitleSelect; }
  285. set { strTitleSelect = value; }
  286. }
  287. private string strFilmSelect = string.Empty;
  288. public string StrFilmSelect
  289. {
  290. get { return strFilmSelect; }
  291. set { strFilmSelect = value; }
  292. }
  293. private MyFilms.ViewContext viewContext = MyFilms.ViewContext.Menu;
  294. public MyFilms.ViewContext ViewContext
  295. {
  296. get { return viewContext; }
  297. set { viewContext = value; }
  298. }
  299. private string currentView = string.Empty;
  300. public string CurrentView
  301. {
  302. get { return currentView; }
  303. set { currentView = value; }
  304. }
  305. private string strTxtView = string.Empty;
  306. public string StrTxtView
  307. {
  308. get { return strTxtView; }
  309. set { strTxtView = value; }
  310. }
  311. private string strTxtSelect = string.Empty;
  312. public string StrTxtSelect
  313. {
  314. get { return strTxtSelect; }
  315. set { strTxtSelect = value; }
  316. }
  317. private bool boolselect;
  318. public bool Boolselect
  319. {
  320. get { return boolselect; }
  321. set { boolselect = value; }
  322. }
  323. private bool boolreturn;
  324. public bool Boolreturn
  325. {
  326. get { return boolreturn; }
  327. set { boolreturn = value; }
  328. }
  329. private bool boolindexed;
  330. public bool Boolindexed
  331. {
  332. get { return boolindexed; }
  333. set { boolindexed = value; }
  334. }
  335. private bool boolindexedreturn;
  336. public bool Boolindexedreturn
  337. {
  338. get { return boolindexedreturn; }
  339. set { boolindexedreturn = value; }
  340. }
  341. private int indexedChars = 0;
  342. public int IndexedChars
  343. {
  344. get { return indexedChars; }
  345. set { indexedChars = value; }
  346. }
  347. private bool boolReverseNames;
  348. public bool BoolReverseNames
  349. {
  350. get { return boolReverseNames; }
  351. set { boolReverseNames = value; }
  352. }
  353. private bool boolShowEmptyValuesInViews;
  354. public bool BoolShowEmptyValuesInViews
  355. {
  356. get { return boolShowEmptyValuesInViews; }
  357. set { boolShowEmptyValuesInViews = value; }
  358. }
  359. private bool boolSkipViewState = false;
  360. public bool BoolSkipViewState
  361. {
  362. get { return boolSkipViewState; }
  363. set { boolSkipViewState = value; }
  364. }
  365. private string wselectedlabel = string.Empty;
  366. public string Wselectedlabel
  367. {
  368. get { return wselectedlabel; }
  369. set { wselectedlabel = value; }
  370. }
  371. private string wStrSort = string.Empty;
  372. public string WStrSort
  373. {
  374. get { return wStrSort; }
  375. set { wStrSort = value; }
  376. }
  377. private string wStrSortSensCount = string.Empty;
  378. public string WStrSortSensCount
  379. {
  380. get { return wStrSortSensCount; }
  381. set { wStrSortSensCount = value; }
  382. }
  383. private bool boolSortCountinViews;
  384. public bool BoolSortCountinViews
  385. {
  386. get { return boolSortCountinViews; }
  387. set { boolSortCountinViews = value; }
  388. }
  389. private string wstar = string.Empty;
  390. public string Wstar
  391. {
  392. get { return wstar; }
  393. set { wstar = value; }
  394. }
  395. private int strLayOut = 0;
  396. public int StrLayOut
  397. {
  398. get { return strLayOut; }
  399. set { strLayOut = value; }
  400. }
  401. private int wStrLayOut = 0;
  402. public int WStrLayOut
  403. {
  404. get { return wStrLayOut; }
  405. set { wStrLayOut = value; }
  406. }
  407. private int strLayOutInHierarchies = 0;
  408. public int StrLayOutInHierarchies
  409. {
  410. get { return this.strLayOutInHierarchies; }
  411. set { this.strLayOutInHierarchies = value; }
  412. }
  413. private int lastID = 0;
  414. public int LastID
  415. {
  416. get { return lastID; }
  417. set { lastID = value; }
  418. }
  419. private int indexItem = 0;
  420. public int IndexItem
  421. {
  422. get { return indexItem; }
  423. set { indexItem = value; }
  424. }
  425. private string titleItem = string.Empty;
  426. public string TitleItem
  427. {
  428. get { return titleItem; }
  429. set { titleItem = value; }
  430. }
  431. // CurrentView", MyFilms.conf.CurrentView.SaveToString());
  432. #endregion
  433. public void InitDefaults()
  434. {
  435. strSelect = string.Empty;
  436. strPersons = string.Empty;
  437. strTitleSelect = string.Empty;
  438. strFilmSelect = string.Empty;
  439. viewContext = MyFilms.ViewContext.Menu;
  440. strTxtView = string.Empty;
  441. strTxtSelect = string.Empty;
  442. boolselect = false;
  443. boolreturn = false;
  444. boolindexed = false;
  445. boolindexedreturn = false;
  446. indexedChars = 0;
  447. boolReverseNames = false;
  448. boolShowEmptyValuesInViews = false;
  449. wselectedlabel = string.Empty;
  450. wStrSort = string.Empty;
  451. wStrSortSensCount = string.Empty;
  452. boolSortCountinViews = false;
  453. wstar = string.Empty;
  454. strLayOut = 0;
  455. wStrLayOut = 0;
  456. strLayOutInHierarchies = 0;
  457. lastID = 0;
  458. indexItem = 0;
  459. titleItem = string.Empty;
  460. }
  461. public string SaveToString()
  462. {
  463. string savestring =
  464. strSelect + "|" +
  465. strPersons + "|" +
  466. strTitleSelect + "|" +
  467. strFilmSelect + "|" +
  468. Enum.GetName(typeof(MyFilms.Layout), viewContext) + "|" +
  469. strTxtView + "|" +
  470. strTxtSelect + "|" +
  471. boolselect.ToString() + "|" +
  472. boolreturn.ToString() + "|" +
  473. boolindexed.ToString() + "|" +
  474. boolindexedreturn.ToString() + "|" +
  475. indexedChars.ToString() + "|" +
  476. boolReverseNames.ToString() + "|" +
  477. boolShowEmptyValuesInViews.ToString() + "|" +
  478. wselectedlabel + "|" +
  479. wStrSort + "|" +
  480. wStrSortSensCount + "|" +
  481. boolSortCountinViews.ToString() + "|" +
  482. wstar + "|" +
  483. strLayOut.ToString() + "|" +
  484. wStrLayOut.ToString() + "|" +
  485. strLayOutInHierarchies.ToString() + "|" +
  486. lastID.ToString() + "|" +
  487. indexItem.ToString() + "|" +
  488. titleItem;
  489. LogMyFilms.Debug("SaveToString() - output = '" + savestring + "'");
  490. return savestring;
  491. }
  492. public void LoadFromString(string inputstring)
  493. {
  494. int i = 0;
  495. string[] split = inputstring.Split(new char[] { '|' }, StringSplitOptions.None);
  496. LogMyFilms.Debug("LoadFromString() - parsed '" + split.Length + "' elements from inputstring = '" + inputstring + "'");
  497. foreach (string s in split)
  498. {
  499. LogMyFilms.Debug("LoadFromString() - Parsed Value [" + i + "] = '" + s + "'");
  500. i++;
  501. }
  502. strSelect = split[0];
  503. strPersons = split[1];
  504. strTitleSelect = split[2];
  505. strFilmSelect = split[3];
  506. viewContext = (MyFilms.ViewContext)Enum.Parse(typeof(MyFilms.ViewContext), split[4], true); // MyFilms.ViewContext.Menu;
  507. strTxtView = split[5];
  508. strTxtSelect = split[6];
  509. boolselect = bool.Parse(split[7]);
  510. boolreturn = bool.Parse(split[8]);
  511. boolindexed = bool.Parse(split[9]);
  512. boolindexedreturn = bool.Parse(split[10]);
  513. indexedChars = int.Parse(split[11]);
  514. boolReverseNames = bool.Parse(split[12]);
  515. boolShowEmptyValuesInViews = bool.Parse(split[13]);
  516. wselectedlabel = split[14];
  517. wStrSort = split[15];
  518. wStrSortSensCount = split[16];
  519. boolSortCountinViews = bool.Parse(split[17]);
  520. wstar = split[18];
  521. strLayOut = int.Parse(split[19]);
  522. wStrLayOut = int.Parse(split[20]);
  523. strLayOutInHierarchies = int.Parse(split[21]);
  524. lastID = int.Parse(split[22]);
  525. indexItem = int.Parse(split[23]);
  526. titleItem = split[24];
  527. }
  528. }
  529. }