public PreviewStartup(int currPageId) { App.appWindowList.Clear(); List <ScreenCfg> list = screenCfgBll.findAll(); //屏幕排序 List <System.Windows.Forms.Screen> listScreen = new List <System.Windows.Forms.Screen>(); foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens) { listScreen.Add(s); } listScreen = this.sort(listScreen); for (int i = list.Count - 1; i >= 0; i--) { ScreenCfg sCfg = list[i]; int previewCurrPageId = sCfg.indexPageId; if (sCfg.id == 1) { previewCurrPageId = currPageId; } if (listScreen.Count > i && listScreen[i] != null) { this.loadOneWindow(sCfg, listScreen[i], previewCurrPageId); } else { this.loadOneWindow(sCfg, listScreen[0], previewCurrPageId); } } }
/* * 保存数据 */ private void Submit_Button_Click(object sender, RoutedEventArgs e) { string diyNameVal = diyName.Text; int indexPageIdVal = 0; ComboBoxItem item = (ComboBoxItem)indexPageId.SelectedItem; if (item != null) { indexPageIdVal = (int)item.Tag; } if (string.IsNullOrWhiteSpace(diyNameVal)) { MessageBox.Show("屏幕名称不能为空"); return; } ScreenCfg tmp = new ScreenCfg(); tmp.indexPageId = indexPageIdVal; tmp.diyName = diyNameVal; screenCfgBll.insert(tmp); this.DialogResult = true; Close(); }
public MainStartup( ) { App.appWindowList.Clear(); List <ScreenCfg> list = screenCfgBll.findAll(); //屏幕排序 List <System.Windows.Forms.Screen> listScreen = new List <System.Windows.Forms.Screen>(); foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens) { listScreen.Add(s); } listScreen = this.sort(listScreen); for (int i = list.Count - 1; i >= 0; i--) { ScreenCfg sCfg = list[i]; if (listScreen.Count > i && listScreen[i] != null) { this.loadOneWindow(sCfg, listScreen[i]); } else { this.loadOneWindow(sCfg, listScreen[0]); } } }
public ScreenCfg insert(ScreenCfg entity) { String sql = "insert into screenCfg(deviceName,diyName,width,height,isPrimary,indexPageId) " + "values(@deviceName,@diyName,@width,@height,@isPrimary,@indexPageId);select last_insert_rowid();"; SQLiteParameter[] parameters = { new SQLiteParameter("@deviceName", DbType.String, 100), new SQLiteParameter("@diyName", DbType.String, 100), new SQLiteParameter("@width", DbType.Int32, 4), new SQLiteParameter("@height", DbType.Int32, 4), new SQLiteParameter("@isPrimary", DbType.Int32, 4), new SQLiteParameter("@indexPageId", DbType.Int32, 4) }; parameters[0].Value = entity.deviceName; parameters[1].Value = entity.diyName; parameters[2].Value = entity.width; parameters[3].Value = entity.height; parameters[4].Value = entity.isPrimary; parameters[5].Value = entity.indexPageId; DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters); int id = DataType.ToInt32(dt.Rows[0]["last_insert_rowid()"].ToString()); entity.id = id; return(entity); }
/* * 更新配置 */ public int update(ScreenCfg entity) { string sql = "update screenCfg set deviceName=@deviceName,diyName=@diyName,width=@width" + ",height=@height,isPrimary=@isPrimary,indexPageId=@indexPageId" + " where id=@id"; SQLiteParameter[] parameters = { new SQLiteParameter("@deviceName", DbType.String, 255), new SQLiteParameter("@diyName", DbType.String, 255), new SQLiteParameter("@width", DbType.Int32, 4), new SQLiteParameter("@height", DbType.Int32, 4), new SQLiteParameter("@isPrimary", DbType.Int32, 4), new SQLiteParameter("@indexPageId", DbType.Int32, 4), new SQLiteParameter("@id", DbType.Int32, 4) }; parameters[0].Value = entity.deviceName; parameters[1].Value = entity.diyName; parameters[2].Value = entity.width; parameters[3].Value = entity.height; parameters[4].Value = entity.isPrimary; parameters[5].Value = entity.indexPageId; parameters[6].Value = entity.id; int result = Common.SQLiteHelper.ExecuteNonQuery(sql, parameters); return(result); }
private void loadPageData(int id) { this.screenCfg = screenCfgBll.get(id); if (screenCfg == null) { MessageBox.Show("当前屏幕不存在"); } this.diyName.Content = screenCfg.diyName; }
private void loadPageData(int id) { this.screenCfg = screenCfgBll.get(id); if (screenCfg == null) { return; } this.id.Content = screenCfg.id; this.diyName.Text = screenCfg.diyName; this.initCombox_linkToPageId(indexPageId, screenCfg.indexPageId); }
public MainWindow(int currPageId, ScreenCfg screenCfg, System.Windows.Forms.Screen screen) { this.currPageId = currPageId; this.screenCfgId = screenCfg.id; this.screenCfg = screenCfg; this.screen = screen; InitializeComponent(); App.localStorage.currWindow = this; this.mqServer.sendMsgEvent += Client_ReceiveMsgEvent; init(); Unloaded += Window_Unloaded; this.Loaded += Window_Loaded; }
//通过id获取cfg public ScreenCfg get(int id) { String sql = "select * from screenCfg where id=@id"; SQLiteParameter[] parameters = { new SQLiteParameter("@id", DbType.Int32, 4) }; parameters[0].Value = id; DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters); ScreenCfg screenCfg = DataToEntity <ScreenCfg> .FillModel(dt.Rows[0]); return(screenCfg); }
private void loadOneWindow(ScreenCfg sCfg, System.Windows.Forms.Screen s, int currPageId) { //如果页面不存在显示首页 int indexPageId = currPageId; DPage dPage = dPageBll.get(indexPageId); if (dPage == null) { indexPageId = 1; } PreviewWindow win1 = new PreviewWindow(indexPageId, sCfg, s); App.appWindowList.Add(win1); Rectangle r1 = s.Bounds; win1.Left = r1.Left; win1.Top = r1.Top; win1.Show(); }
/* * 添加 */ public ScreenCfg insert(ScreenCfg screenCfg) { return(screenCfgDal.insert(screenCfg)); }
/* * 更新配置信息 */ public ScreenCfg update(ScreenCfg screenCfg) { int rows = screenCfgDal.update(screenCfg); return(screenCfg); }
//通过id获取cfg public ScreenCfg get(Int32 id) { ScreenCfg screenCfg = screenCfgDal.get(id); return(screenCfg); }