コード例 #1
0
        /*
         * Watermarking Tab Events
         */
        private void edit_watermarker(object sender, EventArgs e)
        {
            Control box    = (Control)sender;
            Button  button = (Button)sender;

            string page_location = box.Name.Split('_')[1];
            Label  label         = this.Controls.Find("label_" + page_location, true).FirstOrDefault() as Label;

            if (label.Text == "")
            {
                watermarkContextMenu.Show(button, new Point(0, button.Height));
            }
            else
            {
                SerializableStringDictionary related_config = Configurator.GetConfigSerializableStringDict(page_location);
                if (label.Text == "Text")
                {
                    Form wm = new Text_Watermark(page_location, related_config);
                    wm.ShowDialog(this);
                }
                else if (label.Text == "Page Number")
                {
                    Form wm = new Page_Number_Watermark(page_location, related_config);
                    wm.ShowDialog(this);
                }
                else if (label.Text == "Image")
                {
                    Form wm = new Image_Watermark(page_location, related_config);
                    wm.ShowDialog(this);
                }
            }
        }
コード例 #2
0
        public Text_Watermark(string caller_name, SerializableStringDictionary watermark_settings)
            : base(caller_name)
        {
            InitializeComponent();
            wmFontName.Text  = watermark_settings["font_name"];
            wmFontSize.Text  = watermark_settings["font_size"];
            wmFontStyle.Text = watermark_settings["font_style"];
            wmText.Text      = watermark_settings["text"];
            wmTimestamp.Text = watermark_settings["add_timestamp"];
            FontStyle fstyle;

            if (wmFontStyle.Text == "Regular")
            {
                fstyle = FontStyle.Regular;
            }
            else if (wmFontStyle.Text == "Bold")
            {
                fstyle = FontStyle.Bold;
            }
            else if (wmFontStyle.Text == "Italic")
            {
                fstyle = FontStyle.Italic;
            }
            else
            {
                fstyle = FontStyle.Regular;
            }
            Font settings_font = new Font(watermark_settings["font_name"], Int32.Parse(watermark_settings["font_size"]), fstyle);

            fontDialog1.Font = settings_font;
        }
コード例 #3
0
 private void loadPageLayoutConfigs()
 {
     foreach (string page_layout_location in this.watermark_page_location_names)
     {
         SerializableStringDictionary watermark_settings = Configurator.GetConfigSerializableStringDict(page_layout_location);
         if (watermark_settings != null)
         {
             Label  label          = this.Controls.Find("label_" + page_layout_location, true).FirstOrDefault() as Label;
             string new_label_text = "";
             if (watermark_settings["watermark_type"] == "text")
             {
                 new_label_text = "Text";
             }
             else if (watermark_settings["watermark_type"] == "image")
             {
                 new_label_text = "Image";
             }
             else if (watermark_settings["watermark_type"] == "page_number")
             {
                 new_label_text = "Page Number";
             }
             // Don't change labels if no response, exit early
             else
             {
                 return;
             }
             label.Text = new_label_text;
             Button button = this.Controls.Find("edit_" + page_layout_location, true).FirstOrDefault() as Button;
             button.Text = "Edit";
         }
     }
 }
コード例 #4
0
        public Page_Number_Watermark(string caller_name, SerializableStringDictionary watermark_settings)
            : base(caller_name)
        {
            InitializeComponent();
            pageNumberFontName.Text = watermark_settings["font_name"];
            pageNumberFontSize.Text = watermark_settings["font_size"];
            pageNumbersPrefix.Text  = watermark_settings["text"];
            FontStyle fstyle;

            if (pageNumberFontStyle.Text == "Regular")
            {
                fstyle = FontStyle.Regular;
            }
            else if (pageNumberFontStyle.Text == "Bold")
            {
                fstyle = FontStyle.Bold;
            }
            else if (pageNumberFontStyle.Text == "Italic")
            {
                fstyle = FontStyle.Italic;
            }
            else
            {
                fstyle = FontStyle.Regular;
            }
            Font settings_font = new Font(watermark_settings["font_name"], Int32.Parse(watermark_settings["font_size"]), fstyle);
        }
コード例 #5
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            SerializableStringDictionary watermark_settings = new SerializableStringDictionary();

            watermark_settings = save_settings(watermark_settings);
            Configurator.SetConfig(this.page_location, watermark_settings);
            Configurator.SaveConfig();
            Label  label          = this.Owner.Controls.Find("label_" + page_location, true).FirstOrDefault() as Label;
            string new_label_text = "";

            if (watermark_settings["watermark_type"] == "text")
            {
                new_label_text = "Text";
            }
            else if (watermark_settings["watermark_type"] == "image")
            {
                new_label_text = "Image";
            }
            else if (watermark_settings["watermark_type"] == "page_number")
            {
                new_label_text = "Page Number";
            }
            label.Text = new_label_text;
            Button button = this.Owner.Controls.Find("edit_" + page_location, true).FirstOrDefault() as Button;

            button.Text = "Edit";

            this.Close();
        }
コード例 #6
0
 protected override SerializableStringDictionary save_settings(SerializableStringDictionary watermark_settings)
 {
     {
         watermark_settings["watermark_type"] = "image";
         watermark_settings["image_location"] = wmImage.Text;
         return(watermark_settings);
     }
 }
