Пример #1
0
        void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox box = sender as TextBox;

            if (e.Key == Key.Enter)
            {
                Label lbl = new Label();
                lbl.Content = box.Text;
                SilverlightVertice vertice = box.Tag as SilverlightVertice;

                if (vertice != null)
                {
                    vertice.Weight = int.Parse(box.Text);
                }

                lbl.Foreground = new SolidColorBrush(Color.FromArgb((byte)255, (byte)255, (byte)0, (byte)0));
                lbl.FontSize   = 9;
                lbl.Width      = 20;
                lbl.Height     = 20;
                lbl.SetValue(Canvas.LeftProperty, (double)box.GetValue(Canvas.LeftProperty) + 5);
                lbl.SetValue(Canvas.TopProperty, (double)box.GetValue(Canvas.TopProperty) + 5);
                lbl.SetValue(Canvas.ZIndexProperty, 2);
                this.LayoutRoot.Children.Remove(box);
                this.LayoutRoot.Children.Add(lbl);
            }
        }
Пример #2
0
        private void AddNewVertice(SilverlightEdge edge1, SilverlightEdge edge2)
        {
            if (!Vertice.CheckIfVerticeExist(edge1.Edge, edge2.Edge))
            {
                SilverlightVertice vertice = new SilverlightVertice(edge1.Position, edge2.Position);
                vertice.Line.MouseLeftButtonDown += new MouseButtonEventHandler(line_MouseLeftButtonDown);

                edge1.Edge.AddVertice(new Vertice(edge2.Edge));
                edge2.Edge.AddVertice(new Vertice(edge1.Edge));
                this.LayoutRoot.Children.Add(vertice.Line);
            }
        }
Пример #3
0
        private void DrawLines(List <int> order)
        {
            for (int i = 0; i < order.Count - 1; i++)
            {
                SilverlightVertice vertice = new SilverlightVertice(_slEdges[order[i]].Position, _slEdges[order[i + 1]].Position);
                vertice.Color = _slEdges[order[i]].Color;
                this.LayoutRoot.Children.Add(vertice.Line);
            }

            SilverlightVertice vertice1 = new SilverlightVertice(_slEdges[order[order.Count - 1]].Position, _slEdges[order[0]].Position);

            vertice1.Color = _slEdges[order[order.Count - 1]].Color;
            this.LayoutRoot.Children.Add(vertice1.Line);
        }
Пример #4
0
        private void DrawLines(List <int> order, Cluster cluster)
        {
            for (int i = 0; i < order.Count - 1; i++)
            {
                SilverlightEdge    edge1   = cluster.Edges.Where(x => x.EdgeNumber == order[i]).First();
                SilverlightEdge    edge2   = cluster.Edges.Where(x => x.EdgeNumber == order[i + 1]).First();
                SilverlightVertice vertice = new SilverlightVertice(edge1.Position, edge2.Position);
                vertice.Color = cluster.Color;
                this.LayoutRoot.Children.Add(vertice.Line);
            }
            SilverlightEdge    edge11   = cluster.Edges.Where(x => x.EdgeNumber == order[order.Count - 1]).First();
            SilverlightEdge    edge22   = cluster.Edges.Where(x => x.EdgeNumber == order[0]).First();
            SilverlightVertice vertice1 = new SilverlightVertice(edge11.Position, edge22.Position);

            vertice1.Color = cluster.Color;
            this.LayoutRoot.Children.Add(vertice1.Line);
        }