📄 nodearray.cs
字号:
using System;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
namespace bs
{
/// <summary>
/// NodeArray 的摘要说明。
/// </summary>
public class NodeArray: System.Collections.CollectionBase
{
private readonly Doc HostForm;
public NodeArray(Doc host)
{
//
// TODO: 在此处添加构造函数逻辑
//
HostForm = host;
}
public void AddNewNode(int x,int y)
{
BNode1 node=new BNode1(new Point(x,y));
node.BackColor = Color.Yellow;
// 将按钮添加到集合的内部列表。
this.List.Add(node);
// 将按钮添加到由 HostForm 字段
// 引用的窗体的控件集合中。
//HostForm.Controls.Add(node);
HostForm.AddTheControl(node);
//HostForm.ad
// 设置按钮对象的初始属性。
//aNode.left=x;
//aNode.Top=y;
//node.FontSize=this.HostForm.fontSize;
node.Tag=this.Count;
node.ID=this.Count;
//node.Size = new System.Drawing.Size((int)System.Math.Round(this.HostForm.ClientSize.Width*0.1),(int)System.Math.Round(this.HostForm.ClientSize.Height*0.05));
node.Size = new Size(80, 30);
node.Text =node.Text+node.Tag.ToString();
node.CPT=new double[100,20];
for(int i=0;i<100;i++)
for(int j=0;j<2;j++)
{
node.CPT[i,j]=0.500;
//MessageBox.Show(node.CPT[i,j].ToString());
}
for(int i=0;i<100;i++)
for(int j=2;j<20;j++)
{
node.CPT[i,j]=0;//cpt条件概率表
//MessageBox.Show(node.CPT[i,j].ToString());
}
}
public void Remove()
{
// 检查以确保存在要删除的按钮。
if (this.Count > 0)
{
// 从宿主窗体控件集合中删除添加到数组
// 的最后一个按钮。请注意在访问数组时
// 索引的使用。
HostForm.Controls.Remove(this[this.Count -1]);
this.List.RemoveAt(this.Count -1);
}
}
public BNode1 this [int Index]
{
get
{
if (Index >= this.List.Count)
{
MessageBox.Show("索引越界!");
return null;
}
else
{
return (BNode1)this.List[Index];
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -