예제 #1
0
        /// <summary>
        /// Theme widtegs
        /// </summary>
        public WidgetsVM()
        {
            try
            {
                var packages = Packaging.FileSystem.LoadWidgets();
                AvailableWidgets = new List<WidgetItem>();
                foreach (var pk in packages)
                {
                    AvailableWidgets.Add(new WidgetItem { Id = pk.Id, Name = pk.Title, Title = pk.Title, ShowTitle = false });
                }

                WidgetZones = new List<WidgetZone>();
                WebClient client = new WebClient();
                var html = client.DownloadString(Utils.AbsoluteWebRoot);
                var cnt = 0;
                var tag = "widgetzone_";

                for (int i = 0; i < 10; i++)
                {
                    int from = html.IndexOf(tag, cnt);
                    if (from > 0)
                    {
                        from = from + 11;
                        int to = html.IndexOf("\"", from);
                        var zoneId = html.Substring(from, to - from);
                        var zone = new WidgetZone();
                        zone.Id = zoneId;

                        var xml = RetrieveXml(zoneId);
                        var wd = new WidgetData { Settings = xml.InnerXml };

                        //------------------------------
                        var widgets = xml.SelectSingleNode("widgets");
                        zone.Widgets = new List<WidgetItem>();
                        if (widgets != null)
                        {
                            foreach (XmlNode node in widgets.ChildNodes)
                            {
                                if (node != null && node.Attributes != null)
                                {
                                    var item = new WidgetItem();
                                    item.Id = node.Attributes["id"].InnerText;
                                    item.Name = node.InnerText;
                                    item.Title = node.Attributes["title"].InnerText;
                                    item.ShowTitle = bool.Parse(node.Attributes["showTitle"].InnerText);
                                    zone.Widgets.Add(item);
                                }
                            }
                        }
                        //------------------------------

                        WidgetZones.Add(zone);
                        cnt = to;
                    }
                    else { break; }
                }
            }
            catch (Exception) { }
        }
예제 #2
0
        /// <summary>
        /// Theme widtegs
        /// </summary>
        public WidgetsVM()
        {
            try
            {
                WidgetZones = new List<WidgetZone>();
                WebClient client = new WebClient();
                var html = client.DownloadString(Utils.AbsoluteWebRoot);
                var cnt = 0;
                var tag = "widgetzone_";

                for (int i = 0; i < 10; i++)
                {
                    int from = html.IndexOf(tag, cnt);
                    if (from > 0)
                    {
                        from = from + 11;
                        int to = html.IndexOf("\"", from);
                        var zoneId = html.Substring(from, to - from);
                        var zone = new WidgetZone();
                        zone.Id = zoneId;

                        //var ws = new WidgetSettings(zoneId);

                        //var abc = ws.GetSettings();

                        // var x = (StringDictionary)ws.GetSettings();


                        var xml = RetrieveXml(zoneId);
                        var wd = new WidgetData { Settings = xml.InnerXml };

                        //------------------------------
                        var widgets = xml.SelectSingleNode("widgets");
                        if (widgets != null)
                        {
                            zone.Widgets = new List<WidgetItem>();
                            foreach (XmlNode node in widgets.ChildNodes)
                            {
                                if (node != null && node.Attributes != null)
                                {
                                    var item = new WidgetItem();
                                    item.Id = new Guid(node.Attributes["id"].InnerText);
                                    item.Title = node.Attributes["title"].InnerText;
                                    item.ShowTitle = bool.Parse(node.Attributes["showTitle"].InnerText);
                                    zone.Widgets.Add(item);
                                }
                            }
                        }
                        //------------------------------

                        WidgetZones.Add(zone);
                        cnt = to;
                    }
                    else { break; }
                }
            }
            catch (Exception) { }
        }
