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
eeacc9b8
Commit
eeacc9b8
authored
Mar 30, 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
9eb6d6b4
cba15236
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
156 additions
and
5 deletions
+156
-5
MyMath.cs
Project.FLY.Misc/MISC/MyMath.cs
+104
-0
MainWindow.xaml.cs
读取xmind/WpfApp1/WpfApp1/MainWindow.xaml.cs
+1
-1
Xmind2UnityConfigUI.csproj
读取xmind/WpfApp1/WpfApp1/Xmind2UnityConfigUI.csproj
+1
-1
Program.cs
读取xmind/WpfApp1/Xmind2UnityConfig/Program.cs
+7
-3
TopicExt.cs
读取xmind/WpfApp1/Xmind2UnityConfigCore/TopicExt.cs
+11
-0
XMindType.cs
读取xmind/WpfApp1/Xmind2UnityConfigCore/XMindType.cs
+30
-0
XMindTypeExt.cs
读取xmind/WpfApp1/Xmind2UnityConfigCore/XMindTypeExt.cs
+0
-0
Xmind2UnityConfigCore.csproj
...pfApp1/Xmind2UnityConfigCore/Xmind2UnityConfigCore.csproj
+2
-0
No files found.
Project.FLY.Misc/MISC/MyMath.cs
View file @
eeacc9b8
...
@@ -500,5 +500,109 @@ namespace Misc
...
@@ -500,5 +500,109 @@ namespace Misc
}
}
return
data_new
;
return
data_new
;
}
}
/// <summary>
/// 对环形数据 分区移位
/// </summary>
/// <param name="data">原始数据</param>
/// <param name="map">key=old_idx, value=new_idx</param>
/// <returns></returns>
public
static
double
[]
Map
(
IEnumerable
<
double
>
data
,
Dictionary
<
int
,
int
>
map
)
{
if
(
map
==
null
||
map
.
Count
()
==
0
)
return
data
.
ToArray
();
double
[]
data_new
=
new
double
[
data
.
Count
()];
if
(
map
.
Count
()
==
1
)
{
//只是平移而已
int
old_idx0
=
map
.
Keys
.
ElementAt
(
0
);
int
new_idx0
=
map
[
old_idx0
];
for
(
int
i
=
0
;
i
<
data
.
Count
();
i
++)
{
int
new_idx
=
i
;
int
old_idx
=
(
old_idx0
-
new_idx0
)
+
new_idx
;
if
(
old_idx
>=
data
.
Count
())
old_idx
-=
data
.
Count
();
else
if
(
old_idx
<
0
)
old_idx
+=
data
.
Count
();
data_new
[
new_idx
]
=
data
.
ElementAt
(
old_idx
);
}
return
data_new
;
}
for
(
int
i
=
0
;
i
<
map
.
Count
();
i
++)
{
int
old_idx0
=
map
.
Keys
.
ElementAt
(
i
);
int
new_idx0
=
map
[
old_idx0
];
int
i_next
=
i
+
1
;
if
(
i_next
>=
map
.
Count
())
i_next
=
0
;
int
old_idx1
=
map
.
Keys
.
ElementAt
(
i_next
);
int
new_idx1
=
map
[
old_idx1
];
int
cnt
=
new_idx1
-
new_idx0
;
if
(
cnt
<
0
)
cnt
+=
data
.
Count
();
int
cnt_old
=
old_idx1
-
old_idx0
;
if
(
cnt_old
<
0
)
cnt_old
+=
data
.
Count
();
double
w
=
1.0
*
cnt_old
/
cnt
;
for
(
int
j
=
0
;
j
<
cnt
;
j
++)
{
int
new_idx
=
j
+
new_idx0
;
if
(
new_idx
>=
data
.
Count
())
new_idx
-=
data
.
Count
();
double
old_idx
=
j
*
w
+
old_idx0
;
int
o1
=
(
int
)
Math
.
Ceiling
(
old_idx
);
int
o0
=
(
int
)
old_idx
;
if
(
o0
==
o1
)
{
int
old_idx_0
=
o0
;
if
(
old_idx_0
>=
data
.
Count
())
old_idx_0
-=
data
.
Count
();
data_new
[
new_idx
]
=
data
.
ElementAt
(
old_idx_0
);
}
else
{
int
old_idx_0
=
o0
;
if
(
old_idx_0
>=
data
.
Count
())
old_idx_0
-=
data
.
Count
();
int
old_idx_1
=
o1
;
if
(
old_idx_1
>=
data
.
Count
())
old_idx_1
-=
data
.
Count
();
if
(
double
.
IsNaN
(
data
.
ElementAt
(
old_idx_1
))
&&
double
.
IsNaN
(
data
.
ElementAt
(
old_idx_0
)))
{
data_new
[
new_idx
]
=
(
data
.
ElementAt
(
old_idx_1
)
*
(
old_idx
-
o0
)
+
data
.
ElementAt
(
old_idx_0
)
*
(
o1
-
old_idx
));
}
else
if
(
double
.
IsNaN
(
data
.
ElementAt
(
old_idx_0
)))
{
data_new
[
new_idx
]
=
data
.
ElementAt
(
old_idx_0
);
}
else
if
(
double
.
IsNaN
(
data
.
ElementAt
(
old_idx_1
)))
{
data_new
[
new_idx
]
=
data
.
ElementAt
(
old_idx_1
);
}
else
{
data_new
[
new_idx
]
=
double
.
NaN
;
}
}
}
}
return
data_new
;
}
}
}
}
}
读取xmind/WpfApp1/WpfApp1/MainWindow.xaml.cs
View file @
eeacc9b8
...
@@ -43,7 +43,7 @@ namespace WpfApp1
...
@@ -43,7 +43,7 @@ namespace WpfApp1
{
{
string
xmindPath
=
openFileDialog
.
FileName
;
string
xmindPath
=
openFileDialog
.
FileName
;
string
outDirPath
=
System
.
IO
.
Path
.
GetDirectoryName
(
xmindPath
);
string
outDirPath
=
System
.
IO
.
Path
.
GetDirectoryName
(
xmindPath
);
if
(
Xmind2UnityConfigCore
.
TopicExt
.
ToUnity
(
openFileDialog
.
FileName
,
null
)
==
0
)
{
if
(
Xmind2UnityConfigCore
.
XMindTypeExt
.
ToUnity
(
openFileDialog
.
FileName
,
null
,
true
)
==
0
)
{
MessageBox
.
Show
(
$@"完成 输出到
{
outDirPath
}
\unity"
);
MessageBox
.
Show
(
$@"完成 输出到
{
outDirPath
}
\unity"
);
}
}
}
}
...
...
读取xmind/WpfApp1/WpfApp1/Xmind2UnityConfigUI.csproj
View file @
eeacc9b8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Configuration
Condition=
" '$(Configuration)' == '' "
>
Debug
</Configuration>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<Platform
Condition=
" '$(Platform)' == '' "
>
AnyCPU
</Platform>
<ProjectGuid>
{840673C1-3705-42EC-A3EB-6A7F803590CF}
</ProjectGuid>
<ProjectGuid>
{840673C1-3705-42EC-A3EB-6A7F803590CF}
</ProjectGuid>
<OutputType>
Win
Exe
</OutputType>
<OutputType>
Exe
</OutputType>
<RootNamespace>
Xmind2UnityConfigUI
</RootNamespace>
<RootNamespace>
Xmind2UnityConfigUI
</RootNamespace>
<AssemblyName>
Xmind2UnityConfigUI
</AssemblyName>
<AssemblyName>
Xmind2UnityConfigUI
</AssemblyName>
<TargetFrameworkVersion>
v4.6.1
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v4.6.1
</TargetFrameworkVersion>
...
...
读取xmind/WpfApp1/Xmind2UnityConfig/Program.cs
View file @
eeacc9b8
...
@@ -17,11 +17,15 @@ namespace Xmind2UnityConfig
...
@@ -17,11 +17,15 @@ namespace Xmind2UnityConfig
}
}
else
if
(
args
.
Length
==
1
)
else
if
(
args
.
Length
==
1
)
{
{
return
Xmind2UnityConfigCore
.
TopicExt
.
ToUnity
(
args
[
0
],
null
);
return
Xmind2UnityConfigCore
.
XMindTypeExt
.
ToUnity
(
args
[
0
],
null
,
true
);
}
}
else
else
if
(
args
.
Length
==
2
)
{
{
return
Xmind2UnityConfigCore
.
TopicExt
.
ToUnity
(
args
[
0
],
args
[
1
]);
return
Xmind2UnityConfigCore
.
XMindTypeExt
.
ToUnity
(
args
[
0
],
args
[
1
],
true
);
}
else
// if (args.Length == 2)
{
return
Xmind2UnityConfigCore
.
XMindTypeExt
.
ToUnity
(
args
[
0
],
args
[
1
],
bool
.
Parse
(
args
[
2
]));
}
}
}
}
}
}
...
...
读取xmind/WpfApp1/Xmind2UnityConfigCore/TopicExt.cs
View file @
eeacc9b8
...
@@ -39,6 +39,12 @@ namespace Xmind2UnityConfigCore
...
@@ -39,6 +39,12 @@ namespace Xmind2UnityConfigCore
string
filePath
=
System
.
IO
.
Path
.
Combine
(
tempPath
,
"content.json"
);
string
filePath
=
System
.
IO
.
Path
.
Combine
(
tempPath
,
"content.json"
);
string
json
=
File
.
ReadAllText
(
filePath
);
string
json
=
File
.
ReadAllText
(
filePath
);
//var xmind = JsonConvert.DeserializeObject<XMindRootTopic[]>(json);
//转义title
//string unescape = System.Text.RegularExpressions.Regex.Unescape(str);
JArray
jArray
=
JsonConvert
.
DeserializeObject
(
json
)
as
JArray
;
JArray
jArray
=
JsonConvert
.
DeserializeObject
(
json
)
as
JArray
;
var
jobject_topic
=
jArray
.
First
()
as
JObject
;
var
jobject_topic
=
jArray
.
First
()
as
JObject
;
...
@@ -82,6 +88,7 @@ namespace Xmind2UnityConfigCore
...
@@ -82,6 +88,7 @@ namespace Xmind2UnityConfigCore
return
topic
;
return
topic
;
}
}
static
void
ToUnity
(
Topic
rootTopic
,
string
path
)
static
void
ToUnity
(
Topic
rootTopic
,
string
path
)
{
{
path
=
System
.
IO
.
Path
.
Combine
(
path
,
"unity"
);
path
=
System
.
IO
.
Path
.
Combine
(
path
,
"unity"
);
...
@@ -97,6 +104,8 @@ namespace Xmind2UnityConfigCore
...
@@ -97,6 +104,8 @@ namespace Xmind2UnityConfigCore
File
.
WriteAllText
(
System
.
IO
.
Path
.
Combine
(
path
,
"relationship.json"
),
json
);
File
.
WriteAllText
(
System
.
IO
.
Path
.
Combine
(
path
,
"relationship.json"
),
json
);
}
}
static
RelationShip
ToRelationShip
(
Topic
topic
,
string
path
)
static
RelationShip
ToRelationShip
(
Topic
topic
,
string
path
)
{
{
RelationShip
relationShip
=
new
RelationShip
();
RelationShip
relationShip
=
new
RelationShip
();
...
@@ -291,4 +300,6 @@ namespace Xmind2UnityConfigCore
...
@@ -291,4 +300,6 @@ namespace Xmind2UnityConfigCore
xdoc
.
Save
(
filepath
);
xdoc
.
Save
(
filepath
);
}
}
}
}
}
}
读取xmind/WpfApp1/Xmind2UnityConfigCore/XMindType.cs
0 → 100644
View file @
eeacc9b8
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Xmind2UnityConfigCore
{
public
class
XMindRootTopic
{
public
XMindTopic
rootTopic
;
public
override
string
ToString
()
{
return
rootTopic
.
ToString
();
}
}
public
class
XMindTopic
{
public
string
title
;
public
XMindChildren
children
;
public
override
string
ToString
()
{
return
title
;
}
}
public
class
XMindChildren
{
public
List
<
XMindTopic
>
attached
;
}
}
读取xmind/WpfApp1/Xmind2UnityConfigCore/XMindTypeExt.cs
0 → 100644
View file @
eeacc9b8
This diff is collapsed.
Click to expand it.
读取xmind/WpfApp1/Xmind2UnityConfigCore/Xmind2UnityConfigCore.csproj
View file @
eeacc9b8
...
@@ -46,6 +46,8 @@
...
@@ -46,6 +46,8 @@
<Compile
Include=
"Topic.cs"
/>
<Compile
Include=
"Topic.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"TopicExt.cs"
/>
<Compile
Include=
"TopicExt.cs"
/>
<Compile
Include=
"XMindType.cs"
/>
<Compile
Include=
"XMindTypeExt.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<PackageReference
Include=
"Newtonsoft.Json"
>
<PackageReference
Include=
"Newtonsoft.Json"
>
...
...
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