Ejemplo n.º 1
0
        public void fromBin(PageBin bin, byte[] picBuffer)
        {
            if (bin.bgSet == 0)
            {
                ///背景颜色显示
                this.BackColor = Color.FromArgb((Int32)bin.bgClr);
            }
            else
            {
                ///背景图片显示
                SVPixmapFile file = new SVPixmapFile();
                this.BackgroundImage = file.getFromFile(picBuffer, bin.bgClr);
            }

            this.ID = bin.id;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void init()
        {
            if (_gif.Attrib.PicError.ImageFileName != null)
            {
                String file = Path.Combine(SVProData.IconPath, _gif.Attrib.PicError.ImageFileName);
                if (File.Exists(file))
                {
                    SVPixmapFile pixmapFile = new SVPixmapFile();
                    pixmapFile.readPixmapFile(file);
                    errBtn.BackgroundImageLayout = ImageLayout.Zoom;
                    errBtn.BackgroundImage       = pixmapFile.getBitmapFromData();
                }
            }

            this.bgBtn.Enabled = (_gif.Attrib.VarName.Count != 0);
            foreach (var item in _gif.Attrib.VarName)
            {
                varListView.Items.Add(item);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 设置出错背景图片
        /// </summary>
        /// <param Name="sender"></param>
        /// <param Name="e"></param>
        private void errBtn_Click(object sender, System.EventArgs e)
        {
            SVBitmapManagerWindow window = new SVBitmapManagerWindow();

            if (window.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
            {
                String file = Path.Combine(SVProData.IconPath, window.SvBitMap.ImageFileName);
                _gif.Attrib.PicError = window.SvBitMap;

                if (!File.Exists(file))
                {
                    return;
                }

                SVPixmapFile pixmapFile = new SVPixmapFile();
                pixmapFile.readPixmapFile(file);
                errBtn.BackgroundImageLayout = ImageLayout.Zoom;
                errBtn.BackgroundImage       = pixmapFile.getBitmapFromData();
            }
        }
Ejemplo n.º 4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(value);
            }

            String str = value as String;

            String infile = System.IO.Path.Combine(SVProData.IconPath, "icon.proj");
            SVPixmapElementManage manage = new SVPixmapElementManage();

            manage.loadElementFromFile(infile);

            String       file1  = System.IO.Path.Combine(SVProData.IconPath, manage.getFilePathFromName(str));
            SVPixmapFile pixmap = new SVPixmapFile();

            pixmap.readPixmapFile(file1);
            System.Drawing.Image  srcImg = System.Drawing.Image.FromStream(pixmap.Pixmap);
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(srcImg);

            return(BitmapToBitmapImage(bitmap));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 解析并显示开关量
        /// </summary>
        /// <param Name="bin">开关量内存结构</param>
        public void fromBin(BinaryBin bin, byte[] byteBuffer)
        {
            ///位置和尺寸
            this.Location = new Point(bin.rect.sX, bin.rect.sY);
            this.Width    = bin.rect.eX - bin.rect.sX;
            this.Height   = bin.rect.eY - bin.rect.sY;

            ///开关量类型
            _typeByte = bin.type;

            ///显示字体
            Dictionary <Byte, Font> FontConfig = new Dictionary <Byte, Font>();

            FontConfig.Add(8, new Font("华文细黑", 8));
            FontConfig.Add(12, new Font("华文细黑", 12));
            FontConfig.Add(16, new Font("华文细黑", 16));
            this.Font = FontConfig[bin.font];

            ///显示内容
            if (bin.type == 0)
            {
                this.Text = Encoding.Unicode.GetString(bin.trueText);
                customList.Add(Encoding.Unicode.GetString(bin.trueText));
                customList.Add(Encoding.Unicode.GetString(bin.falseText));

                trueColor    = Color.FromArgb((Int32)bin.trueClr);
                trueBgColor  = Color.FromArgb((Int32)bin.trueBgClr);
                falseColor   = Color.FromArgb((Int32)bin.falseClr);
                falseBgColor = Color.FromArgb((Int32)bin.falseBgClr);
            }
            else
            {
                SVPixmapFile file = new SVPixmapFile();
                customImageList.Add(file.getFromFile(byteBuffer, bin.trueClr));
                customImageList.Add(file.getFromFile(byteBuffer, bin.falseClr));
            }
        }
Ejemplo n.º 6
0
        public void fromBin(ButtonBin bin, byte[] picBuffer)
        {
            this.MouseDown += new MouseEventHandler((sender, e) =>
            {
                ///如果为0,表示以颜色显示按钮背景
                if (bin.bgUpFlag == 0 && bin.bgDownFlag == 0)
                {
                    Attrib.BackColorgroundDown = Color.FromArgb((Int32)bin.bgDownColor);
                    _paintEvent = drawButtonDown;
                    Refresh();
                }
                else
                {
                    SVPixmapFile file    = new SVPixmapFile();
                    this.BackgroundImage = file.getFromFile(picBuffer, bin.bgDownColor);
                }
            });

            this.MouseUp += new MouseEventHandler((sender, e) =>
            {
                ///如果为0,表示以颜色显示按钮背景
                if (bin.bgUpFlag == 0 && bin.bgDownFlag == 0)
                {
                    Attrib.BackColorground = Color.FromArgb((Int32)bin.bgUpColor);
                    _paintEvent            = drawButtonNormal;
                    Refresh();
                }
                else
                {
                    SVPixmapFile file    = new SVPixmapFile();
                    this.BackgroundImage = file.getFromFile(picBuffer, bin.bgUpColor);
                }
            });


            ///如果为0,表示以颜色显示按钮背景
            if (bin.bgUpFlag == 0 && bin.bgDownFlag == 0)
            {
                Attrib.BackColorground = Color.FromArgb((Int32)bin.bgUpColor);
                _paintEvent            = drawButtonNormal;
                Refresh();
            }
            else
            {
                SVPixmapFile file = new SVPixmapFile();
                this.BackgroundImage = file.getFromFile(picBuffer, bin.bgUpColor);
            }

            ///按钮位置和尺寸
            this.Location = new Point(bin.rect.sX, bin.rect.sY);
            this.Width    = bin.rect.eX - bin.rect.sX;
            this.Height   = bin.rect.eY - bin.rect.sY;

            ///字体
            Dictionary <Byte, Font> FontConfig = new Dictionary <Byte, Font>();

            FontConfig.Add(8, new Font("华文细黑", 8));
            FontConfig.Add(12, new Font("华文细黑", 12));
            FontConfig.Add(16, new Font("华文细黑", 16));
            this.Font = FontConfig[bin.font];

            int len = 0;

            for (int i = 0; i < bin.text.Length; i += 2)
            {
                if (bin.text[i] == 0 && bin.text[i + 1] == 0)
                {
                    break;
                }

                len += 2;
            }

            ///显示字体颜色
            this.ForeColor = Color.FromArgb((Int32)bin.fontClr);
            ///显示字体
            this.Text = System.Text.Encoding.Unicode.GetString(bin.text, 0, len);
        }