public void ListContentFluentConstructorWithNameAndEnumerableListItemContent_FillsNameAndItems() { var listContent = ListContent.Create("Name", new List <ListItemContent>()); Assert.IsNotNull(listContent.Items); Assert.AreEqual("Name", listContent.Name); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter is ListContent) { listContent = (ListContent)e.Parameter; } switch (listContent) { case ListContent.Recommend: WaterfallListView.ItemsSource = Data.OverAll.RecommendList; Data.OverAll.RecommendList.ResumeLoading(); break; case ListContent.Bookmark: WaterfallListView.ItemsSource = Data.OverAll.BookmarkList; Data.OverAll.BookmarkList.ResumeLoading(); break; case ListContent.Following: WaterfallListView.ItemsSource = Data.OverAll.FollowingList; Data.OverAll.FollowingList.ResumeLoading(); break; case ListContent.Ranking: WaterfallListView.ItemsSource = Data.OverAll.RankingList; Data.OverAll.RankingList.ResumeLoading(); break; } }
public void ListContentConstructorWithNameAndEnumerableListItemContent_FillsNameAndItems() { var listContent = new ListContent("Name", new List<ListItemContent>()); Assert.IsNotNull(listContent.Items); Assert.AreEqual("Name", listContent.Name); }
public void ListContentConstructorWithNameAndEnumerableFieldContent_FillsNameAndItems() { var listContent = new ListContent("Name", new ListItemContent[] {}); Assert.IsNotNull(listContent.Items); Assert.AreEqual("Name", listContent.Name); }
public void ListContentConstructorWithNameAndItems_FillsNameAndItems() { var listContent = new ListContent("Name", new ListItemContent(), new ListItemContent()); Assert.AreEqual(2, listContent.Items.Count()); Assert.AreEqual("Name", listContent.Name); }
private static ListContent ListContentWith1StaticContent() { var listContent = new ListContent(); listContent.Content.AddContent(new StaticContent()); return(listContent); }
public void ShouldCheckEquality(string minorValue1, string minorValue2, bool expectedEqualityResult) { //Given var firstListContent = new ListContent("Name", new[] { new ListItemContent("Header", "value", new ListItemContent("Subheader", "value").AsArray()), new ListItemContent("Header", "value", new [] { new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value2", new ListItemContent("Subsubheader", minorValue1).AsArray()) }) } ); var secondListContent = new ListContent("Name", new[] { new ListItemContent("Header", "value", new ListItemContent("Subheader", "value").AsArray()), new ListItemContent("Header", "value", new [] { new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value2", new ListItemContent("Subsubheader", minorValue2).AsArray()) }) }); //When var result = firstListContent.Equals(secondListContent); //Then result.Should().Be(expectedEqualityResult); }
/// <summary> /// 模拟移动 或者 点击 网址 /// </summary> private void SimMoveAndClick(string _retStr) { ListContent _retData; if (string.IsNullOrEmpty(_retStr)) { // 没有返回则不移动,因为重定向 return; // 如果没有返回,只随机移动 _retData = new ListContent(); _retData.top = ConstParameter.RandomSeed.Next(300, 600); _retData.left = ConstParameter.RandomSeed.Next(200, 800); } else { _retData = JsonConvert.DeserializeObject <ListContent>(_retStr); } CommonFunction.SimMoveAndLefClick(_retData.left, _retData.top, true); // 执行点击事件 if (!string.IsNullOrEmpty(_retStr)) { browser.ExecuteScriptAsync("var _n=" + _retData.title + ConstParameter.GET_POPUP_CLICK_A); } }
static void GenFile() { var templateFileName = "template.docx"; var tableContent = new TableContent("row"); tableContent.AddRow(new FieldContent("subject", "數學"), new FieldContent("score", "90")); tableContent.AddRow(new FieldContent("subject", "物理"), new FieldContent("score", "80")); var listContent = new ListContent("Team Members List") .AddItem( new FieldContent("Name", "Eric"), new FieldContent("Role", "Program Manager")) .AddItem( new FieldContent("Name", "Bob"), new FieldContent("Role", "Developer")); var nestLiest = new ListContent("NestedList") .AddItem(new ListItemContent("Role", "Program Manager") .AddNestedItem(new FieldContent("Name", "Eric")) .AddNestedItem(new FieldContent("Name", "Ann"))) .AddItem(new ListItemContent("Role", "Developer") .AddNestedItem(new FieldContent("Name", "Bob")) .AddNestedItem(new FieldContent("Name", "Richard"))); var imageContent = new ImageContent("Image", File.ReadAllBytes("cat.jpg")); var valuesToFill = new Content(new FieldContent("name", "王大明"), new FieldContent("avg", "85"), tableContent, listContent, nestLiest, imageContent); using var file = new FileStream(templateFileName, FileMode.Open, FileAccess.Read); using var outputFileStream = new FileStream("output.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite); file.CopyTo(outputFileStream); using var ouputDocument = new TemplateProcessor(outputFileStream).SetRemoveContentControls(true); ouputDocument.FillContent(valuesToFill); ouputDocument.SaveChanges(); }
private ListContent CreateList(ListType listType) { ListContent list = new ListContent() { ListType = listType }; for (int i = 0; i < 5; i++) { List <IContentEntity> itemList = new List <IContentEntity>(); ParagraphContent content = new ParagraphContent(); for (int j = 0; j < 5; j++) { content.Content.Add(new ContentText() { Content = "列表项" + j, Font = j % 2 == 1 ? font : fontYellow }); } content.Content.Add(new ContentText() { Content = i.ToString(), Font = i % 2 == 1 ? font : fontYellow }); itemList.Add(content); list.Content.Add(itemList); } return(list); }
public void ListContentFluentConstructorWithNameAndItems_FillsNameAndItems() { var listContent = ListContent.Create("Name", new ListItemContent(), new ListItemContent()); Assert.AreEqual(2, listContent.Items.Count()); Assert.AreEqual("Name", listContent.Name); }
public void ReportAboutCurrentDirectory(DirectoryInfoModel directory) { if (directory is null) { return; } string now = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); string pathResultedReport = Path.Combine( Directory.GetCurrentDirectory(), "Reports", "Report-Dir-" + now + ".docx"); CopyTemlateToResultDir("Dir", pathResultedReport); List <TableRowContent> rows = GetDrivesInfoRows(directory.FullName); var valuesToFill = new Content( new FieldContent("dateTime", now), new FieldContent("ShortName", directory.Name), new FieldContent("FullName", directory.FullName), new FieldContent("CreationDate", directory.Created.ToString()), new FieldContent("LastModifiedDate", directory.LastModyfied.ToString()), TableContent.Create("TableDisks", rows) ); ListContent listItems = new ListContent("AttributesList"); listItems = GetAttributes(directory.Attributes, listItems); valuesToFill.Lists.Add(listItems); SetValuesToFile(pathResultedReport, valuesToFill); }
public MainPage() { InitializeComponent(); var listContent = new ListContent(); #region testElements /*//TESTING IMAGEBUTTON * var imageButton = listContent.MountImageButton("https://www.al-murad.co.uk/3805/gloss-black-square-48cm-x-48cm-wall-mosaic.jpg", 108, 108, new Label(), 0, Color.Black); * MainGrid.Children.Add(imageButton);*/ /*//TESTING IMAGEHEADER * var imageHeader = listContent.MountImageHeader("http://curiosamente.diariodepernambuco.com.br/wp-content/uploads/2017/08/banana.png",200 ,200, "https://www.al-murad.co.uk/3805/gloss-black-square-48cm-x-48cm-wall-mosaic.jpg", 400, 400); * MainGrid.Children.Add(imageHeader);*/ /*//TESTING FOOTERLOGO * List<string> footerList = new List<string>() * { * "http://curiosamente.diariodepernambuco.com.br/wp-content/uploads/2017/08/banana.png", * "https://www.al-murad.co.uk/3805/gloss-black-square-48cm-x-48cm-wall-mosaic.jpg" * }; * var fl = listContent.MountFooterLogo(footerList); * MainGrid.Children.Add(fl);*/ //TESTING ROUNDED ENTRY /*var roundedEntry = listContent.MountRoundedEntry( * new Entry() { WidthRequest = 200 }, "https://image.flaticon.com/icons/png/16/34/34202.png", * 100, LayoutOptions.Center, LayoutOptions.Center); * * MainGrid.Children.Add(roundedEntry);*/ #endregion }
public object SaveChartToFile([FromQuery] string fileName) { byte[] chart = Convert.FromBase64String(StaticData.DataChart); string filePath = Path.ChangeExtension(fileName + " отчет с графиком", ".docx"); System.IO.File.Copy("TemplatesReportsWord/ChartReportTemplate.docx", filePath); using (FileStream fstream = System.IO.File.Open(filePath, FileMode.Open)) { List <IContentItem> fieldContents = new List <IContentItem>(); ListContent listContent = new ListContent("systems"); ListItemContent contentItems; TableContent tableContent; List <FieldContent> rows = new List <FieldContent>(); int number; foreach (var calculation in StaticData.ChartCalculation.calculations) { number = 1; tableContent = TableContent.Create("systemsMembers"); foreach (var value in calculation.values) { rows.Clear(); rows.Add(new FieldContent("number", number.ToString() + ".")); rows.Add(new FieldContent("parameterX", value.X.ToString())); rows.Add(new FieldContent("parameterY", value.Y.ToString())); tableContent.AddRow(rows.ToArray()); number++; } contentItems = new ListItemContent("system", calculation.nameSystem); contentItems.AddTable(tableContent); listContent.AddItem(contentItems); } fieldContents.Add(listContent); fieldContents.Add(new FieldContent("nameParameterX", StaticData.ChartCalculation.parameterNameX)); fieldContents.Add(new FieldContent("nameParameterY", StaticData.ChartCalculation.parameterNameY)); fieldContents.Add(new ImageContent("chart", chart)); using (var outputDocument = new TemplateProcessor(fstream).SetRemoveContentControls(true)) { outputDocument.FillContent(new Content(fieldContents.ToArray())); outputDocument.SaveChanges(); } } var memory = new MemoryStream(); using (var stream = new FileStream(filePath, FileMode.Open)) { stream.CopyTo(memory); } System.IO.File.Delete(filePath); memory.Position = 0; return(File(memory, MimeTypesMap.GetMimeType(filePath), filePath)); }
public void AddToList(IDockContent content) { if (ListContent.Contains(content) || IsInActiveList(content)) { return; } ListContent.Add(content); }
private static ListContent ListContentWithRowNumber() { var listContent = new ListContent(); listContent.Content.AddContent(new ExpressionContent { Expression = "Context.ItemNumber" }); return(listContent); }
public void ShouldSetNameAndItemsFromConstructor() { //Given //When var listContent = new ListContent(Name, new List <ListItemContent>()); //Then listContent.Name.Should().Be(Name); listContent.Items.Should().NotBeNull(); }
public void ShouldSetNameFromConstructor() { //Given //when var listContent = new ListContent(Name); //Then listContent.Name.Should().Be(Name); }
public void RemoveFromList(IDockContent content) { if (IsInActiveList(content)) { RemoveFromActiveList(content); } if (ListContent.Contains(content)) { ListContent.Remove(content); } }
private void htmlDocComplete(object sender, HtmlDocumentLoadCompleted e) { if (e.Error == null) { HtmlDocument htmlDoc = e.Document; if (htmlDoc != null) { HtmlNode node = htmlDoc.GetElementbyId("post_list"); //MessageBox.Show("Hellworld"); // string value = ""; List<ListContent> listContent = new List<ListContent>(); foreach (HtmlNode child in node.ChildNodes) { if (child.Attributes["class"] == null || child.Attributes["class"].Value != "post_item") continue; HtmlNode hn = HtmlNode.CreateNode(child.OuterHtml); ListContent listContextObj = new ListContent(); string tuijian = hn.SelectSingleNode("//*[@class=\"diggnum\"]").InnerText; string title = hn.SelectSingleNode("//*[@class=\"titlelnk\"]").InnerText; string jieshao = hn.SelectSingleNode("//*[@class=\"post_item_summary\"]").InnerText; string xinxi = hn.SelectSingleNode("//*[@class=\"post_item_foot\"]").InnerText; string xinxi2 = hn.SelectSingleNode("//*[@class=\"lightblue\"]").InnerText.Trim(); string xinxi3 = hn.SelectSingleNode("//*[@class=\"article_comment\"]").InnerText.Trim(); string xinxi4 = hn.SelectSingleNode("//*[@class=\"article_view\"]").InnerText.Trim(); String titleIDValue = hn.SelectSingleNode("//*[@class=\"diggnum\"]").InnerText; String titlelnk = hn.SelectSingleNode("//*[@class=\"titlelnk\"]").GetAttributeValue("href", ""); listContextObj.recommendImage = "/images/cream.png"; listContextObj.recommendCount=tuijian; listContextObj.Title = title; listContextObj.Introduce = jieshao; listContextObj.Info = xinxi2 + xinxi3 + xinxi4; listContextObj.titleLink = titlelnk; listContent.Add(listContextObj); } this.listBox1.ItemsSource = listContent; } } }
public void EqualsTest_CompareWithNull_NotEquals() { var firstListContent = new ListContent("Name", new ListItemContent("Header", "value", new ListItemContent("Subheader", "value")), new ListItemContent("Header", "value", new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value", new ListItemContent("Subsubheader1", "value")))); Assert.IsFalse(firstListContent.Equals(null)); }
private void StoreListToProviderA() { ListHolder lh = CreateHolder(); ListContent lc1 = new ListContent("c1"); ListContent lc2 = new ListContent("c2"); lh.Add(lc1); lh.Add(lc2); A().Provider().StoreNew(lh); A().Provider().Commit(); EnsureContent(A(), new string[] { "h1" }, new string[] { "c1", "c2" }); }
public void ListContentFluentAddItem_FillsNameAndItems() { var listContent = ListContent.Create("Name", new List <ListItemContent>()) .AddItem(ListItemContent.Create("ItemName", "Name")); Assert.IsNotNull(listContent.Items); Assert.AreEqual("Name", listContent.Name); Assert.AreEqual(listContent.Items.Count, 1); Assert.AreEqual(listContent.Items.First().Fields.Count, 1); Assert.AreEqual(listContent.Items.First().Fields.First().Name, "ItemName"); Assert.AreEqual(listContent.Items.First().Fields.First().Value, "Name"); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter is ListContent content) { listContent = content; } switch (listContent) { case ListContent.Recommend: if (IllustsCollectionManager.RecommendList is null) { IllustsCollectionManager.RefreshRecommendList(); } WaterfallListView.ItemsSource = IllustsCollectionManager.RecommendList; break; case ListContent.Bookmark: if (IllustsCollectionManager.BookmarkList is null) { IllustsCollectionManager.RefreshBookmarkList(); } WaterfallListView.ItemsSource = IllustsCollectionManager.BookmarkList; break; case ListContent.Following: if (IllustsCollectionManager.FollowingList is null) { IllustsCollectionManager.RefreshFollowingList(); } WaterfallListView.ItemsSource = IllustsCollectionManager.FollowingList; break; case ListContent.Ranking: if (IllustsCollectionManager.RankingList is null) { IllustsCollectionManager.RefreshRankingList(); } WaterfallListView.ItemsSource = IllustsCollectionManager.RankingList; break; case ListContent.SearchResult: ((Frame.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder(OverAll.GetResourceString("SearchPagePlain")); WaterfallListView.ItemsSource = IllustsCollectionManager.SearchResults.Pop(); break; } if (WaterfallListView.ItemsSource is IllustsCollectionBase <ViewModels.WaterfallItemViewModel> collection) { Debug.WriteLine(WaterfallListView.ItemsSource + "\tResumeLoading"); collection.ResumeLoading(); verticalOffset = collection.VerticalOffset; } }
internal void SetCellContents(ListContent renderContents) { if (m_instance != null) { m_instance.SetNewContext(); } m_currentListContents = renderContents; if (m_shimContainer != null) { m_cellContents.SetNewContext(); m_shimContainer.UpdateListContents(m_currentListContents); } }
public void SetCellContents(ListContent renderContents) { if (base.m_instance != null) { base.m_instance.SetNewContext(); } this.m_currentListContents = renderContents; if (this.m_shimContainer != null) { base.m_cellContents.SetNewContext(); this.m_shimContainer.UpdateListContents(this.m_currentListContents); } }
protected override void InitResultHandler(MySqlDataReader re) { while (re.Read()) { Paper paper = new Paper() { Name = (string)GetObjectFromReader("name", re), Location = (string)GetObjectFromReader("location", re), Date = (string)GetObjectFromReader("date", re), }; ListContent.Add(paper); } }
public ActionResult Index(PagerParameters pagerParameters, SearchVM search, bool ShowVideo = false) { dynamic Options = new System.Dynamic.ExpandoObject(); Options.ShowVideo = false; if (!_orchardServices.Authorizer.Authorize(TestPermission)) { return(new HttpUnauthorizedResult()); } var expression = search.Expression; IContentQuery <ContentItem> contentQuery = _orchardServices.ContentManager.Query().ForType(contentType).OrderByDescending <CommonPartRecord>(cpr => cpr.ModifiedUtc); Int32 currentiduser = _orchardServices.WorkContext.CurrentUser.Id; IEnumerable <ContentItem> ListContent; bool hasAdminPermission = _orchardServices.Authorizer.Authorize(Permissions.AdminTwitterAccount); if (hasAdminPermission) { ListContent = contentQuery.List(); } else { ListContent = contentQuery.List().Where(x => x.As <TwitterAccountPart>().IdUser == currentiduser); } if (!string.IsNullOrEmpty(search.Expression)) { ListContent = from content in ListContent where ((content.As <TitlePart>().Title ?? "").Contains(expression, StringComparison.InvariantCultureIgnoreCase)) select content; } IEnumerable <ContentIndexVM> listVM = ListContent.Select(p => new ContentIndexVM { Id = p.Id, Title = p.As <TwitterAccountPart>().AccountType + " - " + p.As <TwitterAccountPart>().DisplayAs,// string.IsNullOrEmpty(p.As<TwitterAccountPart>().PageName) ? "User Account" : " Page -> " + p.As<TwitterAccountPart>().PageName, ModifiedUtc = p.As <CommonPart>().ModifiedUtc, UserName = p.As <CommonPart>().Owner.UserName, Option = new { Valid = p.As <TwitterAccountPart>().Valid, Shared = p.As <TwitterAccountPart>().Shared, Image = Url.Content("~/Media/" + _shellSettings.Name + "/twitter_" + p.As <TwitterAccountPart>().DisplayAs + ".jpg") } }); Pager pager = new Pager(_orchardServices.WorkContext.CurrentSite, pagerParameters); dynamic pagerShape = _orchardServices.New.Pager(pager).TotalItemCount(listVM.Count()); var list = listVM.Skip(pager.GetStartIndex()) .Take(pager.PageSize); var model = new SearchIndexVM(list, search, pagerShape, Options); return(View((object)model)); }
///<inheritdoc cref="ITemplateDocumentBuilder.FillTabelsContent{TRow}"/> public ITemplateDocumentBuilder FillTabelsContent <TRow>(DocumentList <DocumentTable <TRow> > tabels) where TRow : class { var listContent = new ListContent(tabels.ListKey); foreach (var table in tabels.ListItems) { var tableContent = ConstructTableContent(table); listContent.AddItem(new ListItemContent("TableHeader", table.TableHeader).AddTable(tableContent)); } _documentContent.Lists.Add(listContent); return(this); }
public void ShouldSetNameAndItemsByContructorParams() { //Given var item1 = new ListItemContent(); var item2 = new ListItemContent(); //When var listContent = new ListContent(Name, new[] { item1, item2 }); //Then listContent.Name.Should().Be(Name); listContent.Items.Count.Should().Be(2); listContent.Items.Should().Contain(item1); listContent.Items.Should().Contain(item2); }
public ActionResult Index(int?id) { Pagintation paginat = new Pagintation(id); var request = (from c in db.preposts orderby c.id descending select c).Skip(paginat.firstElement).Take(elementPage); List <preposts> content = request.ToList(); ListContent listContent = new ListContent(content); ViewBag.Preposts = listContent.GetCardPage(elementLine); ViewBag.Pagination = paginat; return(View()); }
protected override void InitResultHandler(MySqlDataReader re) { while (re.Read()) { ServiceCommon v = new ServiceCommon() { Title = (string)GetObjectFromReader("title", re), Content = (string)GetObjectFromReader("content", re), Remark = (string)GetObjectFromReader("Remark", re), Time = (string)GetObjectFromReader("date", re), }; ListContent.Add(v); } }
private void AddElementInProviderA() { ListHolder lh = (ListHolder)GetOneInstance (A(), typeof(ListHolder)); lh.SetName("h3"); ListContent lc3 = new ListContent("co3"); A().Provider().StoreNew(lc3); lh.GetList().Add(lc3); A().Provider().Update(lh.GetList()); A().Provider().Update(lh); A().Provider().Commit(); EnsureContent(A(), new string[] { "h3" }, new string[] { "co1", "co2", "co3" }); }
public void ListContentGetFieldnames() { var listContent = new ListContent("Name", new ListItemContent("Header", "value", new ListItemContent("Subheader", "value")), new ListItemContent("Header", "value", new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value2", new ListItemContent("Subsubheader", "value")))); Assert.IsNotNull(listContent.Items); Assert.AreEqual("Name", listContent.Name); Assert.AreEqual(3, listContent.FieldNames.Count()); Assert.AreEqual("Header", listContent.FieldNames.ToArray()[0]); Assert.AreEqual("Subheader", listContent.FieldNames.ToArray()[1]); Assert.AreEqual("Subsubheader", listContent.FieldNames.ToArray()[2]); }
public void EqualsTest_ValuesDifferByNestedValue_NotEquals() { var firstListContent = new ListContent("Name", new ListItemContent("Header", "value", new ListItemContent("Subheader", "value")), new ListItemContent("Header", "value", new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value", new ListItemContent("Subsubheader1", "value")))); var secondListContent = new ListContent("Name", new ListItemContent("Header", "value", new ListItemContent("Subheader", "value")), new ListItemContent("Header", "value", new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value", new ListItemContent("Subsubheader2", "value")))); Assert.IsFalse(firstListContent.Equals(secondListContent)); }
public void ListContentConstructorWithName_FillsName() { var listContent = new ListContent("Name"); Assert.AreEqual("Name", listContent.Name); }
public void EqualsTest_ValuesAreEqual_Equals() { var firstListContent = new ListContent("Name", new ListItemContent("Header", "value", new ListItemContent("Subheader", "value")), new ListItemContent("Header", "value", new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value2", new ListItemContent("Subsubheader", "value")))); var secondListContent = new ListContent("Name", new ListItemContent("Header", "value", new ListItemContent("Subheader", "value")), new ListItemContent("Header", "value", new ListItemContent("Subheader", "value"), new ListItemContent("Subheader", "value2", new ListItemContent("Subsubheader", "value")))); Assert.IsTrue(firstListContent.Equals(secondListContent)); }