Пример #1
0
        private String getDefaultImagePath(String strAction)
        {
            String strImagePath = "";

            if (strAction == "options")
            {
                strImagePath = "lib/res/options_btn.png";
            }
            else if (strAction == "home")
            {
                strImagePath = "lib/res/home_btn.png";
            }
            else if (strAction == "refresh")
            {
                strImagePath = "lib/res/refresh_btn.png";
            }
            else if (strAction == "back")
            {
                strImagePath = "lib/res/back_btn.png";
            }
            else if (strAction == "forward")
            {
                strImagePath = "lib/res/forward_btn.png";
            }

            return(strImagePath.Length > 0 ? CFilePath.join(getRhoRootPath(), strImagePath) : null);
        }
Пример #2
0
 public static void deleteDirectory(String path)
 {
     using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
     {
         isoStore.DeleteDirectory(CFilePath.removeLastSlash(path));
     }
 }
Пример #3
0
 public static string[] enumDirectory(String path)
 {
     using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
     {
         return(isoStore.GetFileNames(CFilePath.join(path, "*")));
     }
 }
Пример #4
0
        public bool open(String szFilePath, EOpenModes eMode)
        {
            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                szFilePath = CFilePath.removeFirstSlash(szFilePath);
                if (eMode == EOpenModes.OpenForAppend || eMode == EOpenModes.OpenForReadWrite)
                {
                    if (!isFileExist(szFilePath))
                    {
                        m_st = isoStore.OpenFile(szFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
                    }

                    if (eMode == EOpenModes.OpenForAppend)
                    {
                        movePosToEnd();
                    }
                }
                else if (eMode == EOpenModes.OpenReadOnly)
                {
                    m_st = isoStore.OpenFile(szFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                }
                else if (eMode == EOpenModes.OpenForWrite)
                {
                    m_st = isoStore.OpenFile(szFilePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);
                }
            }

            return(isOpened());
        }
Пример #5
0
        public void Init(WebBrowser browser, PhoneApplicationPage appMainPage, Grid layoutRoot, RhoView rhoView)
        {
            initAppUrls();
            RhoLogger.InitRhoLog();
            LOG.INFO("Init");

            CRhoFile.recursiveCreateDir(CFilePath.join(getBlobsDirPath(), " "));

            m_webBrowser = browser;
            if (m_appMainPage == null)
            {
                m_appMainPage = appMainPage;
            }
            if (m_layoutRoot == null)
            {
                m_layoutRoot = layoutRoot;
            }
            //m_appMainPage.ApplicationBar = null;

            if (m_httpServer == null)
            {
                m_httpServer = new CHttpServer(CFilePath.join(getRhoRootPath(), "apps"));
            }

            m_rhoView = rhoView;
            if (m_rhoView.MasterView)
            {
                m_masterView = rhoView;
            }
        }
Пример #6
0
        public static byte[] readResourceFile(String path)
        {
            byte[] content = new byte[0];
            path = CFilePath.removeFirstSlash(path);

            if (!CRhoFile.isResourceFileExist(path))
            {
                return(content);
            }

            var task = StorageFile.GetFileFromApplicationUriAsync(new Uri(path, UriKind.Relative)).AsTask();

            task.Wait();
            var sr         = task.Result;
            var streamTask = sr.OpenStreamForReadAsync();

            streamTask.Wait();

            using (System.IO.BinaryReader br = new BinaryReader(streamTask.Result))
            {
                content = br.ReadBytes((int)streamTask.Result.Length);
            }

            return(content);
        }
Пример #7
0
        public void Init(WebBrowser browser)
        {
            initAppUrls();
            RhoLogger.InitRhoLog();
            LOG.INFO("Init");

            CRhoFile.recursiveCreateDir(CFilePath.join(getBlobsDirPath(), " "));

            m_webBrowser = browser;
            m_httpServer = new CHttpServer(CFilePath.join(getRhoRootPath(), "apps"));
            CRhoResourceMap.deployContent();
            RhoRuby.Init(m_webBrowser);

            DBAdapter.initAttrManager();

            LOG.INFO("Starting sync engine...");
            SyncThread sync = null;

            try{
                sync = SyncThread.Create();
            }catch (Exception exc) {
                LOG.ERROR("Create sync failed.", exc);
            }
            if (sync != null)
            {
                //sync.setStatusListener(this);
            }

            RhoRuby.InitApp();
            RhoRuby.call_config_conflicts();
            RHOCONF().conflictsResolved();
        }
Пример #8
0
        public String resolveDBFilesPath(String strFilePath)
        {
            if (strFilePath.length() == 0 || strFilePath.startsWith(getRhoRootPath()))
            {
                return(strFilePath);
            }

            return(CFilePath.join(getRhoRootPath(), strFilePath));
        }
Пример #9
0
 public static void deleteFilesInFolder(String path)
 {
     using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
     {
         string[] arFiles = isoStore.GetFileNames(CFilePath.join(path, "*"));
         foreach (string strFile in arFiles)
         {
             isoStore.DeleteFile(CFilePath.join(path, strFile));
         }
     }
 }
Пример #10
0
        public static bool isResourceFileExist(String path)
        {
            StreamResourceInfo sr = Application.GetResourceStream(new Uri(CFilePath.removeFirstSlash(path), UriKind.Relative));

            if (sr == null)
            {
                return(false);
            }

            return(sr != null);
        }
Пример #11
0
        public String getPath(String szName)
        {
            String strPath = getString(szName);

            if (strPath.length() == 0)
            {
                return(strPath);
            }

            return(CFilePath.join(strPath, "/"));
        }
Пример #12
0
        public String canonicalizeRhoUrl(String url)
        {
            if (url == null || url.length() == 0)
            {
                return(getHomeUrl());
            }

            String strUrl = url.Replace('\\', '/');

            if (!strUrl.startsWith(getHomeUrl()) && !isExternalUrl(strUrl))
            {
                strUrl = CFilePath.join(getHomeUrl(), strUrl);
            }

            return(strUrl);
        }
Пример #13
0
        public static byte[] readResourceFile(String path)
        {
            byte[] content = new byte[0];
            path = CFilePath.removeFirstSlash(path);

            if (!CRhoFile.isResourceFileExist(path))
            {
                return(content);
            }

            StreamResourceInfo sr = Application.GetResourceStream(new Uri(path, UriKind.Relative));

            using (System.IO.BinaryReader br = new BinaryReader(sr.Stream))
            {
                content = br.ReadBytes((int)sr.Stream.Length);
            }

            return(content);
        }
Пример #14
0
        public static String readFileToString(String path)
        {
            string content = "";

            path = CFilePath.removeFirstSlash(path);

            if (!isFileExist(path))
            {
                return(content);
            }

            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
                using (Stream st = isoStore.OpenFile(path, FileMode.Open, FileAccess.Read, FileShare.None))
                    using (System.IO.BinaryReader br = new BinaryReader(st))
                    {
                        content = new String(br.ReadChars((int)st.Length));
                    }
            return(content);
        }
Пример #15
0
        public static String readStringFromResourceFile(String path)
        {
            string content = "";

            path = CFilePath.removeFirstSlash(path);

            if (!CRhoFile.isResourceFileExist(path))
            {
                return(content);
            }

            StreamResourceInfo sr = Application.GetResourceStream(new Uri(path, UriKind.Relative));

            using (System.IO.BinaryReader br = new BinaryReader(sr.Stream))
            {
                char[] str = br.ReadChars((int)sr.Stream.Length);
                content = new string(str);
            }

            return(content);
        }