Beispiel #1
0
        private void CopyImage(int iPos)
        {
            if (m_a.Count == 0)
            {
                return;
            }

            int iY = (iPos / m_a[0].m_a.Count);
            int iX = iPos % m_a[0].m_a.Count;

            //m_AppFrame.SetStatusText( iY.ToString() + " | " + iX.ToString() );

            ThemeImg thi = m_a[iY].m_a[iX];

            if (!thi.Checked)
            {
                return;
            }
            if (thi.FullPath.Length == 0)
            {
                return;
            }

            //m_AppFrame.SetStatusText( thi.FullPath );

            RscStore store = new RscStore();

            string sPath;

            sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".png";
            if (store.FileExists(sPath))
            {
                store.DeleteFile(sPath);
            }

            sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".jpg";
            if (store.FileExists(sPath))
            {
                store.DeleteFile(sPath);
            }

            string sPathTrg = thi.FullPath;

            sPathTrg = sPathTrg.Replace("\\" + thi.Name + "\\", "\\" + "Current" + "\\");

            store.CopyFile(thi.FullPath, sPathTrg);
        }
Beispiel #2
0
        private void CopyImage(int iPos)
        {
            if (m_a.Count == 0)
            {
                return;
            }

            int iY = (iPos / m_iCX);             // + 1;
            int iX = iPos % m_iCX;

            //m_AppFrame.SetStatusText( iY.ToString() + " | " + iX.ToString() );

            ThemeImg thi = m_a[iY].m_a[iX];

            if (!thi.Checked)
            {
                return;
            }
            if (thi.FullPath.Length == 0)
            {
                return;
            }

            //m_AppFrame.SetStatusText( thi.FullPath );

            RscStore store = new RscStore();

            string sPath;

            sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".png";
            if (store.FileExists(sPath))
            {
                store.DeleteFile(sPath);
            }

            sPath = m_strThemeFolder + "\\" + "Current" + "\\" + thi.Image + ".jpg";
            if (store.FileExists(sPath))
            {
                store.DeleteFile(sPath);
            }

            string sPathTrg = thi.FullPath;

            sPathTrg = sPathTrg.Replace("\\" + thi.Name + "\\", "\\" + "Current" + "\\");

            store.CopyFile(thi.FullPath, sPathTrg);

            if (iY == 0)
            {
                int iPos2 = thi.FullPath.LastIndexOf('\\');
                if (iPos2 >= 0)
                {
                    string sSrc = thi.FullPath.Substring(0, iPos2 + 1);
                    sSrc += "ThemeColors.xml";

                    if (store.FileExists(sSrc))
                    {
                        string sTrg = sSrc.Replace("\\" + thi.Name + "\\", "\\" + "Current" + "\\");

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

                        store.CopyFile(sSrc, sTrg);
                    }
                }
            }
        }
        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);
        }