private static void BuildRootDocument(FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler) { if (ProcessInfoHandler != null) { ProcessInfoHandler("RememberIt.html"); } string root_path = Globals.GetCardsPath(); string[] group_paths = Globals.GetPathOfEachGroup(); if (group_paths == null) { return; } byte[] file_bytes = RememberItTemplate; string card_group_doc = ASCIIEncoding.ASCII.GetString(file_bytes); card_group_doc = card_group_doc.Replace("$groups", Globals.GetButtonsForGroups()); file_bytes = ASCIIEncoding.ASCII.GetBytes(card_group_doc); if (file_bytes.Length <= 3) { return; } file_bytes[0] = 0xEF; file_bytes[1] = 0xBB; file_bytes[2] = 0xBF; string html_file_name = root_path + "/RememberIt.html"; File.WriteAllBytes(html_file_name, file_bytes); Process.Start(html_file_name); }
internal static void BuildHtmlDocs(FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler) { string[] all_cards_paths = Globals.GetPathOfEachCard(); foreach (string card_path in all_cards_paths) { try { BuildHtmlDocs(card_path, ProcessInfoHandler); } catch { continue; } } string[] all_groups = Globals.GetPathOfEachGroup(); if (all_groups != null) { foreach (string group in all_groups) { try { BuildHtmlGroupInfo(group, ProcessInfoHandler); } catch { continue; } } } BuildRootDocument(ProcessInfoHandler); }
private void btnClonePcToPhone_Click(object sender, EventArgs e) { string[] pc_side_groups = Globals.GetPathOfEachGroup(); string group = ""; foreach (string g in pc_side_groups) { group = Globals.GetLastPartOfDir(g); com.DirCreate("Cards/"+group); } }
private void GetPcCardGroups() { string[] groups = Globals.GetPathOfEachGroup(); cmbPcCardGroup.Items.Clear(); cmbPcCardGroup.Items.Add("[ALL]"); foreach (string g in groups) { cmbPcCardGroup.Items.Add(Globals.GetLastPartOfDir(g)); } cmbPcCardGroup.SelectedIndex = 0; }
private static string GetButtonsForGroups() { string buttons = ""; string[] groups = Globals.GetPathOfEachGroup(); if (groups == null) { return(""); } foreach (string group in groups) { string btn_text = Globals.GetLastPartOfDir(group); string href = string.Format("{0}/Group.html", btn_text); buttons += GetButton(btn_text, 200, 30, href); buttons += "<br />"; buttons += "\r\n"; } return(buttons); }
public void Init() { if (this.is_initialized) { return; } cmbCardGroups.Items.Clear(); cmbCardGroups.Items.Add("[ALL]"); string[] groups = Globals.GetPathOfEachGroup(); this.CardGroupPaths = groups; foreach (string grp_path in groups) { string grp = Globals.GetLastPartOfDir(grp_path); cmbCardGroups.Items.Add(grp); } cmbCardGroups.SelectedIndex = 0; this.is_initialized = true; }
private void Init() { this.GroupPaths = Globals.GetPathOfEachGroup(); if (GroupPaths == null) { return; } if (GroupPaths.Length == 0) { return; } cmbGroups.Items.Clear(); for (int i = 0; i < GroupPaths.Length; i++) { string grp_str = Globals.GetLastPartOfDir(GroupPaths[i]); cmbGroups.Items.Add(grp_str); } cmbGroups.SelectedIndex = 0; }
private void Init() { this.AddExtButton( grdContent, 0, /*Col Index*/ "New Card", "Add a new Card", "pack://application:,,,/pic/plus_64.png", OnNewCardClicked, null,/*Tag*/ out btnNewCard); this.AddExtButton( grdContent, 0, /*Col Index*/ "Search", "Search & Filter", "pack://application:,,,/pic/search_64.png", OnSearchClicked, null,/*Tag*/ out btnSearch ); string def_grp_name = Globals.GetDefaultGroupName(); this.AddExtButton( grdContent, 0, /*Col Index*/ string.Format("Default Group: [{0}]", def_grp_name), "Press to change the default group.", "pack://application:,,,/pic/group_64.png", OnChangeDefaultGroupClicked, null, /*Tag*/ out btnDefaultGroup); if (this.Face == Faces.ShowMissedCards) { int cnt = Globals.GetNumberOfMissedCards(); this.AddExtButton( grdContent, 0, /*Col Index*/ string.Format("Missed: [{0}]", cnt), "Total Missed cards", "pack://application:,,,/pic/missed_64.png", OnShowMissedCardsClicked, "[ALL]", out btnCards ); string[] groups = Globals.GetPathOfEachGroup(); if (groups != null) { foreach (string group_path in groups) { string group_name = Globals.GetLastPartOfDir(group_path); cnt = Globals.GetNumberOfMissedCards(group_path); if (cnt == 0) { continue; } CtrlExtButton btn_grp = null; int row_index = this.AddExtButton( grdCards, 1, /*Col Index*/ string.Format("{0}: [{1}]", group_name, cnt), string.Format("You have {0} cards avilable", cnt), "pack://application:,,,/pic/group_128.png", OnShowMissedCardsClicked, group_path, out btn_grp); btnCardGroups.Add(btn_grp); this.SetImageToGrid( grdCards, "pack://application:,,,/pic/down_right_100.png", row_index, 0); } } } else if (this.Face == Faces.ShowPendingCards) { int cnt = Globals.GetNumberOfPendingCards(); this.AddExtButton( grdContent, 0, /*Col Index*/ string.Format("Pending: [{0}]", cnt), "Total Pending cards", "pack://application:,,,/pic/alarm_64.png", OnShowPendingCardsClicked, "[ALL]", out btnCards ); string[] groups = Globals.GetPathOfEachGroup(); if (groups != null) { foreach (string group_path in groups) { string group_name = Globals.GetLastPartOfDir(group_path); cnt = Globals.GetNumberOfPendingCards(group_path); if (cnt == 0) { continue; } CtrlExtButton btn_grp = null; int row_index = this.AddExtButton( grdCards, 1, /*Col Index*/ string.Format("{0}: [{1}]", group_name, cnt), string.Format("You have {0} cards avilable", cnt), "pack://application:,,,/pic/group_128.png", OnShowPendingCardsClicked, group_path, out btn_grp); btnCardGroups.Add(btn_grp); this.SetImageToGrid( grdCards, "pack://application:,,,/pic/down_right_100.png", row_index, 0); } } } else if (this.Face == Faces.ShowAllCards) { int cnt = Globals.GetNumberOfAllCards(); this.AddExtButton( grdContent, 0, /*Col Index*/ string.Format("All: [{0}]", cnt), "Total cards", "pack://application:,,,/pic/star_128.png", OnShowAllCardsClicked, "[ALL]", out btnCards ); string[] groups = Globals.GetPathOfEachGroup(); if (groups != null) { foreach (string group_path in groups) { string group_name = Globals.GetLastPartOfDir(group_path); cnt = Globals.GetNumberOfCards(group_path); if (cnt == 0) { continue; } CtrlExtButton btn_grp = null; int row_index = this.AddExtButton( grdCards, 1, /*Col Index*/ string.Format("{0}: [{1}]", group_name, cnt), string.Format("You have {0} cards avilable", cnt), "pack://application:,,,/pic/group_128.png", OnShowAllCardsClicked, group_path, out btn_grp); btnCardGroups.Add(btn_grp); this.SetImageToGrid( grdCards, "pack://application:,,,/pic/down_right_100.png", row_index, 0); } } } }
private void btnRefresh_Click(object sender, EventArgs e) { dgvCards.Rows.Clear(); string[] Phone_cards = com.GetListOfCards(cmbPhoneCardGroup.SelectedItem.ToString()); string[] Pc_cards =null; int row = 0; foreach (string phone_side_card in Phone_cards) { int indx = dgvCards.Rows.Add(1); dgvCards.Rows[indx].Cells[clmnRow.Index].Value = ++row; dgvCards.Rows[indx].Cells[clmnSelectPcCard.Index].Value = false; dgvCards.Rows[indx].Cells[clmnCard.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnAction.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnSelectPhCard.Index].Value = false; dgvCards.Rows[indx].Cells[clmnCardPhone.Index].Value = Globals.GetLastPartOfDir(phone_side_card); dgvCards.Rows[indx].Cells[clmnCardPathPc.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnCardPathPhone.Index].Value = phone_side_card; dgvCards.Rows[indx].Cells[clmnCroup.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnManifestDataPc.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnManifestDataPhone.Index].Value = ""; } if (cmbPcCardGroup.SelectedIndex == 0) { List<string> all_cards = new List<string>(); string[] groups = Globals.GetPathOfEachGroup(); foreach (string group in groups) { string[] cards = Globals.GetPathOfEachCard(group); foreach (string card in cards) { all_cards.Add(card); } } Pc_cards = all_cards.ToArray(); } else { string group = group = Globals.GetCardsPath() + "\\" + cmbPcCardGroup.SelectedItem.ToString(); Pc_cards = Globals.GetPathOfEachCard(group); } if (Phone_cards != null) { if (Pc_cards!=null) foreach (string card_dir_path in Pc_cards) { string card_name = Globals.GetLastPartOfDir(card_dir_path); int idx = Lookup(card_name, dgvCards); if (idx == -1) { int indx = dgvCards.Rows.Add(1); dgvCards.Rows[indx].Cells[clmnRow.Index].Value = ++row; dgvCards.Rows[indx].Cells[clmnSelectPcCard.Index].Value = false; dgvCards.Rows[indx].Cells[clmnCard.Index].Value = card_name; dgvCards.Rows[indx].Cells[clmnAction.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnSelectPhCard.Index].Value = false; dgvCards.Rows[indx].Cells[clmnCardPhone.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnCardPathPc.Index].Value = card_dir_path; dgvCards.Rows[indx].Cells[clmnCardPathPhone.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnCroup.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnManifestDataPc.Index].Value = ""; dgvCards.Rows[indx].Cells[clmnManifestDataPhone.Index].Value = ""; } else { dgvCards.Rows[idx].Cells[clmnCard.Index].Value = card_name; dgvCards.Rows[idx].Cells[clmnCardPathPc.Index].Value = card_dir_path; } } } // Extract manifest data for (int i = 0; i < dgvCards.Rows.Count; i++) { // Extract manifest data of phone-side cards string card_path_phone = (string)dgvCards.Rows[i].Cells[clmnCardPathPhone.Index].Value; string manifest_phone = ""; if (card_path_phone != "") { manifest_phone = com.GetManifestData(card_path_phone); dgvCards.Rows[i].Cells[clmnManifestDataPhone.Index].Value = manifest_phone; } // Extract manifest data of pc-side cards string card_path_pc = (string)dgvCards.Rows[i].Cells[clmnCardPathPc.Index].Value; string manifest_pc = ""; if (card_path_pc != "") { manifest_pc = File.ReadAllText(card_path_pc+"/manifest.man"); KeyValPair kvp = new KeyValPair('\n','='); kvp.Fill(manifest_pc); manifest_pc = kvp.GetString(';',':'); dgvCards.Rows[i].Cells[clmnManifestDataPc.Index].Value = manifest_pc; } } // Define proper action for transfering cards to/from pc from/to phone. for (int i = 0; i < dgvCards.Rows.Count; i++) { string manifest_phone = (string)dgvCards.Rows[i].Cells[clmnManifestDataPhone.Index].Value; string manifest_pc = (string)dgvCards.Rows[i].Cells[clmnManifestDataPc.Index].Value; if (manifest_phone == "" && manifest_pc == "") continue; else if (manifest_phone == "") dgvCards.Rows[i].Cells[clmnAction.Index].Value = "--->"; else if (manifest_pc == "") dgvCards.Rows[i].Cells[clmnAction.Index].Value = "<---"; else { KeyValPair kvp_phone = new KeyValPair(';', ':'); kvp_phone.Fill(manifest_phone); KeyValPair kvp_pc = new KeyValPair(';', ':'); kvp_pc.Fill(manifest_pc); double ph_last_modified = 0; double pc_last_modified = 0; try { ph_last_modified = Double.Parse(kvp_phone.GetVal("last_modified")); pc_last_modified = Double.Parse(kvp_pc.GetVal("last_modified")); } catch { dgvCards.Rows[i].Cells[clmnAction.Index].Value = "!"; continue; } if (pc_last_modified == ph_last_modified) dgvCards.Rows[i].Cells[clmnAction.Index].Value = "<--->"; else if (pc_last_modified > ph_last_modified) dgvCards.Rows[i].Cells[clmnAction.Index].Value = "--->"; else dgvCards.Rows[i].Cells[clmnAction.Index].Value = "<---"; } } if (chbxShowDiffs.Checked) ShowOnlyDiffs(); }