Пример #1
0
        //修改节点数据
        void ModifyStyle(ref XmlNode xNode, StyleSet CurrentStyle)
        {
            Color cColor;
            String strFont;
            int intSize, intSharp, intMode;

            cColor = CurrentStyle.ForeColor;
            xNode.ChildNodes.Item(3).InnerText = ColorToString(cColor);
            cColor = CurrentStyle.BackColor;
            xNode.ChildNodes.Item(4).InnerText = ColorToString(cColor);
            cColor = CurrentStyle.FrameColor;
            xNode.ChildNodes.Item(5).InnerText = ColorToString(cColor);
            cColor = CurrentStyle.HLForeColor;
            xNode.ChildNodes.Item(6).InnerText = ColorToString(cColor);
            cColor = CurrentStyle.HLBackColor;
            xNode.ChildNodes.Item(7).InnerText = ColorToString(cColor);
            cColor = CurrentStyle.HLFrameColor;
            xNode.ChildNodes.Item(8).InnerText = ColorToString(cColor);
            intSharp = (int)CurrentStyle.Sharp;
            xNode.ChildNodes.Item(9).InnerText = intSharp.ToString();
            intMode = (int)CurrentStyle.SmoothMode;
            xNode.ChildNodes.Item(10).InnerText = intMode.ToString();
            strFont = CurrentStyle.charFont.Name;
            xNode.ChildNodes.Item(11).InnerText = strFont;
            intSize = Convert.ToInt32(CurrentStyle.charFont.Size);
            xNode.ChildNodes.Item(12).InnerText = intSize.ToString();
        }
Пример #2
0
 //更新网络样式集
 void IfPaintStrategy.UpdateStyle(StyleSet GlobalStyle)
 {
     if (GlobalStyle != null)
     {
         NetStyle = GlobalStyle;
     }
 }
Пример #3
0
 //更新网络样式集
 void IfPaintStrategy.UpdateStyle(StyleSet GlobalStyle)
 {
     if (GlobalStyle != null)
     {
         NetStyle = GlobalStyle;
     }
 }
Пример #4
0
        //重载Equals函数,判断两个样式集是否一样
        public override bool Equals(object obj)
        {
            //判断与之比较的类型是否为null。这样不会造成递归的情况
            if (obj == null)
            {
                return(false);
            }
            //类型是否一致
            if (GetType() != obj.GetType())
            {
                return(false);
            }
            //拆箱
            StyleSet Traget = (StyleSet)obj;

            if (this.colFore != Traget.colFore)
            {
                return(false);
            }
            if (this.colBack != Traget.colBack)
            {
                return(false);
            }
            if (this.colFrame != Traget.colFrame)
            {
                return(false);
            }
            if (this.HLForeColor != Traget.HLForeColor)
            {
                return(false);
            }
            if (this.HLBackColor != Traget.HLBackColor)
            {
                return(false);
            }
            if (this.HLFrameColor != Traget.HLFrameColor)
            {
                return(false);
            }
            if (this.Sharp != Traget.Sharp)
            {
                return(false);
            }
            if (this.SmoothMode != Traget.SmoothMode)
            {
                return(false);
            }
            if (this.charFont.Name != Traget.charFont.Name)
            {
                return(false);
            }
            if (this.charFont.Size != Traget.charFont.Size)
            {
                return(false);
            }
            return(true);
        }
Пример #5
0
 //刷新两个PictureBox,并用指定样式绘图
 void RefreshGraph(StyleSet PaintStyle)
 {
     //普通节点视图
     NodeImage.Image = DrawNode(PaintStyle, false);
     NodeImage.Refresh();
     //高亮节点视图
     HLImage.Image = DrawNode(PaintStyle, true);
     HLImage.Refresh();
 }
Пример #6
0
 //网络初始化,在加入所有节点之后执行一次
 public void Initialized(StyleSet PaintStyle)
 {
     NetworkType();//网络类型分析
     DegreeStat();//节点度统计
     if (PaintStyle != null)
     {
         NetPainter = new DefaultStrategy(PaintStyle);
     }
     NetPainter.UpdateLocation(this.ToXML());//节点坐标刷新
     NetPainter.UpdateImage();//节点图像刷新
 }
Пример #7
0
        public StyleSet GlobalPaintStyle;  // 全局变量 绘图风格


        public FrmComBehavior(FrmMain owner)
        {
            InitializeComponent();
            //设置FrmMain为父窗体,可以读取父窗体数据
            father = owner;
            GlobalPaintStyle = father.GlobalPaintStyle;
            PicWidth = father.PicWidth;
            PicHeight = father.PicHeight;
            XmlDocument doc = father.ComplexNet.ToXML();
            curNetwork = new bNet(doc, GlobalPaintStyle);
        }
Пример #8
0
 //网络初始化,在加入所有节点之后执行一次
 public void Initialized(StyleSet PaintStyle)
 {
     NetworkType();//网络类型分析
     DegreeStat();//节点度统计
     switch (PaintStyle.Sharp)
     {
         case StyleSet.sharp.Round:
             NetPainter = new DefaultStrategy(PaintStyle);
             break;
     }
     NetPainter.UpdateLocation(this.ToXML());//节点坐标刷新
     NetPainter.UpdateImage();//节点图像刷新
 }
