Пример #1
0
        /// <summary>
        /// 检查更新字段并赋值
        /// </summary>
        /// <param name="mobj"></param>
        private void CheckElementChange(t_Element mobj)
        {
            var vobj = _DataContext.t_Elements.Where(a => a.ElementID == mobj.ElementID);
            if (vobj.Count() > 0)
                return;
            t_Element saveEle = vobj.First();

            if (saveEle.ScreenX != mobj.ScreenX)
                saveEle.ScreenX = mobj.ScreenX;
            if (saveEle.ScreenY != mobj.ScreenY)
                saveEle.ScreenY = mobj.ScreenY;
            if (saveEle.TxtInfo != mobj.TxtInfo)
                saveEle.TxtInfo = mobj.TxtInfo;
            if (saveEle.Width != mobj.Width)
                saveEle.Width = mobj.Width;
            if (saveEle.Height != mobj.Height)
                saveEle.Height = mobj.Height;
            if (saveEle.ImageURL != mobj.ImageURL)
                saveEle.ImageURL = mobj.ImageURL;
            if (saveEle.ForeColor != mobj.ForeColor)
                saveEle.ForeColor = mobj.ForeColor;
            if (saveEle.Font != mobj.Font)
                saveEle.Font = mobj.Font;
            if (saveEle.ChildScreenID != mobj.ChildScreenID)
                saveEle.ChildScreenID = mobj.ChildScreenID;
            if (saveEle.DeviceID != mobj.DeviceID)
                saveEle.DeviceID = mobj.DeviceID;
            if (saveEle.ChannelNo != mobj.ChannelNo)
                saveEle.ChannelNo = mobj.ChannelNo;
            if (saveEle.ScreenID != mobj.ScreenID)
                saveEle.ScreenID = mobj.ScreenID;
            if (saveEle.BackColor != mobj.BackColor)
                saveEle.BackColor = mobj.BackColor;
            if (saveEle.Transparent != mobj.Transparent)
                saveEle.Transparent = mobj.Transparent;
            if (saveEle.oldX != mobj.oldX)
                saveEle.oldX = mobj.oldX;
            if (saveEle.oldY != mobj.oldY)
                saveEle.oldY = mobj.oldY;
            if (saveEle.Method != mobj.Method)
                saveEle.Method = mobj.Method;
            if (saveEle.MinFloat != mobj.MinFloat)
                saveEle.MinFloat = mobj.MinFloat;
            if (saveEle.MaxFloat != mobj.MaxFloat)
                saveEle.MaxFloat = mobj.MaxFloat;
            if (saveEle.SerialNum != mobj.SerialNum)
                saveEle.SerialNum = mobj.SerialNum;
            if (saveEle.TotalLength != mobj.TotalLength)
                saveEle.TotalLength = mobj.TotalLength;
            if (saveEle.LevelNo != mobj.LevelNo)
                saveEle.LevelNo = mobj.LevelNo;
            if (saveEle.ComputeStr != mobj.ComputeStr)
                saveEle.ComputeStr = mobj.ComputeStr;
        }
Пример #2
0
 private static void RemoveOldProperties(t_Element meleObj, string elementType)
 {
     var removeElements = _DataContext.t_Elements.Where(t => t.ParentID == meleObj.ElementID && t.ElementType == elementType).ToList();
     // 删除老的ToolTip\子控件,及他们的老属性
     foreach (var removeElement in removeElements)
     {
         _DataContext.t_Elements.Remove(removeElement);
         // 删除属性
         var removeProperties = _DataContext.t_ElementProperties.Where(p => p.ElementID == removeElement.ElementID).ToList();
         foreach (var removeProperty in removeProperties)
         {
             _DataContext.t_ElementProperties.Remove(removeProperty);
         }
     }
 }
Пример #3
0
        private void AddChildControl(Canvas canvas, ElementSate el, t_Element meleObj)
        {
            // 添加子控件
            foreach (var child in canvas.Children)
            {
                var childMoinitor = child as MonitorControl;
                if (null != childMoinitor)
                {
                    // 保存ToolTip 子控件
                    var childElement = childMoinitor.ScreenElement.Clone();
                    childElement.Width = Convert.ToInt32(childMoinitor.Width);
                    childElement.Height = Convert.ToInt32(childMoinitor.Height);
                    childElement.ScreenX = (int)Canvas.GetLeft(childMoinitor);
                    childElement.ScreenY = (int)Canvas.GetTop(childMoinitor);
                    if (el != ElementSate.New)
                    {
                        childElement.ParentID = meleObj.ElementID;
                        childElement.ScreenID = meleObj.ScreenID;
                    }
                    else
                    {
                        childElement.ScreenID = null;
                    }
                    if (_DataContext.t_Elements.Contains(childElement))
                    {
                        _DataContext.t_Elements.Remove(childElement);
                    }

                    _DataContext.t_Elements.Add(childElement.Clone());// 2个必须同步添加
                    listMonitorAddElement.Add(childMoinitor);// 2个必须同步添加
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 显示元素
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="eleStae"></param>
        /// <param name="listObj"></param>
        /// <returns></returns>
        public MonitorControl ShowElement(Canvas canvas, t_Element obj, ElementSate eleStae, List<t_ElementProperty> listObj)
        {
            try
            {
                if (obj.ImageURL != null && obj.ImageURL.IndexOf("MonitorSystem") == 0)
                {
                    MonitorControl instance = (MonitorControl)Activator.CreateInstance(Type.GetType(obj.ImageURL));
                    //var instance = Activator.CreateInstance(Type.GetType(t.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 = _DataContext.t_Elements.Where(e => e.ParentID == obj.ElementID && e.ElementType == "Background").ToList();
                            ShowElements(childElements, backgroundControl.BackgroundCanvas, backgroundControl);
                            return backgroundControl;
                        default:
                            string url = string.Format("/MonitorSystem;component/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;
            }
        }
Пример #5
0
 /// <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;
 }
Пример #6
0
        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;
            };
            if (eleStae == ElementSate.Save)
            {
                mControl.Name = obj.ElementID.ToString();
            }
            mControl.ScreenElement = obj;
            mControl.ListElementProp = listObj;
            mControl.ElementState = eleStae;

            //if (eleStae == ElementSate.Save)
            //{
            //    mControl.Name = obj.ElementID.ToString();
            //}
            mControl.SetPropertyValue();
            mControl.SetCommonPropertyValue();
            //添加到场景
            canvas.Children.Add(mControl);

            //if (CBIsztControl.IsChecked.Value)
            if (IsZT)
            {
                mControl.DesignMode();
            }
        }
Пример #7
0
 /// <summary>
 /// 用于向 t_Element EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddTot_Element(t_Element t_Element)
 {
     base.AddObject("t_Element", t_Element);
 }
Пример #8
0
 /// <summary>
 /// 创建新的 t_Element 对象。
 /// </summary>
 /// <param name="elementID">ElementID 属性的初始值。</param>
 public static t_Element Createt_Element(global::System.Int32 elementID)
 {
     t_Element t_Element = new t_Element();
     t_Element.ElementID = elementID;
     return t_Element;
 }