void BitmapImage_OpenedTrue(object sender, RoutedEventArgs e)
            {
                BitmapImage bImage = (BitmapImage)sender;

                WriteableBitmap wbmp = new WriteableBitmap(bImage);

                RscStore store = new RscStore();

                if (m_sPathToSave1.Length > 0)
                {
                    System.IO.Stream stream = store.CreateFile(m_sPathToSave1);

                    System.Windows.Media.Imaging.
                    Extensions.SaveJpeg(wbmp, stream,
                                        wbmp.PixelWidth, wbmp.PixelHeight,
                                        0, 100);

                    stream.Close();
                }

                if (m_sPathToSave2.Length > 0)
                {
                    System.IO.Stream stream = store.CreateFile(m_sPathToSave2);

                    System.Windows.Media.Imaging.
                    Extensions.SaveJpeg(wbmp, stream,
                                        wbmp.PixelWidth, wbmp.PixelHeight,
                                        0, 100);

                    stream.Close();
                }
            }
Example #2
0
        private void cam_CaptureImageAvailable(object sender, Microsoft.Devices.ContentReadyEventArgs e)
        {
            if (m_sFnDtNext.Length == 0)
            {
                DateTime dNow = DateTime.Now;
                m_sFnDtNext = dNow.Year.ToString() + RscUtils.pad60(dNow.Month)
                              + RscUtils.pad60(dNow.Day) + "_" + RscUtils.pad60(dNow.Hour) + RscUtils.pad60(dNow.Minute)
                              + RscUtils.pad60(dNow.Second);
            }

            if (m_bSaveToMediaLibrary)
            {
                MediaLibrary media = new MediaLibrary();
                media.SavePicture(m_sFnDtNext, e.ImageStream);

                e.ImageStream.Seek(0, System.IO.SeekOrigin.Begin);
            }
            else
            {
                RscStore store = new RscStore();

                string fName = RscKnownFolders.GetMediaPath("DCIM") + "\\" + m_sFnDtNext + ".jpg";
                int    iCnt  = 0;
                for (;;)
                {
                    if (!store.FileExists(fName))
                    {
                        break;
                    }
                    iCnt++;
                    fName = RscKnownFolders.GetMediaPath("DCIM") + "\\" + m_sFnDtNext + "_" + iCnt.ToString() + ".jpg";
                }

                System.IO.Stream stream = store.CreateFile(fName);
                // Initialize the buffer for 4KB disk pages.
                byte[] readBuffer = new byte[4096];
                int    bytesRead  = -1;
                // Copy the thumbnail to the local folder.
                while ((bytesRead = e.ImageStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
                {
                    stream.Write(readBuffer, 0, bytesRead);
                }
                stream.Close();
            }
        }
Example #3
0
        private void m_btnDownloadFile_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_sLastFile.Length == 0)
            {
                return;
            }

            if (m_bLastFileIsFolder)
            {
                return;
            }

            if (m_lLastFileSize < 0)
            {
                return;
            }

            if (m_ftpc.WorkingDirectory.Length == 0)
            {
                return;
            }

            string sPath = m_ftpc.WorkingDirectory;

            sPath += m_sLastFile;

            RscStore store = new RscStore();

            string sLocalPath = "A:\\FTP";

            if (!store.FolderExists(sLocalPath))
            {
                store.CreateFolder(sLocalPath);
            }
            sLocalPath += "\\" + m_sLastFile;
            if (store.FileExists(sLocalPath))
            {
                store.DeleteFile(sLocalPath);
            }
            System.IO.Stream stream = store.CreateFile(sLocalPath);

            RscFtpClientCommand cmd = RscFtpClientCommand.DownloadBin(sPath, m_lLastFileSize, "", null, stream);

            _SendAutoPASV(cmd);
        }
        private void RenderText(string text, int width, int height, double fontsize, string imagepath, Brush backColor, Brush brFore)
        {
            WriteableBitmap b = new WriteableBitmap(width, height);

            var canvas = new Grid();

            canvas.Width  = b.PixelWidth;
            canvas.Height = b.PixelHeight;

            var background = new Canvas();

            background.Height = b.PixelHeight;
            background.Width  = b.PixelWidth;

            //SolidColorBrush backColor = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
            //SolidColorBrush backColor = new SolidColorBrush( Colors.Black );
            background.Background = backColor;

            var textBlock = new TextBlock();

            textBlock.Text                = text;
            textBlock.FontWeight          = FontWeights.Bold;
            textBlock.TextAlignment       = TextAlignment.Left;
            textBlock.HorizontalAlignment = HorizontalAlignment.Center;
            textBlock.VerticalAlignment   = VerticalAlignment.Stretch;
            textBlock.Margin              = new Thickness(35);
            textBlock.Width               = b.PixelWidth - textBlock.Margin.Left * 2;
            textBlock.TextWrapping        = TextWrapping.Wrap;
            textBlock.Foreground          = brFore;    //new SolidColorBrush(Colors.White); //color of the text on the Tile
            textBlock.FontSize            = fontsize;

            canvas.Children.Add(textBlock);

            b.Render(background, null);
            b.Render(canvas, null);
            b.Invalidate();             //Draw bitmap

            RscStore store = new RscStore();

            System.IO.Stream stream = store.CreateFile(imagepath);
            b.SaveJpeg(stream, b.PixelWidth, b.PixelHeight, 0, 100);

            stream.Close();
        }
        protected void SaveToXml(string path)
        {
            XDocument xDoc = new XDocument();

            XElement xRoot = new XElement("ThemeColors");

            // //
            //

            xRoot.Add(new XElement("ListZebraBack1", ListZebraBack1));
            xRoot.Add(new XElement("ListZebraBack2", ListZebraBack2));
            xRoot.Add(new XElement("ListZebraFore", ListZebraFore));

            xRoot.Add(new XElement("TreeDescBack", TreeDescBack));
            xRoot.Add(new XElement("TreeDescFore", TreeDescFore));
            xRoot.Add(new XElement("TreeLeafBack", TreeLeafBack));
            xRoot.Add(new XElement("TreeLeafFore", TreeLeafFore));
            xRoot.Add(new XElement("TreeContainerBack", TreeContainerBack));
            xRoot.Add(new XElement("TreeContainerFore", TreeContainerFore));

            xRoot.Add(new XElement("TextDarkBack", TextDarkBack));
            xRoot.Add(new XElement("TextDarkFore", TextDarkFore));
            xRoot.Add(new XElement("TextLightBack", TextLightBack));
            xRoot.Add(new XElement("TextLightFore", TextLightFore));

            xRoot.Add(new XElement("GalleryItemBack", GalleryItemBack));
            xRoot.Add(new XElement("GalleryItemBorder", GalleryItemBorder));
            xRoot.Add(new XElement("GalleryItemFore", GalleryItemFore));

            xRoot.Add(new XElement("DialogLightBack", DialogLightBack));

            xRoot.Add(new XElement("ToolBarLightBack", ToolBarLightBack));
            xRoot.Add(new XElement("ToolBarLightFore", ToolBarLightFore));

            xRoot.Add(new XElement("AppTitleBack", AppTitleBack));
            xRoot.Add(new XElement("AppTitleFore", AppTitleFore));

            xRoot.Add(new XElement("AppStatusBack", AppStatusBack));
            xRoot.Add(new XElement("AppStatusFore", AppStatusFore));

            xRoot.Add(new XElement("IconBack", IconBack));
            xRoot.Add(new XElement("IconBorder", IconBorder));
            xRoot.Add(new XElement("IconFore", IconFore));

            xRoot.Add(new XElement("ThemeBack", ThemeBack));

            //
            // //
            //

            xDoc.Add(xRoot);

            RscStore store = new RscStore();

            System.IO.Stream strm = store.CreateFile(path);

            xDoc.Save(strm);

            strm.Close();

            //
            // //
        }