Пример #9
0
 //填充界面控件内容
 void FillContent(StyleSet PaintStyle)
 {
     DescBox.Text = PaintStyle.Description;
     FontBox.Text = PaintStyle.charFont.Name;
     SizeBox.Text = PaintStyle.charFont.Size.ToString();
     ForeLabel.BackColor = PaintStyle.ForeColor;
     BackLabel.BackColor = PaintStyle.BackColor;
     FrameLabel.BackColor = PaintStyle.FrameColor;
     HLForeLabel.BackColor = PaintStyle.HLForeColor;
     HLBackLabel.BackColor = PaintStyle.HLBackColor;
     HLFrameLabel.BackColor = PaintStyle.HLFrameColor;
     SmoothBox.SelectedIndex = (int)PaintStyle.SmoothMode;
 }
Пример #10
0
 //构造函数,从一个已有样式集生成
 public StyleSet(StyleSet Original)
 {
     this.Name        = this.Name;
     this.colFore     = Original.ForeColor;
     this.colBack     = Original.BackColor;
     this.colFrame    = Original.FrameColor;
     this.colHLFore   = Original.HLForeColor;
     this.colHLBack   = Original.HLBackColor;
     this.colHLFrame  = Original.HLFrameColor;
     this.NodeSharp   = Original.NodeSharp;
     this.sMode       = Original.sMode;
     this.cFont       = Original.cFont;
     this.Description = Original.Description;
 }
Пример #11
0
 //保存当前用户设置
 public void SaveCurrent(StyleSet CurrentStyle)
 {
     XmlDocument doc;
     XmlNode xmlroot, xNode;
     //新建数据库读写代理对象
     dbHandler = new DataProxy();
     //读入xml文件
     doc = dbHandler.Read(strTablePath);
     //查找数据根节点标签
     xmlroot = doc.SelectSingleNode("dataroot");
     //指向第0个节点,当前使用样式
     xNode = xmlroot.ChildNodes.Item(0);
     //修改节点数据
     ModifyStyle(ref xNode, CurrentStyle);
     //保存回文件
     dbHandler.Save(strTablePath, doc);
 }
Пример #12
0
        //读取当前用户设定的样式
        public StyleSet ReadCurrent()
        {
            StyleSet CurrentStyle ;
            XmlElement Result;

            //新建数据库读写代理对象
            dbHandler = new DataProxy();
            //获取路径下文件所有数据
            Result = dbHandler.ReadIndexOf(strTablePath, 0);
            if (Result == null)
            {
                return null;
            }
            //从数据生成样式集
            CurrentStyle = new StyleSet(Result);
            return CurrentStyle;
        }
Пример #13
0
        //方法
        //将xml文件转化为网络
        public bNet(XmlDocument doc, StyleSet PaintStyle)
        {
            XmlNodeList Nodelist;
            XmlNode xmlroot;
            IfComBehavior newNode;

            this.Network = new List<IfComBehavior>();
            xmlroot = doc.ChildNodes.Item(0);
            Nodelist = xmlroot.ChildNodes;                                             //获取节点列表

            this.intNumber = 0;
            foreach (XmlElement curNode in Nodelist)                                      //遍历节点列表
            {
                newNode = new bNode(intNumber);
                newNode.XMLinput(curNode, 0);
                this.Network.Add(newNode);                          //调用下层函数,生成新节点
                this.intNumber++;
            }
            Initialized(PaintStyle);
        }
Пример #14
0
        //绘制预览节点
        Image DrawNode(StyleSet NetStyle, Boolean isHL)
        {
            Pen frame;					//显示变量 边框画笔
            GraphicsPath path;  //路径图形
            PathGradientBrush pthGrBrush;   //路径画笔
            Graphics graPreview;
            Image imgPreview;
            int intRand;

            intRand = 30;
            imgPreview = new Bitmap(2 * intRand + 1, 2 * intRand + 1);
            graPreview = Graphics.FromImage(imgPreview);

            //新建位图,存放节点图像
            graPreview.SmoothingMode = NetStyle.SmoothMode;//平滑处理
            //立体效果绘制
            path = new GraphicsPath();
            path.AddEllipse(0, 0, intRand * 2, intRand * 2);
            pthGrBrush = new PathGradientBrush(path);
            pthGrBrush.CenterColor = Color.FromArgb(255, 255, 255, 255);
            pthGrBrush.CenterPoint = new Point(Convert.ToInt32(2 * intRand * 0.618), Convert.ToInt32(intRand * 0.618));
            //高亮节点采用特定的颜色
            if (isHL == true)
            {
                frame = new Pen(NetStyle.HLFrameColor);
                pthGrBrush.SurroundColors = new Color[] { NetStyle.HLBackColor };
            }
            else
            {
                frame = new Pen(NetStyle.FrameColor);
                pthGrBrush.SurroundColors = new Color[] { NetStyle.BackColor };
            }
            graPreview.FillEllipse(pthGrBrush, 0, 0, intRand * 2, intRand * 2);
            //外围边框绘制
            graPreview.DrawEllipse(frame, 0, 0, 2 * intRand, 2 * intRand);
            //绘制节点编号
            DrawString(NetStyle, ref graPreview, isHL);
            return imgPreview;
        }
