Exemplo n.º 1
0
        private void GetRadiusesOfNode(CircleDiagramNode node,
                                       out float firstRadius, out float secondRadius)
        {
            try
            {
                if (node == null)
                {
                    firstRadius  = 0;
                    secondRadius = 0;
                    return;
                }

                var ringThickness = GetRingThickness();

                if (node.StartCircleNumber == 0)
                {
                    firstRadius  = ringThickness * (node.CountCircles * 2 - 1);
                    secondRadius = 0;
                }
                else
                {
                    firstRadius  = ringThickness * (node.StartCircleNumber * 2 + 1);
                    secondRadius = ringThickness * (node.StartCircleNumber * 2 - (node.CountCircles - 1) * 2);
                }
            }
            catch (Exception)
            {
                firstRadius  = 0;
                secondRadius = 0;
            }
        }
Exemplo n.º 2
0
 public static void SetNodePropertiesToCircleDiagramNode(
     this CircleDiagramNodeProperies nodePropeties, CircleDiagramNode node)
 {
     if (node == null || nodePropeties == null)
     {
         return;
     }
     node.ChangeParametersValues(nodePropeties.Text, nodePropeties.StartAngle,
                                 nodePropeties.SweepAngle, nodePropeties.StartCircleNumber,
                                 nodePropeties.CountCircles, new SolidBrush(nodePropeties.BackgroundColor),
                                 new SolidBrush(nodePropeties.TextColor), nodePropeties.TextFont);
 }
Exemplo n.º 3
0
 private List <CircleDiagramRelationship> GetOrderedOutRelationshipsForNode(
     CircleDiagramNode node)
 {
     if (CircleDiagramModel == null || !CircleDiagramModel.IsCorrect() || node == null)
     {
         return(new List <CircleDiagramRelationship>());
     }
     return(CircleDiagramModel.Relationships
            .Where(g => g.BeginNode == node)
            .OrderBy(g => g.EndNode.StartCircleNumber + g.EndNode.SweepAngle / 2)
            .ToList());
 }
Exemplo n.º 4
0
        private void DrawNode(CircleDiagramNode circleDiagramNode, Graphics graphics)
        {
            if (circleDiagramNode == null)
            {
                return;
            }
            if (graphics == null)
            {
                return;
            }
            if (circleDiagramNode.StartCircleNumber >= CircleDiagramModel.CountLevels)
            {
                return;
            }
            if (circleDiagramNode.CountCircles <= 0)
            {
                return;
            }
            if (circleDiagramNode.StartCircleNumber != 0 &&
                circleDiagramNode.StartCircleNumber + 1 - circleDiagramNode.CountCircles < 0)
            {
                return;
            }

            float radius1, radius2;

            GetRadiusesOfNode(circleDiagramNode, out radius1, out radius2);

            var actualPen = (Pen)CircleDiagramModel.NodeBorder.Clone();

            actualPen.Width = actualPen.Width * PercentageScale;

            if (circleDiagramNode.StartCircleNumber == 0)
            {
                var radius = radius1 >= radius2 ? radius1 : radius2;
                graphics.FillEllipse(circleDiagramNode.Background, -radius, -radius, radius * 2, radius * 2);
                graphics.DrawEllipse(actualPen, -radius, -radius, radius * 2, radius * 2);
                graphics.DrawStringInBox(circleDiagramNode.Text, -radius, -radius, radius * 2, radius * 2,
                                         circleDiagramNode.TextBrush, GetModifiedFont(circleDiagramNode.TextFont));
                return;
            }

            graphics.FillTruncSector(new PointF(0, 0), radius2 - 1, radius1 + 1,
                                     circleDiagramNode.StartAngle, circleDiagramNode.SweepAngle, circleDiagramNode.Background);

            graphics.DrawTruncSector(new PointF(0, 0), radius1, radius2,
                                     circleDiagramNode.StartAngle, circleDiagramNode.SweepAngle, actualPen);

            graphics.DrawStringAround(circleDiagramNode.Text, new PointF(0, 0), radius1, radius2,
                                      circleDiagramNode.StartAngle, circleDiagramNode.SweepAngle, circleDiagramNode.TextBrush,
                                      GetModifiedFont(circleDiagramNode.TextFont), true);
        }
