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
d313a049
Commit
d313a049
authored
Feb 03, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导航控件更新
parent
bd1a1995
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
198 additions
and
18 deletions
+198
-18
VIZ.Framework.Common/VIZ.Framework.Common.csproj
+1
-0
VIZ.Framework.Common/Widgets/NavigationControl/NavigationConfig.cs
+5
-0
VIZ.Framework.Common/Widgets/NavigationControl/NavigationControl.cs
+65
-0
VIZ.Framework.Common/Widgets/NavigationControl/NavigationControlCreateMode.cs
+24
-0
VIZ.Framework.Common/Widgets/NavigationControl/NavigationItemControl.cs
+88
-5
VIZ.Framework.Core/Core/Delay/DelayManager.cs
+5
-3
VIZ.Framework.Core/Core/Timer/TimerManager.cs
+10
-10
No files found.
VIZ.Framework.Common/VIZ.Framework.Common.csproj
View file @
d313a049
...
...
@@ -322,6 +322,7 @@
<Compile Include="Widgets\LabelValue\LabelValue.cs" />
<Compile Include="Widgets\NavigationControl\NavigationConfig.cs" />
<Compile Include="Widgets\NavigationControl\NavigationControl.cs" />
<Compile Include="Widgets\NavigationControl\NavigationControlCreateMode.cs" />
<Compile Include="Widgets\NavigationControl\NavigationItemControl.cs" />
<Compile Include="Widgets\NoneWindow\NoneWindow.cs" />
<Compile Include="Widgets\ResizeImageControl\ResizeImageControl.cs" />
...
...
VIZ.Framework.Common/Widgets/NavigationControl/NavigationConfig.cs
View file @
d313a049
...
...
@@ -47,6 +47,11 @@ namespace VIZ.Framework.Common
public
WeakReference
<
object
>
View
{
get
;
set
;
}
/// <summary>
/// 容器
/// </summary>
public
WeakReference
<
NavigationItemControl
>
Container
{
get
;
set
;
}
/// <summary>
/// 视图创建后触发 参数: 导航配置, 视图
/// </summary>
public
Action
<
NavigationConfig
,
object
>
ViewCreated
{
get
;
set
;
}
...
...
VIZ.Framework.Common/Widgets/NavigationControl/NavigationControl.cs
View file @
d313a049
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Collections.Specialized
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -26,9 +29,29 @@ namespace VIZ.Framework.Common
DefaultStyleKeyProperty
.
OverrideMetadata
(
typeof
(
NavigationControl
),
new
FrameworkPropertyMetadata
(
typeof
(
NavigationControl
)));
}
#
region
CreateMode
--
创建模式
/// <summary>
/// 创建模式
/// </summary>
public
NavigationControlCreateMode
CreateMode
{
get
{
return
(
NavigationControlCreateMode
)
GetValue
(
CreateModeProperty
);
}
set
{
SetValue
(
CreateModeProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for CreateMode. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
CreateModeProperty
=
DependencyProperty
.
Register
(
"CreateMode"
,
typeof
(
NavigationControlCreateMode
),
typeof
(
NavigationControl
),
new
PropertyMetadata
(
NavigationControlCreateMode
.
Delay
));
#
endregion
protected
override
DependencyObject
GetContainerForItemOverride
()
{
NavigationItemControl
itemControl
=
new
NavigationItemControl
();
itemControl
.
OwnerNavigaiton
=
new
WeakReference
<
NavigationControl
>(
this
);
return
itemControl
;
}
...
...
@@ -37,5 +60,47 @@ namespace VIZ.Framework.Common
{
return
item
is
NavigationItemControl
;
}
protected
override
void
OnItemsSourceChanged
(
IEnumerable
oldValue
,
IEnumerable
newValue
)
{
base
.
OnItemsSourceChanged
(
oldValue
,
newValue
);
INotifyCollectionChanged
newCollection
=
newValue
as
INotifyCollectionChanged
;
if
(
newCollection
!=
null
)
{
newCollection
.
CollectionChanged
-=
NewCollection_CollectionChanged
;
newCollection
.
CollectionChanged
+=
NewCollection_CollectionChanged
;
}
INotifyCollectionChanged
oldCollection
=
oldValue
as
INotifyCollectionChanged
;
if
(
oldCollection
!=
null
)
{
oldCollection
.
CollectionChanged
-=
NewCollection_CollectionChanged
;
}
}
private
void
NewCollection_CollectionChanged
(
object
sender
,
NotifyCollectionChangedEventArgs
e
)
{
// 导航控件目前仅处理移除的情况
if
(
e
.
Action
!=
NotifyCollectionChangedAction
.
Remove
)
return
;
if
(
e
.
OldItems
==
null
)
return
;
foreach
(
object
item
in
e
.
OldItems
)
{
if
(!(
item
is
NavigationConfig
config
))
continue
;
if
(
config
.
Container
==
null
)
continue
;
if
(!
config
.
Container
.
TryGetTarget
(
out
NavigationItemControl
container
))
continue
;
container
.
DisposeContent
();
}
}
}
}
VIZ.Framework.Common/Widgets/NavigationControl/NavigationControlCreateMode.cs
0 → 100644
View file @
d313a049
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Framework.Common
{
/// <summary>
/// 导航控件创建模式
/// </summary>
public
enum
NavigationControlCreateMode
{
/// <summary>
/// 延时
/// </summary>
Delay
,
/// <summary>
/// 实时
/// </summary>
RealTime
}
}
VIZ.Framework.Common/Widgets/NavigationControl/NavigationItemControl.cs
View file @
d313a049
using
System
;
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -21,6 +22,11 @@ namespace VIZ.Framework.Common
/// </summary>
public
class
NavigationItemControl
:
ListBoxItem
{
/// <summary>
/// 日志
/// </summary>
private
readonly
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
NavigationItemControl
));
static
NavigationItemControl
()
{
DefaultStyleKeyProperty
.
OverrideMetadata
(
typeof
(
NavigationItemControl
),
new
FrameworkPropertyMetadata
(
typeof
(
NavigationItemControl
)));
...
...
@@ -29,6 +35,7 @@ namespace VIZ.Framework.Common
public
NavigationItemControl
()
{
this
.
IsVisibleChanged
+=
NavigationItemControl_IsVisibleChanged
;
this
.
DataContextChanged
+=
NavigationItemControl_DataContextChanged
;
}
#
region
Key
--
键
...
...
@@ -70,6 +77,36 @@ namespace VIZ.Framework.Common
#
endregion
/// <summary>
/// 所屬导航容器
/// </summary>
internal
WeakReference
<
NavigationControl
>
OwnerNavigaiton
;
/// <summary>
/// 销毁内容
/// </summary>
public
void
DisposeContent
()
{
this
.
OwnerNavigaiton
=
null
;
if
(
this
.
Content
==
null
)
return
;
IDisposable
disposable
=
this
.
Content
as
IDisposable
;
this
.
Content
=
null
;
if
(
disposable
==
null
)
return
;
try
{
disposable
.
Dispose
();
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
);
}
}
/// <summary>
/// 可见性改变时触发
/// </summary>
private
void
NavigationItemControl_IsVisibleChanged
(
object
sender
,
DependencyPropertyChangedEventArgs
e
)
...
...
@@ -77,21 +114,67 @@ namespace VIZ.Framework.Common
if
(!
this
.
IsVisible
)
return
;
if
(
this
.
Content
!=
null
&&
this
.
Content
.
GetType
()
==
this
.
ViewType
)
this
.
TryCreateContent
();
}
/// <summary>
/// 上下文改变时触发
/// </summary>
private
void
NavigationItemControl_DataContextChanged
(
object
sender
,
DependencyPropertyChangedEventArgs
e
)
{
if
(
this
.
OwnerNavigaiton
==
null
)
return
;
if
(!
this
.
OwnerNavigaiton
.
TryGetTarget
(
out
NavigationControl
navigation
))
return
;
if
(
navigation
!=
null
&&
navigation
.
CreateMode
!=
NavigationControlCreateMode
.
RealTime
)
return
;
this
.
TryCreateContent
();
}
/// <summary>
/// 尝试创建内容
/// </summary>
private
void
TryCreateContent
()
{
// 已经包含内容,则不创建
if
(
this
.
Content
!=
null
)
return
;
NavigationConfig
config
=
this
.
DataContext
as
NavigationConfig
;
if
(
config
!=
null
)
{
this
.
TryCreateContentFromConfig
(
config
);
}
else
{
this
.
TryCreateContentFromViewType
();
}
}
if
(
this
.
ViewType
!=
null
)
/// <summary>
/// 尝试从ViewType属性创建内容
/// </summary>
private
void
TryCreateContentFromViewType
()
{
if
(
this
.
ViewType
==
null
)
return
;
this
.
Content
=
this
.
ViewType
.
Assembly
.
CreateInstance
(
this
.
ViewType
.
FullName
);
}
if
(
config
!=
null
)
/// <summary>
/// 尝试从导航配置创建视图
/// </summary>
/// <param name="config">导航配置</param>
private
void
TryCreateContentFromConfig
(
NavigationConfig
config
)
{
this
.
Content
=
config
.
ViewType
.
Assembly
.
CreateInstance
(
config
.
ViewType
.
FullName
);
config
.
View
=
new
WeakReference
<
object
>(
this
.
Content
);
config
.
Container
=
new
WeakReference
<
NavigationItemControl
>(
this
);
config
.
ViewCreated
?.
Invoke
(
config
,
this
.
Content
);
}
}
}
}
VIZ.Framework.Core/Core/Delay/DelayManager.cs
View file @
d313a049
...
...
@@ -126,11 +126,11 @@ namespace VIZ.Framework.Core
{
while
(!
this
.
IsDisposabled
)
{
lock
(
this
.
Pool
)
{
List
<
DelayInfo
>
list
=
this
.
Pool
.
Values
.
ToList
();
DateTime
now
=
DateTime
.
Now
;
List
<
DelayInfo
>
removeList
=
new
List
<
DelayInfo
>();
foreach
(
DelayInfo
info
in
this
.
Pool
.
Values
)
foreach
(
DelayInfo
info
in
list
)
{
if
(
this
.
IsDisposabled
)
break
;
...
...
@@ -150,6 +150,8 @@ namespace VIZ.Framework.Core
}
}
lock
(
this
.
Pool
)
{
foreach
(
DelayInfo
info
in
removeList
)
{
this
.
Pool
.
Remove
(
info
.
Key
);
...
...
VIZ.Framework.Core/Core/Timer/TimerManager.cs
View file @
d313a049
...
...
@@ -132,11 +132,15 @@ namespace VIZ.Framework.Core
{
while
(!
this
.
IsDisposabled
)
{
List
<
TimerInfo
>
list
=
null
;
lock
(
this
.
Pool
)
{
list
=
this
.
Pool
.
Values
.
ToList
();
}
DateTime
now
=
DateTime
.
Now
;
List
<
TimerInfo
>
removeList
=
new
List
<
TimerInfo
>();
foreach
(
TimerInfo
info
in
this
.
Pool
.
Values
)
foreach
(
TimerInfo
info
in
list
)
{
if
(
this
.
IsDisposabled
)
break
;
...
...
@@ -144,26 +148,22 @@ namespace VIZ.Framework.Core
if
(
info
.
ExecuteTime
+
info
.
Interval
>
now
)
continue
;
try
{
if
(
info
.
IsDisposed
)
{
removeList
.
Add
(
info
);
}
info
.
Action
?.
Invoke
();
}
catch
(
Exception
ex
)
if
(
info
.
Action
!=
null
)
{
log
.
Error
(
ex
);
ThreadHelper
.
SafeRun
(
info
.
Action
);
}
finally
{
info
.
ExecuteCount
++;
info
.
ExecuteTime
=
now
;
}
}
lock
(
this
.
Pool
)
{
foreach
(
var
item
in
removeList
)
{
this
.
Pool
.
Remove
(
item
.
Key
);
...
...
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