/// <summary>
        /// Initializes a new instance of the <see cref="ClientViewModel" /> class.
        /// </summary>
        /// <exception cref="System.Exception">
        /// Wrong application start argument
        /// </exception>
        public ClientViewModel()
        {
            try
            {
                var args = Environment.GetCommandLineArgs();
                int i = 0; //This is dumy variable for TryParse
                if (args.Length < 2)
                    throw new Exception("Wrong application start argument");
                else if (!int.TryParse(args[1], out i))
                    throw new Exception("Wrong application start argument");

                this.Streams = new ObservableCollection<StreamDataViewModel>();
                this.ClientSetUpProccess = new ClientSetUpProcess("..\\..\\..\\Configs\\NetworkClient\\clientConfig" + args[1] + ".xml");
                this.ClientSetUpProccess.StreamsCreated += new StreamsCreatedHandler(OnStreamsCreated);
                this.ClientSetUpProccess.StreamCreated += new StreamCreatedHandler(OnStreamCreated);
                this.ClientSetUpProccess.StartClientProcess();
                this.ClientSetUpProccess.ClientNode.StreamAdded += new StreamChangedHandler(OnStreamAdded);
                this.ClientSetUpProccess.ClientNode.StreamRemoved += new StreamChangedHandler(OnStreamRemoved);
                this.ClientSetUpProccess.ClientNode.RegisterDataListener(new HandleClientData(OnHandleClientData));
                this.SendMessage = new ExternalCommand(SendNewMessage, true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientViewModel" /> class.
        /// </summary>
        /// <exception cref="System.Exception">
        /// Wrong application start argument
        /// </exception>
        public ClientViewModel()
        {
            try
            {
                var args = Environment.GetCommandLineArgs();
                int i    = 0; //This is dumy variable for TryParse
                if (args.Length < 2)
                {
                    throw new Exception("Wrong application start argument");
                }
                else if (!int.TryParse(args[1], out i))
                {
                    throw new Exception("Wrong application start argument");
                }

                this.Streams             = new ObservableCollection <StreamDataViewModel>();
                this.ClientSetUpProccess = new ClientSetUpProcess("..\\..\\..\\Configs\\NetworkClient\\clientConfig" + args[1] + ".xml");
                this.ClientSetUpProccess.StreamsCreated += new StreamsCreatedHandler(OnStreamsCreated);
                this.ClientSetUpProccess.StreamCreated  += new StreamCreatedHandler(OnStreamCreated);
                this.ClientSetUpProccess.StartClientProcess();
                this.ClientSetUpProccess.ClientNode.StreamAdded   += new StreamChangedHandler(OnStreamAdded);
                this.ClientSetUpProccess.ClientNode.StreamRemoved += new StreamChangedHandler(OnStreamRemoved);
                this.ClientSetUpProccess.ClientNode.RegisterDataListener(new HandleClientData(OnHandleClientData));
                this.SendMessage = new ExternalCommand(SendNewMessage, true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }