示例#1
0
        public static void WriteFile(string i_Path)
        {
            XRWatermark xrwatermark = null;

            if (System.IO.File.Exists(i_Path))
            {
                xrwatermark = ReadFile(i_Path);
            }

            if (xrwatermark == null)
            {
                xrwatermark = new XRWatermark();
            }

            WatermarkEditorForm form = new WatermarkEditorForm();

            form.StartPosition = FormStartPosition.CenterScreen;

            form.Assign(xrwatermark);

            if (form.ShowDialog() == DialogResult.OK)
            {
                SerializableWatermark serilizeWatermark = new SerializableWatermark();

                serilizeWatermark.CopyFrom(form.Watermark);

                try
                {
                    Webb.Utilities.Serializer.Serialize(serilizeWatermark, i_Path, true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Saving Watermark error. Message:\n{0}", ex.Message));
                    Webb.Utilities.TextLog.WriteLine(string.Format("Saving Watermark error. Message:{0}", ex.Message));
                }
                finally
                {
                    serilizeWatermark.Dispose();
                }
            }

            form.Dispose();

            xrwatermark.Dispose();

            Environment.Exit(0);
        }
示例#2
0
        public static XRWatermark ReadFile(string i_Path)
        {
            if (System.IO.File.Exists(i_Path))
            {
                try
                {
                    SerializableWatermark serilizeWatermark = Webb.Utilities.Serializer.Deserialize(i_Path) as SerializableWatermark;

                    XRWatermark xrwatermark = serilizeWatermark.ConvertTo();

                    return(xrwatermark);
                }
                catch (Exception ex)
                {
                    Webb.Utilities.TextLog.WriteLine(string.Format("Read Watermark Error. Message:{0}", ex.Message));
                }
            }
            return(null);
        }