public static Collection <menu> getMenus()
        {
            Collection <menu> arr = new Collection <menu>();

            System.Windows.Resources.StreamResourceInfo stream = Application.GetResourceStream(new Uri("menus.txt", UriKind.Relative));
            StreamReader reader = new StreamReader(stream.Stream);
            XDocument    xml    = XDocument.Load(reader);

            foreach (XElement ee in xml.Descendants("menu"))
            {
                menu item = new menu();
                item.name = (ee.Descendants(XName.Get("name")).First().Value);
                item.apps = new Collection <appentry>();
                foreach (XElement application in ee.Descendants("application"))
                {
                    appentry app = new appentry();
                    app.name = application.Attribute(XName.Get("name")).Value;
                    app.guid = application.Attribute(XName.Get("guid")).Value;
                    app.path = application.Attribute(XName.Get("path")).Value;
                    item.apps.Add(app);
                }
                arr.Add(item);
            }
            return(arr);
        }
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            if (!isInit)
            {
                NavigationContext.QueryString.TryGetValue("folder", out folderName);
                if (folderName != "")
                {
                    PageTitle.Text = "edit: " + folderName;
                    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        using (var stream = new IsolatedStorageFileStream(folderName + ".folder", FileMode.OpenOrCreate, store))
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                curMenu = new menu();
                                try
                                {
                                    var serial = new XmlSerializer(typeof(menu));
                                    curMenu = (menu)serial.Deserialize(stream);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                    if (curMenu.apps == null)
                    {
                        curMenu.apps = new System.Collections.ObjectModel.Collection <appentry>();
                    }

                    string appName = "";
                    NavigationContext.QueryString.TryGetValue("add", out appName);
                    if (appName != "" && appName != null)
                    {
                        string appGuid = "";
                        NavigationContext.QueryString.TryGetValue("guid", out appGuid);
                        appentry app = new appentry();
                        app.name = appName;
                        app.guid = appGuid;
                        string appPath = "";
                        NavigationContext.QueryString.TryGetValue("path", out appPath);
                        if (appPath != "" && appPath != null)
                        {
                            app.path = "app://" + appPath;
                        }
                        curMenu.apps.Add(app);
                    }
                    save();
                    regenList();
                }
                else
                {
                    MessageBox.Show("I didn't get any arguments...", "Well this is awkward", MessageBoxButton.OK);
                }
                isInit = true;
            }
        }
Beispiel #3
0
        void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                appimages.Clear();
                apps.Clear();
                string   data = e.Result;
                string[] s    = data.Split(new string[] { "<a:entry>" }, StringSplitOptions.None);
                string[] s2;
                bool     isfirst = true;
                foreach (string app in s)
                {
                    if (isfirst)
                    {
                        isfirst = false;
                    }
                    else
                    {
                        appentry appentry = new appentry();
                        s2 = app.Split(new string[] { "<a:title" }, StringSplitOptions.None);
                        s2 = s2[1].Split(">".ToCharArray());
                        s2 = s2[1].Split("<".ToCharArray());
                        listBox1.Items.Add(s2[0]);
                        appentry.name = s2[0];

                        s2            = app.Split(new string[] { "<a:id>urn:uuid:" }, StringSplitOptions.None);
                        s2            = s2[1].Split("<".ToCharArray());
                        appentry.guid = s2[0];

                        s2 = app.Split(new string[] { "<id>urn:uuid:" }, StringSplitOptions.None);
                        s2 = s2[1].Split("<".ToCharArray());

                        appimages.Add(s2[0]);
                        apps.Add(appentry);
                    }
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("That didn't work ):\r\n" + ee.Message);
            }
            updateListbox();
        }
        public static void initInstalledApps()
        {
            if (installedApps.Count < 1)
            {
                //init applications list
                isRoot = WP7RootToolsSDK.Environment.HasRootAccess();

                if (isRoot)
                {
                    foreach (var x in WP7RootToolsSDK.Applications.GetApplicationList())
                    {
                        clsData.installedApps.Add(ManifestLoader.getAppFromManifest(@"\Applications\Install\" + x.ProductID.ToString() + @"\Install\"));
                    }
                }
            }

            for (int i = 0; i < appTitles.Length; i++)
            {
                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (var stream = new IsolatedStorageFileStream(appTitles[i] + ".jpg", FileMode.OpenOrCreate, store))
                    {
                        System.Windows.Resources.StreamResourceInfo str = Application.GetResourceStream(new Uri(defaultImgs[i], UriKind.Relative));
                        str.Stream.CopyTo(stream);
                        stream.Close();
                    }
                }
                appentry app = new appentry();
                app.guid = appTitles[i];
                app.name = appTitles[i];
                app.path = "app://" + defaultApps[i];

                clsData.installedApps.Add(app);
            }
            clsData.installedApps = new Collection <appentry>(clsData.installedApps.OrderBy(arr => arr.name).ToList());
        }
Beispiel #5
0
        public static appentry getAppFromManifest(string path)
        {
            appentry toreturn = new appentry();

            toreturn.name = "";
            System.Diagnostics.Debug.WriteLine(path);
            var    bdata = WP7RootToolsSDK.FileSystem.ReadFile(path + "WMAppManifest.xml");
            string data  = System.Text.Encoding.UTF8.GetString(bdata, 0, bdata.Length);

            //MessageBox.Show(data);
            data = data.Substring(data.IndexOf("<"));

            try
            {
                var appManifestXml = XDocument.Parse(data);
                using (var rdr = appManifestXml.CreateReader(ReaderOptions.None))
                {
                    rdr.ReadToDescendant("App");
                    if (!rdr.IsStartElement())
                    {
                        MessageBox.Show("App tag not found in WMAppManifest.xml");
                        throw new System.FormatException("App tag not found in WMAppManifest.xml");
                    }
                    rdr.MoveToFirstAttribute();
                    while (rdr.MoveToNextAttribute())
                    {
                        if (rdr.Name == "ProductID")
                        {
                            toreturn.guid = rdr.Value;
                        }
                    }
                    rdr.MoveToContent();
                    rdr.ReadToDescendant("IconPath");
                    string icon = rdr.ReadElementContentAsString();

                    toreturn.name = WP7RootToolsSDK.Applications.GetApplicationName(new Guid(toreturn.guid));


                    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        if (!store.FileExists(toreturn.guid + ".jpg"))
                        {
                            using (var stream = new IsolatedStorageFileStream(toreturn.guid + ".jpg", FileMode.OpenOrCreate, store))
                            {
                                byte[] buf = WP7RootToolsSDK.FileSystem.ReadFile(path + icon);
                                stream.Write(buf, 0, buf.Length);
                                //CSharp___DllImport.Phone.IO.File7.WriteAllBytes("/Applications/Install/a2e30887-7682-43cf-9a71-c20104b190fa/Install/apps/" + toreturn.guid + ".jpg", buf);
                            }
                        }
                    }
                    rdr.ReadToNextSibling("Tasks");
                    //rdr.MoveToContent();
                    rdr.ReadToDescendant("DefaultTask");
                    //rdr.ReadToDescendant("DefaultTask");

                    rdr.MoveToFirstAttribute();
                    //while (rdr.MoveToNextAttribute())
                    //  if (rdr.Name == "Name")
                    toreturn.path = "app://" + toreturn.guid.Replace("{", "").Replace("}", "") + "/" + rdr.Value;


                    //MessageBox.Show(toreturn.path);
                    //MessageBox.Show(rdr.ReadToDescendant("IconPath").ToString());
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message);
            }

            return(toreturn);
        }