Exemplo n.º 1
0
        public LocalHtml(PContent content, String userPath)
        {
            //var browser = new WebView();
            //String imagePfadContent = "SMK.zeug.PContent.p";
            String source = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                        (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString())), content.files[0]));
            var browser = new BaseUrlWebView(); // temporarily use this so we can custom-render in iOS

            var htmlSource = new HtmlWebViewSource();

            if (DependencyService.Get<ISaveAndLoad>().FileExistExact(source))
            {
                htmlSource.Html = DependencyService.Get<ISaveAndLoad>().LoadText(source);
            }

            if (Device.OS != TargetPlatform.iOS)
            {
                // the BaseUrlWebViewRenderer does this for iOS, until bug is fixed
                htmlSource.BaseUrl = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString()));
            }

            browser.Source = htmlSource;

            Content = browser;
        }
Exemplo n.º 2
0
        public LocalHtml2(PContent content, String userPath)
        {
            //Pfad setzen
            String source = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                        (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString())), content.files[0]));
            //browser und viewsource initalisieren
            var browser = new WebView();
            var htmlSource = new HtmlWebViewSource();
            // fals Datei vorhanden einlesen
            if (DependencyService.Get<ISaveAndLoad>().FileExistExact(source))
            {
                htmlSource.Html = DependencyService.Get<ISaveAndLoad>().LoadText(source);
            }
            //BaseUrl setzen um auf andere Dateien referenzieren zu können(Css, javascript oder html)
            htmlSource.BaseUrl = (DependencyService.Get<ISaveAndLoad>().PathCombine(
                            DependencyService.Get<ISaveAndLoad>().Getpath(userPath), "p" + content.content_ID.ToString()));

            browser.Source = htmlSource;
            Content = browser;
        }
Exemplo n.º 3
0
        public async Task<List<PContent>> GetPContent(int productid)
        {
            try
            {
                var client = new RestClient("http://" + _serverAdress);
                var request = new RestRequest("getPContent.php", Method.GET);
                request.AddParameter("product_ID", productid);

                request.Timeout = 5000;
                IRestResponse response = await client.ExecuteGetTaskAsync(request);
                if (response.ErrorException != null)
                {
                    throw response.ErrorException;
                }
                if (response.Content.Equals("0 results"))
                {
                    PContent pcontent = new PContent();
                    List<PContent> pContentList = new List<PContent>();
                    pContentList.Add(pcontent);
                    return pContentList;
                }
                var model = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PContent>>(response.Content);

                //creates a new List<PContent> and inserts all PContents as a List
                var model2 = new List<PContent>();
                foreach (var pcontent in model)
                {
                    //creates a new server request to add a List of PContent
                    var request2 = new RestRequest("getFileNames.php", Method.GET);
                    request2.AddParameter("content_ID", pcontent.content_ID);

                    request.Timeout = 1000;

                    IRestResponse response2 = await client.ExecuteGetTaskAsync(request2);
                    if (response.ErrorException != null)
                    {
                        throw response.ErrorException;
                    }
                    if (response2.Content.Equals("0 results"))
                    {
                        return new List<PContent>();
                    }
                    //inserts the List<PContent> for each PContent
                    List<string> nameList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(response2.Content);
                    PContent pContent2 = pcontent;
                    pContent2.files = nameList;
                    model2.Add(pContent2);
                }
                return model2;
            }
            catch (Exception e)
            {
                throw new Exception("Fehler aufgetreten: " + e);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// initialises dummies for testing purpoess
        /// </summary>
        /// <param name="userPath"></param>
        public void Initaldummies(String userPath)
        {
            string testText = "have some Text i hope you like it fighting and burning from turning from who we really are, flying to close to the sun as we were invincible, around the world we grow weaker as we exterminate, we are the children of the sun bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";

            List<Product> returnList = new List<Product>();
            var pro1 = new Product();
            pro1.product_ID = 0;
            pro1.product_Name = "Test";
            pro1.product_Thumbnail = ".png";
            pro1.product_Text = testText;
            pro1.PContents = new List<int>(new int[] { 0, 1, 2 });

            Product pro2 = new Product();
            pro2.product_ID = 1;
            pro2.product_Name = "Test";
            pro2.product_Thumbnail = ".png";
            pro2.product_Text = testText;
            pro2.PContents = new List<int>(new int[] { 3 });

            Product pro3 = new Product();
            pro3.product_ID = 2;
            pro3.product_Name = "Test";
            pro3.product_Thumbnail = ".png";
            pro3.product_Text = testText;
            pro3.PContents = new List<int>(new int[] { 4 });

            Product pro4 = new Product();
            pro4.product_ID = 3;
            pro4.product_Name = "Test";
            pro4.product_Thumbnail = ".png";
            pro4.product_Text = testText;
            pro4.PContents = new List<int>(new int[] { 5, 6 });

            returnList.Add(pro1);
            returnList.Add(pro2);
            returnList.Add(pro3);
            returnList.Add(pro4);

            List<PContent> returnList2 = new List<PContent>();
            PContent content1 = new PContent();
            content1.files = new List<string>(new String[] { "da.jpg", "haha.png", "devil.png" });
            content1.content_ID = 0;
            content1.content_Kind = 0;
            content1.content_Title = "BilderGalarie";

            PContent content2 = new PContent();
            content2.files = new List<string>(new String[] { "da.jpg", "haha.png", "devil.png" });
            content2.content_ID = 1;
            content2.content_Kind = 0;
            content2.content_Title = "BilderGalarie";

            PContent content3 = new PContent();
            content3.files = new List<string>(new String[] { "1 Profi Pneum-III_D-3_Üb.html" });
            content3.content_ID = 2;
            content3.content_Kind = 2;
            content3.content_Title = "WebView";

            PContent content4 = new PContent();
            content4.files = new List<string>(new String[] { "test.png", "test1.png" });
            content4.content_ID = 3;
            content4.content_Kind = 4;
            content4.content_Title = "Gallary";

            PContent content5 = new PContent();
            content5.files = new List<string>(new String[] { "da.jpg", "haha.png", "devil.png" });
            content5.content_ID = 4;
            content5.content_Kind = 0;
            content5.content_Title = "BilderGalarie";

            PContent content6 = null;
            PContent content7 = null;
            returnList2.Add(content1);
            returnList2.Add(content2);
            returnList2.Add(content3);
            returnList2.Add(content4);
            returnList2.Add(content5);
            returnList2.Add(content6);
            returnList2.Add(content7);

            SaveModelsLocal(userPath, returnList, returnList2);
        }