/// <summary> /// 分页加载信息 /// </summary> /// <param name="e"></param> void OnNextPage(PageData e) { int cnt = AtState.GetScalar <int>("select count(*) from Letter where otherid=@otherid and loginid=@loginid", new Dict { { "otherid", OtherID }, { "loginid", Kit.UserID } }); int start = cnt - (e.PageNo + 1) * e.PageSize; int limit = e.PageSize; if (start < 0) { limit = cnt - e.PageNo * e.PageSize; } Nl <Letter> data = new Nl <Letter>(); var ls = AtState.Each <Letter>($"select * from Letter where otherid={OtherID} and loginid={Kit.UserID} order by stime limit {limit} offset {start}"); foreach (var l in ls) { var photo = l.IsReceived ? _other.Photo : Kit.UserPhoto; if (string.IsNullOrEmpty(photo)) { photo = "photo/profilephoto.jpg"; } l.Photo = photo; data.Add(l); } e.LoadPageData(data); }
public static Nl <Person> CreatePersonsList(int p_count) { DateTime birth = new DateTime(1950, 8, 22); var persons = Person.Persons; Nl <Person> pers = new Nl <Person>(); for (int i = 0; i < p_count; i++) { var per = persons[i % persons.Length]; birth = birth.AddDays(10); var p = new Person { ID = "2202820-" + i.ToString().PadLeft(5, '0'), Xm = per.Xm, Bh = i + 1, Chushengrq = birth, Shenfenzh = per.Shenfenzh, Xb = per.Xb, Hunfou = per.Hunfou, Shengao = per.Shengao, Bumen = per.Bumen, Note = per.Note, }; pers.Add(p); } return(pers); }
void InitPaperName() { Nl <string> ls = new Nl <string>(); foreach (var item in PaperSize.Dict.Keys) { ls.Add(item.ToString()); } ((CList)_fv["papername"]).Data = ls; }
/// <summary> /// 加载具有指定名称或拼音缩写的菜单项 /// </summary> /// <param name="p_filter"></param> /// <returns></returns> public static Nl <OmMenu> LoadMenusByName(string p_filter) { Nl <OmMenu> ls = new Nl <OmMenu>(); List <OmMenu> last = new List <OmMenu>(); foreach (var grp in _rootPageMenus) { foreach (var om in grp) { // 确保优先级,以搜索为开头的排在前 string py = Kit.GetPinYin(om.Name); if (om.Name.StartsWith(p_filter) || py.StartsWith(p_filter)) { ls.Add(om); } else if (om.Name.Contains(p_filter) || py.Contains(p_filter)) { last.Add(om); } } } foreach (var om in _leaveMenus) { // 不包含分组 if (om.IsGroup) { continue; } string py = Kit.GetPinYin(om.Name); if (om.Name.StartsWith(p_filter) || py.StartsWith(p_filter)) { ls.Add(om); } else if (om.Name.Contains(p_filter) || py.Contains(p_filter)) { last.Add(om); } } ls.AddRange(last); return(ls); }
/// <summary> /// 创建枚举类型数据源 /// </summary> /// <param name="p_type"></param> /// <returns></returns> Nl <object> CreateEnumData(Type p_type) { Nl <object> ls = new Nl <object>(); foreach (var fi in from f in p_type.GetRuntimeFields() where f.IsLiteral select f) { ls.Add(fi.GetValue(p_type)); } return(ls); }
public static Nl <string> CreateXmList(int p_count) { var persons = Person.Persons; Nl <string> pers = new Nl <string>(); for (int i = 0; i < p_count; i++) { var per = persons[i % persons.Length]; pers.Add(per.Xm); } return(pers); }
static Nl <ColorItem> GetColorList() { if (_colors == null) { Type type = typeof(Windows.UI.Colors); _colors = new Nl <ColorItem>(); _colors.Add(new ColorItem(new Color(), "无")); #if UWP foreach (PropertyInfo info in type.GetProperties()) { var color = (Color)info.GetValue(type); _colors.Add(new ColorItem(color, $"{info.Name} ({color})")); } #else foreach (FieldInfo info in type.GetFields()) { _colors.Add(new ColorItem(Colors.Parse(info.Name), info.Name)); } #endif } return(_colors); }
/// <summary> /// 获取所有图标项列表 /// </summary> /// <returns></returns> public static Nl <IconItem> GetAllIcons() { if (_icons == null) { _icons = new Nl <IconItem>(); Type type = typeof(Icons); foreach (var fi in from f in type.GetRuntimeFields() where f.IsLiteral select f) { _icons.Add(new IconItem((Icons)fi.GetValue(type))); } } return(_icons); }
void LoadExecDrop(WfdAtv p_atv) { var items = from item in p_atv.Table.OfType <WfdAtv>() where item != p_atv && item.Type != WfdAtvType.Sync && item.Type != WfdAtvType.Finish select item; Nl <IDStr> ls = new Nl <IDStr>(); foreach (var atv in items) { ls.Add(new IDStr() { ID = atv.ID.ToString(), Str = atv.Name }); } ((CList)_fv["execatvid"]).Data = ls; }
/// <summary> /// 加载当前登录用户的菜单,性能已调优 /// </summary> public static async Task LoadMenus() { // 所有可访问项 List <long> idsAll = await GetAllUserMenus(); // 常用组菜单项:固定项 + 点击次数最多的前n项,总项数 <= 8 _favMenus.Clear(); var fixedMenus = Kit.Stub.FixedMenus; if (fixedMenus != null) { // 固定项 foreach (var om in fixedMenus) { _favMenus.Add(om); } } // 点击次数最多的前n项 int maxFav = 8; if (_favMenus.Count < maxFav) { var favMenu = AtState.Each <MenuFav>($"select menuid from menufav where userid={Kit.UserID} order by clicks desc LIMIT {maxFav}"); foreach (var fav in favMenu) { // 过滤无权限的项 if (idsAll.Contains(fav.MenuID)) { var om = AtModel.First <OmMenu>($"select * from OmMenu where id={fav.MenuID}"); _favMenus.Add(om); idsAll.Remove(fav.MenuID); if (_favMenus.Count >= maxFav) { break; } } } } // 根页面菜单 _rootPageMenus = new Nl <GroupData <OmMenu> >(); // 除根页面的剩余项 _leaveMenus = new List <OmMenu>(); // 所有一级项 var roots = new List <OmMenu>(); // 整理菜单项 foreach (var item in AtModel.Each <OmMenu>("select * from OmMenu")) { // 过滤无权限的项,保留所有分组 if (!item.IsGroup && !idsAll.Contains(item.ID)) { continue; } // 一级项和其他分开 if (!item.ParentID.HasValue) { roots.Add(item); } else { _leaveMenus.Add(item); } } // 根页面常用组 if (_favMenus.Count > 0) { _rootPageMenus.Add(_favMenus); } // 移除无用的分组 int index = 0; while (index < _leaveMenus.Count) { var om = _leaveMenus[index]; if (!om.IsGroup || IsExistChild(om)) { index++; } else { _leaveMenus.RemoveAt(index); } } // 整理一级菜单 GroupData <OmMenu> grpLast = null; foreach (var om in roots) { // 一级的实体菜单项 if (!om.IsGroup) { if (grpLast == null) { grpLast = new GroupData <OmMenu>() { Title = "其它" } } ; grpLast.Add(om); continue; } // 一级为分组,处理二级 GroupData <OmMenu> grpCur = new GroupData <OmMenu>() { Title = om.Name }; index = 0; while (index < _leaveMenus.Count) { var ch = _leaveMenus[index]; if (ch.ParentID == om.ID) { // 二级菜单 grpCur.Add(ch); _leaveMenus.RemoveAt(index); } else { index++; } } if (grpCur.Count > 0) { _rootPageMenus.Add(grpCur); } } // 一级实体项放在最后 if (grpLast != null) { _rootPageMenus.Add(grpLast); } }
void LoadSampleList() { Nl <GroupData <DataCmd> > ds = new Nl <GroupData <DataCmd> >(); GroupData <DataCmd> group = null; #region 框架结构 group = new GroupData <DataCmd> { new DataCmd { Title = "空白窗口", Note = "整个窗口内容为空,完全自定义,相当于空白页面", Tag = typeof(BlankWin) }, new DataCmd { Title = "主区窗口", Note = "只包括主区,主区有标题栏,等同于有标题栏的空白窗口", Tag = typeof(SingleViewWin) }, new DataCmd { Title = "动态主区窗口", Note = "包括左区和主区,主区内容支持UserControl、窗口及所有可视元素,一般通过左区操作联动来切换主区内容", Tag = typeof(ToggleWinCenter) }, new DataCmd { Title = "两区窗口", Note = "包括左区和主区,每个区都支持多Tab页,各Tab页之间在Windows模式可联动、Phone模式时可导航", Tag = typeof(TwoPanelWin) }, new DataCmd { Title = "三区窗口", Note = "包括左区、主区、右区,每个区都支持多Tab页,各Tab页之间在Windows模式可联动、Phone模式时可导航", Tag = typeof(ThreePanelWin) }, new DataCmd { Title = "窗口布局", Note = "Windows模式:窗口分上下左右和主区五个区域,由Tab承载内容,拖动时自动停靠", Tag = typeof(WinLayout) }, new DataCmd { Title = "窗口内导航", Note = "Phone模式:窗口内所有区域的Tab自适应为可导航的页面,多个Tab可组合成多Tab页,页面之间支持循环导航", Tag = typeof(WinNavi) }, new DataCmd { Title = "对话框", Note = "模拟传统对话框,Windows模式显示在窗口上层,可拖动、调整大小、自动关闭等,Phone模式承载在PhonePage内", Tag = typeof(DlgDemo), Callback = OnNaviTo }, new DataCmd { Title = "提示信息", Note = "提供两个级别的提示信息(普通、警告),在对话框上层显示,可自动关闭,最多可显示一个操作按钮", Tag = typeof(NotifyDemo), Callback = OnNaviTo }, }; group.Title = "框架结构"; ds.Add(group); #endregion #region 数据控件 group = new GroupData <DataCmd> { new DataCmd { Title = "表单Fv", Note = "表单由单元格组成,单元格包括列名和编辑器,自动布局,支持自定义行数和内容,可作为独立的布局面板使用", Tag = typeof(FvHome) }, new DataCmd { Title = "列表Lv", Note = "支持三类视图表格、列表、磁贴,两种数据源,三种选择模式,定制分组,上下文菜单", Tag = typeof(LvHome) }, new DataCmd { Title = "树Tv", Note = "支持动态加载子节点,自定义节点样式、节点内容,动态设置节点模板,上下文菜单", Tag = typeof(TvHome) }, new DataCmd { Title = "报表", Note = "可视化报表模板设计,报表预览时支持导出、打印、简单编辑,支持报表绘制过程脚本", Tag = typeof(RptDemo) }, new DataCmd { Title = "数据图表", Note = "支持柱线饼等9大类40种不同图表,每种图表提供多种不同的调色板,支持交互操作", Tag = typeof(ChartHome) }, new DataCmd { Title = "Excel", Note = "包含类似Excel编辑的常用功能,报表模板设计的基础", Tag = typeof(ExcelHome) }, new DataCmd { Title = "数据访问与异常", Note = "包括数据表操作、数据序列化、远程/本地数据的增删改查、远程过程调用等", Tag = typeof(DataAccessHome) }, }; group.Title = "数据控件"; ds.Add(group); #endregion #region 基础控件 group = new GroupData <DataCmd> { new DataCmd { Title = "菜单", Note = "包括普通工具栏菜单、上下文菜单,支持多层子项、选择和分组单选等功能", Tag = typeof(MenuHome), }, new DataCmd { Title = "文件", Note = "跨平台文件选择、上传下载文件、不同类型图像资源", Tag = typeof(FileHome), }, new DataCmd { Title = "Tab页", Note = "TabControl控件基本功能演示", Tag = typeof(TabControlDemo) }, new DataCmd { Title = "系统监视输出", Note = "内部使用的调试输出与断言处理,调试输出内容同时保存在日志,断言处理在调试与非调试状态有不同行为", Tag = typeof(SysTraceDemo) }, new DataCmd { Title = "杂项", Note = "基础事件、分隔栏、可停靠面板、流程图、控件事件顺序", Tag = typeof(MiscHome) }, }; group.Title = "基础控件"; ds.Add(group); #endregion #region 样式资源 group = new GroupData <DataCmd> { new DataCmd { Title = "图标", Note = "内置的矢量文字,可用作图标、提示", Tag = typeof(IconDemo) }, new DataCmd { Title = "按钮", Note = "标准按钮和自定义按钮的常用样式", Tag = typeof(BtnDemo), Callback = OnNaviTo }, new DataCmd { Title = "常用画刷", Note = "", Tag = typeof(BrushDemo), Callback = OnNaviTo }, new DataCmd { Title = "生成App图片", Note = "生成 android 和 iOS 中用到的app图片", Tag = typeof(AppIcon), Callback = OnNaviTo }, }; group.Title = "样式资源"; ds.Add(group); #endregion #region 临时 group = new GroupData <DataCmd> { new DataCmd { Title = "测试1", Note = "Daoting测试", Tag = typeof(TestDemo1) }, new DataCmd { Title = "测试2", Note = "忠宝测试", Tag = typeof(TestDemo2) }, }; group.Title = "临时"; ds.Add(group); #endregion _lv.Data = ds; }