bovender framework
C# framework that implements MVVM and more
HtmlFileViewModel.cs
1 /* HtmlFileViewModel.cs
2  * part of Daniel's XL Toolbox NG
3  *
4  * Copyright 2014-2018 Daniel Kraus
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 using System;
19 using System.Collections.Generic;
20 using System.Linq;
21 using System.Text;
22 using Bovender.Mvvm;
23 using System.Windows.Resources;
24 using System.Windows;
26 using System.IO;
27 
28 namespace Bovender.HtmlFiles
29 {
34  {
35  #region Constructors
36 
43  public HtmlFileViewModel(string packUri)
44  {
45  _packUri = packUri;
46  HtmlStream = Application.GetResourceStream(new Uri(packUri)).Stream;
47  }
48 
55  public HtmlFileViewModel(string assemblyName, string filePath)
56  : this(String.Format(
57  "pack://application:,,,/{0};component/{1}",
58  assemblyName, filePath
59  ))
60  { }
61 
68  public HtmlFileViewModel(string caption, string assemblyName, string filePath)
69  : this(assemblyName, filePath)
70  {
71  Caption = caption;
72  }
73 
74  #endregion
75 
76  #region Properties
77 
78  public string Caption { get; set; }
79  public Stream HtmlStream { get; set; }
80 
81  #endregion
82 
83  #region Private fields
84 
85  readonly string _packUri;
86 
87  #endregion
88 
89  #region Implementation of ViewModelBase's abstract methods
90 
91  public override object RevealModelObject()
92  {
93  return _packUri;
94  }
95 
96  #endregion
97  }
98 }
HtmlFileViewModel(string packUri)
Constructor that loads a HTML file from a qualified pack URI.
HtmlFileViewModel(string caption, string assemblyName, string filePath)
Loads a HTML file given an assembly name and file name and sets a caption.
HtmlFileViewModel(string assemblyName, string filePath)
Constructor that loads a HTML file given an assembly name and a path to a file that has its build act...
View model for a HTML file.
override object RevealModelObject()
Returns the model object that this view model wraps or null if there is no wrapped model object...