//NOT WORKING!!!

        /*
         * private void m_tmrGif_Tick(object sender, System.EventArgs e)
         * {
         *      m_tmrGif.Stop();
         *
         *      m_iFrameGif++;
         *      if( m_iFrameGif > 10 )
         *              m_iFrameGif = 0;
         *
         *      imgGif.Clip = new RectangleGeometry {
         *                     Rect =
         *                         new Rect(
         *                             m_iFrameGif * m_iImgWidth,
         *                             0,
         *                             m_iImgWidth,
         *                             m_iImgHeight)
         *                         };
         *
         *      Canvas.SetLeft( imgGif, -1 * m_iImgWidth * m_iFrameGif);
         *
         *      m_tmrGif.Start();
         * }
         */

        private void m_btnSaveToPhone_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (m_iIndex < 0)
            {
                return;
            }
            if (m_iIndex >= m_aImages.Count)
            {
                return;
            }

            RscStore store = new RscStore();

            string sPath = m_aImages[m_iIndex];
            string sName = store.GetOriginalFileNameOfPath(sPath);

            //MessageBox.Show( sPath + "\r\n" + sName ); //sTnFolder + "\r\n" + sTnPath );

            Stream stream = store.GetReaderStream(sPath, false);

            MediaLibrary media = new MediaLibrary();

            media.SavePicture(sName, stream);

            stream.Close();

            MessageBox.Show("Image (" + sName + ") saved to device's Saved Pictures folder.");
        }
