private void ShowSavedThreadData(string sPath, int iStartIndex, TreeLbItem tiHead = null) { RscStore store = new RscStore(); sPath += "\\Threads"; if (!store.FolderExists(sPath)) { return; } int iCountAll = 0; iCountAll = store.ReadXmlDataFile(sPath + "\\" + "Count" + ".xml", iCountAll); int iCount_NonAckAll = 0; iCount_NonAckAll = store.ReadXmlDataFile(sPath + "\\" + "Count_NonAck" + ".xml", iCount_NonAckAll); if (iStartIndex == 0) { m_tiSum = new TreeLbItem(m_aTI, null); m_tiSum.DetailsFontSize = cdFontSize; UpdateSumItem(iCount_NonAckAll, iCountAll); m_aTI.Add(m_tiSum); tiHead = new TreeLbItem(m_aTI, null); //tiHead.DetailsFontSize = cdFontSize; tiHead.DetailsOnly = "..."; m_aTI.Add(tiHead); } string sThreadIdOrder = ""; sThreadIdOrder = store.ReadTextFile(sPath + "\\" + "IdOrder" + ".txt", sThreadIdOrder); string [] asThreadIdOrders = sThreadIdOrder.Split('|'); bool bMoreItems = false; int iThCnt = asThreadIdOrders.Length; for (int iTh = iStartIndex; iTh < iThCnt; iTh++) { //NOT all... if ((iTh - iStartIndex) >= ciMaxAtOnce) { bMoreItems = true; break; } string sID = asThreadIdOrders[iTh]; if (sID.Length == 0) { continue; } if (!store.FolderExists(sPath + "\\" + sID)) { continue; } string sIdOrder = ""; sIdOrder = store.ReadTextFile(sPath + "\\" + sID + "\\" + "IdOrder" + ".txt", sIdOrder); string [] asIdOrders = sIdOrder.Split('|'); string sHistoryID = asIdOrders[0]; if (sHistoryID.Length == 0) { continue; } if (!store.FileExists(sPath + "\\" + sID + "\\" + sHistoryID + ".xml")) { continue; } MyThread2 th = new MyThread2(); th = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sHistoryID + ".xml", th); if (th.ID.Length == 0) { continue; } TreeLbItem ti = new TreeLbItem(m_aTI, null); // ti.DetailsFontSize = cdFontSize; ti.DetailsBackColor = m_AppFrame.Theme.ThemeColors.TextDarkBack; ti.DetailsForeColor = m_AppFrame.Theme.ThemeColors.TextDarkFore; if (!th.Acknowledged) { ti.CustomBackColor = Colors.Orange; ti.BtnCustom1Visibility = Rsc.Visible; } ti.BtnCustom1Image = m_isCheckOn; //Off; // string sTitle = ""; sTitle += RscUtils.toDateDiff(th.DateSaved); if (asIdOrders.Length > 1) { sTitle += " ( +" + (asIdOrders.Length - 1).ToString() + " )"; } ti.Title = sTitle; ti.DetailsOfTitle = TreeLbItemThread.DecorateSnippet(th); ti.IsLeaf = (asIdOrders.Length <= 1); m_aTI.Add(ti); ti.sID = sID; ti.sHistoryID = sHistoryID; foreach (string sId in asIdOrders) { if (sId.Length == 0) { continue; } if (sId == sHistoryID) { continue; } MyThread2 thSub = new MyThread2(); thSub = store.ReadXmlDataFile(sPath + "\\" + sID + "\\" + sId + ".xml", thSub); if (thSub.ID.Length == 0) { continue; } //DO NOT!!! /* * TreeLbItem tiSub = new TreeLbItem( m_aTI, ti ); * tiSub.Title = RscUtils.toDateDiff( thSub.DateSaved ) + "retrived..."; * tiSub.DetailsOfTitle = thSub.Snippet; * tiSub.IsLeaf = true; * m_aTI.Add( tiSub ); */ ti.m_a.Add(thSub); } } if (tiHead != null) { string sTit = "Threads " + (iStartIndex + 1).ToString() + " - "; if (bMoreItems) { sTit += (iStartIndex + ciMaxAtOnce).ToString(); } else { sTit += iThCnt.ToString(); } //tiHead.DetailsFontSize = cdFontSize; tiHead.DetailsOnly = sTit; } if (bMoreItems) { TreeLbItem ti = new TreeLbItem(m_aTI, null); ti.Title = "Threads " + (iStartIndex + ciMaxAtOnce + 1).ToString() + " - ... (press to list)"; ti.sID = csMoreItems; ti.sHistoryID = (iStartIndex + ciMaxAtOnce).ToString(); ti.CustomBackColor = m_AppFrame.Theme.ThemeColors.TreeDescBack; ti.CustomForeColor = m_AppFrame.Theme.ThemeColors.TreeDescFore; m_aTI.Add(ti); } }
private void m_btnSaveToPhone_Click(object sender, System.Windows.RoutedEventArgs e) { if (m_iIndex < 0) { return; } if (m_iIndex >= m_aVideos.Count) { return; } string sPath = m_aVideos[m_iIndex]; // // // string sTnPath = ""; int iPos = sPath.LastIndexOf('\\'); if (iPos < 0) { iPos = 0; } else { iPos++; } int iPos2 = sPath.LastIndexOf('.'); if (iPos2 >= 0) { if (iPos > 0) { sTnPath += sPath.Substring(0, iPos); } sTnPath += "tn\\"; sTnPath += sPath.Substring(iPos, iPos2 - iPos); sTnPath += ".tn"; sTnPath += ".jpg"; //sPath.Substring( iPos2 ); } // // // RscStore store = new RscStore(); if (!store.FileExists(sTnPath)) { sTnPath = ""; } //MessageBox.Show( sPath + "\r\n" + sTnPath ); RscPageArgsRet appInput = new RscPageArgsRet(m_AppArgs, ApplicationTitle.Text, "Images/Ico001_Ressive.jpg", "SaveToPhone"); appInput.SetData(0, sPath); appInput.SetData(1, sTnPath); appInput.SetInput("RscDC_FlashV10"); this.NavigationService.Navigate(appInput.GetNavigateUri("RscDC")); }
private void btnEx_Click(object sender, System.Windows.RoutedEventArgs e) { if (m_tags == null) { return; } switch (m_tags.GetType().ToString()) { case "Ressive.Formats.RscTextTags_VCF": { RscStore store = new RscStore(); store.CreateFolderPath("A:\\Desktop\\Contacts\\tn"); string sPath = "A:\\Desktop\\Contacts\\" + ((RscTextTags_VCF)m_tags).Name + ".txt"; string sPathTn = "A:\\Desktop\\Contacts\\tn\\" + ((RscTextTags_VCF)m_tags).Name + ".txt.jpg"; if (store.FileExists(sPath)) { store.DeleteFile(sPath); store.DeleteFile(sPathTn); btnEx.Content = "Add to Desktop"; BtnGridEx.Background = new SolidColorBrush(Colors.Green); } else { try { store.WriteTextFile(sPath, m_aPathes[m_iIndex], true); if (((RscTextTags_VCF)m_tags).PhotoPresent && ((RscTextTags_VCF)m_tags).PhotoIsBase64 && ((RscTextTags_VCF)m_tags).PhotoIs("JPEG")) { string sBase64 = ((RscTextTags_VCF)m_tags).PhotoData; //RscFs.WriteTextFile( "vcf.photo.txt", sBase64, true ); byte [] ayImage = Convert.FromBase64String(sBase64); if (store.FileExists(sPathTn)) { store.DeleteFile(sPathTn); } if (ayImage != null) { if (ayImage.Length > 0) { System.IO.Stream stream = store.CreateFile(sPathTn); stream.Write(ayImage, 0, ayImage.Length); stream.Close(); } } } } catch (Exception) { MessageBox.Show("ERROR: Unable to create Desktop icon for Contact!"); return; } btnEx.Content = "Remove from Desktop"; BtnGridEx.Background = new SolidColorBrush(Colors.Red); } MessageBox.Show("NOTE: To take into effect, restart application!"); break; } default: MessageBox.Show("No action defined!"); break; } }
private void LoadContent( ) { string sPath = m_sPath_TEMP; m_sPath_TEMP = ""; string sContent = m_sContent_TEMP; m_sContent_TEMP = ""; // // // string sExt = RscStore.ExtensionOfPath(sPath); sExt = sExt.ToUpper(); switch (sExt) { case ".VCF": RscTextTags_VCF tags = new RscTextTags_VCF(); m_tags = tags; tags.Parse(sContent, "\r\n", ":", ";"); if (tags.PhotoPresent && tags.PhotoIsBase64 && tags.PhotoIs("JPEG")) { string sBase64 = tags.PhotoData; //RscFs.WriteTextFile( "vcf.photo.txt", sBase64, true ); byte [] ayImage = Convert.FromBase64String(sBase64); if (ayImage != null) { if (ayImage.Length > 0) { /* * RscStore store = new RscStore(); * if( store.FileExists("vcf.photo.jpg") ) store.DeleteFile("vcf.photo.jpg"); * System.IO.Stream stream = store.CreateFile("vcf.photo.jpg"); * stream.Write( ayImage, 0, ayImage.Length ); * stream.Close(); */ System.IO.MemoryStream ms = new System.IO.MemoryStream(ayImage.Length); ms.Write(ayImage, 0, ayImage.Length); ms.Seek(0, System.IO.SeekOrigin.Begin); BitmapImage bmp = new BitmapImage(); bmp.SetSource(ms); ms.Close(); Img.Source = bmp; Img.Visibility = Rsc.Visible; } else { Img.Visibility = Rsc.Collapsed; } } else { Img.Visibility = Rsc.Collapsed; } } else { //MessageBox.Show( "No photo present!" ); Img.Visibility = Rsc.Collapsed; } btnCall.Content = "Call " + tags.PhoneNumber(0); BtnGrid.Visibility = Rsc.ConditionalVisibility(tags.PhoneNumber(0).Length > 0); RscStore store = new RscStore(); bool bExists = false; if (store.FolderExists("A:\\Desktop")) { if (store.FolderExists("A:\\Desktop\\Contacts")) { bExists = store.FileExists("A:\\Desktop\\Contacts\\" + tags.Name + ".txt"); } } if (bExists) { btnEx.Content = "Remove from Desktop"; BtnGridEx.Background = new SolidColorBrush(Colors.Red); } else { btnEx.Content = "Add to Desktop"; BtnGridEx.Background = new SolidColorBrush(Colors.Green); } BtnGridEx.Visibility = Rsc.ConditionalVisibility(tags.PhoneNumber(0).Length > 0); break; default: Img.Visibility = Rsc.Collapsed; BtnGrid.Visibility = Rsc.Collapsed; m_tags = null; break; } // // // if (m_tags == null) { m_aLines.FontSize = 18; m_aLines.Text = sContent; } else { m_aLines.FontSize = 22; m_aLines.Text = m_tags.ToString(); } }
private void SaveImage(bool bThumbnail) { RscStore store = new RscStore(); string sFolder = m_sAppFolder; if (bThumbnail) { sFolder += "\\" + "tn"; if (!store.FolderExists(sFolder)) { store.CreateFolder(sFolder); } } string sPreExt = ""; if (bThumbnail) { sPreExt = ".tn"; } string sFName = m_sPicFileName; string sFExt = ""; int iPos = sFName.LastIndexOf('.'); if (iPos >= 0) { sFExt = sFName.Substring(iPos); sFName = sFName.Substring(0, iPos); } string sPath = sFolder + "\\" + sFName + sPreExt + sFExt; /* * iCnt = 0; * for(;;) * { * if( !store.FileExists(sPath) ) break; * iCnt++; * sPath = sFolder + "\\" + sFName + "_" + iCnt.ToString() + sPreExt + sFExt; * } */ System.IO.Stream strmSrc; if (bThumbnail) { strmSrc = m_pic.GetThumbnail(); } else { strmSrc = m_pic.GetImage(); } if (store.FileExists(sPath)) { store.DeleteFile(sPath); } System.IO.Stream stream = store.CreateFile(sPath); // Initialize the buffer for 4KB disk pages. byte[] readBuffer = new byte[4096]; int bytesRead = -1; // Copy the image/thumbnail to the local folder. while ((bytesRead = strmSrc.Read(readBuffer, 0, readBuffer.Length)) > 0) { stream.Write(readBuffer, 0, bytesRead); } stream.Close(); strmSrc.Close(); if (!bThumbnail) { store.WriteTextFile(sFolder + "\\" + sFName + sPreExt + sFExt + ".inf", m_sInf, true); } }
private string GetImagePath(string sIndiciesToItem, bool bThumbnail, out Picture pic, bool bForceCreateFolderPath = false) { RscStore store = new RscStore(); //string sFolder = RscFs.GetRscMediaFolderPath("Zune"); string sFolder = RscKnownFolders.GetMediaPath("Media Library", "", false); // // // PictureAlbum pa = m_media.RootPictureAlbum; pic = null; string [] asInd = sIndiciesToItem.Split('|'); int iCnt = asInd.Length; for (int i = 0; i < iCnt; i++) { if (i == iCnt - 1) { sFolder += "\\" + pa.Name; if (!store.FolderExists(sFolder)) { if (!bForceCreateFolderPath) { return(""); } store.CreateFolder(sFolder); } pic = pa.Pictures[Int32.Parse(asInd[i])]; } else { sFolder += "\\" + pa.Name; if (!store.FolderExists(sFolder)) { if (!bForceCreateFolderPath) { return(""); } store.CreateFolder(sFolder); } pa = pa.Albums[Int32.Parse(asInd[i])]; } } if (bThumbnail) { sFolder += "\\" + "tn"; if (!store.FolderExists(sFolder)) { if (!bForceCreateFolderPath) { return(""); } store.CreateFolder(sFolder); } } // // // string sPreExt = ""; if (bThumbnail) { sPreExt = ".tn"; } string sFName = pic.Name; string sFExt = ""; int iPos = sFName.LastIndexOf('.'); if (iPos >= 0) { sFExt = sFName.Substring(iPos); sFName = sFName.Substring(0, iPos); } string sPath = sFolder + "\\" + sFName + sPreExt + sFExt; //ROLLBACK... /* * iCnt = 0; * for(;;) * { * if( !store.FileExists(sPath) ) break; * iCnt++; * sPath = sFolder + "\\" + sFName + "_" + iCnt.ToString() + sPreExt + sFExt; * } */ if (!bForceCreateFolderPath) { if (!store.FileExists(sPath)) { return(""); } } return(sPath); }