Ejemplo n.º 1
0
        protected void prepareLegend(MatrixIncViewModel vm)
        {
            for (int x = 0; x < vm.NodeCount; ++x)
            {
                var Label = new MatrixControlItem();
                var ivm   = new MatrixItemViewModel()
                {
                    Text       = (x + 1).ToString(),
                    Hint       = "",
                    Background = new SolidColorBrush(Colors.Gray),
                };
                Label.DataContext = ivm;

                MatrixIncGrid.Children.Add(Label);
                Grid.SetRow(Label, 0);
                Grid.SetColumn(Label, x + 1);
            }

            for (int y = 0; y < vm.ConnectionCount; ++y)
            {
                var Label = new MatrixControlItem();
                var ivm   = new MatrixItemViewModel()
                {
                    Text       = (y + 1).ToString(),
                    Hint       = "",
                    Background = new SolidColorBrush(Colors.Gray)
                };
                Label.DataContext = ivm;
                MatrixIncGrid.Children.Add(Label);
                Grid.SetRow(Label, y + 1);
                Grid.SetColumn(Label, 0);
            }
        }
Ejemplo n.º 2
0
        private void prepareMatrixInc()
        {
            MatrixIncViewModel vm = new MatrixIncViewModel(Graph.NodesNr, Graph.ConnectionCount);

            var matrixInc = Converter.ConvertToSMatrixInc(Converter.ConvertToSList(Graph));

            for (int connection = 0; connection < matrixInc.ConnectNr; ++connection)
            {
                for (int node = 0; node < matrixInc.NodesNr; ++node)
                {
                    vm.Connections[node, connection] = matrixInc.GetConnectionArray(node, connection) ? 1 : 0;
                }
            }

            MatrixIncControl.DataContext = vm;
        }
Ejemplo n.º 3
0
 protected virtual void createLabels(MatrixIncViewModel vm)
 {
     for (int node = 0; node < vm.NodeCount; ++node)
     {
         for (int connection = 0; connection < vm.ConnectionCount; ++connection)
         {
             MatrixControlItem item = new MatrixControlItem();
             var ivm = new MatrixItemViewModel()
             {
                 Text       = vm.Connections[node, connection].ToString(),
                 Background = vm.Connections[node, connection] != 0
                 ? new SolidColorBrush(Color.FromArgb(50, 0, 255, 0)) : new SolidColorBrush(Colors.Transparent),
                 Visibility = Visibility.Collapsed,
                 Hint       = string.Format("[{0}, {1}] - {2}", connection, node, vm.Connections[node, connection])
             };
             item.DataContext = ivm;
             MatrixIncGrid.Children.Add(item);
             Grid.SetRow(item, connection + 1);
             Grid.SetColumn(item, node + 1);
         }
     }
 }