internal static string GetDefaultGroupName() { string gp = GetDefaultGroupPath(); string gn = Globals.GetLastPartOfDir(gp); return(gn); }
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 FetchPhoneCardGroups() { string[] groups = com.GetListOfCardGroups(); cmbPhoneCardGroup.Items.Clear(); cmbPhoneCardGroup.Items.Add("[ALL]"); foreach (string g in groups) { cmbPhoneCardGroup.Items.Add(Globals.GetLastPartOfDir(g)); } cmbPhoneCardGroup.SelectedIndex = 0; }
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; }
public string GetGroupName() { string gp = GetGroupPath(); try { return(Globals.GetLastPartOfDir(gp)); } catch (Exception) { return(""); } }
private static void BuildHtmlGroupInfo(string group, FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler) { if (ProcessInfoHandler != null) { ProcessInfoHandler(group); } string[] card_paths = Globals.GetPathOfEachCard(group); if (card_paths == null) { return; } byte[] file_bytes = GroupTemplate; string card_group_doc = ASCIIEncoding.ASCII.GetString(file_bytes); card_group_doc = card_group_doc.Replace("$home", GetButton("Home", 100, 30, "../RememberIt.html")); card_group_doc = card_group_doc.Replace("$group_name", Globals.GetLastPartOfDir(group)); card_group_doc = card_group_doc.Replace("$missed_cards", GetButtonsForMissedCards(group)); card_group_doc = card_group_doc.Replace("$pending_cards", GetButtonsForPendingCards(group)); card_group_doc = card_group_doc.Replace("$stage_0", GetButtonsForStage(group, 0)); card_group_doc = card_group_doc.Replace("$stage_1", GetButtonsForStage(group, 1)); card_group_doc = card_group_doc.Replace("$stage_2", GetButtonsForStage(group, 2)); card_group_doc = card_group_doc.Replace("$stage_3", GetButtonsForStage(group, 3)); card_group_doc = card_group_doc.Replace("$stage_4", GetButtonsForStage(group, 4)); card_group_doc = card_group_doc.Replace("$stage_5", GetButtonsForStage(group, 5)); 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; File.WriteAllBytes(group + "/Group.html", file_bytes); //foreach (string cp in card_paths) //{ // try // { // } // catch // { // continue; // } //} }
public void Diagnose() { dgvDefections.Rows.Clear(); List <string> defective_cards = Globals.GetListOfDefectiveCards(); int row = 0; foreach (string cp in defective_cards) { row++; string card_name = Globals.GetLastPartOfDir(cp); int q_cnt = Globals.GetNumberOfFiles(cp + "\\Q"); int a_cnt = Globals.GetNumberOfFiles(cp + "\\A"); int r_cnt = Globals.GetNumberOfFiles(cp + "\\R"); dgvDefections.Rows.Add(row, false, card_name, cp, q_cnt, a_cnt, r_cnt); } }
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 static string GetButtonsForMissedCards(string CardGroup) { string buttons = ""; string[] missed_cards = Globals.GetPathOfEachMissedCard(CardGroup); if (missed_cards == null) { return(""); } var cards = Globals.GetListOfCards(missed_cards); foreach (Card card in cards) { string btn_text = Globals.GetLastPartOfDir(card.CardAbsPath); string href = string.Format("{0}/Q.html", btn_text); buttons += GetButton(btn_text, 200, 30, href); buttons += "<br />"; buttons += "\r\n"; } return(buttons); }
private void btnNewGroup_Click(object sender, EventArgs e) { if (txtNewGroupName.Text.Trim() == "") { MessageBox.Show("Invalid Group Name."); return; } string cards_path = Globals.GetCardsPath(); string grp_path = cards_path + txtNewGroupName.Text.Trim(); try { DirectoryInfo di = Directory.CreateDirectory(grp_path); if (di.Exists) { MessageBox.Show("Group Created!"); this.Init(); string grp_name = Globals.GetLastPartOfDir(di.FullName); for (int i = 0; i < cmbGroups.Items.Count; i++) { if (cmbGroups.Items[i].ToString() == grp_name) { cmbGroups.SelectedIndex = i; break; } } } else { MessageBox.Show("Unable to create group"); } } catch (Exception ex) { MessageBox.Show("Invalid Group Name.\r\n" + ex.Message); } }
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(); }