Exemplo n.º 5
0
        private void AddNode()
        {
            if (CircleDiagramModel == null || !CircleDiagramModel.IsCorrect())
            {
                return;
            }

            var newNode = new CircleDiagramNode("Новая вершина",
                                                0, 0, 0, 1, new SolidBrush(Color.Red), new SolidBrush(Color.Black), new Font("Verdana", 10));

            if (CircleDiagramModel.AddNode(newNode))
            {
                lvNodes.AddCircleDiagramNode(newNode);
            }
            RedrawDiagramOnControl();
        }
Exemplo n.º 6
0
 public static void GetNodePropertiesFromCircleDiagramNode(this CircleDiagramNodeProperies nodePropeties,
                                                           CircleDiagramNode node)
 {
     if (node == null || nodePropeties == null)
     {
         return;
     }
     nodePropeties.Name              = node.Name;
     nodePropeties.BackgroundColor   = SerializeUtils.BrushToColor(node.Background);
     nodePropeties.StartAngle        = node.StartAngle;
     nodePropeties.SweepAngle        = node.SweepAngle;
     nodePropeties.StartCircleNumber = node.StartCircleNumber;
     nodePropeties.CountCircles      = node.CountCircles;
     nodePropeties.Text              = node.Text;
     nodePropeties.TextColor         = SerializeUtils.BrushToColor(node.TextBrush);
     nodePropeties.TextFont          = node.TextFont;
 }
        public void AddCircleDiagramNode(CircleDiagramNode node)
        {
            var lvItem = new ListViewItem {
                Text = node.Text.Trim().Replace("\r\n", " "), Name = node.Name
            };
            var targetGroup = Groups[node.StartCircleNumber.ToString()]
                              ?? Groups[Consts.NoneGroup];

            if (targetGroup != null)
            {
                lvItem.Group = targetGroup;
            }
            var newListItem = Items.Add(lvItem);

            SelectedIndices.Clear();
            SelectedIndices.Add(newListItem.Index);
        }
        private static XmlNode GetXmlNode(CircleDiagramNode node)
        {
            if (node == null)
            {
                return(null);
            }

            var name              = node.Name;
            var text              = node.Text;
            var startAngle        = node.StartAngle;
            var sweepAngle        = node.SweepAngle;
            var startCircleNumber = node.StartCircleNumber;
            var countCircles      = node.CountCircles;
            var backgroundColor   = SerializeUtils.BrushToInt(node.Background);
            var textColor         = SerializeUtils.BrushToInt(node.TextBrush);
            var textFont          = SerializeUtils.FontToString(node.TextFont);

            return(new XmlNode(name, text, startAngle, sweepAngle,
                               startCircleNumber, countCircles, backgroundColor, textColor, textFont));
        }
Exemplo n.º 9
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var selBeginItem = cbBeginNode.SelectedItem;
            var selEndItem   = cbEndNode.SelectedItem;

            if (selBeginItem == null ||
                !(selBeginItem is ComboBoxItem) ||
                selEndItem == null ||
                !(selEndItem is ComboBoxItem))
            {
                BeginNode = null;
                EndNode   = null;
                MessageBox.Show(@"Необходимо выбрать начальную и конечную вершины");
                DialogResult = DialogResult.None;
                return;
            }

            BeginNode = (selBeginItem as ComboBoxItem).CircleDiagramNode;
            EndNode   = (selEndItem as ComboBoxItem).CircleDiagramNode;

            if (Relationships
                .SingleOrDefault(g => g.BeginNode.Name == BeginNode.Name &&
                                 g.EndNode.Name == EndNode.Name) != null)
            {
                BeginNode = null;
                EndNode   = null;
                MessageBox.Show(@"Такая связь уже существует");
                DialogResult = DialogResult.None;
                return;
            }

            if (BeginNode.StartCircleNumber <= EndNode.StartCircleNumber)
            {
                MessageBox.Show(@"Уровень начальной вершины должен быть больше уровня конечной вершины");
                DialogResult = DialogResult.None;
            }
        }
Exemplo n.º 10
0
 public BuldingRelationshipsNode(CircleDiagramNode node)
 {
     Node             = node;
     InRelationships  = new List <CircleDiagramRelationship>();
     OutRelationships = new List <CircleDiagramRelationship>();
 }
Exemplo n.º 11
0
 public ComboBoxItem(CircleDiagramNode circleDiagramNode)
 {
     CircleDiagramNode = circleDiagramNode;
 }