Пример #15
0
 public StyleUpdateEventArgs(StyleSet NewStyleSet)
 {
     curStyle = NewStyleSet;
 }
Пример #16
0
 //构造函数,从一个已有样式集生成
 public StyleSet(StyleSet Original)
 {
     this.Name = this.Name;
     this.colFore = Original.ForeColor;
     this.colBack = Original.BackColor;
     this.colFrame = Original.FrameColor;
     this.colHLFore = Original.HLForeColor;
     this.colHLBack = Original.HLBackColor;
     this.colHLFrame = Original.HLFrameColor;
     this.NodeSharp = Original.NodeSharp;
     this.sMode = Original.sMode;
     this.cFont = Original.cFont;
     this.Description = Original.Description;
     this.bolArrowShow = Original.bolArrowShow;
 }
Пример #17
0
        //用户选项菜单项响应函数
       private void OptionMI_Click(object sender, EventArgs e)
       {
           DiaOption diaOption = null;

           if (diaOption == null)
           {
               diaOption = new DiaOption();
           }
           diaOption.ShowDialog(this);
           //获取用户设置的样式集
           if (GlobalPaintStyle.Equals( diaOption.CurrentStyle) == false)
           {
               GlobalPaintStyle = diaOption.CurrentStyle;
           }
           //更新当前网络图像
           UpdateStyleSet();
           diaOption.Dispose();
       }
Пример #18
0
 //启动定时器中断函数
 private void StartTimer_Tick(object sender, EventArgs e)
 {
     StyleSetProxy dbReader = new StyleSetProxy();
     //响应一次后就关,以后不再进入
     StartTimer.Enabled = false;
     //读入数据库中保存的样式集
     GlobalPaintStyle = dbReader.ReadCurrent();
     GlobalPaintStyle.IsArrowShow = ArrowMI.Checked;
     //读取xml格式的zachary网络文件
     Read(Application.StartupPath.ToString() + "\\ComLink3.sst");
     //响应一次后就关,以后不再进入
     StartTimer.Enabled = false;
 }
Пример #19
0
 public StyleUpdateEventArgs(StyleSet NewStyleSet)
 {
     curStyle = NewStyleSet;
 }
Пример #20
0
 //启动定时器中断函数
 private void StartTimer_Tick(object sender, EventArgs e)
 {
     StyleSetProxy dbReader = new StyleSetProxy();
     //响应一次后就关,以后不再进入
     StartTimer.Enabled = false;
     //读取当前工作用的样式集
     CurrentStyle = dbReader.ReadCurrent();
     //读取系统预设的样式集列表
     Preset = dbReader.ReadPreset();
     //刷新预览图
     RefreshGraph(CurrentStyle);
     //填充界面数据
     FillContent(CurrentStyle);
     //读取预设样式集列表
     LoadStyle();
     //使用当前工作的样式集初始化待用户修改的样式集
     ModifyStyle = new StyleSet(CurrentStyle);
     //启动后台检测定时器,用户检查ModifyStyle是否被用户改动了
     CheckTimer.Enabled = true;
 }
Пример #21
0
        //绘制节点编号,使用前景色
        void DrawString(StyleSet NetStyle, ref Graphics GraCam, Boolean isHL)
        {
            SolidBrush fore;				//显示变量 背景色刷

            //高亮节点使用高亮前景色
            if (isHL == true)
            {
                fore = new SolidBrush(NetStyle.HLForeColor);
            }
            else
            {
                fore = new SolidBrush(NetStyle.ForeColor);
            }
            
            //字符绘制
            GraCam.DrawString("预览", NetStyle.charFont, fore, 14, 24);
            fore.Dispose();
        }
Пример #22
0
 //预设样式集列表选项修改响应
 private void StyleList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (StyleList.SelectedIndex < 0)
     {
         return;
     }
     //设置选中预设样式集为当前暂存样式集
     ModifyStyle = Preset[StyleList.SelectedIndex];
     //回填数据到窗体控件
     FillContent(ModifyStyle);
     //刷新预览图
     RefreshGraph(ModifyStyle);
 }
Пример #23
0
        //构造函数,输入用户当前使用的样式集
        public DefaultStrategy(StyleSet GlobalStyle)
		{
            NetStyle = GlobalStyle;
		}
Пример #24
0
 //构造函数,输入用户当前使用的样式集
 public DefaultStrategy(StyleSet GlobalStyle)
 {
     NetStyle = GlobalStyle;
 }
Пример #25
0
 //保存用户暂存数据到数据库
 private void ApplyButton_Click(object sender, EventArgs e)
 {
     StyleSetProxy dbReader = new StyleSetProxy();
     //保存数据到数据库
     dbReader.SaveCurrent(ModifyStyle);
     //用当前用户设定样式集替换目前工作的样式集
     CurrentStyle = ModifyStyle;
 }