async Task <StorageFolder> OpenFolder(string p_name) { try { return(await KnownFolders.PicturesLibrary.CreateFolderAsync(p_name, CreationCollisionOption.OpenIfExists)); } catch { Kit.Error("无访问图片库权限!"); return(null); } }
/// <summary> /// 加载xml /// </summary> /// <param name="p_reader"></param> public virtual void ReadXml(XmlReader p_reader) { p_reader.MoveToElement(); if (p_reader.IsEmptyElement) { p_reader.Read(); return; } string name = p_reader.Name; p_reader.Read(); while (p_reader.NodeType != XmlNodeType.None) { if (p_reader.NodeType == XmlNodeType.EndElement && p_reader.Name == name) { break; } RptItem item = null; switch (p_reader.Name) { case "Text": item = new RptText(this); break; case "Table": item = new RptTable(this); break; case "Matrix": item = new RptMatrix(this); break; case "Chart": item = new RptChart(this); break; default: if (item == null) { Kit.Error(string.Format("反序列化报表模板时错误,无法识别报表项【{0}】!", p_reader.Name)); } break; } item.ReadXml(p_reader); Items.Add(item); } p_reader.Read(); }
async Task <StorageFile> SaveIcon( double p_width, double p_height, double p_fontSize, Icons p_icon, string p_fileName, StorageFolder p_folder) { _bd.Width = p_width; _bd.Height = p_height; _tb.FontSize = p_fontSize; _tb.Text = Res.GetIconChar(p_icon); RenderTargetBitmap bmp = new RenderTargetBitmap(); await bmp.RenderAsync(_bd); var pixelBuffer = await bmp.GetPixelsAsync(); StorageFile saveFile = null; try { saveFile = await p_folder.CreateFileAsync(p_fileName, CreationCollisionOption.ReplaceExisting); } catch { Kit.Error("创建图片文件失败!"); return(null); } using (var fileStream = await saveFile.OpenAsync(FileAccessMode.ReadWrite)) { var di = DisplayInformation.GetForCurrentView(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream); float dpi = di.LogicalDpi; encoder.SetPixelData( BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)bmp.PixelWidth, (uint)bmp.PixelHeight, dpi, dpi, pixelBuffer.ToArray()); await encoder.FlushAsync(); } return(saveFile); }
void OnInsertMtx(object sender, Mi e) { _owner.Excel.DecorationRange = null; CellRange range = _owner.Excel.ActiveSheet.Selections[0]; var item = new RptMatrix(_owner.GetContainer()); range = new CellRange(range.Row, range.Column, 2, 2); if (RptItem.ValidEmptyRange(item.Part, range)) { Kit.Error("对象创建后与其他对象位置冲突,请确认。"); return; } _owner.Excel.ActiveSheet.SetSelection(range); _owner.Info.ExecuteCmd(RptCmds.InsertMatrix, new InsertCmdArgs(item, range)); _owner.UpdateSelection(); }
public async void ShowDlg() { Tv tv = _owner.Tv; tv.ItemClick -= OnSingleClick; if (tv.SelectionMode == SelectionMode.Multiple) { _menu.Show("确定"); } else { _menu.Hide("确定"); tv.ItemClick += OnSingleClick; } // 拆分填充列 if (!string.IsNullOrEmpty(_owner.SrcID) && !string.IsNullOrEmpty(_owner.TgtID)) { _srcIDs = _owner.SrcID.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries); _tgtIDs = _owner.TgtID.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries); if (_srcIDs.Length != _tgtIDs.Length) { _srcIDs = null; _tgtIDs = null; Kit.Error("数据填充:源列表、目标列表列个数不一致!"); } } // 第一次或动态加载数据源时 if (tv.Data == null || _owner.RefreshData) { await _owner.OnLoadData(); } if (tv.View == null) { tv.View = (tv.Data is Table) ? Application.Current.Resources["CListRowView"] : Application.Current.Resources["CListObjView"]; } // 不向下层对话框传递Press事件 AllowRelayPress = false; Show(); }
public ListDlg(CList p_owner) { InitializeComponent(); Title = "选择"; _owner = p_owner; Lv lv = _owner.Lv; Content = lv; if (lv.SelectionMode == SelectionMode.Multiple) { Mi mi = new Mi { ID = "确定", Icon = Icons.保存 }; mi.Click += OnMultipleOK; Menu menu = new Menu(); menu.Items.Add(mi); Menu = menu; } else { lv.ItemClick += OnSingleClick; } // 拆分填充列 if (!string.IsNullOrEmpty(_owner.SrcID) && !string.IsNullOrEmpty(_owner.TgtID)) { _srcIDs = _owner.SrcID.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries); _tgtIDs = _owner.TgtID.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries); if (_srcIDs.Length != _tgtIDs.Length) { _srcIDs = null; _tgtIDs = null; Kit.Error("数据填充:源列表、目标列表列个数不一致!"); } } }
void OnClicked2(object sender, RoutedEventArgs e) { Kit.Error("错误消息内容!"); }