public static Task <bool> UpdatePictureElementAsync(string LayoutName, string PictureName, string PicturePath) { //Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName)); if (layoutItem == null) { return(Task.FromResult(false)); } return(QueuedTask.Run <bool>(() => { //Reference and load the layout associated with the layout item Layout lyt = layoutItem.GetLayout(); //Reference a picture element by name PictureElement picElm = lyt.FindElement(PictureName) as PictureElement; if (picElm == null) { return false; } //Change the path to a new source picElm.SetSourcePath(PicturePath); return true; })); }
//中国气象局图标,国家卫星气象中心图标 private void ReplaceElement(XElement element, PictureElement pictureElement) { string name = pictureElement.Name; Bitmap bitmap = pictureElement.Bitmap; var eles = element.Elements("PictureElementZGQXJ").Where((ele) => { return(ele.Attribute("name") != null && ele.Attribute("name").Value == name); }); if (eles != null && eles.Count() != 0) { foreach (XElement subEle in eles) { subEle.Attribute("bitmap").Value = GetBinaryString(pictureElement.GetType().InvokeMember("Bitmap", BindingFlags.GetProperty, null, pictureElement, null));; } } else { eles = element.Elements("PictureElementGJWXQXZX").Where((ele) => { return(ele.Attribute("name") != null && ele.Attribute("name").Value == name); }); if (eles != null && eles.Count() != 0) { foreach (XElement subEle in eles) { subEle.Attribute("bitmap").Value = GetBinaryString(pictureElement.GetType().InvokeMember("Bitmap", BindingFlags.GetProperty, null, pictureElement, null));; } } } }
public ActionResult Edit(PictureElement element) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { element.ImageMimeType = file.ContentType; element.ImageData = new byte[file.ContentLength]; file.InputStream.Read(element.ImageData, 0, file.ContentLength); } } picturesRepo.Save(element); TempData["status"] = string.Format("Изображение {0} было сохранено", element.Name); return(RedirectToAction("Index")); } else { return(View(element)); } }
public ActionResult Delete(int pictureId) { PictureElement element = picturesRepo.Delete(pictureId); if (element != null) { TempData["status"] = string.Format("Изображение {0} удалено", element.Name); } return(RedirectToAction("Index")); }
public ViewResult Create() { var element = new PictureElement(); element.Name = " "; element.StartTime = " "; element.Link = " "; return(View("Edit", element)); }
async public static void PictureElementSnippets() { #region PictureElement_SetSourcePath LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout Name")); await QueuedTask.Run(() => { Layout layout = layoutItem.GetLayout(); PictureElement picElm = layout.FindElement("Rectangle") as PictureElement; picElm.SetSourcePath(@"C:\Some\New\Path\And\file.ext"); }); #endregion PictureElement_SetSourcePath }
public override void Execute() { ILayoutViewer layout = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer; if (layout == null) { return; } _bitmap = _smartSession.UIFrameworkHelper.GetImage("system:指北针2.bmp") as Bitmap; PictureElement pic = new PictureElement(_bitmap); layout.LayoutHost.LayoutRuntime.Layout.Elements.Add(pic); layout.LayoutHost.Render(); TryRefreshLayerManager(); }
private void button7_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Filter = "JPEG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Bitmap bp = Bitmap.FromFile(dlg.FileName) as Bitmap; PictureElement pic = new PictureElement(bp); //pic.Size = new System.Drawing.SizeF(_host.LayoutRuntime.Layout.Size.Width - 3, // _host.LayoutRuntime.Layout.Size.Height - 3); // pic.Angle = 45; _host.LayoutRuntime.Layout.Elements.Add(pic); _host.Render(); } } }
public override void Execute() { ILayoutViewer viewer = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer; if (viewer == null) { return; } ILayoutHost host = viewer.LayoutHost; if (host == null) { return; } ILayoutRuntime runtime = host.LayoutRuntime; if (runtime == null) { return; } float w = 0, h = 0; using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Filter = "JPEG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp|PNG(*.png)|*.png"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PictureElement pic = new PictureElement(dlg.FileName); w = pic.Size.Width; h = pic.Size.Height; runtime.Pixel2Layout(ref w, ref h); pic.Size = new System.Drawing.SizeF(w, h); viewer.LayoutHost.LayoutRuntime.Layout.Elements.Add(pic); viewer.LayoutHost.Render(); } } TryRefreshLayerManager(); }
public void snippets_UpdateElements() { double x = 0; double y = 0; #region Update Text Element properties // Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout")); if (layoutItem != null) { QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { // Reference a text element by name TextElement txtElm = layout.FindElement("MyTextElement") as TextElement; if (txtElm != null) { // Change placement properties txtElm.SetAnchor(Anchor.CenterPoint); txtElm.SetX(x); txtElm.SetY(y); // Change TextProperties TextProperties txtProperties = new TextProperties("Hello world", "Times New Roman", 48, "Regular"); txtElm.SetTextProperties(txtProperties); } } }); } #endregion #region Update a picture element QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { // Reference a picture element by name PictureElement picElm = layout.FindElement("MyPicture") as PictureElement; // Change the path to a new source if (picElm != null) { picElm.SetSourcePath(@"D:\MyData\Pics\somePic.jpg"); } } }); #endregion #region Update a map surround QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { // Reference a scale bar element by name MapSurround scaleBar = layout.FindElement("MyScaleBar") as MapSurround; // Reference a map frame element by name MapFrame mf = layout.FindElement("MyMapFrame") as MapFrame; if ((scaleBar != null) && (mf != null)) { //Set the scale bar to the newly referenced map frame scaleBar.SetMapFrame(mf); } } }); #endregion #region Lock an element // The Locked property is displayed in the TOC as a lock symbol next to each element. // If locked the element can't be selected in the layout using the graphic // selection tools. QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { //Reference an element by name Element element = layout.FindElement("MyElement"); if (element != null) { // Modify the Locked property via the CIM CIMElement CIMElement = element.GetDefinition() as CIMElement; CIMElement.Locked = true; element.SetDefinition(CIMElement); } } }); #endregion #region Update an elements transparency QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { // Reference a element by name GraphicElement graphicElement = layout.FindElement("MyElement") as GraphicElement; if (graphicElement != null) { // Modify the Transparency property that exists only in the CIMGraphic class. CIMGraphic CIMGraphic = graphicElement.Graphic as CIMGraphic; CIMGraphic.Transparency = 50; // mark it 50% transparent graphicElement.SetGraphic(CIMGraphic); } } }); #endregion double xOffset = 0; double yOffset = 0; #region Clone an element QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { // Reference a element by name GraphicElement graphicElement = layout.FindElement("MyElement") as GraphicElement; if (graphicElement != null) { // clone and set the new x,y GraphicElement cloneElement = graphicElement.Clone("Clone"); cloneElement.SetX(cloneElement.GetX() + xOffset); cloneElement.SetY(cloneElement.GetY() + yOffset); } } }); #endregion }
public ViewResult Edit(int pictureId) { PictureElement element = picturesRepo.GetAllItems().First(p => p.Id == pictureId); return(View(element)); }