📄 findata.fxjconverter.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using FinData;
namespace FinData
{
internal partial class DzhConverter : Form
{
public DzhConverter()
{
InitializeComponent();
}
private void changeDzhPath_Click(object sender, EventArgs e)
{
}
private bool stopConverting=false;
private void DzhConverter_Load(object sender, EventArgs e)
{
DzhData dzh = new DzhData();
if (dzh.DzhPath == "")
{
dzhPath.Text = "没有找到大智慧!";
dzhPath.ForeColor = Color.Red;
}
else
{
this.dzhPath.Text = dzh.DzhPath;
this.ver.Text = dzh.Version;
if (dzh.GetMarkets().GetLength(0) > 0)
{
TreeNode[] marketNode = new TreeNode[dzh.GetMarkets().GetLength(0) + 1];
treeView1.ExpandAll();
for (int i = 0; i < dzh.GetMarkets().GetLength(0); i++)
{
DirectoryInfo dir = new DirectoryInfo(dzh.DzhPath + @"\data\" + dzh.GetMarkets()[i, 0].Trim());
if (dir.Exists)
{
marketNode[i] = treeView1.Nodes.Add(dzh.GetMarkets()[i, 1]);
string[,] tables = dzh.GetTables();
for (int j = 0; j < tables.GetLength(0); j++)
{
if ("..SH,SZ,".IndexOf(dzh.GetMarkets()[i, 0].ToUpper()) > 0 && tables[j, 0].ToLower() != "bk") //深沪
{
if (File.Exists(dzh.DzhPath + @"data\" + dzh.GetMarkets()[i, 0] + @"\" + tables[j, 2]) ||
",,,fp,gb,gd,cw,jjjz,jjzh".IndexOf(tables[j, 0].ToLower()) > 0 && File.Exists(dzh.DzhPath + @"data\" + tables[j, 2]))
{
marketNode[i].Nodes.Add(tables[j, 1] + "|" + dzh.GetMarkets()[i, 0].ToLower() + "|" + tables[j, 0] + "|" + dzh.GetMarkets()[i, 0].ToLower() + tables[j, 0] + ".txt|" + tables[j, 2]);
}
}
else //其它市场
{
if (File.Exists(dzh.DzhPath + @"data\" + dzh.GetMarkets()[i, 0] + @"\" + tables[j, 2]))
{
if (",,,fp,gb,gd,cw,jjjz,jjzh".IndexOf(tables[j, 0].ToLower()) <= 0 && tables[j, 0].ToLower() != "bk")
{
marketNode[i].Nodes.Add(tables[j, 1] + "|" + dzh.GetMarkets()[i, 0].ToLower() + "|" + tables[j, 0] + "|" + dzh.GetMarkets()[i, 0].ToLower() + tables[j, 0] + ".txt|" + tables[j, 2]);
}
}
}
}
foreach (FileInfo file in dir.GetFiles(@"*.PRP"))
{
marketNode[i].Nodes.Add("历史分笔成交|" + dzh.GetMarkets()[i, 0].ToLower() + "|hqmb|"+ dzh.GetMarkets()[i, 0].ToLower()+"hqmb" + file.Name.Substring(0, file.Name.IndexOf(".")) + ".txt|" + file.Name);
}
}
}
marketNode[dzh.GetMarkets().GetLength(0)] = treeView1.Nodes.Add("其它数据");
marketNode[dzh.GetMarkets().GetLength(0)].Nodes.Add("板块|ss|bk|bk.txt|block.def");
marketNode[dzh.GetMarkets().GetLength(0)].Nodes.Add("评级|ss|pj|pj.txt|评级.str");
}
}
}
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
// The code only executes if the user caused the checked state to change.
if (e.Action != TreeViewAction.Unknown)
{
if (e.Node.Nodes.Count > 0)
{
/* Calls the CheckAllChildNodes method, passing in the current
Checked value of the TreeNode whose checked state changed. */
this.CheckAllChildNodes(e.Node, e.Node.Checked);
}
}
}
private void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
{
foreach (TreeNode node in treeNode.Nodes)
{
node.Checked = nodeChecked;
if (node.Nodes.Count > 0)
{
// If the current node has child nodes, call the CheckAllChildsNodes method recursively.
this.CheckAllChildNodes(node, nodeChecked);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "取消(&C)")
{
if (MessageBox.Show("确定要中断数据转换吗?", "确定", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
{
stopConverting = true;
outputBox.Enabled = true;
treeView1.Enabled = true;
status3.Text += DateTime.Now.ToString("HH:mm:ss") + ":中断转换!\n";
}
return;
}
if (treeView1.Nodes.Count < 1)
{
MessageBox.Show("没有找到数据!", "错误");
return;
}
if (descPath.Text.Trim() == "")
{
MessageBox.Show("请选择目标文件夹!", "错误");
descPath.Focus();
return;
}
if(Directory.Exists(descPath.Text)==false)
{
MessageBox.Show("文件夹“" + descPath.Text +"”不存在!请重新选择或创建!", "错误",MessageBoxButtons.OK);
descPath.Focus();
return;
}
if (MessageBox.Show("转换数据时将根据您的选择在“" + descPath.Text.Trim() + "”中创建多个文件,同名文件将被覆盖!\n\n确定开始转换吗?","确定",MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2)!=DialogResult.OK)
{
return;
}
//转换数据
int errorCounts = 0;
button1.Text = "取消(&C)";
status.Text = "";
status2.Text = "";
status3.Text = DateTime.Now.ToString("HH:mm:ss") + ":开始转换...\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -