/// <summary> /// Convert /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var str = value as string; if (string.IsNullOrWhiteSpace(str)) { return(null); } var xfSource = imageSourceConverter.ConvertFromInvariantString(str) as ImageSource; //TODO Parse width / height eg. image.svg@SVG=0x200 where 200 is width return(new SvgImageSource(xfSource, 0, 0, true)); }
/// <summary> /// class constructor /// </summary> public DocumentViewModel() { IsDirty = false; //Set the icon only for open documents (just a test) IconSource = ISC.ConvertFromInvariantString(@"pack://application:,,/Demos/Images/document.png") as ImageSource; }
public DocumentPaneViewModel(string filePath, int count) : base() { this.Title = new ReactiveProperty <string>(); var textFile = FileManager.LoadTextFile(filePath); this.FilePath = new ReactiveProperty <string>(textFile.FilePath); this.Text = new ReactiveProperty <string>(textFile.Text ?? string.Empty); this.Encoding = new ReactiveProperty <Encoding>(textFile.Encoding); this.IsModified = new ReactiveProperty <bool>(false); this.FileName = this.FilePath .Select(p => (p == null) ? this.DefaultFileName + ((count >= 0) ? " " + count : string.Empty) + ".txt" : Path.GetFileName(p)) .ToReactiveProperty(); this.Text.Pairwise() .Subscribe(x => this.IsModified.Value = true); this.IsModified.Subscribe(m => this.Title.Value = this.FileName.Value + (m ? " *" : "")); this.IconSource.Value = imageSourceConverter.ConvertFromInvariantString(documentIcon) as ImageSource; this.SaveCommand = this.IsModified.ToReactiveCommand(); this.SaveCommand.Subscribe(_ => App.MainViewModel.Save(this, false)); this.SaveAsCommand = new ReactiveCommand(); this.SaveAsCommand.Subscribe(_ => App.MainViewModel.Save(this, true)); this.CloseCommand = new ReactiveCommand(); this.CloseCommand.Subscribe(_ => App.MainViewModel.Close(this)); }
public FileViewModel(string filePath) { FilePath = filePath; Title = FileName; //Set the icon only for open documents (just a test) IconSource = ISC.ConvertFromInvariantString(@"pack://application:,,/Images/document.png") as ImageSource; }
/// <summary> /// Converts image source (string) to ImageSource class instance. /// </summary> /// <param name="source">Image path as string.</param> /// <returns>ImageSoruce class instance created from specified string.</returns> private ImageSource SourceToImageSource(string source) { return(source == null ? null : (ImageSource)_converter.ConvertFromInvariantString(source)); }
public override object ConvertFrom(object o) { return(_converter.ConvertFromInvariantString(o as string)); }
public FileViewModel(string filePath) { FilePath = filePath; Title = FileName; IconSource = ISC.ConvertFromInvariantString(@"pack://application:,,/Images/document.png") as ImageSource; }
/// <summary> /// /// </summary> public DocumentVM() { IsDirty = false; Title = FileName; Icon = ISC.ConvertFromInvariantString(@"pack://application:,,/Images/document.png") as ImageSource; }