예제 #1
0
        void UpdateXaml()
        {
            var sb = new StringBuilder();

            using (var xmlWriter = XmlWriter.Create(sb)) {
                DesignSurface.SaveDesigner(xmlWriter);
                Text = XamlFormatter.Format(sb.ToString());
            }
        }
예제 #2
0
        void UpdateXaml()
        {
            var sb = new StringBuilder();

            using (var xmlWriter = new XamlXmlWriter(sb)) {
                DesignSurface.SaveDesigner(xmlWriter);
                Dictionary <XamlElementLineInfo, XamlElementLineInfo> d;
                Text = XamlFormatter.Format(sb.ToString(), out d);

                if (DesignSurface.DesignContext.Services.Selection.PrimarySelection != null)
                {
                    var item = DesignSurface.DesignContext.Services.Selection.PrimarySelection;
                    var line = ((PositionXmlElement)((XamlDesignItem)item).XamlObject.XmlElement).LineNumber;
                    var pos  = (((XamlDesignItem)item).XamlObject.PositionXmlElement).LinePosition;
                    var newP = d.FirstOrDefault(x => x.Key.LineNumber == line && x.Key.LinePosition == pos);
                    XamlElementLineInfo = newP.Value;
                }
            }
        }
		protected override void SaveInternal(OpenedFile file, System.IO.Stream stream)
		{
			if (wasChangedInDesigner && designer.DesignContext != null) {
				SD.AnalyticsMonitor.TrackFeature(typeof(WpfViewContent), "Save");
				XmlWriterSettings settings = new XmlWriterSettings();
				settings.Indent = true;
				settings.IndentChars = SD.EditorControlService.GlobalOptions.IndentationString;
				settings.NewLineOnAttributes = true;
				using (XmlWriter xmlWriter = XmlWriter.Create(stream, settings)) {
					designer.SaveDesigner(xmlWriter);
				}
			} else {
				_stream.Position = 0;
				using (var reader = new StreamReader(new UnclosableStream(_stream))) {
					using (var writer = new StreamWriter(stream)) {
						writer.Write(reader.ReadToEnd());
					}
				}
			}
		}
예제 #4
0
 protected override void SaveInternal(OpenedFile file, System.IO.Stream stream)
 {
     if (designer.DesignContext != null)
     {
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent              = true;
         settings.IndentChars         = EditorControlService.GlobalOptions.IndentationString;
         settings.NewLineOnAttributes = true;
         using (XmlWriter xmlWriter = XmlTextWriter.Create(stream, settings)) {
             designer.SaveDesigner(xmlWriter);
         }
     }
     else
     {
         if (_stream.CanRead)
         {
             _stream.Position = 0;
             using (var reader = new StreamReader(_stream))
                 using (var writer = new StreamWriter(stream)) {
                     writer.Write(reader.ReadToEnd());
                 }
         }
     }
 }