Exemplo n.º 1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context,
                                         System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                SVVarDefine variable = value as SVVarDefine;
                if (variable == null)
                {
                    return(value);
                }

                SVWpfControl variableDialog = new SVWpfControl();
                variableDialog.Width  = 280;
                variableDialog.Height = 400;

                SVWPFVariableDialog dialog = new SVWPFVariableDialog();
                dialog.setFilter(new List <String> {
                    "BOOL", "BOOL_S"
                });
                dialog.name.DataContext = variable.VarName;
                dialog.type.DataContext = variable.VarBlockType;
                variableDialog.addContent(dialog);

                edSvc.DropDownControl(variableDialog);

                variable.VarName      = (String)dialog.name.DataContext;
                variable.VarBlockType = Convert.ToByte(dialog.type.DataContext);
            }

            return(value);
        }
Exemplo n.º 2
0
        public SVCurveProperties()
        {
            _font        = new Font("华文细黑", 12);
            _rect        = new Rectangle(0, 0, 270, 260);
            _bgcolor     = Color.DimGray;
            _fgcolor     = Color.White;
            _min         = 0;
            _max         = 200;
            _interval    = 60;
            _step        = 60;
            _controlType = "趋势图";
            _isLock      = false;

            _forwardControl  = new SVVarDefine();
            _curControl      = new SVVarDefine();
            _backwardControl = new SVVarDefine();

            ///设置跳转变量
            _forwardControl.VarName       = SVCurveProperties.getIndexNumber();
            _curControl.VarName           = SVCurveProperties.getIndexNumber();
            _backwardControl.VarName      = SVCurveProperties.getIndexNumber();
            _forwardControl.VarBlockType  = 3;
            _curControl.VarBlockType      = 3;
            _backwardControl.VarBlockType = 3;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 重写父类,这里不需要关注
        /// </summary>
        /// <param oldName="context"></param>
        /// <param oldName="sourceType"></param>
        /// <returns></returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            SVVarDefine varDefine = value as SVVarDefine;

            if (varDefine == null)
            {
                return(base.ConvertTo(context, culture, value, destinationType));
            }

            if (String.IsNullOrWhiteSpace(varDefine.VarName))
            {
                return("None");
            }

            return(varDefine.VarName);
        }
Exemplo n.º 4
0
        public SVAnalogProperties()
        {
            _font             = new Font("华文细黑", 12);
            _rect             = new Rectangle(0, 0, 120, 40);
            _normalColor      = Color.Green;
            _overMaxClr       = Color.Black;
            _overMinClr       = Color.White;
            _normalBgColor    = Color.Moccasin;
            _overMaxBgClr     = Color.Red;
            _overMinBgClr     = Color.Red;
            _exceptionColor   = Color.Red;
            _exceptionBgColor = Color.White;
            _decNum           = 1;
            _min      = 1;
            _max      = 100;
            _variable = new SVVarDefine();

            _controlType = "模拟量";
            _isLock      = false;
        }
Exemplo n.º 5
0
        public SVButtonProperties()
        {
            _font        = new Font("华文细黑", 12);
            _rect        = new Rectangle(0, 0, 120, 60);
            _text        = "Button";
            _fText       = "None";
            _fMemo       = "";
            _bgcolor     = Color.FromArgb(236, 236, 236);
            _fgcolor     = Color.Black;
            _bgDownColor = _bgcolor;
            _btnType     = new SVBtnChoicePage();
            _controlType = "按钮";
            _enVarText   = new SVVarDefine();
            _btnVarText  = new SVVarDefine();

            _btnDownPic = new SVBitmap();
            _btnUpPic   = new SVBitmap();
            _isShowPic  = false;
            _isLock     = false;
        }
Exemplo n.º 6
0
        public SVBinaryProperties()
        {
            _font             = new Font("华文细黑", 12);
            _rect             = new Rectangle(0, 0, 120, 40);
            _trueColor        = Color.Green;
            _trueBgColor      = Color.Moccasin;
            _falseColor       = Color.Blue;
            _falseBgColor     = Color.White;
            _exceptionColor   = Color.Red;
            _exceptionBgColor = Color.White;
            _type             = 0;
            _customTrueText   = "True";
            _customFlaseText  = "False";
            _controlType      = "开关量";
            _isLock           = false;
            _var = new SVVarDefine();

            _truePicture  = new SVBitmap();
            _flasePicture = new SVBitmap();
            _exPicture    = new SVBitmap();
        }
Exemplo n.º 7
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            SVVarDefine var = e.Value as SVVarDefine;

            if (var == null)
            {
                return;
            }

            StringFormat strFormat = new StringFormat();

            strFormat.Alignment     = StringAlignment.Center;
            strFormat.LineAlignment = StringAlignment.Center;

            Rectangle rect = new Rectangle(1, 1, 19, 17);

            if (String.IsNullOrWhiteSpace(var.VarName))
            {
                e.Graphics.DrawString("-", new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Black), rect, strFormat);
                return;
            }

            switch (var.VarBlockType)
            {
            case 0:
                e.Graphics.DrawString("I", new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Black), rect, strFormat);
                break;

            case 1:
                e.Graphics.DrawString("O", new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Black), rect, strFormat);
                break;

            case 2:
                e.Graphics.DrawString("S", new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Black), rect, strFormat);
                break;
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取当前页面中的所有变量
        /// </summary>
        /// <returns></returns>
        public List <SVVarDefine> getCurrPageAllVar()
        {
            List <SVVarDefine> result = new List <SVVarDefine>();

            foreach (var item in this.Controls)
            {
                if (item is SVBinary)
                {
                    var varItem = ((SVBinary)item).Attrib.Variable;
                    if (!result.Contains(varItem) && varItem.isValid())
                    {
                        result.Add(varItem);
                    }
                }

                if (item is SVAnalog)
                {
                    var varItem = ((SVAnalog)item).Attrib.Variable;
                    if (!result.Contains(varItem) && varItem.isValid())
                    {
                        result.Add(varItem);
                    }
                }

                if (item is SVCurve)
                {
                    foreach (var child in ((SVCurve)item).Attrib.Variable)
                    {
                        if (!result.Contains(child.Var) && child.Var.isValid())
                        {
                            result.Add(child.Var);
                        }
                    }
                }

                if (item is SVButton)
                {
                    var varDefine = ((SVButton)item).Attrib.BtnVarText;
                    if (!result.Contains(varDefine) && varDefine.isValid())
                    {
                        result.Add(varDefine);
                    }
                }

                if (item is SVGif)
                {
                    var varNameList = ((SVGif)item).Attrib.VarName;
                    var varTypeList = ((SVGif)item).Attrib.VarType;
                    int nCount      = varNameList.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        SVVarDefine varDefine = new SVVarDefine();
                        varDefine.VarName      = varNameList[i];
                        varDefine.VarBlockType = varTypeList[i];
                        if (!result.Contains(varDefine) && varDefine.isValid())
                        {
                            result.Add(varDefine);
                        }
                    }
                }
            }

            return(result);
        }