private void menuItem_addItem_Click(object sender, EventArgs e) { _isPressedCtrl = false; if (SelectedPage == null) { return; } if (_ancherItems.Count > 0) { return; } var selectedCells = _cells.Where(o => o.IsSelected).ToList(); if (selectedCells.Count == 0) { return; } var minX = selectedCells.Min(o => o.X); var minY = selectedCells.Min(o => o.Y); var maxX = selectedCells.Max(o => o.X); var maxY = selectedCells.Max(o => o.Y); var src = new PageItem() { X = minX, Y = minY, Width = maxX - minX + PageBody.Grid, Height = maxY - minY + PageBody.Grid, }; var item = CreatePageItem(SelectedPage, src, SelectedPage.PageName); if (item != null) { AddAncherItem(item); } src.Dispose(); src = null; _cells.ForEach(o => o.IsSelected = false); }
public PageItem Copy() { var result = new PageItem(); try { var categoryFilter = new string[] { "Page Option" }; var ignorePropertyFilter = new string[] { "BackgroundImage" }; ReflectionUtil.CopyProperties(this, result, categoryFilter, ignorePropertyFilter); if (BackgroundImage != null) { result.BackgroundImage = CopyBackgroundImage(); } return(result); } catch { result.Dispose(); return(null); } }
private static void LoadPageItems(Dictionary <string, object> properties) { if (!properties.ContainsKey("PageItemProperties")) { return; } var pageItemProperties = JsonUtil.FromJArray(properties["PageItemProperties"]); if (pageItemProperties == null && pageItemProperties.Count == 0) { return; } PageItems = new List <PageItem>(); foreach (var props in pageItemProperties) { var item = new PageItem(); item.PageName = JsonUtil.GetValue <string>(props, "PageName"); item.BackgroundImage = ImageUtil.FromBase64(JsonUtil.GetValue <string>(props, "BackgroundImage")); item.TextContent = JsonUtil.GetValue <string>(props, "TextContent"); item.TextAlign = JsonUtil.GetValue <ContentAlignment>(props, "TextAlign"); string fontName = JsonUtil.GetValue <string>(props, "TextFont_Name"); int size = (int)JsonUtil.GetValue <double>(props, "TextFont_Size"); bool bold = JsonUtil.GetValue <bool>(props, "TextFont_Bold"); bool italic = JsonUtil.GetValue <bool>(props, "TextFont_Italic"); bool strikeout = JsonUtil.GetValue <bool>(props, "TextFont_Strikeout"); bool underline = JsonUtil.GetValue <bool>(props, "TextFont_Underline"); FontStyle style = FontStyle.Regular; if (bold) { style = FontStyle.Bold; } if (italic) { style |= FontStyle.Italic; } if (strikeout) { style |= FontStyle.Strikeout; } if (underline) { style |= FontStyle.Underline; } Font font = new Font(fontName, size, style); item.TextFont = font; item.ClickMode = JsonUtil.GetValue <ClickMode>(props, "ClickMode"); item.StartWithAdministrator = JsonUtil.GetValue <bool>(props, "StartWithAdministrator"); item.FilePath = JsonUtil.GetValue <string>(props, "FilePath"); item.Arguments = JsonUtil.GetValue <string>(props, "Arguments"); item.LinkPageName = JsonUtil.GetValue <string>(props, "LinkPageName"); item.X = (int)JsonUtil.GetValue <long>(props, "X"); item.Y = (int)JsonUtil.GetValue <long>(props, "Y"); item.Width = (int)JsonUtil.GetValue <long>(props, "Width"); item.Height = (int)JsonUtil.GetValue <long>(props, "Height"); PageItems.Add(item); } }
private void DeletePageItem(Page targetPage, PageItem item) { item.OnMouseDownEventForEdit -= pageItem_MouseDown; targetPage.RemoveItem(item); }
public void RemoveItem(PageItem item) { pageBody.RemoveItem(item); }