���ø�
예제 #1
0
        public static LbTemplate FromXml(XElement xElement)
        {
            /**
             * 	<Template Key="SingleStringPage" DisplayName="1-line text" Description="Show single line of text" TemplateView="SimpleText" TemplateModel="SingleStringPage">
                    <DataList>
                        <Data Key="Text" Name="Text" ValueType="String" DefaultData="" />
                    </DataList>
                </Template>
             * */
            var template = new LbTemplate();
            template.Key = xElement.Attribute("Key").Value;
            template.DisplayName = xElement.Attribute("Name").Value;
            template.Description = xElement.Attribute("Description").Value;
            template.TemplateView = xElement.Attribute("TemplateView").Value;
            template.TemplateModel = xElement.Attribute("TemplateModel").Value;

            // �ٱ��� ó��.
            try
            {
                var loader = new Windows.ApplicationModel.Resources.ResourceLoader("TemplateList");
                var localeName = loader.GetString(String.Format("{0}/{1}", template.Key, "Name"));
                if (!String.IsNullOrEmpty(localeName))
                    template.DisplayName = localeName;
                var localeDescription = loader.GetString(String.Format("{0}/{1}", template.Key, "Description"));
                if (!String.IsNullOrEmpty(localeDescription))
                    template.Description = localeDescription;
            }
            catch (Exception)
            {
            }

            if (xElement.Element("DataList") != null && xElement.Element("DataList").HasElements)
                template.DataList = new List<LbPageData>();
            else
                return template;

            foreach (var data in xElement.Element("DataList").Elements("Data"))
            {
                template.DataList.Add(LbPageData.FromXml(template.Key, data));
            }

            Debug.WriteLine(typeof(IEnumerable<string>));
            return template;
        }
예제 #2
0
		/// <summary>
		/// 데이터로 템플릿 사용.
		/// </summary>
		/// <param name="template"></param>
		/// <returns></returns>
		private IPage generatePageFromTemaplate(LbTemplate template)
		{
			if (template == null)
				throw new ArgumentNullException("template");

			var model = Type.GetType("LiveBoard.PageTemplate.Model." + template.TemplateModel);
			if (model == null)
				throw new ArgumentException("Template model not found.");

			var page = (IPage)Activator.CreateInstance(model);
			page.TemplateKey = template.Key;
			page.View = template.TemplateView;
			page.Title = "Page " + (ActiveBoard.Board.Pages.Count + 1);
			page.Duration = TimeSpan.FromSeconds(5.0d);
			page.IsVisible = true;
			page.Guid = Guid.NewGuid().ToString();
			page.Data = new List<LbPageData>();
			foreach (var d in template.DataList)
			{
				var copyData = LbPageData.FromXml(page.TemplateKey, d.ToXml(true));
				((List<LbPageData>)page.Data).Add(copyData);
			}

			return page;
		}
예제 #3
0
		/// <summary>
		/// 페이지 추가
		/// </summary>
		private void AddPage()
		{
			// 템플릿오브젝트에서 페이지 생성.
			var t = new LbTemplate
			{
				Key = "SingleUrlImage",
				DisplayName = "Simple image viewer from web",
				Description = "Show single image",
				TemplateView = "SimpleUrlImage",
				TemplateModel = "SingleStringPage",
				DataList = new List<LbPageData>()
				{
					new LbPageData()
					{
						Key = "Url", 
						DefaultData = "http://inserbia.info/news/wp-content/uploads/2013/05/grizzly-650x487.jpg",
						Name = "헤더 정보",
						ValueType = typeof(String)
					}
				}
			};

			var pageExample1 = generatePageFromTemaplate(t);
			ActiveBoard.Board.Pages.Add(pageExample1);
		}