-
Notifications
You must be signed in to change notification settings - Fork 0
/
NodeProperties.cs
168 lines (153 loc) · 5.68 KB
/
NodeProperties.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Collections;
using System.Xml;
using WeifenLuo.WinFormsUI.Docking;
namespace DagonSpots2
{
public partial class NodeProperties : DockContent
{
public NodeProperties()
{
InitializeComponent();
_nodes = this; // required to share controls
}
public static NodeProperties _nodes;// required to share controls
public Image Img;
string extension;
// load the node images
private void loadBtn_Click(object sender, EventArgs e)
{
Spotlist.Items.Clear();
OpenFileDialog Dlg = new OpenFileDialog();
Dlg.Filter = "";
Dlg.Title = "Select image";
if (Dlg.ShowDialog(this) == DialogResult.OK)
{
extension = Path.GetExtension(Dlg.FileName);
String pathfolder = Path.GetDirectoryName(Dlg.FileName);
dagonpath.Text = pathfolder;
if (extension == ".tga")
{
Img = Paloma.TargaImage.LoadTargaImage(Dlg.FileName);
}
else
{
Img = Image.FromFile(Dlg.FileName);
//Image.FromFile(String) method creates an image from the specifed file, here dlg.Filename contains the name of the file from which to create the image
Picview1._imgs.LoadImage();
pictureBox2.Image = Img;
{
DirectoryInfo dinfo3 = new DirectoryInfo(dagonpath.Text);
FileInfo[] Files3 = dinfo3.GetFiles("*00*" + extension);
foreach (FileInfo file in Files3)
{
object resultx = Path.GetFileNameWithoutExtension(file.Name);
Spotlist.Items.Add(resultx);
}
}
}
}
}
private void Spotlist_SelectedIndexChanged(object sender, EventArgs e)
{
Img = Image.FromFile(dagonpath.Text + "\\" + Spotlist.Text + extension);
//Image.FromFile(String) method creates an image from the specifed file, here dlg.Filename contains the name of the file from which to create the image
Picview1._imgs.LoadImage();
//Zoombtna();
pictureBox2.Image = Img;
nodeface.Text = Spotlist.Text;
// look for the suffix in the image name, if it 2 zeros
string s1 = "001";
string s2 = "002";
string s3 = "003";
string s4 = "004";
string s5 = "005";
string s6 = "006";
string s = null;
// look for the suffix in the image name, if it 3 zeros
string s1a = "0001";
string s2a = "0002";
string s3a = "0003";
string s4a = "0004";
string s5a = "0005";
string s6a = "0006";
s = Spotlist.Text;
// based on the last digits value add directions to spotdirection.Text
//TextBox4.Text = work
if (nodeface.Text.Contains(s1))
{
spotdirection.Text = "NORTH";
nodespotetxt.Text = (s.Substring(0, s.Length - 3));
}
if (nodeface.Text.Contains(s2))
{
spotdirection.Text = "EAST";
nodespotetxt.Text = (s.Substring(0, s.Length - 3));
}
if (nodeface.Text.Contains(s3))
{
spotdirection.Text = "SOUTH";
nodespotetxt.Text = (s.Substring(0, s.Length - 3));
}
if (nodeface.Text.Contains(s4))
{
spotdirection.Text = "WEST";
nodespotetxt.Text = (s.Substring(0, s.Length - 3));
}
if (nodeface.Text.Contains(s5))
{
spotdirection.Text = "UP";
nodespotetxt.Text = (s.Substring(0, s.Length - 3));
}
if (nodeface.Text.Contains(s6))
{
spotdirection.Text = "DOWN";
nodespotetxt.Text = (s.Substring(0, s.Length - 3));
}
if (nodeface.Text.Contains(s1a))
{
spotdirection.Text = "NORTH";
nodespotetxt.Text = (s.Substring(0, s.Length - 4));
}
if (nodeface.Text.Contains(s2a))
{
spotdirection.Text = "EAST";
nodespotetxt.Text = (s.Substring(0, s.Length - 4));
}
if (nodeface.Text.Contains(s3a))
{
spotdirection.Text = "SOUTH";
nodespotetxt.Text = (s.Substring(0, s.Length - 4));
}
if (nodeface.Text.Contains(s4a))
{
spotdirection.Text = "WEST";
nodespotetxt.Text = (s.Substring(0, s.Length - 4));
}
if (nodeface.Text.Contains(s5a))
{
spotdirection.Text = "UP";
nodespotetxt.Text = (s.Substring(0, s.Length - 4));
}
if (nodeface.Text.Contains(s6a))
{
spotdirection.Text = "DOWN";
nodespotetxt.Text = (s.Substring(0, s.Length - 4));
}
}
}
}