public MainWindow()
        {
            GroupAddressesProvider.SeedList();
            Container = BuildContainer();
            mesh      = Container.Resolve <IBluetoothMeshContext>();

            foreach (var server in mesh.NodeServers)
            {
                server.SetDispacher(Container.Resolve <ICommandDispatcher>());
            }

            Node clientNode = mesh.Nodes[0];

            bearer      = mesh.NodeServers.ToList().FirstOrDefault(x => x.Node.Id == 1);
            serverModel = (ConfigurationClientModel)clientNode.Elements[ElementType.primary].Models[ModelType.ConfigurationClient];

            InitializeComponent();

            Providers.LayoutProvider.DrawGrid(canvas);
            Providers.LayoutProvider.DrawGrid(canvas);
            Providers.LayoutProvider.DrawConnections(canvas, mesh);
            Providers.LayoutProvider.DrawNodes(canvas, mesh);
            Providers.LayoutProvider.ColorNodes();
            Providers.LayoutProvider.SignNodes(canvas, mesh);

            Setup();
        }
예제 #2
0
        public static void IssuingNodeSetter(object sender, IBluetoothMeshContext context)
        {
            var           combobox = sender as ComboBox;
            List <string> dataList = new List <string>();

            foreach (var node in context.Nodes)
            {
                dataList.Add(node.Id.ToString());
            }
            combobox.ItemsSource   = dataList;
            combobox.SelectedIndex = 0;
        }
예제 #3
0
        private static List <Node> GetAllInRange(Node baseNode, IBluetoothMeshContext mesh)
        {
            List <Node> result = new List <Node>();

            foreach (Node node in mesh.Nodes)
            {
                if (node.Posistion.DistanceTo(baseNode.Posistion) <= baseNode.Range && node.Id != baseNode.Id)
                {
                    result.Add(node);
                }
            }
            return(result);
        }
예제 #4
0
        public static void SignNodes(Canvas canvas, IBluetoothMeshContext mesh)
        {
            foreach (Node node in mesh.Nodes)
            {
                TextBlock textBlock = new TextBlock
                {
                    Text = node.Id.ToString()
                };

                Canvas.SetLeft(textBlock, node.Posistion.X * 10 - CircleSize / 6);
                Canvas.SetTop(textBlock, node.Posistion.Y * 10 - CircleSize / 3);
                canvas.Children.Add(textBlock);
            }
        }
예제 #5
0
        public SenderViewModel(INodeRepository nodeRepository, IAddressRepository addressRepository, IBluetoothMeshContext context, IEventAggregator eventAggregator)
        {
            _nodeRepository = nodeRepository;
            Nodes           = new List <NodeModel>();

            nodeRepository.GetAll().ToList().ForEach(x => Nodes.Add(new NodeModel(x)));
            _addressRepository   = addressRepository;
            _context             = context;
            this.eventAggregator = eventAggregator;

            SelectedNode          = new NodeModel(nodeRepository.Get(1));
            SelectedProcedureType = Procedure.DefaultTTL.ToString();
            SelectedMessageType   = MessageType.GET.ToString();
            SuccedMessagesCounter = 0;
        }
예제 #6
0
        public static void DrawNodes(Canvas canvas, IBluetoothMeshContext mesh)
        {
            foreach (Node node in mesh.Nodes)
            {
                Ellipse ellipse = new Ellipse()
                {
                    Width = CircleSize, Height = CircleSize, Fill = Brushes.White
                };
                NodeIcons.Add(new KeyValuePair <Node, Ellipse>(node, ellipse));
                ellipse.MouseDown += Ellipse_Click;
                ellipse.Name       = "e" + Convert.ToString(node.Id);
                canvas.Children.Add(ellipse);

                Canvas.SetLeft(ellipse, node.Posistion.X * 10 - ellipse.Width / 2);
                Canvas.SetTop(ellipse, node.Posistion.Y * 10 - ellipse.Height / 2);
            }
        }
예제 #7
0
        public ble()
        {
            InitializeComponent();
            GroupAddressesProvider.SeedList();
            Container = BuildContainer();
            mesh      = Container.Resolve <IBluetoothMeshContext>();

            foreach (var server in mesh.NodeServers)
            {
                server.SetDispacher(Container.Resolve <ICommandDispatcher>());
            }

            Node clientNode = mesh.Nodes[0];

            bearer      = mesh.NodeServers.ToList().FirstOrDefault(x => x.Node.Id == 1);
            serverModel = (ConfigurationClientModel)clientNode.Elements[ElementType.primary].Models[ModelType.ConfigurationClient];
        }
예제 #8
0
        public static void DrawConnections(Canvas canvas, IBluetoothMeshContext mesh)
        {
            foreach (Node node in mesh.Nodes)
            {
                IEnumerable <Node> nodesInRange = GetAllInRange(node, mesh);
                foreach (Node nodeInRange in nodesInRange)
                {
                    Line line = new Line
                    {
                        Stroke = Brushes.Black,

                        X1 = node.Posistion.X * 10,
                        X2 = nodeInRange.Posistion.X * 10,
                        Y1 = node.Posistion.Y * 10,
                        Y2 = nodeInRange.Posistion.Y * 10,

                        StrokeThickness = LineThiccccness
                    };
                    canvas.Children.Add(line);
                }
            }
        }
 public AddressRepository(IBluetoothMeshContext context)
 {
     _context = context;
 }
 public ModelRepository(IBluetoothMeshContext context)
 {
     _context = context;
 }
예제 #11
0
        public static void AddressSetter(object sender, ComboBox target, TextBox textTarget, IBluetoothMeshContext context)
        {
            var    comboBox = sender as ComboBox;
            string address  = comboBox.SelectedItem as string;

            Enum.TryParse(address, out AddressType addressType);
            List <string> dataList;

            switch (addressType)
            {
            case AddressType.Unassigned:
                textTarget.Visibility = System.Windows.Visibility.Hidden;
                target.Visibility     = System.Windows.Visibility.Hidden;
                break;

            case AddressType.Unicast:
                dataList = new List <string>();
                foreach (var node in context.Nodes)
                {
                    dataList.Add(node.Id.ToString());
                }
                textTarget.Visibility = System.Windows.Visibility.Visible;
                target.Visibility     = System.Windows.Visibility.Visible;
                target.ItemsSource    = dataList;
                target.SelectedIndex  = 0;
                break;

            case AddressType.Virtual:
                dataList = new List <string>();
                foreach (var model in context.Nodes.SelectMany(x => x.Elements.Values).SelectMany(x => x.Models.Values))
                {
                    //dataList.Add(model.Address.GuidId.ToString());
                }
                textTarget.Visibility = System.Windows.Visibility.Visible;
                target.Visibility     = System.Windows.Visibility.Visible;
                target.ItemsSource    = dataList;
                target.SelectedIndex  = 0;
                break;

            case AddressType.Group:
                dataList = new List <string>();
                foreach (var addr in GroupAddressesProvider.Dictionary)
                {
                    dataList.Add(addr.Key);
                }
                textTarget.Visibility = System.Windows.Visibility.Visible;
                target.Visibility     = System.Windows.Visibility.Visible;
                target.ItemsSource    = dataList;
                target.SelectedIndex  = 0;
                break;

            default:
                break;
            }
        }
예제 #12
0
 public ElementRepository(IBluetoothMeshContext context)
 {
     _context = context;
 }