//この下からイベント

        public MainWindow()
        {
            InitializeComponent();
            per = new performance();
            max_memlabel.Content = string.Format("{0}MB", per.max_mem());
            IP_label.Content     = string.Format("IPアドレス:{0}", get_ip());

            tick_switch = true;
            start_tick();
        }
        //この下からイベント

        public MainWindow()
        {
            InitializeComponent();
            per = new performance();
            max_memlabel.Content = string.Format("{0}MB", per.max_mem());
            IP_label.Content = string.Format("IPアドレス:{0}", get_ip());

            tick_switch = true;
            start_tick();
        }
        private void listen()
        {
            status_label.Dispatcher.BeginInvoke(
                new Action(() =>
            {
                status_label.Content = "サーバ待機";
                statusbar.Background = getBrushColor(202, 81, 0, 255);
                BorderBrush          = getBrushColor(202, 81, 0, 255);
            })
                );

            tcp.listen();

            /*
             * string str;
             * str = string.Format("{0},{1},0", per.cpu_count(), per.max_mem());
             * System.Console.WriteLine(str);
             *
             * tcp.send(str);
             *
             */

            bool ok = false;

            while (!ok)
            {
                string tcp_str = tcp.recive();
                if (tcp_str != "0")
                {
                    if (tcp_str == password)
                    {
                        ok             = true;
                        tcp.connection = true;  //tcp.connectionを違うインスタンスからいじるのはよくない気がする、どうにかしたいね
                        System.Console.WriteLine("準備完了");

                        status_label.Dispatcher.BeginInvoke(
                            new Action(() =>
                        {
                            status_label.Content    = "接続完了";
                            statusbar.Background    = getBrushColor(104, 33, 122, 255);
                            BorderBrush             = getBrushColor(104, 33, 122, 255);
                            client_label.Content    = tcp.get_client_IP();
                            client_label.Foreground = getBrushColor(45, 133, 193, 255);
                        })
                            );

                        string str;
                        str = string.Format("{0},{1},0", per.cpu_count(), per.max_mem());
                        System.Console.WriteLine(str);

                        tcp.send(str);
                    }
                    else //パスワード間違えるとだんだんCPU使用率が上がっていく
                    {
                        tcp.send("password_error");

                        tcp.disconnection();

                        tcp = new tcp_conection("0,0,0,0", port);

                        this.Dispatcher.BeginInvoke(
                            new Action(() =>
                        {
                            listen();
                        })
                            );
                    }
                }
            }

            /*
             * status_label.Dispatcher.BeginInvoke(
             *      new Action(() =>
             *      {
             *          status_label.Content = "接続完了";
             *          statusbar.Background = getBrushColor(104, 33, 122, 255);
             *          BorderBrush = getBrushColor(104, 33, 122, 255);
             *          client_label.Content = tcp.get_client_IP();
             *          client_label.Foreground = getBrushColor(45,133,193,255);
             *      })
             *  );
             */
        }