Example #6
0
        private void m_ftpc_ServerDataReceivedSYNC(object sender, Ressive.FTP.RscFtpCommandEventArgs e)
        {
            if (!e.ServerData.ParseOk)
            {
                _Log("20", "<DATA ERROR> " + e.ClientCommand.ToString( ), false);
            }
            else
            {
                switch (e.ClientCommand.Command)
                {
                case "LIST":
                {
                    prsBarData.Visibility = Rsc.Collapsed;

                    int iCount;
                    RscFtpServerDataItemFileInfo fi;

                    iCount = e.ServerData.Count;

                    if (iCount == 0)
                    {
                        _Log("20", e.ClientCommand.Command + " returned 0 item.", false, true);
                    }
                    else
                    {
                        for (int i = 0; i < iCount; i++)
                        {
                            fi = (RscFtpServerDataItemFileInfo)e.ServerData.GetItem(i);

                            _Log("20", fi.GetItemTitle( ), false, true, fi);
                        }
                    }

                    break;
                }

                case "RETR":
                {
                    prsBarData.Visibility = Rsc.Collapsed;

                    _Log("20", e.ClientCommand.Command + " returned " +
                         e.ClientCommand.DataSize.ToString() + " bytes.", false, true);

                    if (e.ClientCommand.HasMemStream)
                    {
                        string sPath = e.ClientCommand.Arg1;
                        int    iPos  = sPath.LastIndexOf(m_ftpc.BackSlashInPath);
                        string sFn   = sPath;
                        if (iPos >= 0)
                        {
                            sFn = sPath.Substring(iPos + m_ftpc.BackSlashInPath.Length);
                        }

                        _Log("20", e.ClientCommand.Command + " saving local file '" +
                             sFn + "'.", false, true);

                        RscStore store = new RscStore();

                        string sLocalPath = "A:\\FTP";
                        if (!store.FolderExists(sLocalPath))
                        {
                            store.CreateFolder(sLocalPath);
                        }
                        sLocalPath += "\\" + sFn;
                        if (store.FileExists(sLocalPath))
                        {
                            store.DeleteFile(sLocalPath);
                        }

                        System.IO.Stream stream = store.CreateFile(sLocalPath);
                        e.ServerData.MemStream.WriteTo(stream);
                        e.ServerData.MemStream.Close();
                        stream.Close();
                    }

                    break;
                }
                }
            }
        }
