Beispiel #1
0
        /// <summary>
        /// Remove handler from observable collection.
        /// </summary>
        /// <param name="handler">Handler to remove.</param>
        public void RemoveHandler(string handler)
        {
            string[] args = { handler };
            //Create command for closing handler.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.CloseHandler, args, "");

            //Send command.
            TCPClientChannel.GetTCPClientChannel().Send(command);
            //Remove handler from list.
            Handlers.Remove(handler);
        }
Beispiel #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public SettingsModel()
        {
            //Create command.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.GetConfigCommand, null, "");

            //Add function to event.
            TCPClientChannel.GetTCPClientChannel().NotifyMessage += UpdateByNotification;
            //Send command.
            string settingsMsg = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);

            //Update notification.
            UpdateByNotification(settingsMsg);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public MainWindowViewModel()
 {
     //Create main window model.
     this.MainWindowModel = new MainWindowModel();
     //Check if there is connection.
     if (VMIsConnected == IsConnectedEnum.Connected)
     {
         //Create constructor for models.
         this.SettingViewModel = new SettingViewModel();
         this.LogViewModel     = new LogViewModel();
         //Listen to server.
         TCPClientChannel.GetTCPClientChannel().ListenToServer();
     }
 }
Beispiel #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public LogModel()
        {
            LogMessages = new ObservableCollection <MessageRecievedEventArgs>();
            // Set new command for creating log.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.LogCommand, null, "");

            // Adding notify function.
            TCPClientChannel.GetTCPClientChannel().NotifyMessage += UpdateByNotification;
            // Send command and recevie back log history.
            string settingsMsg = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);

            // Add log history to log.
            UpdateByNotification(settingsMsg);
        }
Beispiel #5
0
        /// <summary>
        /// constructor.
        /// </summary>
        public ImageServiceDetails()
        {
            string message;
            ConfigurationRecieveEventArgs returnParam;

            UpdateStudentList();

            //Create command to get echo from server.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.EchoCommand, null, "");

            try
            {
                TCPClientChannel.GetTCPClientChannel().DisconnectClientChannel();
                //Send echo command.
                message = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);
                //Deserialize return object.
                returnParam = JsonConvert.DeserializeObject <ConfigurationRecieveEventArgs>(message);
                //Check if we get ack.
                if ((ConfigurationEnum)returnParam.ConfigurationID == ConfigurationEnum.Ack)
                {
                    ImageServiceStatus = "ON";
                }
            }
            catch (Exception e)
            {
                //If there was exception - it means that there is no connection.
                ImageServiceStatus = "OFF";
            }

            try
            {
                command = new CommandRecievedEventArgs((int)CommandEnum.GetConfigCommand, null, "");
                //Send GetConfig command.
                message = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);
                //Deserialize return object.
                returnParam   = JsonConvert.DeserializeObject <ConfigurationRecieveEventArgs>(message);
                OutputDirPath = returnParam.Args[0];
                //Create list of extention
                m_filesExtention = new List <string>
                {
                    ".jpg", ".png", ".gif", ".bmp"
                };

                UpdateNumberOfPictures();
            }
            catch (Exception)
            {
                NumberOfPictures = 0;
            }
        }
Beispiel #6
0
 /// <summary>
 /// constructor.
 /// </summary>
 public LogInfoModel()
 {
     LogMessages = new List <Log>();
     try
     {
         // Set new command for creating log.
         CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.LogCommand, null, "");
         // Send command and recevie back log history.
         TCPClientChannel.GetTCPClientChannel().DisconnectClientChannel();
         string settingsMsg = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);
         // Add log history to log.
         UpdateByNotification(settingsMsg);
         //TCPClientChannel.GetTCPClientChannel().ListenToServer();
     }
     catch (Exception)
     {
     }
 }
Beispiel #7
0
        /// <summary>
        /// constructor.
        /// </summary>
        public ConfigModel()
        {
            //Create command.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.GetConfigCommand, null, "");

            try
            {
                //Add function to event.
                //TCPClientChannel.GetTCPClientChannel().NotifyMessage += UpdateByNotification;
                TCPClientChannel.GetTCPClientChannel().DisconnectClientChannel();
                //Send command.
                string settingsMsg = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);
                //Update notification.
                UpdateByNotification(settingsMsg);
                //TCPClientChannel.GetTCPClientChannel().ListenToServer();
            }
            catch (Exception)
            {
                string[] emptyArgs = { " ", " ", " ", " " };
                SetSettings(emptyArgs);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Remove handler from observable collection.
        /// </summary>
        /// <param name="handler">Handler to remove.</param>
        public HandlerRemoval RemoveHandler(string handler)
        {
            string[] args = { handler };
            //Create command for closing handler.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.CloseHandler, args, "");
            //Send command.
            string returnMessage = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);

            if (UpdateByNotification(returnMessage))
            {
                Thread.Sleep(200);
                if (Handlers.Contains(handler))
                {
                    return(HandlerRemoval.FailedToRemove);
                }
                else
                {
                    return(HandlerRemoval.Removed);
                }
            }
            return(HandlerRemoval.FailedToRemove);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainWindowModel()
        {
            //Create command to get echo from server.
            CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.EchoCommand, null, "");

            try
            {
                //Send echo command.
                string message = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);
                //Deserialize return object.
                ConfigurationRecieveEventArgs returnParam =
                    JsonConvert.DeserializeObject <ConfigurationRecieveEventArgs>(message);
                //Check if we get ack.
                if ((ConfigurationEnum)returnParam.ConfigurationID == ConfigurationEnum.Ack)
                {
                    IsConnected = IsConnectedEnum.Connected;
                }
            }
            catch (Exception)
            {
                //If there was exception - it means that there is no connection.
                IsConnected = IsConnectedEnum.NotConnected;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public PhotosModel()
        {
            string message;
            ConfigurationRecieveEventArgs returnParam;

            PhotosList = new List <Photo>();

            try
            {
                //Initialize command.
                CommandRecievedEventArgs command = new CommandRecievedEventArgs((int)CommandEnum.GetConfigCommand, null, "");
                //Send GetConfig command.
                message = TCPClientChannel.GetTCPClientChannel().SendAndReceive(command);
                //Deserialize return object.
                returnParam = JsonConvert.DeserializeObject <ConfigurationRecieveEventArgs>(message);
                //Get outputdir.
                OutputDirPath = returnParam.Args[0];
                //Update photos list.
                UpdatePhotosList();
            }
            catch (Exception)
            {
            }
        }