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
bce25c66
Commit
bce25c66
authored
Dec 16, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
扩展功能
parent
99bd5ece
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
2 deletions
+115
-2
VIZ.Framework.Common/Widgets/WindowHost/WindowHost.cs
+4
-2
VIZ.Framework.Core/Core/Converter/NumberAddConverter.cs
+37
-0
VIZ.Framework.Core/Core/Converter/StringNotNull2BoolConverter.cs
+41
-0
VIZ.Framework.Core/Core/WPF/WPFHelper.cs
+31
-0
VIZ.Framework.Core/VIZ.Framework.Core.csproj
+2
-0
No files found.
VIZ.Framework.Common/Widgets/WindowHost/WindowHost.cs
View file @
bce25c66
...
...
@@ -142,8 +142,10 @@ namespace VIZ.Framework.Common
if
(
this
.
PART_ContainerForm
==
null
)
return
;
int
width
=
(
int
)
sizeInfo
.
NewSize
.
Width
;
int
height
=
(
int
)
sizeInfo
.
NewSize
.
Height
;
var
dpi
=
WPFHelper
.
GetDpiByGraphics
();
int
width
=
(
int
)(
sizeInfo
.
NewSize
.
Width
*
(
dpi
.
X
/
96d
));
int
height
=
(
int
)(
sizeInfo
.
NewSize
.
Height
*
(
dpi
.
Y
/
96d
));
// 改变宿主窗口大小
if
(!
Win32Helper
.
MoveWindow
(
this
.
PART_ContainerForm
.
Handle
,
0
,
0
,
width
,
height
,
false
))
...
...
VIZ.Framework.Core/Core/Converter/NumberAddConverter.cs
0 → 100644
View file @
bce25c66
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Data
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// 数字相加转化器
/// </summary>
public
class
NumberAddConverter
:
IValueConverter
{
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
int
a
=
0
;
int
b
=
0
;
if
(
value
!=
null
)
{
int
.
TryParse
(
value
.
ToString
(),
out
a
);
}
if
(
parameter
!=
null
)
{
int
.
TryParse
(
parameter
.
ToString
(),
out
a
);
}
return
a
+
b
;
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/Core/Converter/StringNotNull2BoolConverter.cs
0 → 100644
View file @
bce25c66
using
System
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Data
;
namespace
VIZ.Framework.Core
{
/// <summary>
/// 非空字符串到Bool转化
/// </summary>
public
class
StringNotNull2BoolConverter
:
IValueConverter
{
/// <summary>
/// 为空时的返回值
/// </summary>
public
bool
NullResult
{
get
;
set
;
}
=
false
;
/// <summary>
/// 非空时的返回值
/// </summary>
public
bool
NotNullResult
{
get
;
set
;
}
=
true
;
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(!(
value
is
string
))
return
this
.
NullResult
;
string
str
=
value
as
string
;
return
string
.
IsNullOrWhiteSpace
(
str
)
?
this
.
NullResult
:
this
.
NotNullResult
;
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
}
VIZ.Framework.Core/Core/WPF/WPFHelper.cs
View file @
bce25c66
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Drawing
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Media
;
using
System.Windows.Threading
;
using
log4net
;
using
TDx.SpaceMouse.Navigation3D
;
...
...
@@ -18,6 +21,22 @@ namespace VIZ.Framework.Core
public
static
class
WPFHelper
{
/// <summary>
/// DPI值
/// </summary>
public
class
DPI
{
/// <summary>
/// X DPI值
/// </summary>
public
double
X
{
get
;
set
;
}
/// <summary>
/// Y DPI值
/// </summary>
public
double
Y
{
get
;
set
;
}
}
/// <summary>
/// 日志
/// </summary>
private
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
WPFHelper
));
...
...
@@ -33,6 +52,18 @@ namespace VIZ.Framework.Core
}
/// <summary>
/// 获取DPI
/// </summary>
/// <returns>DPI</returns>
public
static
DPI
GetDpiByGraphics
()
{
using
(
var
graphics
=
Graphics
.
FromHwnd
(
IntPtr
.
Zero
))
{
return
new
DPI
{
X
=
graphics
.
DpiX
,
Y
=
graphics
.
DpiY
};
}
}
/// <summary>
/// 绑定视图模型
/// </summary>
/// <param name="view">视图</param>
...
...
VIZ.Framework.Core/VIZ.Framework.Core.csproj
View file @
bce25c66
...
...
@@ -100,6 +100,8 @@
<Compile Include="Core\Converter\Enum2EnumDescriptionConverter.cs" />
<Compile Include="Core\Converter\String2ImageSourceConverter.cs" />
<Compile Include="Core\Converter\StringAppendConverter.cs" />
<Compile Include="Core\Converter\NumberAddConverter.cs" />
<Compile Include="Core\Converter\StringNotNull2BoolConverter.cs" />
<Compile Include="Core\Enum\EnumHelper.cs" />
<Compile Include="Core\Enum\EnumModel.cs" />
<Compile Include="Core\Helper\ByteHelper.cs" />
...
...
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