コード例 #7
0
 protected override SerializableStringDictionary save_settings(SerializableStringDictionary watermark_settings)
 {
     watermark_settings["watermark_type"] = "text";
     watermark_settings["font_name"]      = wmFontName.Text;
     watermark_settings["font_size"]      = wmFontSize.Text;
     watermark_settings["font_style"]     = wmFontStyle.Text;
     watermark_settings["text"]           = wmText.Text;
     watermark_settings["add_timestamp"]  = wmTimestamp.Text;
     return(watermark_settings);
 }
コード例 #8
0
 protected override SerializableStringDictionary save_settings(SerializableStringDictionary watermark_settings)
 {
     {
         watermark_settings["watermark_type"] = "page_number";
         watermark_settings["font_name"]      = pageNumberFontName.Text;
         watermark_settings["font_size"]      = pageNumberFontSize.Text;
         watermark_settings["font_style"]     = pageNumberFontStyle.Text;
         watermark_settings["text"]           = pageNumbersPrefix.Text;
         watermark_settings["show_total"]     = pageNumbersShowTotal.Text;
         return(watermark_settings);
     }
 }
コード例 #9
0
        private void clear_watermark_config(object sender, EventArgs e)
        {
            Button       s             = (Button)sender;
            string       page_location = s.Name.Split('_')[1];
            DialogResult results       = MessageBox.Show("Delete existing watermark configuration?", "Remove Watermark?", MessageBoxButtons.YesNo);

            if (results == DialogResult.Yes)
            {
                SerializableStringDictionary empty_config = new SerializableStringDictionary();
                Configurator.SetConfig(page_location, empty_config);
                Configurator.SaveConfig();
                Label label = this.Controls.Find("label_" + page_location, true).FirstOrDefault() as Label;
                label.Text = "";
                Button button = this.Controls.Find("edit_" + page_location, true).FirstOrDefault() as Button;
                button.Text = "Add";
            }
        }
コード例 #10
0
 // Reads the configuration settings and creates the appropriate Watermark objects
 public bool SetPageLocationWatermarkFromConfig(string pageLocation, SerializableStringDictionary configuration)
 {
     if (configuration != null)
     {
         if (configuration["watermark_type"] == "text")
         {
             PageLocations[pageLocation] = new TextWatermark(configuration["text"])
             {
                 FontName     = configuration["font_name"],
                 FontSize     = Int32.Parse(configuration["font_size"]),
                 FontStyle    = configuration["font_style"],
                 PageLocation = pageLocation
             };
             if (configuration["add_timestamp"] == "Yes")
             {
                 PageLocations[pageLocation].AddTimestampFlag = true;
             }
         }
         else if (configuration["watermark_type"] == "image")
         {
             PageLocations[pageLocation] = new ImageWatermark(configuration["image_location"])
             {
                 PageLocation = pageLocation
             };
         }
         else if (configuration["watermark_type"] == "page_number")
         {
             bool show_total = false;
             if (configuration["show_total"] == "Yes")
             {
                 show_total = true;
             }
             PageLocations[pageLocation] = new PageNumberer(configuration["text"], show_total)
             {
                 FontName     = configuration["font_name"],
                 FontSize     = Int32.Parse(configuration["font_size"]),
                 FontStyle    = configuration["font_style"],
                 PageLocation = pageLocation
             };
         }
     }
     return(true);
 }
コード例 #11
0
        public bool setPageLocationWatermarkFromConfig(string page_location, SerializableStringDictionary config_dict)
        {
            if (config_dict != null)
            {
                if (config_dict["watermark_type"] == "text")
                {
                    page_locations[page_location]            = new Text_Watermark(config_dict["text"]);
                    page_locations[page_location].font_name  = config_dict["font_name"];
                    page_locations[page_location].font_size  = Int32.Parse(config_dict["font_size"]);
                    page_locations[page_location].font_style = config_dict["font_style"];
                    if (config_dict["add_timestamp"] == "Yes")
                    {
                        page_locations[page_location].add_timestamp = true;
                    }
                    page_locations[page_location].page_location = page_location;
                }
                else if (config_dict["watermark_type"] == "image")
                {
                    page_locations[page_location] = new Image_Watermark(config_dict["image_location"]);
                    page_locations[page_location].page_location = page_location;
                }

                else if (config_dict["watermark_type"] == "page_number")
                {
                    bool show_total = false;
                    if (config_dict["show_total"] == "Yes")
                    {
                        show_total = true;
                    }
                    page_locations[page_location]               = new PageNumberer(config_dict["text"], show_total);
                    page_locations[page_location].font_name     = config_dict["font_name"];
                    page_locations[page_location].font_size     = Int32.Parse(config_dict["font_size"]);
                    page_locations[page_location].font_style    = config_dict["font_style"];
                    page_locations[page_location].page_location = page_location;
                }
            }
            return(true);
        }
コード例 #12
0
 public static void SetConfig(string setting, SerializableStringDictionary vals)
 {
     Properties.Settings.Default[setting] = vals;
 }
コード例 #13
0
 protected virtual SerializableStringDictionary save_settings(SerializableStringDictionary watermark_settings)
 {
     return(watermark_settings);
 }
コード例 #14
0
 public Image_Watermark(string caller_name, SerializableStringDictionary watermark_settings)
     : base(caller_name)
 {
     InitializeComponent();
     wmImage.Text = watermark_settings["image_location"];
 }