Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
3cb9fe98
Commit
3cb9fe98
authored
Apr 11, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev6.0' of
http://private.flyautomation.net:82/panruising/thick_public
into dev6.0
parents
76e9a208
ad6ef49b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
789 additions
and
24 deletions
+789
-24
FLY.ControlLibrary.csproj
...ntrolLibrary/FLY.ControlLibrary/FLY.ControlLibrary.csproj
+21
-0
PercentRing.xaml
...ct.FLY.ControlLibrary/FLY.ControlLibrary/PercentRing.xaml
+52
-0
PercentRing.xaml.cs
...FLY.ControlLibrary/FLY.ControlLibrary/PercentRing.xaml.cs
+226
-0
PercentRing2.xaml
...t.FLY.ControlLibrary/FLY.ControlLibrary/PercentRing2.xaml
+34
-0
PercentRing2.xaml.cs
...LY.ControlLibrary/FLY.ControlLibrary/PercentRing2.xaml.cs
+146
-0
PieChart.xaml
Project.FLY.ControlLibrary/FLY.ControlLibrary/PieChart.xaml
+30
-0
PieChart.xaml.cs
...ct.FLY.ControlLibrary/FLY.ControlLibrary/PieChart.xaml.cs
+239
-0
KeyboardBehavior.cs
...trolLibrary/FLY.ControlLibrary/UI.OSK/KeyboardBehavior.cs
+11
-1
RatioConverter.cs
....Thick.Base/FLY.Thick.Base.UI/Converter/RatioConverter.cs
+30
-23
No files found.
Project.FLY.ControlLibrary/FLY.ControlLibrary/FLY.ControlLibrary.csproj
View file @
3cb9fe98
...
...
@@ -77,6 +77,15 @@
<Compile
Include=
"GraphScanCircular.xaml.cs"
>
<DependentUpon>
GraphScanCircular.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"PercentRing.xaml.cs"
>
<DependentUpon>
PercentRing.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"PercentRing2.xaml.cs"
>
<DependentUpon>
PercentRing2.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"PieChart.xaml.cs"
>
<DependentUpon>
PieChart.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"ResetAction.cs"
/>
<Compile
Include=
"UI.OSK\IVirtualKeyboard.cs"
/>
<Compile
Include=
"UI.OSK\KeyboardBehavior.cs"
/>
...
...
@@ -153,6 +162,18 @@
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"PercentRing.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"PercentRing2.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"PieChart.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
<Page
Include=
"Rules\Dictionary_MyRule.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
...
...
Project.FLY.ControlLibrary/FLY.ControlLibrary/PercentRing.xaml
0 → 100644
View file @
3cb9fe98
<UserControl x:Class="FLY.ControlLibrary.PercentRing"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
xmlns:local="clr-namespace:FLY.ControlLibrary"
mc:Ignorable="d" >
<UserControl.Resources >
<local:Percent2AngleMultiConverter x:Key="p2aconv"/>
<local:PercentMultiConverter x:Key="pconv"/>
<local:TestUnit_PercentRing x:Key="testunit" Ratio="0.5" Total="1" ColorText="#FF008BE5" ColorUnit="#FF464646"/>
</UserControl.Resources>
<Grid>
<ed:Arc Width="114" Height="114"
ArcThickness="5"
ArcThicknessUnit="Pixel"
StartAngle="0" EndAngle="360"
Fill="#FFF1F1F1" Stretch="None" Stroke="#FF988585" />
<ed:Arc x:Name="arc_value" Width="114" Height="114"
ArcThickness="5"
ArcThicknessUnit="Pixel"
StartAngle="0"
Fill="#FF008BE5" Stretch="None" Stroke="#FF988585" >
<ed:Arc.EndAngle>
<MultiBinding Converter="{StaticResource p2aconv}">
<Binding Path="Ratio"/>
<Binding Path="Total"/>
</MultiBinding>
</ed:Arc.EndAngle>
</ed:Arc>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">
<Run x:Name="run_value" FontSize="30" FontFamily="Arial" >
<Run.Text>
<MultiBinding Converter="{StaticResource pconv}" StringFormat="{}{0:F1}">
<Binding Path="Ratio"/>
<Binding Path="Total"/>
</MultiBinding>
</Run.Text>
<Run.Foreground>
<Binding Path="ColorText"/>
</Run.Foreground>
</Run>
<Run x:Name="run_unit" Text="%" FontSize="18">
<Run.Foreground>
<Binding Path="ColorUnit"/>
</Run.Foreground>
</Run>
</TextBlock>
</Grid>
</UserControl>
Project.FLY.ControlLibrary/FLY.ControlLibrary/PercentRing.xaml.cs
0 → 100644
View file @
3cb9fe98
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Globalization
;
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
FLY.ControlLibrary
{
/// <summary>
/// PercentRing.xaml 的交互逻辑
/// </summary>
public
partial
class
PercentRing
:
UserControl
,
INotifyPropertyChanged
{
#
region
附加属性
/// <summary>
/// 比例
/// </summary>
public
static
readonly
DependencyProperty
RatioProperty
=
DependencyProperty
.
Register
(
"Ratio"
,
typeof
(
double
),
typeof
(
PercentRing
),
new
PropertyMetadata
(
0.3
,
new
PropertyChangedCallback
(
delegate
(
DependencyObject
d
,
DependencyPropertyChangedEventArgs
e
)
{
})));
/// <summary>
/// 比例
/// </summary>
public
double
Ratio
{
get
{
return
(
double
)
GetValue
(
RatioProperty
);
}
set
{
SetValue
(
RatioProperty
,
value
);
NotifyPropertyChanged
(
"Ratio"
);
}
}
/// <summary>
/// 总量
/// </summary>
public
static
readonly
DependencyProperty
TotalProperty
=
DependencyProperty
.
Register
(
"Total"
,
typeof
(
double
),
typeof
(
PercentRing
),
new
PropertyMetadata
(
1.0
));
/// <summary>
/// 总量
/// </summary>
public
double
Total
{
get
{
return
(
double
)
GetValue
(
RatioProperty
);
}
set
{
if
(
value
!=
Total
)
{
SetValue
(
RatioProperty
,
value
);
NotifyPropertyChanged
(
"Total"
);
}
}
}
/// <summary>
/// 字的颜色
/// </summary>
public
static
readonly
DependencyProperty
ColorTextProperty
=
DependencyProperty
.
Register
(
"ColorText"
,
typeof
(
Brush
),
typeof
(
PercentRing
),
new
PropertyMetadata
(
new
SolidColorBrush
(
Color
.
FromRgb
(
0x46
,
0x46
,
0x46
))));
/// <summary>
/// 字的颜色
/// </summary>
public
Brush
ColorText
{
get
{
return
(
Brush
)
GetValue
(
ColorTextProperty
);
}
set
{
if
(
value
!=
ColorText
)
{
SetValue
(
ColorTextProperty
,
value
);
NotifyPropertyChanged
(
"ColorText"
);
}
}
}
/// <summary>
/// 单位的颜色
/// </summary>
public
static
readonly
DependencyProperty
ColorUnitProperty
=
DependencyProperty
.
Register
(
"ColorUnit"
,
typeof
(
Brush
),
typeof
(
PercentRing
),
new
PropertyMetadata
(
new
SolidColorBrush
(
Color
.
FromRgb
(
0x46
,
0x46
,
0x46
))));
/// <summary>
/// 单位的颜色
/// </summary>
public
Brush
ColorUnit
{
get
{
return
(
Brush
)
GetValue
(
ColorUnitProperty
);
}
set
{
if
(
value
!=
ColorUnit
)
{
SetValue
(
ColorUnitProperty
,
value
);
NotifyPropertyChanged
(
"ColorUnit"
);
}
}
}
#
endregion
/// <summary>
///
/// </summary>
public
PercentRing
()
{
InitializeComponent
();
//this.DataContext = this;
Draw
();
}
void
Draw
()
{
arc_value
.
DataContext
=
this
;
run_value
.
DataContext
=
this
;
run_unit
.
DataContext
=
this
;
}
#
region
INotifyPropertyChanged
成员
public
void
NotifyPropertyChanged
(
string
propertyName
)
{
if
(
PropertyChanged
!=
null
)
PropertyChanged
.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
propertyName
));
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
#
endregion
}
public
class
Percent2AngleConverter
:
IValueConverter
{
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(!(
value
is
double
))
return
0
;
double
d
=
(
double
)
value
;
return
d
*
360
;
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
public
class
Percent2AngleMultiConverter
:
IMultiValueConverter
{
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(
values
.
Length
!=
2
)
return
0
;
if
(!(
values
[
0
]
is
double
))
return
0
;
if
(!(
values
[
1
]
is
double
))
return
0
;
double
d
=
(
double
)
values
[
0
]
/
((
double
)
values
[
1
]);
return
d
*
360
;
}
public
object
[]
ConvertBack
(
object
value
,
Type
[]
targetTypes
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
public
class
PercentConverter
:
IValueConverter
{
public
object
Convert
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(!(
value
is
double
))
return
0
;
double
d
=
(
double
)
value
;
return
d
*
100
;
}
public
object
ConvertBack
(
object
value
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
public
class
PercentMultiConverter
:
IMultiValueConverter
{
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
CultureInfo
culture
)
{
if
(
values
.
Length
!=
2
)
return
0
;
if
(!(
values
[
0
]
is
double
))
return
0
;
if
(!(
values
[
1
]
is
double
))
return
0
;
double
d
=
(
double
)
values
[
0
]
/
((
double
)
values
[
1
]);
return
d
*
100
;
}
public
object
[]
ConvertBack
(
object
value
,
Type
[]
targetTypes
,
object
parameter
,
CultureInfo
culture
)
{
throw
new
NotImplementedException
();
}
}
public
class
TestUnit_PercentRing
{
public
double
Ratio
{
get
;
set
;
}
public
double
Total
{
get
;
set
;
}
public
Brush
ColorText
{
get
;
set
;
}
public
Brush
ColorUnit
{
get
;
set
;
}
}
}
Project.FLY.ControlLibrary/FLY.ControlLibrary/PercentRing2.xaml
0 → 100644
View file @
3cb9fe98
<UserControl x:Class="FLY.ControlLibrary.PercentRing2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
xmlns:local="clr-namespace:FLY.ControlLibrary"
mc:Ignorable="d" >
<UserControl.Resources >
<local:Percent2AngleMultiConverter x:Key="p2aconv"/>
<local:PercentMultiConverter x:Key="pconv"/>
<local:TestUnit_PercentRing x:Key="testunit" Ratio="0.5" Total="1" ColorText="#FF008BE5" ColorUnit="#FF464646"/>
</UserControl.Resources>
<Grid>
<ed:Arc Width="114" Height="114"
ArcThickness="5"
ArcThicknessUnit="Pixel"
StartAngle="0" EndAngle="360"
Fill="#FFF1F1F1" Stretch="None" Stroke="#FF988585" />
<ed:Arc x:Name="arc_value" Width="114" Height="114"
ArcThickness="5"
ArcThicknessUnit="Pixel"
StartAngle="0"
Fill="#FF008BE5" Stretch="None" Stroke="#FF988585" >
<ed:Arc.EndAngle>
<MultiBinding Converter="{StaticResource p2aconv}">
<Binding Path="Ratio"/>
<Binding Path="Total"/>
</MultiBinding>
</ed:Arc.EndAngle>
</ed:Arc>
</Grid>
</UserControl>
Project.FLY.ControlLibrary/FLY.ControlLibrary/PercentRing2.xaml.cs
0 → 100644
View file @
3cb9fe98
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Globalization
;
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
FLY.ControlLibrary
{
/// <summary>
/// PercentRing.xaml 的交互逻辑
/// </summary>
public
partial
class
PercentRing2
:
UserControl
,
INotifyPropertyChanged
{
#
region
附加属性
/// <summary>
/// 比例
/// </summary>
public
static
readonly
DependencyProperty
RatioProperty
=
DependencyProperty
.
Register
(
"Ratio"
,
typeof
(
double
),
typeof
(
PercentRing2
),
new
PropertyMetadata
(
0.3
,
new
PropertyChangedCallback
(
delegate
(
DependencyObject
d
,
DependencyPropertyChangedEventArgs
e
)
{
})));
/// <summary>
/// 比例
/// </summary>
public
double
Ratio
{
get
{
return
(
double
)
GetValue
(
RatioProperty
);
}
set
{
SetValue
(
RatioProperty
,
value
);
NotifyPropertyChanged
(
"Ratio"
);
}
}
/// <summary>
/// 总量
/// </summary>
public
static
readonly
DependencyProperty
TotalProperty
=
DependencyProperty
.
Register
(
"Total"
,
typeof
(
double
),
typeof
(
PercentRing2
),
new
PropertyMetadata
(
1.0
));
/// <summary>
/// 总量
/// </summary>
public
double
Total
{
get
{
return
(
double
)
GetValue
(
RatioProperty
);
}
set
{
if
(
value
!=
Total
)
{
SetValue
(
RatioProperty
,
value
);
NotifyPropertyChanged
(
"Total"
);
}
}
}
/// <summary>
/// 颜色
/// </summary>
public
static
readonly
DependencyProperty
ColorTextProperty
=
DependencyProperty
.
Register
(
"ColorText"
,
typeof
(
Brush
),
typeof
(
PercentRing2
),
new
PropertyMetadata
(
new
SolidColorBrush
(
Color
.
FromRgb
(
0x46
,
0x46
,
0x46
))));
/// <summary>
/// 颜色
/// </summary>
public
Brush
ColorText
{
get
{
return
(
Brush
)
GetValue
(
ColorTextProperty
);
}
set
{
if
(
value
!=
ColorText
)
{
SetValue
(
ColorTextProperty
,
value
);
NotifyPropertyChanged
(
"ColorText"
);
}
}
}
/// <summary>
///
/// </summary>
public
static
readonly
DependencyProperty
ColorUnitProperty
=
DependencyProperty
.
Register
(
"ColorUnit"
,
typeof
(
Brush
),
typeof
(
PercentRing2
),
new
PropertyMetadata
(
new
SolidColorBrush
(
Color
.
FromRgb
(
0x46
,
0x46
,
0x46
))));
/// <summary>
///
/// </summary>
public
Brush
ColorUnit
{
get
{
return
(
Brush
)
GetValue
(
ColorUnitProperty
);
}
set
{
if
(
value
!=
ColorUnit
)
{
SetValue
(
ColorUnitProperty
,
value
);
NotifyPropertyChanged
(
"ColorUnit"
);
}
}
}
#
endregion
public
PercentRing2
()
{
InitializeComponent
();
//this.DataContext = this;
Draw
();
}
void
Draw
()
{
arc_value
.
DataContext
=
this
;
}
#
region
INotifyPropertyChanged
成员
public
void
NotifyPropertyChanged
(
string
propertyName
)
{
if
(
PropertyChanged
!=
null
)
PropertyChanged
.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
propertyName
));
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
#
endregion
}
}
Project.FLY.ControlLibrary/FLY.ControlLibrary/PieChart.xaml
0 → 100644
View file @
3cb9fe98
<UserControl x:Class="FLY.ControlLibrary.PieChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
mc:Ignorable="d"
Loaded="UserControl_Loaded"
d:DesignHeight="300" d:DesignWidth="300" >
<Grid x:Name="RootGrid">
<ed:Arc
ArcThickness="200"
StartAngle="0" EndAngle="120"
Fill="#FFFFC0C0" Stretch="None" />
<ed:Arc
ArcThickness="200"
StartAngle="120" EndAngle="240"
Fill="#FF008BE5" Stretch="None" />
<ed:Arc
ArcThickness="200"
StartAngle="240" EndAngle="360"
Fill="#FFBCD676" Stretch="None" />
</Grid>
</UserControl>
Project.FLY.ControlLibrary/FLY.ControlLibrary/PieChart.xaml.cs
0 → 100644
View file @
3cb9fe98
using
Microsoft.Expression.Shapes
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Security.Policy
;
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
FLY.ControlLibrary
{
/// <summary>
/// PieChart.xaml 的交互逻辑
/// </summary>
public
partial
class
PieChart
:
UserControl
{
static
SolidColorBrush
[]
defaultColor
;
static
int
defaultcolor_idx
=
0
;
static
PieChart
()
{
defaultColor
=
new
SolidColorBrush
[]
{
new
SolidColorBrush
(
System
.
Windows
.
Media
.
Colors
.
Red
),
new
SolidColorBrush
(
System
.
Windows
.
Media
.
Colors
.
Green
),
new
SolidColorBrush
(
System
.
Windows
.
Media
.
Colors
.
Blue
),
new
SolidColorBrush
(
System
.
Windows
.
Media
.
Colors
.
LightPink
),
new
SolidColorBrush
(
System
.
Windows
.
Media
.
Colors
.
LightGreen
),
new
SolidColorBrush
(
System
.
Windows
.
Media
.
Colors
.
LightBlue
)
};
}
public
static
Brush
GetColor
()
{
Brush
b
=
defaultColor
[
defaultcolor_idx
];
defaultcolor_idx
++;
if
(
defaultcolor_idx
>=
defaultColor
.
Count
())
defaultcolor_idx
=
0
;
return
b
;
}
List
<
PicChartItem
>
items
=
new
List
<
PicChartItem
>();
public
static
readonly
DependencyProperty
ItemsSourceProperty
=
DependencyProperty
.
Register
(
"ItemsSource"
,
typeof
(
IEnumerable
),
typeof
(
PieChart
),
new
PropertyMetadata
((
d
,
e
)
=>
{
PieChart
pc
=
d
as
PieChart
;
pc
.
ItemsBinding
();
}));
public
IEnumerable
ItemsSource
{
get
{
return
(
IEnumerable
)
GetValue
(
ItemsSourceProperty
);
}
set
{
SetValue
(
ItemsSourceProperty
,
value
);
ItemsBinding
();
}
}
public
static
readonly
DependencyProperty
ItemValueBindingProperty
=
DependencyProperty
.
Register
(
"ItemValueBinding"
,
typeof
(
string
),
typeof
(
PieChart
));
/// <summary>
/// 值
/// </summary>
public
string
ItemValueBinding
{
get
{
return
(
string
)
GetValue
(
ItemValueBindingProperty
);
}
set
{
SetValue
(
ItemValueBindingProperty
,
value
);
}
}
public
static
readonly
DependencyProperty
ItemColorBindingProperty
=
DependencyProperty
.
Register
(
"ItemColorBinding"
,
typeof
(
string
),
typeof
(
PieChart
));
/// <summary>
/// 值
/// </summary>
public
string
ItemColorBinding
{
get
{
return
(
string
)
GetValue
(
ItemColorBindingProperty
);
}
set
{
SetValue
(
ItemColorBindingProperty
,
value
);
}
}
private
void
ItemsBinding
()
{
if
(
ItemsSource
==
null
)
return
;
IEnumerator
iterator
=
ItemsSource
.
GetEnumerator
();
while
(
iterator
.
MoveNext
())
{
object
obj
=
iterator
.
Current
;
if
(
obj
is
INotifyPropertyChanged
)
{
((
INotifyPropertyChanged
)
obj
).
PropertyChanged
+=
PieChart_PropertyChanged
;
}
}
Draw
();
}
private
void
PieChart_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
((
e
.
PropertyName
==
ItemValueBinding
)
||
(
e
.
PropertyName
==
ItemColorBinding
))
{
Draw
();
}
}
public
PieChart
()
{
InitializeComponent
();
}
void
Draw
()
{
if
(
ItemsSource
==
null
)
return
;
int
idx
=
0
;
IEnumerator
iterator
=
ItemsSource
.
GetEnumerator
();
while
(
iterator
.
MoveNext
())
{
object
obj
=
iterator
.
Current
;
Type
t
=
obj
.
GetType
();
System
.
Reflection
.
PropertyInfo
pi_value
=
t
.
GetProperty
(
ItemValueBinding
);
System
.
Reflection
.
PropertyInfo
pi_color
=
t
.
GetProperty
(
ItemColorBinding
);
if
(
pi_value
==
null
)
return
;
//if (!(pi_value.PropertyType is System.IConvertible))
// return;
double
v
=
Convert
.
ToDouble
(
pi_value
.
GetValue
(
obj
,
null
));
Brush
c
=
null
;
if
(
pi_color
!=
null
)
c
=
(
Brush
)
pi_color
.
GetValue
(
obj
,
null
);
PicChartItem
item
;
if
(
idx
<
items
.
Count
)
{
item
=
items
[
idx
];
}
else
{
item
=
new
PicChartItem
();
items
.
Add
(
item
);
}
item
.
Value
=
v
;
if
(
c
!=
null
)
item
.
Color
=
c
;
else
item
.
Color
=
GetColor
();
idx
++;
}
//把多余的删除
if
(
items
.
Count
!=
idx
)
items
.
RemoveRange
(
idx
,
items
.
Count
-
idx
);
if
(
items
.
Count
()
==
0
)
return
;
RootGrid
.
Children
.
Clear
();
double
total
=
items
.
Sum
((
item
)
=>
{
return
item
.
Value
;
});
double
startangle
=
0
;
foreach
(
PicChartItem
item
in
items
)
{
double
angle
;
if
(
total
>
0
)
angle
=
item
.
Value
/
total
*
360
;
else
angle
=
360
/
items
.
Count
;
Arc
a
=
new
Arc
()
{
ArcThickness
=
200
,
Stretch
=
Stretch
.
None
,
StartAngle
=
startangle
,
EndAngle
=
startangle
+
angle
,
Fill
=
item
.
Color
};
startangle
+=
angle
;
RootGrid
.
Children
.
Add
(
a
);
}
}
private
void
UserControl_Loaded
(
object
sender
,
RoutedEventArgs
e
)
{
Draw
();
}
class
PicChartItem
:
INotifyPropertyChanged
{
/// <summary>
/// 值
/// </summary>
public
double
Value
{
get
;
set
;
}
/// <summary>
/// 颜色
/// </summary>
public
Brush
Color
{
get
;
set
;
}
#
region
INotifyPropertyChanged
成员
public
event
PropertyChangedEventHandler
PropertyChanged
;
#
endregion
}
}
}
Project.FLY.ControlLibrary/FLY.ControlLibrary/UI.OSK/KeyboardBehavior.cs
View file @
3cb9fe98
...
...
@@ -178,7 +178,17 @@ namespace FLY.ControlLibrary.UI.OSK
Window
window
=
COMMON
.
GetWindow
(
tb
);
w
.
Owner
=
window
;
IsKeyboardOnShow
=
true
;
w
.
Closed
+=
(
s
,
e
)
=>
{
IsKeyboardOnShow
=
false
;
};
w
.
Closed
+=
(
s
,
e
)
=>
{
IsKeyboardOnShow
=
false
;
if
(
window
.
WindowState
==
WindowState
.
Normal
)
{
//当window 为2级时, 关闭虚拟键盘,window有概率不刷新
//移动一下界面。 强制令它刷新
//window.UpdateLayout() 无效
window
.
Left
+=
1
;
}
};
kb
.
Open
(
tb
);
}
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/Converter/RatioConverter.cs
View file @
3cb9fe98
...
...
@@ -9,35 +9,42 @@ namespace FLY.Thick.Base.UI.Converter
public
class
RatioConverter
:
IMultiValueConverter
{
#
region
IMultiValueConverter
成员
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
double
getValue
(
object
value
)
{
if
(
values
.
Length
==
3
&&
(
values
[
0
]
is
int
)
&&
(
values
[
1
]
is
int
)
&&
(
values
[
2
]
is
double
))
//必须要检查,不然 界面生成器 会错误,提示转换异常
if
((
value
is
int
)
&&
(!
Misc
.
MyBase
.
ISVALIDATA
((
int
)
value
)))
return
0
;
try
{
double
ratio
;
int
value
=
(
int
)
values
[
0
];
if
(
value
==
99999998
)
value
=
0
;
int
max
=
(
int
)
values
[
1
];
double
ActualWidth
=
(
double
)
values
[
2
];
if
(
max
<=
0
)
ratio
=
0
;
else
ratio
=
(
double
)
value
/
max
;
if
(
ratio
<
0
)
ratio
=
0
;
else
if
(
ratio
>
1
)
ratio
=
1
;
return
ActualWidth
*
ratio
;
return
System
.
Convert
.
ToDouble
(
value
);
}
else
catch
{
return
0
;
}
}
public
object
Convert
(
object
[]
values
,
Type
targetType
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
{
if
(
values
.
Length
!=
3
)
//必须要检查,不然 界面生成器 会错误,提示转换异常
{
return
100
;
}
double
ratio
;
double
value
=
getValue
(
values
[
0
]);
double
max
=
getValue
(
values
[
1
]);
double
ActualWidth
=
getValue
(
values
[
2
]);
if
(
max
<=
0
)
ratio
=
0
;
else
ratio
=
(
double
)
value
/
max
;
if
(
ratio
<
0
)
ratio
=
0
;
else
if
(
ratio
>
1
)
ratio
=
1
;
return
ActualWidth
*
ratio
;
}
public
object
[]
ConvertBack
(
object
value
,
Type
[]
targetTypes
,
object
parameter
,
System
.
Globalization
.
CultureInfo
culture
)
...
...
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