using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TreeView;

namespace 试验版.socket
{
    public partial class clientform : Form
    {
        private socket_client socketClient;
        private Openfile open;
        private Form2 form2Instance;  // 引用 Form2 实例
        public clientform(Form2 form2)
        {
            InitializeComponent();
            form2Instance = form2;  // 初始化 Form2 实例

            form2Instance.graph = new Graph(); // 初始化 Graph
            form2Instance.graphll = new Graph(); // 初始化 Graphll
            form2Instance.connectionpoints = new List<dian>(); // 初始化连接点列表
            form2Instance.results = new List<dian>(); // 初始化结果列表
            form2Instance.connectlines = new List<liness>();

            socketClient = new socket_client(clientrichbox);// 将日志文本框传入
            socketClient.StartClient();
            open = new Openfile();  
            

        }


        public class FileDataResult
        {
            public List<element> Elements { get; set; }
            public List<dian> DList { get; set; }
            public List<liness> lines { get; set; }
            public Graph graph { get; set; }
            public Graph graphll { get; set; }
        }

        


        private void button1_Click(object sender, EventArgs e)
        {
            string filepath = Application.StartupPath + "\\sblist.txt";
            试验版.Openfile.FileDataResult result = 试验版.Openfile.openfiledata(filepath);

            form2Instance.sblist = result.Elements;
            form2Instance.connectionpoints = result.DList;
            form2Instance.connectlines = result.lines;
            form2Instance.graph = result.graph;
            form2Instance.graphll = result.graphll;

            form2Instance.Invalidate();
            if (form2Instance.sblist != null)
            {
                
                socketClient.SendMessage($"废物七号成功打开文件");
                
            }

        }
    }
}