Example #7
0
        private void mySave()
        {
            RscStore store = new RscStore();

            System.IO.Stream stream = null;

            string fName = host.UI.isoName.Text;

            if (fName == "")
            {
                return;
            }
            fName = ImgFolderPath() + fName;

            // //
            //

            fName += ".ico";

            if (store.FileExists(fName))
            {
                store.DeleteFile(fName);
            }

            //Save original .ICO
            if (m_memIco != null)
            {
                stream = store.CreateFile(fName);
                m_memIco.WriteTo(stream);
                stream.Close();
            }

            //
            // //
            //

            //Save ico uri as IE bookmark...
            store.WriteTextFile(fName + ".ilnk", uIco.ToString(), true);

            //
            // //
            //

            //Lg
            {
                string sIco = fName + ".jpg";

                System.Windows.Media.Imaging.WriteableBitmap wbmp = new System.Windows.Media.
                                                                    Imaging.WriteableBitmap(
                    host.UI.imgIcon,
                    new System.Windows.Media.MatrixTransform());

                if (store.FileExists(sIco))
                {
                    store.DeleteFile(sIco);
                }

                stream = store.CreateFile(sIco);

                System.Windows.Media.Imaging.
                Extensions.SaveJpeg(wbmp, stream,
                                    wbmp.PixelWidth, wbmp.PixelHeight,
                                    0, 100);

                stream.Close();

                host.UI.isoImg.Source     = wbmp;
                host.UI.isoImg.Visibility = System.Windows.Visibility.Visible;
            }

            //Lg
            {
                string sIco = fName + ".sm.jpg";

                System.Windows.Media.Imaging.WriteableBitmap wbmp = new System.Windows.Media.
                                                                    Imaging.WriteableBitmap(
                    host.UI.imgIconSm,
                    new System.Windows.Media.MatrixTransform());

                if (store.FileExists(sIco))
                {
                    store.DeleteFile(sIco);
                }

                stream = store.CreateFile(sIco);

                System.Windows.Media.Imaging.
                Extensions.SaveJpeg(wbmp, stream,
                                    wbmp.PixelWidth, wbmp.PixelHeight,
                                    0, 100);

                stream.Close();

                host.UI.isoImgSm.Source     = wbmp;
                host.UI.isoImgSm.Visibility = System.Windows.Visibility.Visible;
            }

            //
            // //
        }
        private void SaveImage(string sIndiciesToItem, bool bThumbnail)
        {
            RscStore store = new RscStore();

            //string sFolder = RscKnownFolders.GetMediaPath("Zune");
            string sFolder = RscKnownFolders.GetMediaPath("Media Library");

            // //
            //

            PictureAlbum pa  = m_media.RootPictureAlbum;
            Picture      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))
                    {
                        store.CreateFolder(sFolder);
                    }

                    pic = pa.Pictures[Int32.Parse(asInd[i])];
                }
                else
                {
                    sFolder += "\\" + pa.Name;
                    if (!store.FolderExists(sFolder))
                    {
                        store.CreateFolder(sFolder);
                    }

                    pa = pa.Albums[Int32.Parse(asInd[i])];
                }
            }

            if (bThumbnail)
            {
                sFolder += "\\" + "tn";
                if (!store.FolderExists(sFolder))
                {
                    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;

            iCnt = 0;
            for (;;)
            {
                if (!store.FileExists(sPath))
                {
                    break;
                }
                iCnt++;
                sPath = sFolder + "\\" + sFName + "_" + iCnt.ToString() + sPreExt + sFExt;
            }

            System.IO.Stream strmSrc;
            if (bThumbnail)
            {
                strmSrc = pic.GetThumbnail();
            }
            else
            {
                strmSrc = pic.GetImage();
            }

            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();
        }
        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 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 void SaveImage(string sIndiciesToItem, bool bThumbnail)
        {
            //Create folder path...
            RscKnownFolders.GetMediaPath("Media Library", "", true);

            Picture pic;
            string  sPath = GetImagePath(sIndiciesToItem, bThumbnail, out pic, true);

            System.IO.Stream strmSrc;
            if (bThumbnail)
            {
                strmSrc = pic.GetThumbnail();
            }
            else
            {
                strmSrc = pic.GetImage();
            }

            RscStore store = new RscStore();

            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)
            {
                BitmapImage bmp = null;
                try
                {
                    System.IO.Stream stream2 = store.GetReaderStream(sPath);

                    bmp = new BitmapImage();
                    bmp.SetSource(stream2);

                    stream2.Close();
                }
                catch (Exception)
                {
                    bmp = null;
                }

                if (bmp == null)
                {
                    m_btnIsoImage.Visibility = Rsc.Collapsed;
                }
                else
                {
                    m_btnIsoImage.Visibility   = Rsc.Visible;
                    m_btnIsoImage.Image.Source = bmp;
                }
            }
        }