当前位置: 首页>>代码示例>>C#>>正文


C# Diagram.ClearAll方法代码示例

本文整理汇总了C#中Diagram.ClearAll方法的典型用法代码示例。如果您正苦于以下问题:C# Diagram.ClearAll方法的具体用法?C# Diagram.ClearAll怎么用?C# Diagram.ClearAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Diagram的用法示例。


在下文中一共展示了Diagram.ClearAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawNeuralNetPair

        private void DrawNeuralNetPair(Diagram diagram, out List<ShapeNode>[] nodes, BasicNetwork neuralNet)
        {
            if (diagram.Items.Count > 0)
                diagram.ClearAll();

            ProcessPair pp = cbProcessPair.SelectedItem as ProcessPair;
            TemplXML.FormData form = ConvertDataArrayToXml(templ, trainingData[pp.Pair].InputArray);

            double dx = 400;
            double rastNode = 30;
            double startYF = 50;
            double startX = dx + 50; // + (neuralNet.LayerCount - 1) * 300;
            double startY = 50;
            double diam = 30;
            double startYMax = startY;
            nodes = new List<ShapeNode>[neuralNet.LayerCount];
            string label = "null";
            graphPairLinkInput = new List<DiagramLink>(neuralNet.Flat.LayerCounts[neuralNet.LayerCount - 1]);
            for (int i = neuralNet.LayerCount - 1; i >= 0; i--)
            {
                List<ShapeNode> curN = new List<ShapeNode>();
                for (int j = 0; j < neuralNet.Flat.LayerCounts[i]; j++)
                {
                    ShapeNode tmp = DiagramHelper.CreateNode(diagram, startX, startY, diam, diam, j.ToString());
                    tmp.MouseLeftButtonDown += nodeSelected_MouseLeftButtonDown;
                    curN.Add(tmp);

                    if (i == neuralNet.LayerCount - 1 && j < neuralNet.InputCount)
                    {
                        ShapeNode q = DiagramHelper.CreateNode(Shapes.Rectangle, diagram, startX - dx - 200, startY - 10, 200, 50,  form.Values[j].Field.Title);
                        if (form.Values[j] is TemplXML.FormDataValueNumber)
                        {
                            var tmpF = form.Values[j] as TemplXML.FormDataValueNumber;
                            label = string.Format("{0}", tmpF.Value);
                        }
                        else
                        {
                            var tmpF = form.Values[j] as TemplXML.FormDataValueSelect;
                            label = tmpF.Value.Title;
                        }
                        var tmpLink = DiagramHelper.CreateLink(diagram, q, tmp, label);
                        tmpLink.MouseLeftButtonDown += linkSelect_MouseLeftButtonDown;
                        graphPairLinkInput.Add(tmpLink);
                    }

                    startY += diam + rastNode;
                }
                nodes[i] = curN;
                startX += dx;
                if (startYMax < startY) startYMax = startY;
                if (i != 0)
                    startY = startYMax / 2 - neuralNet.Flat.LayerCounts[i - 1] * (rastNode + diam) / 2;
            }

            string tmpWeigth;
            int countN;
            for (int i = neuralNet.LayerCount - 1; i > 0; i--)
            {
                countN = countN = neuralNet.Flat.LayerCounts[i - 1];
                if (i - 1 == neuralNet.LayerCount - 2 && neuralNet.GetLayerBiasActivation(i - 1) > 0)
                    countN -= 1;
                for (int x = 0; x < neuralNet.Flat.LayerCounts[i]; x++)
                {

                    for (int y = 0; y < countN; y++)
                    {
                        tmpWeigth = neuralNet.GetWeight(neuralNet.LayerCount - i - 1, x, y).ToString("F4");
                        var link = DiagramHelper.CreateLink(diagram, nodes[i][x], nodes[i - 1][y], tmpWeigth);
                        link.MouseLeftButtonDown += linkSelect_MouseLeftButtonDown;
                    }
                }
            }
        }
开发者ID:neismit,项目名称:emds,代码行数:73,代码来源:MainWindow.xaml.cs

示例2: DrawNeuralNet

        private void DrawNeuralNet(Diagram diagram, out List<ShapeNode>[] nodes, BasicNetwork neuralNet)
        {
            if (diagram.Items.Count > 0)
                diagram.ClearAll();
            //получение шаблона
            InitEvent netInit = cbTrainsLog.SelectedItem as InitEvent;
            //TemplXML.FormTemplate templ;
            string pathXML = netInit.Path.Replace(".np4", ".xml");
            if (!File.Exists(pathXML))
                MessageBox.Show("Форма не найдена");
            templ = TemplXML.FormTemplate.FromXml(XElement.Load(pathXML));

            double dx = 400;
            double rastNode = 30;
            double startYF = 50;
            double startX = dx + 50; // + (neuralNet.LayerCount - 1) * 300;
            double startY = 50;
            double diam = 30;
            double startYMax = startY;
            nodes = new List<ShapeNode>[neuralNet.LayerCount];
            for (int i = neuralNet.LayerCount - 1 ; i >= 0; i--)
            {
                List<ShapeNode> curN = new List<ShapeNode>();
                for (int j = 0; j < neuralNet.Flat.LayerCounts[i]; j++)
                {
                    ShapeNode tmp = DiagramHelper.CreateNode(diagram, startX, startY, diam, diam, j.ToString());
                    tmp.MouseLeftButtonDown += nodeSelected_MouseLeftButtonDown;;
                    curN.Add(tmp);

                    if (i == neuralNet.LayerCount - 1 && j <neuralNet.InputCount)
                    {
                        ShapeNode q = DiagramHelper.CreateNode(Shapes.Rectangle, diagram, startX - dx, startY, 200, 50, templ.Fields[j].Title);
                        DiagramLink link = DiagramHelper.CreateLink(diagram, q, tmp);
                        link.MouseLeftButtonDown += linkSelect_MouseLeftButtonDown;
                    }

                    startY += diam + rastNode;
                }
                nodes[i] = curN;
                startX += dx;
                if (startYMax < startY) startYMax = startY;
                if(i != 0)
                    startY = startYMax / 2 - neuralNet.Flat.LayerCounts[i - 1] * (rastNode + diam) / 2;
            }

            string tmpWeigth;
            int countN;
            for (int i = neuralNet.LayerCount - 1; i > 0; i--)
            {
                countN = countN = neuralNet.Flat.LayerCounts[i - 1];
                if (i - 1 == neuralNet.LayerCount - 2 && neuralNet.GetLayerBiasActivation(i - 1) > 0)
                    countN -= 1;
                for (int x = 0; x < neuralNet.Flat.LayerCounts[i]; x++)
                {

                    for (int y = 0; y < countN; y++)
                    {
                        tmpWeigth = neuralNet.GetWeight(neuralNet.LayerCount - i - 1, x, y).ToString("F4");
                        var link = DiagramHelper.CreateLink(diagram, nodes[i][x], nodes[i - 1][y], tmpWeigth);
                        link.MouseLeftButtonDown += linkSelect_MouseLeftButtonDown;
                    }
                }
            }
        }
开发者ID:neismit,项目名称:emds,代码行数:64,代码来源:MainWindow.xaml.cs


注:本文中的Diagram.ClearAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。