예제 #3
0
        private void AddZones(string html)
        {
            try
            {
                var  cnt   = 0;
                bool found = false;
                var  tag   = "widgetzone_";

                for (int i = 0; i < 10; i++)
                {
                    int from = html.IndexOf(tag, cnt);
                    if (from > 0)
                    {
                        from = from + 11;
                        int to     = html.IndexOf("\"", from);
                        var zoneId = html.Substring(from, to - from);
                        var zone   = new WidgetZone();
                        zone.Id = zoneId;

                        var xml = RetrieveXml(zoneId);
                        var wd  = new WidgetData {
                            Settings = xml.InnerXml
                        };

                        var widgets = xml.SelectSingleNode("widgets");
                        zone.Widgets = new List <WidgetItem>();
                        if (widgets != null)
                        {
                            foreach (XmlNode node in widgets.ChildNodes)
                            {
                                if (node != null && node.Attributes != null)
                                {
                                    var item = new WidgetItem();
                                    item.Id        = node.Attributes["id"].InnerText;
                                    item.Name      = node.InnerText;
                                    item.Title     = node.Attributes["title"].InnerText;
                                    item.ShowTitle = bool.Parse(node.Attributes["showTitle"].InnerText);
                                    zone.Widgets.Add(item);
                                }
                            }
                        }
                        found = false;
                        if (WidgetZones.Count > 0)
                        {
                            foreach (var z in WidgetZones)
                            {
                                if (z.Id == zone.Id)
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                        if (!found)
                        {
                            WidgetZones.Add(zone);
                        }
                        cnt = to;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception) { }
        }
예제 #4
0
        /// <summary>
        /// Theme widtegs
        /// </summary>
        public WidgetsVM()
        {
            try
            {
                var packages = Packaging.FileSystem.LoadWidgets();
                AvailableWidgets = new List <WidgetItem>();
                foreach (var pk in packages)
                {
                    AvailableWidgets.Add(new WidgetItem {
                        Id = pk.Id, Name = pk.Title, Title = pk.Title, ShowTitle = false
                    });
                }

                WidgetZones = new List <WidgetZone>();
                WebClient client = new WebClient();
                var       html   = client.DownloadString(Utils.AbsoluteWebRoot);
                var       cnt    = 0;
                var       tag    = "widgetzone_";

                for (int i = 0; i < 10; i++)
                {
                    int from = html.IndexOf(tag, cnt);
                    if (from > 0)
                    {
                        from = from + 11;
                        int to     = html.IndexOf("\"", from);
                        var zoneId = html.Substring(from, to - from);
                        var zone   = new WidgetZone();
                        zone.Id = zoneId;

                        var xml = RetrieveXml(zoneId);
                        var wd  = new WidgetData {
                            Settings = xml.InnerXml
                        };

                        //------------------------------
                        var widgets = xml.SelectSingleNode("widgets");
                        zone.Widgets = new List <WidgetItem>();
                        if (widgets != null)
                        {
                            foreach (XmlNode node in widgets.ChildNodes)
                            {
                                if (node != null && node.Attributes != null)
                                {
                                    var item = new WidgetItem();
                                    item.Id        = node.Attributes["id"].InnerText;
                                    item.Name      = node.InnerText;
                                    item.Title     = node.Attributes["title"].InnerText;
                                    item.ShowTitle = bool.Parse(node.Attributes["showTitle"].InnerText);
                                    zone.Widgets.Add(item);
                                }
                            }
                        }
                        //------------------------------

                        WidgetZones.Add(zone);
                        cnt = to;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception) { }
        }
예제 #5
0
        private void AddZones(string html)
        {
            try
            {
                var cnt = 0;
                bool found = false;
                var tag = "widgetzone_";

                for (int i = 0; i < 10; i++)
                {
                    int from = html.IndexOf(tag, cnt);
                    if (from > 0)
                    {
                        from = from + 11;
                        int to = html.IndexOf("\"", from);
                        var zoneId = html.Substring(from, to - from);
                        var zone = new WidgetZone();
                        zone.Id = zoneId;

                        var xml = RetrieveXml(zoneId);
                        var wd = new WidgetData { Settings = xml.InnerXml };

                        var widgets = xml.SelectSingleNode("widgets");
                        zone.Widgets = new List<WidgetItem>();
                        if (widgets != null)
                        {
                            foreach (XmlNode node in widgets.ChildNodes)
                            {
                                if (node != null && node.Attributes != null)
                                {
                                    var item = new WidgetItem();
                                    item.Id = node.Attributes["id"].InnerText;
                                    item.Name = node.InnerText;
                                    item.Title = node.Attributes["title"].InnerText;
                                    item.ShowTitle = bool.Parse(node.Attributes["showTitle"].InnerText);
                                    zone.Widgets.Add(item);
                                }
                            }
                        }
                        found = false;
                        if (WidgetZones.Count > 0)
                        {
                            foreach (var z in WidgetZones)
                            {
                                if(z.Id == zone.Id)
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                        if (!found)
                        {
                            WidgetZones.Add(zone);
                        }
                        cnt = to;
                    }
                    else { break; }
                }
            }
            catch (Exception) { }
        }