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
f0c36ab5
Commit
f0c36ab5
authored
Jan 02, 2019
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,修改了Range
parent
d8728c2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
58 deletions
+167
-58
Misc.csproj
Project.FLY.Misc/MISC/Misc.csproj
+23
-0
Range.cs
Project.FLY.Misc/MISC/Range.cs
+144
-58
No files found.
Project.FLY.Misc/MISC/Misc.csproj
View file @
f0c36ab5
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Project
ToolsVersion=
"4.0"
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<Import
Project=
"..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props"
Condition=
"Exists('..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props')"
/>
<PropertyGroup>
<PropertyGroup>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
...
@@ -33,6 +34,8 @@
...
@@ -33,6 +34,8 @@
<UseApplicationTrust>
false
</UseApplicationTrust>
<UseApplicationTrust>
false
</UseApplicationTrust>
<BootstrapperEnabled>
true
</BootstrapperEnabled>
<BootstrapperEnabled>
true
</BootstrapperEnabled>
<TargetFrameworkProfile
/>
<TargetFrameworkProfile
/>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugSymbols>
true
</DebugSymbols>
<DebugSymbols>
true
</DebugSymbols>
...
@@ -59,6 +62,12 @@
...
@@ -59,6 +62,12 @@
</StartupObject>
</StartupObject>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\Project.FLY.Thick.Normal\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll
</HintPath>
</Reference>
<Reference
Include=
"PropertyChanged2, Version=2.5.13.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL"
>
<HintPath>
..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.5.13\lib\net40\PropertyChanged2.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
>
<Reference
Include=
"System.Core"
>
<RequiredTargetFramework>
3.5
</RequiredTargetFramework>
<RequiredTargetFramework>
3.5
</RequiredTargetFramework>
...
@@ -110,8 +119,22 @@
...
@@ -110,8 +119,22 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<None
Include=
"..\版本说明.txt"
/>
<None
Include=
"..\版本说明.txt"
/>
<None
Include=
"packages.config"
/>
</ItemGroup>
<ItemGroup>
<Content
Include=
"FodyWeavers.xml"
>
<SubType>
Designer
</SubType>
</Content>
</ItemGroup>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.2.13\build\Fody.targets"
Condition=
"Exists('..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.2.13\build\Fody.targets')"
/>
<Target
Name=
"EnsureNuGetPackageBuildImports"
BeforeTargets=
"PrepareForBuild"
>
<PropertyGroup>
<ErrorText>
这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
</ErrorText>
</PropertyGroup>
<Error
Condition=
"!Exists('..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.2.13\build\Fody.targets')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\Fody.3.2.13\build\Fody.targets'))"
/>
<Error
Condition=
"!Exists('..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props')"
Text=
"$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props'))"
/>
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<Target Name="BeforeBuild">
...
...
Project.FLY.Misc/MISC/Range.cs
View file @
f0c36ab5
...
@@ -3,33 +3,32 @@ using System.Collections.Generic;
...
@@ -3,33 +3,32 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.ComponentModel
;
using
System.ComponentModel
;
using
Newtonsoft.Json
;
namespace
Misc
namespace
Misc
{
{
/// <summary>
/// int范围类,
/// </summary>
public
class
Range
:
INotifyPropertyChanged
,
Misc
.
ISaveToXml
public
class
Range
:
INotifyPropertyChanged
,
Misc
.
ISaveToXml
{
{
static
Range
()
#
region
property
{
/// <summary>
Misc
.
SaveToXmlHepler
.
Regist
(
typeof
(
Range
));
/// 开始
}
/// </summary>
public
Range
()
public
int
Begin
{
get
;
set
;
}
{
Reset
();
/// <summary>
}
/// 结束
public
bool
Contain
(
Range
r
)
/// </summary>
{
public
int
End
{
get
;
set
;
}
if
((
Begin
<=
r
.
Begin
)
&&
(
r
.
End
<=
End
))
#
endregion
return
true
;
else
#
region
just
get
property
return
false
;
/// <summary>
}
/// 本范围 中心位置
public
bool
Contain
(
int
p
)
/// </summary>
{
[
JsonIgnore
]
if
((
Begin
<=
p
)
&&
(
p
<=
End
))
return
true
;
else
return
false
;
}
public
int
Mid
public
int
Mid
{
{
get
get
...
@@ -40,6 +39,11 @@ namespace Misc
...
@@ -40,6 +39,11 @@ namespace Misc
return
Misc
.
MyBase
.
NULL_VALUE
;
return
Misc
.
MyBase
.
NULL_VALUE
;
}
}
}
}
/// <summary>
/// 本范围宽度
/// </summary>
[
JsonIgnore
]
public
int
Width
public
int
Width
{
{
get
get
...
@@ -50,54 +54,91 @@ namespace Misc
...
@@ -50,54 +54,91 @@ namespace Misc
return
Misc
.
MyBase
.
NULL_VALUE
;
return
Misc
.
MyBase
.
NULL_VALUE
;
}
}
}
}
public
void
Move
(
int
offset
)
{
Begin
+=
offset
;
/// <summary>
End
+=
offset
;
/// 是否有效
}
/// </summary>
public
int
Begin
[
JsonIgnore
]
public
bool
IsValid
{
{
get
get
{
{
return
begin
;
if
(
Misc
.
MyBase
.
ISVALIDATA
(
Begin
))
}
return
true
;
set
else
{
return
false
;
begin
=
value
;
if
(
this
.
PropertyChanged
!=
null
)
this
.
PropertyChanged
.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
"Begin"
));
}
}
}
}
private
int
begin
;
#
endregion
public
int
End
static
Range
()
{
{
get
Misc
.
SaveToXmlHepler
.
Regist
(
typeof
(
Range
));
{
}
return
end
;
}
set
{
/// <summary>
end
=
value
;
/// 使用无效值初始化
if
(
this
.
PropertyChanged
!=
null
)
/// </summary>
this
.
PropertyChanged
.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
"End"
));
public
Range
()
}
{
Reset
();
}
#
region
methods
/// <summary>
/// 范围 r 在 本范围内
/// </summary>
/// <param name="r"></param>
/// <returns></returns>
public
bool
Contain
(
Range
r
)
{
if
((
Begin
<=
r
.
Begin
)
&&
(
r
.
End
<=
End
))
return
true
;
else
return
false
;
}
/// <summary>
/// 点 p 在 本范围内
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public
bool
Contain
(
int
p
)
{
if
((
Begin
<=
p
)
&&
(
p
<=
End
))
return
true
;
else
return
false
;
}
/// <summary>
/// 平移
/// </summary>
/// <param name="offset"></param>
public
void
Move
(
int
offset
)
{
Begin
+=
offset
;
End
+=
offset
;
}
}
private
int
end
;
/// <summary>
/// 复位为无效
/// </summary>
public
void
Reset
()
public
void
Reset
()
{
{
Begin
=
Misc
.
MyBase
.
NULL_VALUE
;
Begin
=
Misc
.
MyBase
.
NULL_VALUE
;
End
=
Misc
.
MyBase
.
NULL_VALUE
;
End
=
Misc
.
MyBase
.
NULL_VALUE
;
}
}
public
bool
IsValid
{
get
{
if
(
Misc
.
MyBase
.
ISVALIDATA
(
Begin
))
return
true
;
else
return
false
;
}
}
/// <summary>
/// <summary>
/// 转换为8个字节
/// 转换为8个字节
/// </summary>
/// </summary>
...
@@ -125,6 +166,12 @@ namespace Misc
...
@@ -125,6 +166,12 @@ namespace Misc
return
true
;
return
true
;
}
}
/// <summary>
/// 范围并集
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
Range
operator
|(
Range
a
,
Range
b
)
public
static
Range
operator
|(
Range
a
,
Range
b
)
{
{
return
new
Range
()
return
new
Range
()
...
@@ -134,6 +181,12 @@ namespace Misc
...
@@ -134,6 +181,12 @@ namespace Misc
};
};
}
}
/// <summary>
/// 范围交集
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
Range
operator
&(
Range
a
,
Range
b
)
public
static
Range
operator
&(
Range
a
,
Range
b
)
{
{
Range
r
=
new
Range
()
Range
r
=
new
Range
()
...
@@ -150,6 +203,13 @@ namespace Misc
...
@@ -150,6 +203,13 @@ namespace Misc
return
r
;
return
r
;
}
}
}
}
/// <summary>
/// 范围 a小于b
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
bool
operator
<(
Range
a
,
Range
b
)
public
static
bool
operator
<(
Range
a
,
Range
b
)
{
{
if
(
a
.
End
<
b
.
Begin
)
//[a.b,a.e] [b.b,b.e]
if
(
a
.
End
<
b
.
Begin
)
//[a.b,a.e] [b.b,b.e]
...
@@ -161,6 +221,13 @@ namespace Misc
...
@@ -161,6 +221,13 @@ namespace Misc
return
false
;
return
false
;
}
}
}
}
/// <summary>
/// 范围 a大于b
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
bool
operator
>(
Range
a
,
Range
b
)
public
static
bool
operator
>(
Range
a
,
Range
b
)
{
{
if
(
b
.
End
<
(
a
.
Begin
))
// [b.b,b.e][a.b,a.e]
if
(
b
.
End
<
(
a
.
Begin
))
// [b.b,b.e][a.b,a.e]
...
@@ -172,6 +239,8 @@ namespace Misc
...
@@ -172,6 +239,8 @@ namespace Misc
return
false
;
return
false
;
}
}
}
}
public
static
bool
operator
<(
int
p
,
Range
r
)
public
static
bool
operator
<(
int
p
,
Range
r
)
{
{
if
(
p
<
r
.
Begin
)
if
(
p
<
r
.
Begin
)
...
@@ -216,6 +285,7 @@ namespace Misc
...
@@ -216,6 +285,7 @@ namespace Misc
return
false
;
return
false
;
}
}
}
}
/// <summary>
/// <summary>
/// 是否有交集
/// 是否有交集
/// </summary>
/// </summary>
...
@@ -253,17 +323,31 @@ namespace Misc
...
@@ -253,17 +323,31 @@ namespace Misc
return
true
;
return
true
;
return
false
;
return
false
;
}
}
/// <summary>
/// 复制 r 的值到 本范围内
/// </summary>
/// <param name="r"></param>
public
void
Copy
(
Range
r
)
public
void
Copy
(
Range
r
)
{
{
Begin
=
r
.
Begin
;
Begin
=
r
.
Begin
;
End
=
r
.
End
;
End
=
r
.
End
;
}
}
/// <summary>
/// 克隆
/// </summary>
/// <returns></returns>
public
Range
Clone
()
public
Range
Clone
()
{
{
Range
r
=
new
Range
();
Range
r
=
new
Range
();
r
.
Copy
(
this
);
r
.
Copy
(
this
);
return
r
;
return
r
;
}
}
#
endregion
/// <summary>
///
/// </summary>
/// <returns></returns>
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
"["
+
Begin
.
ToString
()
+
","
+
End
.
ToString
()
+
"]="
+
Width
.
ToString
();
return
"["
+
Begin
.
ToString
()
+
","
+
End
.
ToString
()
+
"]="
+
Width
.
ToString
();
...
@@ -332,4 +416,6 @@ namespace Misc
...
@@ -332,4 +416,6 @@ namespace Misc
}
}
}
}
}
}
}
}
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