[12762] | 1 | using System;
|
---|
| 2 | using System.IO;
|
---|
| 3 | using System.Xml;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows.Forms;
|
---|
| 6 | using System.Collections.Generic;
|
---|
| 7 |
|
---|
| 8 | using SharpVectors.Xml;
|
---|
| 9 | using SharpVectors.Dom.Svg;
|
---|
| 10 | using SharpVectors.Dom.Events;
|
---|
| 11 | using SharpVectors.Dom.Stylesheets;
|
---|
| 12 |
|
---|
| 13 | namespace SharpVectors.Renderers.Forms
|
---|
| 14 | {
|
---|
| 15 | public class SvgPictureBoxWindow : SvgWindow
|
---|
| 16 | {
|
---|
| 17 | #region Private fields
|
---|
| 18 |
|
---|
| 19 | private SvgPictureBox _svgPictureBox;
|
---|
| 20 |
|
---|
| 21 | #endregion
|
---|
| 22 |
|
---|
| 23 | #region Contructors and Destructor
|
---|
| 24 |
|
---|
| 25 | public SvgPictureBoxWindow(long innerWidth, long innerHeight, ISvgRenderer renderer)
|
---|
| 26 | : base(innerWidth, innerHeight, renderer)
|
---|
| 27 | {
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public SvgPictureBoxWindow(SvgWindow parentWindow, long innerWidth, long innerHeight)
|
---|
| 31 | : base(parentWindow, innerWidth, innerHeight)
|
---|
| 32 | {
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public SvgPictureBoxWindow(SvgPictureBox control, ISvgRenderer renderer)
|
---|
| 36 | : base(control.Width, control.Height, renderer)
|
---|
| 37 | {
|
---|
| 38 | if (control == null)
|
---|
| 39 | {
|
---|
| 40 | throw new NullReferenceException("control cannot be null");
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | _svgPictureBox = control;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | #endregion
|
---|
| 47 |
|
---|
| 48 | #region ISvgWindow Members
|
---|
| 49 |
|
---|
| 50 | public override long InnerWidth
|
---|
| 51 | {
|
---|
| 52 | get
|
---|
| 53 | {
|
---|
| 54 | if (_svgPictureBox != null)
|
---|
| 55 | {
|
---|
| 56 | return _svgPictureBox.Width;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | return base.InnerWidth;
|
---|
| 60 | }
|
---|
| 61 | set
|
---|
| 62 | {
|
---|
| 63 | base.InnerWidth = value;
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | public override long InnerHeight
|
---|
| 68 | {
|
---|
| 69 | get
|
---|
| 70 | {
|
---|
| 71 | if (_svgPictureBox != null)
|
---|
| 72 | {
|
---|
| 73 | return _svgPictureBox.Height;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | return base.InnerHeight;
|
---|
| 77 | }
|
---|
| 78 | set
|
---|
| 79 | {
|
---|
| 80 | base.InnerHeight = value;
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | public override string Source
|
---|
| 85 | {
|
---|
| 86 | get
|
---|
| 87 | {
|
---|
| 88 | SvgDocument document = (SvgDocument)this.Document;
|
---|
| 89 | return (document != null) ? document.Url : String.Empty;
|
---|
| 90 | }
|
---|
| 91 | set
|
---|
| 92 | {
|
---|
| 93 | Uri uri = new Uri(new Uri(Application.ExecutablePath), value);
|
---|
| 94 |
|
---|
| 95 | SvgDocument document = new SvgDocument(this);
|
---|
| 96 | document.Load(uri.AbsoluteUri);
|
---|
| 97 |
|
---|
| 98 | this.Document = document;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | public override DirectoryInfo WorkingDir
|
---|
| 103 | {
|
---|
| 104 | get
|
---|
| 105 | {
|
---|
| 106 | return SvgApplicationContext.ExecutableDirectory;
|
---|
| 107 | }
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | public override void Alert(string message)
|
---|
| 111 | {
|
---|
| 112 | if (String.IsNullOrEmpty(message))
|
---|
| 113 | {
|
---|
| 114 | return;
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | MessageBox.Show(message);
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | public override SvgWindow CreateOwnedWindow(long innerWidth, long innerHeight)
|
---|
| 121 | {
|
---|
| 122 | return new SvgPictureBoxWindow(this, innerWidth, innerHeight);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | #endregion
|
---|
| 126 | }
|
---|
| 127 | }
|
---|