public ObservableCollection<t_Element> selectAllDate() { string sql = "select * from t_Element"; DataTable dt = null; try { dt = db.ExecuteQuery(sql); } catch (Exception ex) { throw ex; } ObservableCollection<t_Element> _List = new ObservableCollection<t_Element>(); foreach (DataRow dr in dt.Rows) { t_Element obj = new t_Element(dr); _List.Add(obj); } return _List; }
/// <summary> /// 插入t_Element /// </summary> public bool InsertElement(t_Element element) { string intsertElementSQL = @"insert into t_Element (ElementID, ElementName, ControlID, ScreenX, ScreenY, TxtInfo, Width, Height, ImageURL, ForeColor, Font, ChildScreenID, DeviceID, ChannelNo, ScreenID, BackColor, Transparent, oldX, oldY, Method, MinFloat, MaxFloat, SerialNum, TotalLength, LevelNo, ComputeStr, ElementType, ParentID) values (@ElementID, @ElementName, @ControlID, @ScreenX, @ScreenY, @TxtInfo, @Width, @Height, @ImageURL, @ForeColor, @Font, @ChildScreenID, @DeviceID, @ChannelNo, @ScreenID, @BackColor, @Transparent, @oldX, @oldY, @Method, @MinFloat, @MaxFloat, @SerialNum, @TotalLength, @LevelNo, @ComputeStr, @ElementType, @ParentID)"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ElementID", element.ElementID), new SqlParameter("@ElementName", element.ElementName), new SqlParameter("@ControlID", element.ControlID), new SqlParameter("@ScreenX", element.ScreenX), new SqlParameter("@ScreenY", element.ScreenY), new SqlParameter("@TxtInfo", element.TxtInfo), new SqlParameter("@Width", element.Width), new SqlParameter("@Height", element.Height), new SqlParameter("@ImageURL", element.ImageURL), new SqlParameter("@ForeColor", element.ForeColor), new SqlParameter("@Font", element.Font), new SqlParameter("@ChildScreenID", element.ChildScreenID), new SqlParameter("@DeviceID", element.DeviceID), new SqlParameter("@ChannelNo", element.ChannelNo), new SqlParameter("@ScreenID", element.ScreenID), new SqlParameter("@BackColor", element.BackColor), new SqlParameter("@Transparent", element.Transparent), new SqlParameter("@oldX", element.oldX), new SqlParameter("@oldY", element.oldY), new SqlParameter("@Method", element.Method), new SqlParameter("@MinFloat", element.MinFloat), new SqlParameter("@MaxFloat", element.MaxFloat), new SqlParameter("@SerialNum", ConvertToDbNull(element.SerialNum)), new SqlParameter("@TotalLength", element.TotalLength), new SqlParameter("@LevelNo", ConvertToDbNull(element.LevelNo)), new SqlParameter("@ComputeStr", ConvertToDbNull(element.ComputeStr)), new SqlParameter("@ElementType", ConvertToDbNull(element.ElementType)), new SqlParameter("@ParentID", ConvertToDbNull(element.ParentID)) }; CmdList.Add(new CommandList() { strCommandText = intsertElementSQL, Params = parameters }); return true; }
public bool UpdateElement(t_Element element) { string intsertElementSQL = @"update t_Element SET ScreenX=@ScreenX, ScreenY=@ScreenY, TxtInfo=@TxtInfo , Width=@Width, Height=@Height, ImageURL=@ImageURL , ForeColor=@ForeColor, Font=@Font, ChildScreenID=@ChildScreenID , DeviceID=@DeviceID, ChannelNo=@ChannelNo, ScreenID=@ScreenID , BackColor=@BackColor, Transparent=@Transparent, oldX=@oldX, oldY=@oldY , Method=@Method, MinFloat=@MinFloat, MaxFloat=@MaxFloat , SerialNum=@SerialNum, TotalLength=@TotalLength, LevelNo=@LevelNo , ComputeStr=@ComputeStr, ElementType=@ElementType, ParentID=@ParentID WHERE ElementID=@ElementID "; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ElementID", element.ElementID), //new SqlParameter("@ElementName", element.ElementName), //new SqlParameter("@ControlID", element.ControlID), new SqlParameter("@ScreenX", element.ScreenX), new SqlParameter("@ScreenY", element.ScreenY), new SqlParameter("@TxtInfo", element.TxtInfo), new SqlParameter("@Width", element.Width), new SqlParameter("@Height", element.Height), new SqlParameter("@ImageURL", element.ImageURL), new SqlParameter("@ForeColor", element.ForeColor), new SqlParameter("@Font", element.Font), new SqlParameter("@ChildScreenID", element.ChildScreenID), new SqlParameter("@DeviceID", element.DeviceID), new SqlParameter("@ChannelNo", element.ChannelNo), new SqlParameter("@ScreenID", element.ScreenID), new SqlParameter("@BackColor", element.BackColor), new SqlParameter("@Transparent", element.Transparent), new SqlParameter("@oldX", element.oldX), new SqlParameter("@oldY", element.oldY), new SqlParameter("@Method", element.Method), new SqlParameter("@MinFloat", element.MinFloat), new SqlParameter("@MaxFloat", element.MaxFloat), new SqlParameter("@SerialNum", ConvertToDbNull(element.SerialNum)), new SqlParameter("@TotalLength", element.TotalLength), new SqlParameter("@LevelNo", ConvertToDbNull(element.LevelNo)), new SqlParameter("@ComputeStr", ConvertToDbNull(element.ComputeStr)), new SqlParameter("@ElementType", ConvertToDbNull(element.ElementType)), new SqlParameter("@ParentID", ConvertToDbNull(element.ParentID)) }; CmdList.Add(new CommandList() { strCommandText = intsertElementSQL, Params = parameters }); return true; }
public MonitorControl ShowElement(t_Element obj, ElementSate eleStae, List<t_ElementProperty> listObj) { Canvas canvas = csScreen; try { if (obj.ImageURL != null && obj.ImageURL.IndexOf("MonitorSystem") == 0) { MonitorControl instance = (MonitorControl)Activator.CreateInstance(Type.GetType(obj.ImageURL)); SetEletemt(canvas, instance, obj, eleStae, listObj); return instance; } else { switch (obj.ElementName) { case "MyButton": TP_Button mtpButtom = new TP_Button(); SetEletemt(canvas, mtpButtom, obj, eleStae, listObj); return mtpButtom; break; case "MonitorLine": MonitorLine mPubLine = new MonitorLine(); SetEletemt(canvas, mPubLine, obj, eleStae, listObj); return mPubLine; //break; case "MonitorText": MonitorText mPubText = new MonitorText(); mPubText.MyText = obj.TxtInfo; SetEletemt(canvas, mPubText, obj, eleStae, listObj); return mPubText; //break; case "ColorText": ColorText mColorText = new ColorText(); SetEletemt(canvas, mColorText, obj, eleStae, listObj); return mColorText; //break; case "InputTextBox": InputTextBox mInputTextBox = new InputTextBox(); mInputTextBox.MyText = obj.TxtInfo; SetEletemt(canvas, mInputTextBox, obj, eleStae, listObj); return mInputTextBox; //break; case "ButtonCtrl": ButtonCtrl mButtonCtrl = new ButtonCtrl(); mButtonCtrl.MyText = obj.TxtInfo; SetEletemt(canvas, mButtonCtrl, obj, eleStae, listObj); return mButtonCtrl; //break; case "MonitorCur": MonitorCur mPubCur = new MonitorCur(); SetEletemt(canvas, mPubCur, obj, eleStae, listObj); return mPubCur; //break; case "MonitorRectangle": MonitorRectangle mPubRec = new MonitorRectangle(); SetEletemt(canvas, mPubRec, obj, eleStae, listObj); return mPubRec; //break; case "MonitorGrid": MonitorGrid mPubGrid = new MonitorGrid(); SetEletemt(canvas, mPubGrid, obj, eleStae, listObj); return mPubGrid; //break; case "FoldLine": MonitorFoldLine mPubFoldLine = new MonitorFoldLine(); SetEletemt(canvas, mPubFoldLine, obj, eleStae, listObj); return mPubFoldLine; //break; case "Temprary": Temprary mTemprary = new Temprary(); SetEletemt(canvas, mTemprary, obj, eleStae, listObj); return mTemprary; case "DLBiaoPan": DLBiaoPan mDLBiaoPan = new DLBiaoPan(); obj.Width = 2 * obj.Height.Value; SetEletemt(canvas, mDLBiaoPan, obj, eleStae, listObj); return mDLBiaoPan; case "DigitalBiaoPan": DigitalBiaoPan mDigitalBiaoPan = new DigitalBiaoPan(); SetEletemt(canvas, mDigitalBiaoPan, obj, eleStae, listObj); return mDigitalBiaoPan; case "Switch": Switch mSwitch = new Switch(); SetEletemt(canvas, mSwitch, obj, eleStae, listObj); return mSwitch; case "SignalSwitch": SignalSwitch mSignalSwitch = new SignalSwitch(); obj.Width = obj.Height; SetEletemt(canvas, mSignalSwitch, obj, eleStae, listObj); return mSignalSwitch; case "DetailSwitch": DetailSwitch mDetailSwitch = new DetailSwitch(); SetEletemt(canvas, mDetailSwitch, obj, eleStae, listObj); return mDetailSwitch; case "RealTimeCurve": RealTimeCurve mRealTime = new RealTimeCurve(); SetEletemt(canvas, mRealTime, obj, eleStae, listObj); return mRealTime; case "TableCtrl": TableCtrl mTableCtrl = new TableCtrl(); SetEletemt(canvas, mTableCtrl, obj, eleStae, listObj); return mTableCtrl; case "zedGraphCtrl": zedGraphCtrl mzedGraphCtrl = new zedGraphCtrl(); SetEletemt(canvas, mzedGraphCtrl, obj, eleStae, listObj); return mzedGraphCtrl; case "zedGraphLineCtrl": zedGraphLineCtrl mzedGraphLineCtrl = new zedGraphLineCtrl(); SetEletemt(canvas, mzedGraphLineCtrl, obj, eleStae, listObj); return mzedGraphLineCtrl; case "zedGraphPieCtrl": zedGraphPieCtrl mzedGraphPieCtrl = new zedGraphPieCtrl(); SetEletemt(canvas, mzedGraphPieCtrl, obj, eleStae, listObj); return mzedGraphPieCtrl; case "MyLine"://曲线 MyLine mMyLine = new MyLine(); SetEletemt(canvas, mMyLine, obj, eleStae, listObj); return mMyLine; case "BackgroundRect"://背景 BackgroundRect mBackgroundRect = new BackgroundRect(); SetEletemt(canvas, mBackgroundRect, obj, eleStae, listObj); return mBackgroundRect; case "PicBox"://窗口式背景控件 PicBox mPicBox = new PicBox(); SetEletemt(canvas, mPicBox, obj, eleStae, listObj); return mPicBox; case "DrawLine"://窗口式背景控件 DrawLine mDrawLine = new DrawLine(); SetEletemt(canvas, mDrawLine, obj, eleStae, listObj); return mDrawLine; case "ExtProControl"://窗口式背景控件 ExtProControl mExtProControl = new ExtProControl(); SetEletemt(canvas, mExtProControl, obj, eleStae, listObj); return mExtProControl; case "DimorphismGraphCtrl"://窗口式背景控件 DimorphismGraphCtrl mDimorphismGraphCtrl = new DimorphismGraphCtrl(); SetEletemt(canvas, mDimorphismGraphCtrl, obj, eleStae, listObj); return mDimorphismGraphCtrl; case "BackgroundControl": BackgroundControl backgroundControl = new BackgroundControl(); SetEletemt(canvas, backgroundControl, obj, eleStae, listObj); var childElements = new ElementDA().SelectBy(obj.ElementID, "Background"); ShowElements(childElements, backgroundControl.BackgroundCanvas, backgroundControl); return backgroundControl; default: string url = string.Format("/WPFMonitor;component/Resources/Images/ControlsImg/{0}", obj.ImageURL); BitmapImage bitmap = new BitmapImage(new Uri(url, UriKind.Relative)); ImageSource mm = bitmap; TP mtp = new TP(); mtp.Source = mm; SetEletemt(canvas, mtp, obj, eleStae, listObj); return mtp; //break; } } } catch { return null; } }
private void SetEletemt(Canvas canvas, MonitorControl mControl, t_Element obj, ElementSate eleStae, List<t_ElementProperty> listObj) { mControl.Selected += (o, e) => { MonitorControl.UpdatePropertyGrid(mControl.BrowsableProperties, null); MonitorControl.UpdatePropertyGrid(mControl.BrowsableProperties, mControl); }; if (eleStae == ElementSate.Save) { mControl.Name ="slt"+ obj.ElementID.ToString(); } mControl.ScreenElement = obj; mControl.ListElementProp = listObj; mControl.ElementState = eleStae; mControl.SetPropertyValue(); mControl.SetCommonPropertyValue(); //添加到场景 canvas.Children.Add(mControl); }
public void Clone(t_Element obj) { // ElementID = obj.ElementID; // ElementName = obj.ElementName; // ControlID = obj.ControlID; // ScreenX = obj.ScreenX; // ScreenY = obj.ScreenY; // TxtInfo = obj.TxtInfo; // Width = obj.Width; // Height = obj.Height; // ImageURL = obj.ImageURL; // ForeColor = obj.ForeColor; // Font = obj.Font; // ChildScreenID = obj.ChildScreenID; // DeviceID = obj.DeviceID; // ChannelNo = obj.ChannelNo; // ScreenID = obj.ScreenID; // BackColor = obj.BackColor; // Transparent = obj.Transparent; // oldX = obj.oldX; // oldY = obj.oldY; // Method = obj.Method; // MinFloat = obj.MinFloat; // MaxFloat = obj.MaxFloat; // SerialNum = obj.SerialNum; // TotalLength = obj.TotalLength; // LevelNo = obj.LevelNo; // ComputeStr = obj.ComputeStr; // ElementType = obj.ElementType; // ParentID = obj.ParentID; }
public t_Element selectARowDate(string m_id) { string sql = string.Format("select * from t_Element where Elementid='{0}'", m_id); DataTable dt = null; try { dt = db.ExecuteQueryDataSet(sql).Tables[0]; } catch (Exception ex) { throw ex; } if (dt == null) return null; if (dt.Rows.Count == 0) return null; DataRow dr = dt.Rows[0]; t_Element m_Elem = new t_Element(dr); return m_Elem; }
public MonitorControl OnLoadElement(Canvas canvas, t_Element element, ElementSate state, List<t_ElementProperty> properties) { if (null != LoadElement) { return LoadElement(canvas, element, state, properties); } return null; }
/// <summary> /// 复制对象 /// </summary> /// <param name="obj"></param> public void ElementClone(MonitorControl obj, int mWidth, int mHeight) { this.ParentControl = obj.ParentControl; m_Element = new t_Element(); t_Element m_Older= obj.ScreenElement; //ElementID m_Element.ElementName = m_Older.ElementName; m_Element.ControlID = m_Older.ControlID; //m_Element.ScreenX = m_Older.ScreenX; m_Element.ScreenX = Convert.ToInt32(obj.GetValue(Canvas.LeftProperty)); m_Element.ScreenY = Convert.ToInt32(obj.GetValue(Canvas.TopProperty)); // m_Element.ScreenY = m_Older.ScreenY; m_Element.ScreenY += Convert.ToInt16(obj.Height); m_Element.TxtInfo = m_Older.TxtInfo; m_Element.Width = mWidth; m_Element.Height = mHeight; m_Element.ImageURL = m_Older.ImageURL; m_Element.ForeColor = m_Older.ForeColor; m_Element.Font = m_Older.Font; m_Element.ChildScreenID = m_Older.ChildScreenID; m_Element.DeviceID = m_Older.DeviceID; m_Element.ChannelNo = m_Older.ChannelNo; m_Element.ScreenID = m_Older.ScreenID; m_Element.BackColor = m_Older.BackColor; m_Element.Transparent = m_Older.Transparent; m_Element.oldX = m_Older.oldX; m_Element.oldY = m_Older.oldY; m_Element.Method = m_Older.Method; m_Element.MinFloat = m_Older.MinFloat; m_Element.MaxFloat = m_Older.MaxFloat; m_Element.SerialNum = m_Older.SerialNum; m_Element.TotalLength = m_Older.TotalLength; m_Element.LevelNo = m_Older.LevelNo; m_Element.ComputeStr = m_Older.ComputeStr; m_ListElementProperty = new List<t_ElementProperty>(); foreach(t_ElementProperty elePro in obj.ListElementProp) { t_ElementProperty m_elePro = new t_ElementProperty(); m_elePro.PropertyNo = elePro.PropertyNo; m_elePro.PropertyValue = elePro.PropertyValue; m_elePro.Caption = elePro.Caption; m_elePro.PropertyName = elePro.PropertyName; m_ListElementProperty.Add(m_elePro); } }
/// <summary> /// 初使化Element /// </summary> /// <param name="tCon"></param> /// <returns></returns> public t_Element InitElement(t_Control tCon) { t_Element mElem = new t_Element(); mElem.ChildScreenID = "0"; mElem.ControlID = tCon.ControlID; mElem.ElementName = tCon.ControlName; mElem.ImageURL = tCon.ImageURL; mElem.TxtInfo = ""; mElem.ForeColor = "RGB(0,0,0)"; mElem.Font = "宋体"; mElem.DeviceID = -1; mElem.ChannelNo = -1; mElem.BackColor = "RGB(255,255,255)"; mElem.Transparent = 100; mElem.oldX = 0; mElem.oldY = 0; mElem.Method = 0; mElem.MinFloat = 0; mElem.MaxFloat = 0; //mElem.SerialNum = ""; //mElem.TotalLength = ""; if (tCon.ImageURL == "MonitorSystem.Other.RealTimeT") { mElem.BackColor = "#FFEBE8D9"; mElem.ForeColor = "#FFD5D5FF"; } mElem.LevelNo = 1; mElem.ComputeStr = ""; return mElem; }
private void SetEletemt(Canvas canvas, MonitorControl mControl, t_Element obj, ElementSate eleStae, List<t_ElementProperty> listObj) { mControl.Selected += (o, e) => { //PropertyMain.Instance.ControlPropertyGrid.SelectedObject = null; //PropertyMain.Instance.ControlPropertyGrid.BrowsableProperties = mControl.BrowsableProperties; //PropertyMain.Instance.ControlPropertyGrid.SelectedObject = mControl; MonitorControl.OnUpdatePropertyGrid(new string[0], null); MonitorControl.OnUpdatePropertyGrid(mControl.BrowsableProperties, mControl); }; if (eleStae == ElementSate.Save) { mControl.Name = "wpft" + obj.ElementID.ToString(); } mControl.ScreenElement = obj; mControl.ListElementProp = listObj; mControl.ElementState = eleStae; mControl.SetPropertyValue(); mControl.SetCommonPropertyValue(); //添加到场景 canvas.Children.Add(mControl); }