示例#1
0
        public override VMBase Clone()
        {
            DocumentVM retVal = new DocumentVM
            {
                _name   = this._name,
                _width  = this._width,
                _height = this._height,
                _margin = this._margin.Clone() as MarginVM,
                _horizontalAlignment = this._horizontalAlignment,
                _verticalAlignment   = this._verticalAlignment,
                _zIndex                  = this._zIndex,
                _padding                 = this._padding,
                _borderThickness         = this._borderThickness,
                _borderColor             = this._borderColor,
                _cornerRadius            = this._cornerRadius,
                _backgroundColor         = this._backgroundColor,
                _horizontalScrollEnabled = this._horizontalScrollEnabled,
                _verticalScrollEnabled   = this._verticalScrollEnabled,
                _contentHeight           = this._contentHeight,
                _contentWidth            = this._contentWidth,
                _orientation             = this._orientation,
                _fileName                = this._fileName,
                _resources               = this._resources
            };

            foreach (PageVM p in _children)
            {
                retVal.AddPage(p.Clone() as PageVM);
            }

            return(retVal);
        }
示例#2
0
        public static string SerializeToJsonString(DocumentVM document)
        {
            var    myBytes = SerializeToJsonBytes(document);
            string retVal  = Encoding.UTF8.GetString(myBytes, 0, myBytes.Length);

            return(retVal);
        }
示例#3
0
        private void ToolbarMenu_OnNewCommand(object sender, EventArgs e)
        {
            var myDocument = new DOM.DocumentVM();

            if (ShowNewDocumentDialog != null)
            {
                ShowNewDocumentDialog(this, myDocument);
            }
        }
示例#4
0
        public void CreateDocument(DOM.DocumentVM doc = null)
        {
            if (doc == null)
            {
                doc = new DOM.DocumentVM();
            }

            EditArea.Document = doc;
            EditArea.Document.InitFirstPage();
        }
示例#5
0
        public DocumentVM()
        {
            Name        = "NewDocument";
            Orientation = Orientation.Horizontal;
            this.SelectedChildChanged += DocumentVM_SelectedChildChanged;

            _resources = new ResourcesVM();

            Instance = this;
        }
示例#6
0
        private void _myVM_ShowNewDocumentDialog(IDEVM sender, DOM.DocumentVM document)
        {
            NewDocument newDocDialog = new NewDocument()
            {
                DataContext = document
            };

            newDocDialog.Closed += (object sender1, EventArgs e1) =>
            {
                if (newDocDialog.DialogResult.GetValueOrDefault(false))
                {
                    _myVM.CreateDocument(document);
                }
            };
            newDocDialog.Show();
        }
示例#7
0
        public static byte[] SerializeToJsonBytes(DocumentVM document)
        {
            var jsonSerializer = new JsonSerializer();

            jsonSerializer.StringEscapeHandling   = StringEscapeHandling.EscapeHtml;
            jsonSerializer.Formatting             = Formatting.Indented;
            jsonSerializer.TypeNameHandling       = TypeNameHandling.All;
            jsonSerializer.TypeNameAssemblyFormat = FormatterAssemblyStyle.Full;
            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(ms))
                {
                    var jsonWriter = new JsonTextWriter(sw);
                    jsonSerializer.Serialize(jsonWriter, document);
                    jsonWriter.Flush();
                    byte[] myBytes = ms.ToArray();
                    return(myBytes);
                }
            }
        }
示例#8
0
 public EditAreaVM()
 {
     Document = new DOM.DocumentVM();
 }