public override void Execute() { ILayoutViewer viewer = _smartSession.SmartWindowManager.ActiveViewer as ILayoutViewer; if (viewer == null) { return; } ILayoutHost host = viewer.LayoutHost; if (host == null) { return; } ILayoutTemplate template = host.Template; if (template == null || string.IsNullOrEmpty(template.FullPath)) { _smartSession.CommandEnvironment.Get(6006).Execute(); } else { template.SaveTo(template.FullPath); using (System.Drawing.Bitmap bm = viewer.LayoutHost.ExportToBitmap(PixelFormat.Format32bppArgb, new System.Drawing.Size(165, 165))) { bm.Save(template.FullPath.ToLower().Replace(".gxt", ".png"), ImageFormat.Png); } } }
private void 保存模版_Click(object sender, EventArgs e) { ILayoutTemplate temp = _host.Template; if (!String.IsNullOrEmpty(temp.FullPath)) { temp.SaveTo(temp.FullPath); } }
public static void UpdateLegend(ProductColorTable[] colors, Action <int, string> percentProgress) { string path = System.AppDomain.CurrentDomain.BaseDirectory + "LayoutTemplate"; if (!Directory.Exists(path)) { return; } string[] files = Directory.GetFiles(path, "*.gxt", SearchOption.AllDirectories); if (files == null || files.Length == 0) { return; } for (int i = 0; i < files.Length; i++) { string fname = files[i]; ILayoutTemplate template = LayoutTemplate.LoadTemplateFrom(fname); //LayoutTemplate.LoadTemplateFrom(fname); if (template == null) { return; } if (percentProgress != null) { percentProgress((int)((i + 1) * 100f / files.Length), ""); } ILayout layout = template.Layout; bool haUpdate = false; for (int e = 0; e < layout.Elements.Count; e++) { if (layout.Elements[e] is ILegendElement) { ILegendElement legendEle = layout.Elements[e] as ILegendElement; string colotName = legendEle.ColorTableName; if (!string.IsNullOrWhiteSpace(colotName)) { ProductColorTable colorTable = ProductColorTableFactory.GetColorTable(colotName); if (colorTable != null) { List <LegendItem> items = new List <LegendItem>(); foreach (ProductColor pc in colorTable.ProductColors) { if (!pc.DisplayLengend) { continue; } LegendItem item = new LegendItem(pc.LableText, pc.Color); items.Add(item); } legendEle.LegendItems = items.ToArray(); haUpdate = true; } } } } if (haUpdate) { template.SaveTo(fname); } } }