private void _InitStatTopic() { lstTopic.Items.Clear(); string[] arrTopic = new string[] { "General", "Type", "Country", "Rating", "Actress", "Tag", "FilePath", "CountPlay", }; for (int i = 0; i < arrTopic.Length; i++) { lstTopic.Items.Add(arrTopic[i]); hTopic[arrTopic[i]] = new ptkConfig(); } lstTopic.Enabled = false; lstTopic.Visible = false; this.__RebuildStat(); lstTopic.Visible = true; lstTopic.Enabled = true; lstTopic.Focus(); lstTopic.SelectedIndex = 0; }
private void ___CalculateStat_General(ptkConfig stat, MovieProfile profile) { stat[kwTotalMovieProfile] = (stat.GetInt(kwTotalMovieProfile) + 1).ToString(); if (profile.FilePath.Length > 0) { stat[kwLocalProfile] = (stat.GetInt(kwLocalProfile) + 1).ToString(); switch (profile.FileConnect) { case "Y": stat[kwFileOnLine] = (stat.GetInt(kwFileOnLine) + 1).ToString(); break; case "N": stat[kwFileOffLine] = (stat.GetInt(kwFileOffLine) + 1).ToString(); break; case "?": stat[kwFileUnknow] = (stat.GetInt(kwFileUnknow) + 1).ToString(); break; } } else { stat[kwGlobalProfile] = (stat.GetInt(kwGlobalProfile) + 1).ToString(); } }
private void DoShowDetailByTopic(string topic) { lvwDetail.SuspendLayout(); //------------------------ _ClearDetailList(topic); if (!hTopic.Contains(topic)) { that.DebugAndLog("Not found topic [" + topic + "] in hTopic !!!"); return; } ptkConfig stat = (ptkConfig)hTopic[topic]; string[] arrK = new string[stat.Keys.Count]; foreach (string k in stat.Keys) { string stat_value = stat[k].PadLeft(12, ' '); lvwDetail.Items.Add(new ListViewItem(new string[] { k, stat_value })); } for (int i = 0; i < lvwDetail.Columns.Count; i++) { lvwDetail.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.ColumnContent); if (lvwDetail.Columns[i].Width < int.Parse((string)lvwDetail.Columns[i].Tag)) { lvwDetail.AutoResizeColumn(i, ColumnHeaderAutoResizeStyle.HeaderSize); } } lvwColumnSorter.SortColumn = -1; lvwDetail_ColumnClick(lvwDetail, new ColumnClickEventArgs(0)); //------------------------ lvwDetail.ResumeLayout(); }
private void __RebuildStat() { ptkConfig statGeneral = (ptkConfig)hTopic["General"]; { statGeneral[kwFileOffLine] = "0"; statGeneral[kwFileOnLine] = "0"; statGeneral[kwFileUnknow] = "0"; statGeneral[kwGlobalProfile] = "0"; statGeneral[kwLocalProfile] = "0"; statGeneral[kwTotalMovieProfile] = "0"; } ptkConfig statType = (ptkConfig)hTopic["Type"]; ptkConfig statCountry = (ptkConfig)hTopic["Country"]; ptkConfig statRating = (ptkConfig)hTopic["Rating"]; ptkConfig statActress = (ptkConfig)hTopic["Actress"]; ptkConfig statTag = (ptkConfig)hTopic["Tag"]; ptkConfig statFilePath = (ptkConfig)hTopic["FilePath"]; ptkConfig statCountPlay = (ptkConfig)hTopic["CountPlay"]; theProgress.Visible = true; theProgress.Minimum = 0; theProgress.Value = 0; theProgress.Maximum = MovieDB.hMovie.Count; string[] arrK = new string[MovieDB.hMovie.Count]; MovieDB.hMovie.Keys.CopyTo(arrK, 0); MovieProfile profile = null; for (int k = 0; k < arrK.Length; k++) { lock (MovieDB.hMovie.SyncRoot) { if (!MovieDB.hMovie.Contains(arrK[k])) { continue; } // Cloning profile for Safety in build state Process profile = ptkGeneral.CloneObject <MovieProfile>((MovieProfile)MovieDB.hMovie[arrK[k]]); } ___CalculateStat_General(statGeneral, profile); ___CalculateStat_Type(statType, profile); ___CalculateStat_Country(statCountry, profile); ___CalculateStat_Rating(statRating, profile); ___CalculateStat_Actress(statActress, profile); ___CalculateStat_Tag(statTag, profile); ___CalculateStat_FilePath(statFilePath, profile); ___CalculateStat_CountPlay(statCountPlay, profile); profile = null; // After finish Calculate stat Disponse cloning profile theProgress.Value++; this.Refresh(); } theProgress.Visible = false; }
private void ___CalculateStat_FilePath(ptkConfig stat, MovieProfile profile) { if (profile.FilePath.Length.Equals(0)) { return; } string strPath = Path.GetDirectoryName(profile.FilePath); stat[strPath] = (stat.GetInt(strPath) + 1).ToString(); }
private void ___CalculateStat_Tag(ptkConfig stat, MovieProfile profile) { if (profile.Tag.Length.Equals(0)) { return; } string[] arrTag = profile.Tag.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arrTag.Length; i++) { stat[arrTag[i]] = (stat.GetInt(arrTag[i]) + 1).ToString(); } }
private void ___CalculateStat_CountPlay(ptkConfig stat, MovieProfile profile) { string sCount = profile.CountPlay.ToString(); stat[sCount] = (stat.GetInt(sCount) + 1).ToString(); }
private void ___CalculateStat_Rating(ptkConfig stat, MovieProfile profile) { string cRating = "+" + profile.Rating.ToString(); stat[cRating] = (stat.GetInt(cRating) + 1).ToString(); }
private void ___CalculateStat_Type(ptkConfig stat, MovieProfile profile) { string cType = profile.Type; stat[cType] = (stat.GetInt(cType) + 1).ToString(); }
public static bool InitConfig() { zLog.Write("that.InitConfig Begin"); if (!Directory.Exists(pathConfig)) { zLog.Write("Create new config folder [" + pathConfig + "]"); try { Directory.CreateDirectory(pathConfig); } catch (Exception ex) { zLog.Write("Error create config [" + pathConfig + "]"); zLog.Write(ex.Message); return(false); } } zLog.Write("Begin Load config file [" + fileConfig + "]"); Config = new ptkConfig(); if (!Config.LoadFromFile(fileConfig)) { zLog.Write("Error in load config file [" + fileConfig + "]"); zLog.Write("Try created new"); Config = new ptkConfig(); Config[KW.CreatedTime] = ptkConvert.DateTimeToSqlFormatWithMSec(DateTime.Now); if (!Config.SaveToFile(fileConfig)) { zLog.WriteCritical("Error in save Config File! " + Config.LastError); return(false); } } else { zLog.Write("Load config data success, Total " + Config.Count.ToString() + " elements"); } zLog.Write("Begin Load filter file [" + fileFilter + "]"); Filter = new ptkConfig(); if (!Filter.LoadFromFile(fileFilter)) { zLog.Write("Error in load filter file[" + fileFilter + "]"); zLog.Write("Try created new"); Filter = new ptkConfig(); Filter[KW.CreatedTime] = ptkConvert.DateTimeToSqlFormatWithMSec(DateTime.Now); if (!Filter.SaveToFile(fileFilter)) { zLog.WriteCritical("Error in save Filter File! " + Config.LastError); return(false); } } else { zLog.Write("Load filter data success, Total " + Filter.Count.ToString() + " elements"); } //-- Clear & Predefine some config that.Config[KW.ProfileTop] = "0"; // First Time Must top-left = 0, Prevent Screen Resolution Mode that.Config[KW.ProfileLeft] = "0"; //-- Predefine some Configuration if (!that.Config.Contains(KW.AutoBuildHashIfEmpty)) { that.Config[KW.AutoBuildHashIfEmpty] = KW.YES; } // Everything OK return(true); }