예제 #2
0
        private void loadExisting()
        {
            string fName = host.UI.isoName.Text;

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

            //Lg
            {
                string sIco = ImgFolderPath() + fName + ".ico.jpg";

                RscStore store = new RscStore();

                if (!store.FileExists(sIco))
                {
                    return;
                }

                System.IO.Stream stream = store.GetReaderStream(sIco);

                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.
                                                               Imaging.BitmapImage();

                bmp.SetSource(stream);

                stream.Close();

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

            //Sm
            {
                string sIco = ImgFolderPath() + fName + ".ico.sm.jpg";

                RscStore store = new RscStore();

                if (!store.FileExists(sIco))
                {
                    return;
                }

                System.IO.Stream stream = store.GetReaderStream(sIco);

                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.
                                                               Imaging.BitmapImage();

                bmp.SetSource(stream);

                stream.Close();

                host.UI.isoImgSm.Source     = bmp;
                host.UI.isoImgSm.Visibility = System.Windows.Visibility.Visible;
            }
        }
예제 #3
0
        protected void LoadFromXml(string path)
        {
            RscStore store = new RscStore();

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

            XDocument xDoc = XDocument.Load(strm, LoadOptions.None);

            strm.Close();

            try
            {
                XElement xRoot = xDoc.Element("ThemeColors");

                ListZebraBack1 = RscDecode.HexaStringToColor(xRoot.Element("ListZebraBack1").Value);
                ListZebraBack2 = RscDecode.HexaStringToColor(xRoot.Element("ListZebraBack2").Value);
                ListZebraFore  = RscDecode.HexaStringToColor(xRoot.Element("ListZebraFore").Value);

                TreeDescBack      = RscDecode.HexaStringToColor(xRoot.Element("TreeDescBack").Value);
                TreeDescFore      = RscDecode.HexaStringToColor(xRoot.Element("TreeDescFore").Value);
                TreeLeafBack      = RscDecode.HexaStringToColor(xRoot.Element("TreeLeafBack").Value);
                TreeLeafFore      = RscDecode.HexaStringToColor(xRoot.Element("TreeLeafFore").Value);
                TreeContainerBack = RscDecode.HexaStringToColor(xRoot.Element("TreeContainerBack").Value);
                TreeContainerFore = RscDecode.HexaStringToColor(xRoot.Element("TreeContainerFore").Value);

                TextDarkBack  = RscDecode.HexaStringToColor(xRoot.Element("TextDarkBack").Value);
                TextDarkFore  = RscDecode.HexaStringToColor(xRoot.Element("TextDarkFore").Value);
                TextLightBack = RscDecode.HexaStringToColor(xRoot.Element("TextLightBack").Value);
                TextLightFore = RscDecode.HexaStringToColor(xRoot.Element("TextLightFore").Value);

                GalleryItemBack   = RscDecode.HexaStringToColor(xRoot.Element("GalleryItemBack").Value);
                GalleryItemBorder = RscDecode.HexaStringToColor(xRoot.Element("GalleryItemBorder").Value);
                GalleryItemFore   = RscDecode.HexaStringToColor(xRoot.Element("GalleryItemFore").Value);

                DialogLightBack = RscDecode.HexaStringToColor(xRoot.Element("DialogLightBack").Value);

                ToolBarLightBack = RscDecode.HexaStringToColor(xRoot.Element("ToolBarLightBack").Value);
                ToolBarLightFore = RscDecode.HexaStringToColor(xRoot.Element("ToolBarLightFore").Value);

                AppTitleBack = RscDecode.HexaStringToColor(xRoot.Element("AppTitleBack").Value);
                AppTitleFore = RscDecode.HexaStringToColor(xRoot.Element("AppTitleFore").Value);

                AppStatusBack = RscDecode.HexaStringToColor(xRoot.Element("AppStatusBack").Value);
                AppStatusFore = RscDecode.HexaStringToColor(xRoot.Element("AppStatusFore").Value);

                IconBack   = RscDecode.HexaStringToColor(xRoot.Element("IconBack").Value);
                IconBorder = RscDecode.HexaStringToColor(xRoot.Element("IconBorder").Value);
                IconFore   = RscDecode.HexaStringToColor(xRoot.Element("IconFore").Value);

                ThemeBack = RscDecode.HexaStringToColor(xRoot.Element("ThemeBack").Value);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
        private ImageSource LoadThumbnail(string sPath, int iCX, int iCY)
        {
            RscStore store = new RscStore();

            System.IO.Stream stream = store.GetReaderStream(sPath, false);

            System.Windows.Media.Imaging.WriteableBitmap wbmp =
                Microsoft.Phone.PictureDecoder.DecodeJpeg(stream, iCX, iCY);

            return(wbmp);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            m_bInThisApp = true;

            if (!m_bFirstLoad)
            {
                return;
            }
            m_bFirstLoad = false;

            RscPageArgsRetManager appArgsMgr = new RscPageArgsRetManager();

            m_AppInput = appArgsMgr.GetInput("RscViewer_HexaV10");
            if (m_AppInput != null)
            {
                m_AppFrame.AppTitle   = m_AppInput.CallerAppTitle;
                m_AppFrame.AppIconRes = m_AppInput.CallerAppIconRes;

                if (m_stream != null)
                {
                    m_stream.Close();
                    m_stream = null;
                }
                m_lPos = 0;

                m_sPath = m_AppInput.GetData(0);

                //appArgsMgr.Vipe();

                RscStore store = new RscStore();
                try
                {
                    m_stream = store.GetReaderStream(m_sPath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    m_stream = null;
                }

                _ShowDump();
            }
        }
예제 #6
0
        public static ImageSource FaviconForDomain(string sDomain, out bool bFound, out string sPathOut, ImageSource isDefault, bool bSmall = true)
        {
            bFound   = false;
            sPathOut = "";

            // //
            //

            RscStore store = new RscStore();

            string sFolder = "A:\\Internet\\Favicons";

            if (!store.FolderExists(sFolder))
            {
                return(isDefault);
            }

            List <string> asDomainLst = SplitDomain(sDomain);

            string strImgPath = "";

            foreach (string sDn in asDomainLst)
            {
                //MessageBox.Show( sDn );

                string sPath;

                if (bSmall)
                {
                    sPath = sFolder + "\\" + sDn + ".ico.sm.jpg";
                    if (store.FileExists(sPath))
                    {
                        strImgPath = sPath;
                        break;
                    }
                }

                sPath = sFolder + "\\" + sDn + ".ico.jpg";
                if (store.FileExists(sPath))
                {
                    strImgPath = sPath;
                    break;
                }
            }

            if (strImgPath.Length == 0)
            {
                return(isDefault);
            }

            //
            // //
            //

            try
            {
                System.IO.Stream stream = store.GetReaderStream(strImgPath);

                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(stream);
                stream.Close();

                bFound   = true;
                sPathOut = strImgPath;

                return(bmp);
            }
            catch (Exception /*e*/)
            {
                return(isDefault);
            }

            //
            // //
        }
예제 #7
0
        ImageSource _ChkFile(string strName, out string strPath1, out string strPath2)
        {
            strPath1 = "";
            strPath2 = "";

            string sSysFldr1 = RscKnownFolders.GetSystemPath(m_strSysFolder, m_strSysSubFolder1) + "\\" + strName;
            string sSysFldr2 = "";

            if (m_strSysSubFolder2.Length > 0)
            {
                sSysFldr2 = RscKnownFolders.GetSystemPath(m_strSysFolder, m_strSysSubFolder2) + "\\" + strName;
            }

            RscStore store = new RscStore();

            string strExt = "";

            if (store.FileExists(sSysFldr1 + ".png"))
            {
                strExt = ".png";
            }
            if (strExt.Length == 0 && store.FileExists(sSysFldr1 + ".jpg"))
            {
                strExt = ".jpg";
            }

            if (strExt.Length > 0)
            {
                try
                {
                    //FIX: Keeps file locked!!!
                    string strAccDeniPath = RscKnownFolders.GetTempPath("DefaultedImageList", m_strSysFolder) + "\\" + strName + strExt;
                    store.CopyFile(sSysFldr1 + strExt, strAccDeniPath, true);

                    System.IO.Stream stream = store.GetReaderStream(strAccDeniPath);

                    //BUG: Not working...
                    {
                        BitmapImage bmp = new BitmapImage();
                        bmp.SetSource(stream);

                        stream.Close();

                        return(bmp);
                    }

                    //BUG: Not working...

                    /*
                     * BitmapImage bmp = new BitmapImage(new Uri(strResName, UriKind.Relative));
                     *
                     * WriteableBitmap wbmp= new WriteableBitmap(bmp.PixelWidth, bmp.PixelHeight);
                     *
                     * System.Windows.Media.Imaging.
                     *      Extensions.LoadJpeg(wbmp, stream);
                     *
                     * stream.Close();
                     *
                     * return wbmp;
                     */
                }
                catch (Exception)
                {
                    //NOP...
                }
            }

            strPath1 = sSysFldr1 + ".jpg";
            if (sSysFldr2.Length > 0)
            {
                strPath2 = sSysFldr2 + ".jpg";
            }

            return(null);
        }
예제 #8
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (m_AppArgs.Waiting)
            {
                RscPageArgsRet appOutput = m_AppArgs.GetOutput();
                if (appOutput != null)
                {
                    switch (appOutput.ID)
                    {
                    case "FtpHost":
                        txSvrIP.Text = appOutput.GetData(0);
                        LoadFromReg();
                        break;

                    case "txNewFolder":
                    {
                        if (appOutput.GetFlag(0) == "Ok")
                        {
                            m_bLastFileIsFolder = true;
                            string sFile = appOutput.GetData(0);
                            SetLastFile(sFile, true);

                            RscFtpClientCommand cmd = RscFtpClientCommand.CreateFolder(sFile);

                            _Log("21", cmd.ToString());

                            m_ftpc.SendCommandToServer(cmd);
                        }
                        break;
                    }

                    case "BrowseForFile_MEM":
                    {
                        if (appOutput.GetFlag(0) == "Ok")
                        {
                            string sFilePath = appOutput.GetData(0);

                            string sFile = RscStore.FileOfPath(sFilePath);

                            RscStore store = new RscStore();

                            System.IO.Stream stream = store.GetReaderStream(sFilePath);

                            SetLastFile(sFile, false, stream.Length);
                            System.IO.MemoryStream ms = new System.IO.MemoryStream((int)stream.Length);
                            stream.CopyTo(ms);
                            stream.Close();
                            ms.Seek(0, System.IO.SeekOrigin.Begin);

                            RscFtpClientCommand cmd = RscFtpClientCommand.UploadBin(sFile, ms);

                            _SendAutoPASV(cmd);
                        }
                        else
                        {
                            //NOP...
                        }

                        m_AppArgs.Vipe();

                        break;
                    }

                    case "BrowseForFile_FLE":
                    {
                        if (appOutput.GetFlag(0) == "Ok")
                        {
                            string sFilePath = appOutput.GetData(0);

                            string sFile = RscStore.FileOfPath(sFilePath);

                            RscStore store = new RscStore();

                            System.IO.Stream stream = store.GetReaderStream(sFilePath);

                            SetLastFile(sFile, false, stream.Length);

                            /*
                             * MemoryStream ms = new MemoryStream((int) stream.Length);
                             * stream.CopyTo(ms);
                             * stream.Close();
                             * ms.Seek(0, SeekOrigin.Begin);
                             */

                            RscFtpClientCommand cmd = RscFtpClientCommand.UploadBin(sFile, null, stream);

                            _SendAutoPASV(cmd);
                        }
                        else
                        {
                            //NOP...
                        }

                        m_AppArgs.Vipe();

                        break;
                    }
                    }
                }

                m_AppArgs.Clear();
            }
        }
        private void _ShowImage(string sPath, Size sz)
        {
            //NOT WORKING!!!
            //m_tmrGif.Stop();

            txPrevCnt.Text = m_iIndex.ToString();
            txNextCnt.Text = Math.Max(0, ((m_aImages.Count - 1) - m_iIndex)).ToString();

            string strDet = (m_iIndex + 1).ToString() + " / " + m_aImages.Count.ToString() + "\r\n";

            string strFn = sPath;
            int    iPos  = sPath.LastIndexOf('\\');

            if (iPos >= 0)
            {
                strFn = sPath.Substring(iPos + 1);
            }
            strDet += "\r\n" + strFn;

            string strExt = "";
            int    iPos2  = strFn.LastIndexOf('.');

            if (iPos2 >= 0)
            {
                strExt = strFn.Substring(iPos2 + 1);
            }

            //NOT WORKING!!!

            /*
             * bool bGif = false;
             * if( strExt.ToLower() == "gif" )
             *      bGif = true;
             */

            string strFldr = "\\";

            if (iPos >= 0)
            {
                strFldr = sPath.Substring(0, iPos + 1);
            }

            strDet           += "\r\n" + "\r\n" + strFldr;
            txImgDetails.Text = strDet;

            long lFs = 0;

            m_iImgWidth  = 0;
            m_iImgHeight = 0;
            try
            {
                RscStore store = new RscStore();

                //if( !store.FileExists(sPath) ) return;

                Stream stream = store.GetReaderStream(sPath, false);
                lFs = stream.Length;

                //TODO... ImageTools, strExt

                BitmapImage bmp = new BitmapImage();
                bmp.SetSource(stream);
                stream.Close();

                m_iImgWidth  = bmp.PixelWidth;
                m_iImgHeight = bmp.PixelHeight;

                //NOT WORKING!!!

                /*
                 * if( bGif )
                 * {
                 *      imgFull.Visibility = Rsc.Collapsed;
                 *
                 *      //imgGif.Source = bmp;
                 *      imgGif.Source = new Uri( "", UriKind.Absolute );
                 *
                 *      canvGif.Visibility = Rsc.Visible;
                 *
                 *      m_iFrameGif = 0;
                 *      m_tmrGif.Start();
                 * }
                 * else
                 * {
                 *      canvGif.Visibility = Rsc.Collapsed;
                 */

                //strDet += "\r\n" + "bmp( " + bmp.PixelWidth.ToString() + " ; " + bmp.PixelHeight.ToString() + " )";
                //strDet += "\r\n" + "sz( " + sz.Width.ToString() + " ; " + sz.Height.ToString() + " )";
                if ((bmp.PixelWidth <= sz.Width) && (bmp.PixelHeight <= sz.Height))
                {
                    imgFull.Stretch = Stretch.None;
                }
                else
                {
                    imgFull.Stretch = Stretch.Uniform;
                }

                imgFull.Source = bmp;

                //NOT WORKING!!!

                /*
                 *      imgFull.Visibility = Rsc.Visible;
                 * }
                 */
            }
            catch (Exception e)
            {
                strDet += "\r\n" + "\r\nERROR: " + e.Message;

                imgFull.Stretch = Stretch.None;
                imgFull.Source  = m_isDummy;
            }

            if (lFs > 0)
            {
                strDet += "\n\n" + lFs.ToString() + " B" + " ( " + RscUtils.toMBstr(lFs) + " ) ";
            }

            string sDim = "";

            if (m_iImgWidth > 0)
            {
                sDim += m_iImgWidth.ToString();
            }
            else
            {
                sDim += "-";
            }
            sDim += " x ";
            if (m_iImgHeight > 0)
            {
                sDim += m_iImgHeight.ToString();
            }
            else
            {
                sDim += "-";
            }
            strDet += "\n\n" + sDim;

            if (m_strInitErr.Length > 0)
            {
                strDet += "\n\n" + "\r\nApp Init ERROR: " + m_strInitErr;
            }

            txImgDetails.Text = strDet;
        }
        private void _ShowVideo(string sPath)
        {
            txPrevCnt.Text = m_iIndex.ToString();
            txNextCnt.Text = Math.Max(0, ((m_aVideos.Count - 1) - m_iIndex)).ToString();

            string strDet = (m_iIndex + 1).ToString() + " / " + m_aVideos.Count.ToString() + "\r\n";

            string strFn = sPath;
            int    iPos  = sPath.LastIndexOf('\\');

            if (iPos >= 0)
            {
                strFn = sPath.Substring(iPos + 1);
            }
            strDet += "\r\n" + strFn;

            string strFldr = "\\";

            if (iPos >= 0)
            {
                strFldr = sPath.Substring(0, iPos + 1);
            }

            strDet += "\r\n" + "\r\n" + strFldr;

            m_sVidInf         = strDet;
            txImgDetails.Text = strDet;

            long lFs = 0;

            try
            {
                if (RscStore.IsIsoStorePath(sPath))
                {
                    RscStore store = new RscStore();

                    System.IO.Stream stream = store.GetReaderStream(sPath, false);
                    lFs = stream.Length;

                    vidFull.SetSource(stream);

                    stream.Close();
                }
                else
                {
                    RscStore store = new RscStore();
                    lFs = store.GetFileLength(sPath);

                    vidFull.Source = new Uri("file:///" + sPath, UriKind.Absolute);
                }
            }
            catch (Exception e)
            {
                strDet += "\r\n" + "\r\nERROR: " + e.Message;
            }

            if (lFs > 0)
            {
                strDet += "\r\n" + lFs.ToString() + " B" + " ( " + RscUtils.toMBstr(lFs) + " ) ";
            }

            if (m_strInitErr.Length > 0)
            {
                strDet += "\r\n" + "\r\nApp Init ERROR: " + m_strInitErr;
            }

            m_sVidInf         = strDet;
            txImgDetails.Text = strDet;
        }
        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;
                }
            }
        }
        private void btn_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            Button btn;

            btn = ((Button)sender);
            RscMediaLibItemDesc it;

            it = (RscMediaLibItemDesc)btn.Tag;

            m_txtTitle.Text = "TIP: Tap Media Library image to save to Isolated Storage.";

            if (it.bFolder)
            {
                m_btnThumbnail.Visibility = Rsc.Collapsed;
                m_btnImage.Visibility     = Rsc.Collapsed;
                m_btnIsoImage.Visibility  = Rsc.Collapsed;

                //m_path.Push( it.sFn );

                //ListFiles();
            }
            else
            {
                m_txtTitle.Text = "B:\\" + it.sFolderPath + "\\" + it.sName;

                m_btnThumbnail.Visibility   = Rsc.Visible;
                m_btnThumbnail.Tag          = it.sIndiciesToItem;
                m_btnThumbnail.Image.Source = LoadImage(it, true, 48, 80);

                m_btnImage.Visibility   = Rsc.Visible;
                m_btnImage.Tag          = it.sIndiciesToItem;
                m_btnImage.Image.Source = LoadImage(it, false, 96, 160);

                Picture pic;
                string  sPath = GetImagePath(it.sIndiciesToItem, false, out pic);
                if (sPath.Length == 0)
                {
                    m_btnIsoImage.Visibility = Rsc.Collapsed;
                }
                else
                {
                    BitmapImage bmp = null;
                    try
                    {
                        RscStore store = new RscStore();

                        System.IO.Stream stream = store.GetReaderStream(sPath);

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

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

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