Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王永辉
VIZ.Framework
Commits
6404a122
Commit
6404a122
authored
Nov 20, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
包装资源
parent
76fb25d9
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
236 additions
and
1 deletions
+236
-1
VIZ.Framework.Core/Core/Converter/String2ImageSourceConverter.cs
+79
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+1
-0
VIZ.Framework.TVP/Themes/Generic.xaml
+2
-1
VIZ.Framework.TVP/VIZ.Framework.TVP.csproj
+7
-0
VIZ.Framework.TVP/Widgets/Resource/ITvpResource.cs
+24
-0
VIZ.Framework.TVP/Widgets/Resource/TvpResourcePicker.cs
+85
-0
VIZ.Framework.TVP/Widgets/Resource/TvpResourcePicker.xaml
+19
-0
VIZ.Framework.TVP/Widgets/Resource/TvpResourceType.cs
+19
-0
No files found.
VIZ.Framework.Core/Core/Converter/String2ImageSourceConverter.cs
0 → 100644
View file @
6404a122
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Data
;
using
System.Windows.Media.Imaging
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// 字符串转图片源转化器类型
/// </summary>
public
enum
String2ImageSourceConverterType
{
/// <summary>
/// 绝对路径
/// </summary>
Absolute
,
/// <summary>
/// 相对路径
/// </summary>
Relative
}
/// <summary>
/// 字符串转图片源转化器
/// </summary>
public
class
String2ImageSourceConverter
:
IValueConverter
{
/// <summary>
/// 日志
/// </summary>
private
readonly
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
String2ImageSourceConverter
));
/// <summary>
/// 类型
/// </summary>
public
String2ImageSourceConverterType
Type
{
get
;
set
;
}
/// <summary>
/// 工作目录,相对于.exe的路径
/// </summary>
public
string
WorkPath
{
get
;
set
;
}
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
try
{
if
(
value
==
null
)
return
null
;
string
path
=
value
.
ToString
();
if
(
this
.
Type
==
String2ImageSourceConverterType
.
Relative
)
{
path
=
System
.
IO
.
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
this
.
WorkPath
,
path
);
}
BitmapImage
bmp
=
new
BitmapImage
(
new
Uri
(
path
,
UriKind
.
Absolute
));
return
bmp
;
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
);
return
null
;
}
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
6404a122
...
@@ -95,6 +95,7 @@
...
@@ -95,6 +95,7 @@
<Compile Include="Core\Converter\Bool2SolidColorBrushConverter.cs" />
<Compile Include="Core\Converter\Bool2SolidColorBrushConverter.cs" />
<Compile Include="Core\Converter\Color2SolidColorBrushConverter.cs" />
<Compile Include="Core\Converter\Color2SolidColorBrushConverter.cs" />
<Compile Include="Core\Converter\Enum2EnumDescriptionConverter.cs" />
<Compile Include="Core\Converter\Enum2EnumDescriptionConverter.cs" />
<Compile Include="Core\Converter\String2ImageSourceConverter.cs" />
<Compile Include="Core\Converter\StringAppendConverter.cs" />
<Compile Include="Core\Converter\StringAppendConverter.cs" />
<Compile Include="Core\Enum\EnumHelper.cs" />
<Compile Include="Core\Enum\EnumHelper.cs" />
<Compile Include="Core\Enum\EnumModel.cs" />
<Compile Include="Core\Enum\EnumModel.cs" />
...
...
VIZ.Framework.TVP/Themes/Generic.xaml
View file @
6404a122
<ResourceDictionary
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VIZ.Framework.TVP">
xmlns:local="clr-namespace:VIZ.Framework.TVP">
</ResourceDictionary>
</ResourceDictionary>
VIZ.Framework.TVP/VIZ.Framework.TVP.csproj
View file @
6404a122
...
@@ -57,6 +57,10 @@
...
@@ -57,6 +57,10 @@
<Generator>MSBuild:Compile</Generator>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<SubType>Designer</SubType>
</Page>
</Page>
<Page Include="Widgets\Resource\TvpResourcePicker.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<Compile Include="Properties\AssemblyInfo.cs">
...
@@ -72,6 +76,9 @@
...
@@ -72,6 +76,9 @@
<DependentUpon>Settings.settings</DependentUpon>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</Compile>
<Compile Include="Widgets\Resource\ITvpResource.cs" />
<Compile Include="Widgets\Resource\TvpResourcePicker.cs" />
<Compile Include="Widgets\Resource\TvpResourceType.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
...
...
VIZ.Framework.TVP/Widgets/Resource/ITvpResource.cs
0 → 100644
View file @
6404a122
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.TVP
{
/// <summary>
/// 包装资源
/// </summary>
public
interface
ITvpResource
{
/// <summary>
/// 资源名称
/// </summary>
string
ResourceName
{
get
;
}
/// <summary>
/// 资源类型
/// </summary>
TvpResourceType
ResourceType
{
get
;
}
}
}
VIZ.Framework.TVP/Widgets/Resource/TvpResourcePicker.cs
0 → 100644
View file @
6404a122
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
namespace
VIZ.Framework.TVP
{
/// <summary>
/// 包装资源选择器
/// </summary>
public
class
TvpResourcePicker
:
Button
{
static
TvpResourcePicker
()
{
DefaultStyleKeyProperty
.
OverrideMetadata
(
typeof
(
TvpResourcePicker
),
new
FrameworkPropertyMetadata
(
typeof
(
TvpResourcePicker
)));
}
#
region
ResourceName
--
资源名称
/// <summary>
/// 资源名称
/// </summary>
public
string
ResourceName
{
get
{
return
(
string
)
GetValue
(
ResourceNameProperty
);
}
set
{
SetValue
(
ResourceNameProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for ResourceName. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
ResourceNameProperty
=
DependencyProperty
.
Register
(
"ResourceName"
,
typeof
(
string
),
typeof
(
TvpResourcePicker
),
new
PropertyMetadata
(
null
));
#
endregion
#
region
ResourceSource
--
资源源
/// <summary>
/// 资源源
/// </summary>
public
string
ResourceSource
{
get
{
return
(
string
)
GetValue
(
ResourceSourceProperty
);
}
set
{
SetValue
(
ResourceSourceProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for ResourceSource. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
ResourceSourceProperty
=
DependencyProperty
.
Register
(
"ResourceSource"
,
typeof
(
string
),
typeof
(
TvpResourcePicker
),
new
PropertyMetadata
(
null
));
#
endregion
#
region
ResourceType
--
资源类型
/// <summary>
/// 资源类型
/// </summary>
public
TvpResourceType
ResourceType
{
get
{
return
(
TvpResourceType
)
GetValue
(
ResourceTypeProperty
);
}
set
{
SetValue
(
ResourceTypeProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for ResourceType. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
ResourceTypeProperty
=
DependencyProperty
.
Register
(
"ResourceType"
,
typeof
(
TvpResourceType
),
typeof
(
TvpResourcePicker
),
new
PropertyMetadata
(
TvpResourceType
.
Image
));
#
endregion
}
}
VIZ.Framework.TVP/Widgets/Resource/TvpResourcePicker.xaml
0 → 100644
View file @
6404a122
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VIZ.Framework.TVP">
<Style TargetType="local:TvpResourcePicker">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:TvpResourcePicker">
<Border Background="{TemplateBinding Background}">
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"></ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
VIZ.Framework.TVP/Widgets/Resource/TvpResourceType.cs
0 → 100644
View file @
6404a122
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.TVP
{
/// <summary>
/// 包装资源类型
/// </summary>
public
enum
TvpResourceType
{
/// <summary>
/// 图片
/// </summary>
Image
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment