private void BtnAdd_Click(object sender, RoutedEventArgs e) { Window_MakeSession wms = new Window_MakeSession(); Point pt = this.PointToScreen(new Point(0, 0)); wms.Left = pt.X; wms.Top = pt.Y; if (wms.ShowDialog() == true) { string name = wms.textBox_name.Text; string ip = wms.textBox_ip.Text; string id = wms.textBox_id.Text; string password = wms.textBox_password.Password; ServerInfoTextBlock si = new ServerInfoTextBlock(name, ip, id, password); this.child.Items.Add(si); JObject jobj = ServerInfo.jobj_root[this.Content] as JObject; if (jobj == null) { return; } jobj.Add(ServerInfo.ConvertToJson(si.serverinfo)); ServerInfo.save(); } }
protected override void OnMouseDoubleClick(MouseButtonEventArgs e) { base.OnMouseDoubleClick(e); if (e.ChangedButton == MouseButton.Left) { ServerInfoTextBlock sitb = this.SelectedItem as ServerInfoTextBlock; if (sitb == null) { return; } Window_MakeSession wms = new Window_MakeSession(); wms.textBox_name.Text = sitb.serverinfo.name; wms.textBox_ip.Text = sitb.serverinfo.ip; wms.textBox_id.Text = sitb.serverinfo.id; wms.textBox_password.Password = sitb.serverinfo.password; Point pt = this.PointToScreen(new Point(0, 0)); wms.Left = pt.X; wms.Top = pt.Y; if (wms.ShowDialog() == true) { sitb.Text = sitb.serverinfo.name = wms.textBox_name.Text; sitb.serverinfo.ip = wms.textBox_ip.Text; sitb.serverinfo.id = wms.textBox_id.Text; sitb.serverinfo.password = wms.textBox_password.Password; ServerInfo.save(); } } }