Пример #1
0
        private void BtnBrowseImage_Click(object sender, EventArgs e)
        {
            if (ofdWatermarkImage.ShowDialog() == DialogResult.OK)
            {
                txtImageURI.Text = ofdWatermarkImage.FileName;
                LoadWatermarkImagePreview(ofdWatermarkImage.FileName);

                var img = ImageInfo.FromFile(ofdWatermarkImage.FileName);

                lblWidthValue.Text    = $@"{img.Width}px";
                lblHeightValue.Text   = $@"{img.Height}px";
                lblFileSizeValue.Text = img.ByteString();

                //globalWmContext.BetaWatermarkImageBase64 = watermarkImageToBase64((Bitmap)Bitmap.FromFile(ofdWatermarkImage.FileName));
                ImageSelected = true;
                RenderPreview();
            }
        }
Пример #2
0
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            if (reader.Format == FileFormat.Glade)
            {
                string file     = (string)GladeUtils.ExtractProperty(elem, "pixbuf", "");
                string stock    = (string)GladeUtils.ExtractProperty(elem, "stock", "");
                string iconSize = (string)GladeUtils.ExtractProperty(elem, "icon_size", "");
                base.ReadProperties(reader, elem);

                if (stock != null && stock.Length > 0)
                {
                    Pixbuf = ImageInfo.FromTheme(stock, (Gtk.IconSize) int.Parse(iconSize));
                }
                else if (file != null && file != "")
                {
                    Pixbuf = ImageInfo.FromFile(file);
                }
            }
            else
            {
                base.ReadProperties(reader, elem);
            }
        }
Пример #3
0
        protected override void ReadProperties(ObjectReader reader, XmlElement elem)
        {
            if (reader.Format == FileFormat.Glade)
            {
                string icon = (string)GladeUtils.ExtractProperty(elem, "icon", "");
                stockId = (string)GladeUtils.ExtractProperty(elem, "stock_id", "");
                label   = (string)GladeUtils.ExtractProperty(elem, "label", "");
                base.ReadProperties(reader, elem);

                if (stockId != null && stockId.Length > 0)
                {
                    Type = ButtonType.StockItem;
                }
                else if (icon != null && icon != "")
                {
                    imageInfo = ImageInfo.FromFile(icon);
                    Type      = ButtonType.TextAndIcon;
                }
            }
            else
            {
                base.ReadProperties(reader, elem);
            }
        }
Пример #4
0
        private void FrmWatermark_Load(object sender, EventArgs e)
        {
            //setup the default GUI values
            RadDoNothing              = true;
            tabText.Enabled           = false;
            tabImage.Enabled          = false;
            btnFontSelector.ForeColor = GlobalWmContext.BetaWatermarkFont.GetColor();
            btnFontSelector.Font      = GlobalWmContext.BetaWatermarkFont.GetFont(true);

            //realign 'Rendering...' label
            PositionRenderingLabel();

            //reset values to config
            numWatermarkScale.Value   = (decimal)GlobalWmContext.BetaWatermarkScale;
            numWatermarkOffsetX.Value = GlobalWmContext.BetaWatermarkOffset.X;
            numWatermarkOffsetY.Value = GlobalWmContext.BetaWatermarkOffset.Y;

            //setup rendering information using the watermark type
            switch (GlobalWmContext.BetaWatermarkType)
            {
            case WatermarkType.None:
                radWatermarkNone.Checked = true;
                break;

            case WatermarkType.Text:
                SetTypeText();

                txtImageText.Text        = GlobalWmContext.BetaWatermarkInfo.WatermarkText;
                btnFontSelector.Text     = GlobalWmContext.BetaWatermarkInfo.WatermarkText;
                radWatermarkText.Checked = true;
                break;

            case WatermarkType.Image:
            {
                SetTypeImage();
                radWatermarkImage.Checked = true;

                if (File.Exists(GlobalWmContext.BetaWatermarkInfo.WatermarkPath))
                {
                    var img = ImageInfo.FromFile(GlobalWmContext.BetaWatermarkInfo.WatermarkPath);
                    txtImageURI.Text      = GlobalWmContext.BetaWatermarkInfo.WatermarkPath;
                    ImageSelected         = true;
                    lblWidthValue.Text    = $@"{img.Width}px";
                    lblHeightValue.Text   = $@"{img.Height}px";
                    lblFileSizeValue.Text = img.ByteString();

                    LoadWatermarkImagePreview(GlobalWmContext.BetaWatermarkInfo.WatermarkPath);
                    RevertWatermarkImagePreview();
                    RenderPreview();
                }
                else
                {
                    RevertWatermarkImagePreview();
                }

                break;
            }
            }

            RadDoNothing = false;
        }