Пример #1
0
        public void Refresh()
        {
            {
                CameraTabs.Clear();
                CameraTabs.Add(SimpleIoc.Default.GetInstance<CamerasViewModel>());
                foreach (CameraViewModel scvm in SimpleIoc.Default.GetAllCreatedInstances<CameraViewModel>())
                {
                    CameraTabs.Add(scvm);
                }
                IEditableCollectionView itemsView = (IEditableCollectionView)CollectionViewSource.GetDefaultView(CameraTabs);
                itemsView.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;
            }

            {
                MotionControllerTabs.Clear();
                MotionControllerTabs.Add(SimpleIoc.Default.GetInstance<MotionControllersViewModel>());
                foreach (MotionControllerViewModel mcvm in SimpleIoc.Default.GetAllCreatedInstances<MotionControllerViewModel>())
                {
                    MotionControllerTabs.Add(mcvm);
                }
                IEditableCollectionView itemsView = (IEditableCollectionView)CollectionViewSource.GetDefaultView(MotionControllerTabs);
                itemsView.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;
            }

            {
                ServerTabs.Clear();
                ServerTabs.Add(SimpleIoc.Default.GetInstance<ServerViewModel>());
                IEditableCollectionView itemsView = (IEditableCollectionView)CollectionViewSource.GetDefaultView(ServerTabs);
                itemsView.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;
            }
        } // Refresh
Пример #2
0
        /// <summary>
        /// Funzione che crea un nuovo tab
        /// </summary>
        /// <param name="client"></param>
        /// <param name="stream"></param>
        /// <param name="address"></param>
        public void NewTab(TcpClient client, NetworkStream stream, String address)
        {
            DynamicTabItem      tab = new DynamicTabItem(this);
            ServerTabManagement s   = new ServerTabManagement(tab);

            tab.ServerTab = s;

            // Il titolo del nuovo tab ed il suo host remoto corrispondono all'indirizzo del server
            tab.DynamicHeader = tab.RemoteHost = address;

            if (address.StartsWith("127."))
            {
                tab.DynamicHeader = "Loopback";
            }
            else
            {
                Dns.BeginGetHostEntry(address, new AsyncCallback((IAsyncResult ar) =>
                {
                    try
                    {
                        string host = Dns.EndGetHostEntry(ar).HostName;
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                        {
                            tab.DynamicHeader = host;
                        }));
                    }
                    catch (SocketException)
                    {
                        Console.WriteLine("Server {0}: Nessun host trovato", address);
                    }
                }), null);
            }

            s.Connection = client;
            s.Stream     = stream;
            s.StartServerDataExchange();
            tab.Content = s;

            // Aggiunta del nuovo tab alla lista
            ServerTabs.Add(tab);

            // Evidenziazione dell'ultimo tab creato
            ServerTabControl.SelectedIndex = ServerTabs.Count - 1;

            if (ServerTabs.Count > 1)
            {
                ForegroundAppsBox.IsEnabled = true;
            }
        }