Beispiel #1
0
 static public void addPage(String pageName, SVPageWidget obj)
 {
     if (!_pageContainer.ContainsKey(pageName))
     {
         _pageContainer.Add(pageName, obj);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 根据控件初始化窗口
        /// </summary>
        /// <param Name="control"></param>
        public SVControlWindow(Control control)
        {
            //DockAreas = (DockAreas.Document | DockAreas.Float | DockAreas.DockLeft | DockAreas.DockRight | DockAreas.DockTop | DockAreas.DockBottom);
            //ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.Document;
            //HideOnClose = false;
            control.Dock = System.Windows.Forms.DockStyle.Fill;
            this.Controls.Add(control);

            this._control   = control;
            this.AutoScroll = true;

            this.KeyPreview = true;

            ///注册快捷键方式,只有页面控件才有
            if (control is SVPageWidget)
            {
                initShortKey();

                ///当单击当前窗体,也要使得页面控件被反选
                this.MouseDown += new MouseEventHandler((sender, e) =>
                {
                    SVPageWidget widget = this._control as SVPageWidget;
                    widget.selectAll(false);
                    SVSelectPanelObjs._VK_Ctrl = false;
                });
            }
        }
Beispiel #3
0
        /// <summary>
        /// 编译的时候进行的合法性检查
        /// </summary>
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,趋势图ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 0, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (Attrib.Min >= Attrib.Max)
            {
                String msg = String.Format("页面 {0} 中,趋势图ID为:{1}, 起始坐标大于结束坐标", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中,趋势图ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (this._attrib.Variable.Count == 0)
            {
                String msg = String.Format("页面 {0} 中,趋势图ID为:{1}, 未关联变量", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }
        }
Beispiel #4
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context,
                                         System.IServiceProvider provider, object value)
        {
            //从当前对象中获取按钮控件对象
            SVPageWidget page = context.Instance as SVPageWidget;

            if (page == null)
            {
                return(null);
            }

            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                SVWpfControl textDialog = new SVWpfControl();
                textDialog.Width  = 200;
                textDialog.Height = 300;

                WPFWidgetBackGround edit = new WPFWidgetBackGround();
                edit.DataContext = page.Attrib;

                textDialog.addContent(edit);
                edSvc.DropDownControl(textDialog);

                page.refreshPropertyToPanel();
            }

            return(value);
        }
Beispiel #5
0
        /// <summary>
        /// 检查静态图中的合法项
        /// </summary>
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,静态图ID为:{1}, ID值已经超出合法范围[{2} - {3}]", pageName, Attrib.ID, 1, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (Attrib.PicIconData.bitmap() == null)
            {
                String msg = String.Format("页面 {0} 中,静态图ID为:{1}, 图片属性没有设置!", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中,静态图ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }
        }
Beispiel #6
0
        public void selectAllMethod()
        {
            SVPageWidget widget = this._control as SVPageWidget;

            if (widget != null)
            {
                widget.selectAll(true);
            }
        }
Beispiel #7
0
        public void undoMethod()
        {
            SVPageWidget widget = this._control as SVPageWidget;

            if (widget != null)
            {
                widget.RedoUndo.Undo();
            }
        }
Beispiel #8
0
        /// <summary>
        /// 按下删除键
        /// </summary>
        /// <param Name="sender"></param>
        /// <param Name="e"></param>
        void delItem_Click(object sender, System.EventArgs e)
        {
            SVPageWidget widget = _control as SVPageWidget;

            if (widget != null)
            {
                SVSelectPanelObjs.removeOperator();
            }
            widget.ChildRemoveEvent(null, null);
        }
Beispiel #9
0
        /// <summary>
        /// 检查当前按钮对象中内容是否合法
        ///
        /// 不合法-抛出SVCheckValidException异常
        /// </summary>
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,心跳控件ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 1, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (!isHasParent())
            {
                String msg = String.Format("页面 {0} 中,心跳控件ID为:{1}, 没有在页面控件中", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (this.Parent == null)
            {
                String msg = String.Format("页面 {0} 中,心跳控件ID为:{1}, 没有父控件", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中,心跳控件ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            var image = Attrib.BitMapArray.BitmapArray;

            if (image.Count == 0)
            {
                String msg = String.Format("页面 {0} 中,心跳控件ID为:{1}, 未设置任何图片", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            for (int i = 0; i < image.Count; i++)
            {
                var tmpImage = image[i];
                if (tmpImage.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中,心跳控件ID为:{1}, 第{2}个图片设置有误", pageName, Attrib.ID, i);
                    throw new SVCheckValidException(msg);
                }
            }
        }
Beispiel #10
0
        private void initalizeWindow()
        {
            foreach (var v in SVGlobalData.PageContainer)
            {
                DataGridViewRow         row  = new DataGridViewRow();
                DataGridViewTextBoxCell text = new DataGridViewTextBoxCell();
                text.Value = v.Key;

                DataGridViewTextBoxCell id     = new DataGridViewTextBoxCell();
                SVPageWidget            widget = (SVPageWidget)v.Value;
                id.Value = widget.Attrib.id.ToString();

                row.Cells.Add(text);
                row.Cells.Add(id);

                dataGridView.Rows.Add(row);
            }
        }
Beispiel #11
0
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,模拟量ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 0, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (Attrib.Min >= Attrib.Max)
            {
                String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 最小值 >= 最大值", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            var varInstance = SVVaribleType.instance();

            var address = varInstance.strToAddress(Attrib.Variable.VarName, Attrib.Variable.VarBlockType);

            if ((address & 0x00ffffff) > 48 * 1024)
            {
                String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 未正确设置变量", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            //var type = (Byte)varInstance.strToType(Attrib.Variable.VarName, Attrib.Variable.VarBlockType);
            //if (type == 0)
            //{
            //    String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 变量类型不满足条件", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}
        }
Beispiel #12
0
        /// <summary>
        /// 检查其合法性
        /// </summary>
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面{0}中的动态图ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (_attrib.VarName.Count == 0)
            {
                String msg = String.Format("页面 {0} 中的动态图ID为:{1}, 没有设置变量!", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (_attrib.PicError.bitmap() == null)
            {
                String msg = String.Format("页面 {0} 中的动态图ID为:{1}, 没有设置异常图片!", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if ((Int32)Math.Pow(2, _attrib.VarName.Count) != _attrib.Pic.BitmapArray.Count)
            {
                String msg = String.Format("页面 {0} 中的动态图ID为:{1}, 变量个数和图片个数不匹配!", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            for (int i = 0; i < _attrib.Pic.BitmapArray.Count; i++)
            {
                var itemPic = _attrib.Pic.BitmapArray[i];

                if (itemPic.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中的动态图ID为:{1}, 第{2}副图片设置有误。", pageName, Attrib.ID, i);
                    throw new SVCheckValidException(msg);
                }
            }
        }
Beispiel #13
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            SVPageWidget widget = e.Context.Instance as SVPageWidget;

            if (widget == null)
            {
                return;
            }

            if (widget.Attrib.BackGroundType == 0)
            {
                SolidBrush brush = new SolidBrush(widget.Attrib.BackColor);
                Rectangle  rect  = new Rectangle(1, 1, 19, 17);

                e.Graphics.FillRectangle(brush, rect);
            }
            else
            {
                Rectangle rect = new Rectangle(1, 1, 19, 17);
                e.Graphics.DrawImage(widget.Attrib.PicIconData.bitmap(), rect);
            }
        }
Beispiel #14
0
        /// <summary>
        /// 保存当前工程中的所有页面数据
        /// </summary>
        public void saveAllPageData()
        {
            ///根节点,工程名节点
            foreach (TreeNode stationNode in this.Nodes)
            {
                ///所有分类节点
                foreach (TreeNode item in stationNode.Nodes)
                {
                    ///所有页面节点
                    foreach (SVPageNode page in item.Nodes)
                    {
                        SVPageWidget widget = page.Addtionobj as SVPageWidget;
                        if (widget == null)
                        {
                            continue;
                        }

                        ///保存页面
                        widget.saveSelf();
                    }
                }
            }
        }
Beispiel #15
0
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,文本ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 0, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (!isHasParent())
            {
                String msg = String.Format("页面 {0} 中,文本ID为:{1}, 没有在页面控件中", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (this.Parent == null)
            {
                String msg = String.Format("页面 {0} 中,文本ID为:{1}, 没有父控件", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (String.IsNullOrEmpty(Attrib.Text))
            {
                String msg = String.Format("页面 {0} 中,文本ID为:{1}, 文本内容不能为空", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中,文本ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }
        }
Beispiel #16
0
        private void pageTextBox_TextChanged(object sender, EventArgs e)
        {
            dataGridView.Rows.Clear();

            if (pageTextBox.Text == String.Empty)
            {
                initalizeWindow();
                return;
            }

            foreach (var v in SVGlobalData.PageContainer)
            {
                String upValue = v.Key.ToUpper();
                String upText  = pageTextBox.Text.ToUpper();

                SVPageWidget widget = (SVPageWidget)v.Value;
                String       strID  = widget.Attrib.id.ToString();

                if (!upValue.Contains(upText) &&
                    !strID.Contains(pageTextBox.Text))
                {
                    continue;
                }

                DataGridViewRow         row  = new DataGridViewRow();
                DataGridViewTextBoxCell text = new DataGridViewTextBoxCell();
                text.Value = v.Key;

                DataGridViewTextBoxCell id = new DataGridViewTextBoxCell();
                id.Value = strID;

                row.Cells.Add(text);
                row.Cells.Add(id);

                dataGridView.Rows.Add(row);
            }
        }
Beispiel #17
0
        /// <summary>
        /// 检查当前按钮对象中内容是否合法
        ///
        /// 不合法-抛出SVCheckValidException异常
        /// </summary>
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,按钮ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 0, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (!isHasParent())
            {
                String msg = String.Format("页面 {0} 中,按钮ID为:{1}, 没有在页面控件中", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (this.Parent == null)
            {
                String msg = String.Format("页面 {0} 中,按钮ID为:{1}, 没有父控件", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中,按钮ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            //if (!Attrib.isValidFont())
            //{
            //    String msg = String.Format("页面 {0} 中,按钮ID为:{1}, 设置的文本字体不合法", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}

            //var varInstance = SVVaribleType.instance();
            //if (!varInstance.isOpen())
            //{
            //    String msg = String.Format("数据库打开失败,请检查!");
            //    throw new SVCheckValidException(msg);
            //}

            //var address = varInstance.strToAddress(Attrib.ButtonPage.EnVarText, Attrib.ButtonPage.EnVarTextType);
            //if (address == 0)
            //{
            //    String msg = String.Format("页面 {0} 中, 按钮ID为:{1}, 使能变量未正确设置", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}

            //var varAddress = varInstance.strToAddress(Attrib.ButtonPage.VarText, Attrib.ButtonPage.VarTextType);
            //if (varAddress == 0)
            //{
            //    String msg = String.Format("页面 {0} 中, 按钮ID为:{1}, 按钮关联变量未正确设置", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}

            if (Attrib.IsShowPic)
            {
                if (Attrib.BtnUpPic.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中, 按钮ID为:{1}, 按钮弹起图片未设置", pageName, Attrib.ID);
                    throw new SVCheckValidException(msg);
                }

                if (Attrib.BtnDownPic.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中, 按钮ID为:{1}, 按钮按下图片未设置", pageName, Attrib.ID);
                    throw new SVCheckValidException(msg);
                }
            }
        }
Beispiel #18
0
        public override void checkValid()
        {
            SVPageWidget pageWidget = this.Parent as SVPageWidget;
            String       pageName   = pageWidget.PageName;

            SVUniqueID uniqueObj = SVUniqueID.instance();

            if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID)
            {
                String msg = String.Format("页面 {0} 中,开关ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 1, uniqueObj.MaxID);
                throw new SVCheckValidException(msg);
            }

            if (!this.Parent.ClientRectangle.Contains(this.Bounds))
            {
                String msg = String.Format("页面 {0} 中,开关量ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }

            if (Attrib.Type == 1)
            {
                if (Attrib.TruePicture.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中,开关量ID为:{1}, 为真的图片未设置,或者图元数据有误!", pageName, Attrib.ID);
                    throw new SVCheckValidException(msg);
                }

                if (Attrib.FlasePicture.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中,开关量ID为:{1}, 为假的图片未设置,或者图元数据有误!", pageName, Attrib.ID);
                    throw new SVCheckValidException(msg);
                }

                if (Attrib.ExPicture.bitmap() == null)
                {
                    String msg = String.Format("页面 {0} 中,开关量ID为:{1}, 异常图片未设置,或者图元数据有误!", pageName, Attrib.ID);
                    throw new SVCheckValidException(msg);
                }
            }

            if (String.IsNullOrWhiteSpace(Attrib.Variable.VarName))
            {
                String msg = String.Format("页面 {0} 中,开关量ID为:{1}, 变量未设置!", pageName, Attrib.ID);
                throw new SVCheckValidException(msg);
            }
            //var varInstance = SVVaribleType.instance();
            //varInstance.loadVariableData();
            //varInstance.setDataType(Attrib.VarBlockType);
            //if (!varInstance.isOpen())
            //{
            //    String msg = String.Format("数据库打开失败,请检查!");
            //    throw new SVCheckValidException(msg);
            //}

            //if (String.IsNullOrWhiteSpace(Attrib.Var))
            //{
            //    String msg = String.Format("页面 {0} 中, 开关量ID为:{1}, 变量不合法", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}

            //var address = varInstance.strToAddress(Attrib.Var, Attrib.VarBlockType);
            //if (address == 0)
            //{
            //    String msg = String.Format("页面 {0} 中, 开关量ID为:{1}, 未正确设置变量", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}

            //var type = varInstance.strToType(Attrib.Var);
            //if (type == -1)
            //{
            //    String msg = String.Format("页面 {0} 中, 开关量ID为:{1}, 变量类型不满足条件", pageName, Attrib.ID);
            //    throw new SVCheckValidException(msg);
            //}
        }