Beispiel #1
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (InteropLib.HasRootAccess() == false)
            {
                // double check
                System.Threading.Thread.Sleep(1000);
                if (InteropLib.HasRootAccess() == false)
                {
                    MessageBox.Show(LocalizedResources.txtNoRootAccess, LocalizedResources.txtError, MessageBoxButton.OK);
                    throw new Exception("Quit");
                }
            }
            if (!IsolatedStorageSettings.ApplicationSettings.Contains("LicenseShownOnce"))
            {
                NavigationService.Navigate(new Uri("/pageLicense.xaml", UriKind.Relative));
                return;
            }
            IDictionary <String, String> qs = this.NavigationContext.QueryString;
            string arg = null;

            if (qs.ContainsKey("file"))
            {
                arg = qs["file"];
            }

            if (arg != null)
            {
                var bytes = System.Text.Encoding.Unicode.GetBytes(arg);
                var uri   = new Uri("/MainPage.xaml?file=base64" + Convert.ToBase64String(bytes) + "&cleanstack=true", UriKind.Relative);
                NavigationService.Navigate(uri);
                return;
            }
            LoadState();
            ShowGreetingAnimation.Begin();

            /*
             * ApplicationBarIconButton button1 = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
             * if (button1 != null)
             * {
             *  button1.Text = LocalizedResources.txtFileBrowser;
             * }
             *
             * ApplicationBarMenuItem item = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
             * if (item != null)
             * {
             *  item.Text = LocalizedResources.txtAbout;
             * }
             */
        }
        private static List <FileViewModel> GetActualItemList(string path)
        {
            var list = new List <FileViewModel>();

            bool isRoot = false;

            if (path == "\\" || path == "")
            {
                isRoot = true;
            }

            if (!isRoot)
            {
                var back = new FileViewModel();
                back.Text        = "..";
                back.IsDirectory = true;
                back.IconUri     = "icons/back.png";
                back.IsSpecial   = true;
                if (Utils.IsLightTheme())
                {
                    back.IconUri = back.IconUri.Replace("icons/", "icons/light/");
                }
                list.Add(back);
            }

            string searchPattern = System.IO.Path.Combine(path, "*");
            var    files         = InteropLib.GetContent(searchPattern);

            foreach (var file in files)
            {
                string loweredFileName = file.FileName.ToLower();
                if (file.IsDirectory ||
                    loweredFileName.EndsWith(".xap") ||
                    loweredFileName.EndsWith(".exe7") ||
                    loweredFileName.EndsWith(".exe") ||
                    loweredFileName.EndsWith(".provxml"))
                {
                    var lbd = new FileViewModel();
                    lbd.Text        = file.FileName;
                    lbd.IsDirectory = file.IsDirectory;
                    if (file.IsDirectory)
                    {
                        lbd.IconUri = "icons/folder.png";
                    }
                    else
                    {
                        if (loweredFileName.EndsWith(".xap"))
                        {
                            lbd.IconUri = "icons/xap.png";
                        }
                        else if (loweredFileName.EndsWith(".exe"))
                        {
                            lbd.IconUri = "icons/exe.png";
                        }
                        else if (loweredFileName.EndsWith(".provxml"))
                        {
                            lbd.IconUri = "icons/provxml.png";
                        }
                        else
                        {
                            lbd.IconUri = "icons/exe7.png";
                        }
                    }
                    if (Utils.IsLightTheme())
                    {
                        lbd.IconUri = lbd.IconUri.Replace("icons/", "icons/light/");
                    }
                    list.Add(lbd);
                }
            }
            list.Sort(new FileViewModelComparer());
            return(list);
        }