Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.file_detail);

            _userName   = Intent.GetStringExtra(AppConstants.UserName);
            _ip         = Intent.GetStringExtra(AppConstants.HostIp);
            _portNumber = Intent.GetIntExtra(AppConstants.PortNumber, 8080);
            _client     = new FileSharingClient(_ip, _portNumber);

            _fileName = Intent.GetStringExtra(AppConstants.FileName);
            _image    = FindViewById <MvxCachedImageView>(Resource.Id.imgMain);

            _image.SetImageDrawable(_fileName.HasImageExtension()
                                ? ContextCompat.GetDrawable(Application.Context, Resource.Drawable.default_image)
                                : ContextCompat.GetDrawable(Application.Context, Resource.Drawable.default_file));

            _closeBtn        = FindViewById <ImageView>(Resource.Id.closeBtn);
            _closeBtn.Click += CloseView;

            _downloadBtn        = FindViewById <ImageView>(Resource.Id.downloadBtn);
            _downloadBtn.Click += Download;

            _imageData = _client.GetImage(_userName, _fileName).FileData;
            ImageService.Instance.LoadStream(GetStream).DownSample(500).Into(_image);
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            _userName   = Intent.GetStringExtra(AppConstants.UserName);
            _ip         = Intent.GetStringExtra(AppConstants.HostIp);
            _portNumber = Intent.GetIntExtra(AppConstants.PortNumber, 8080);
            _client     = new FileSharingClient(_ip, _portNumber);
            CrossCurrentActivity.Current.Init(this, savedInstanceState);
            CrossMedia.Current.Initialize();

            _rvFiles       = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _uploadFileBtn = FindViewById <ImageView>(Resource.Id.btnUpload);
            _takePhotoBtn  = FindViewById <ImageView>(Resource.Id.btnTakePhoto);

            _files = _client.GetFileNames(_userName);
            if (_files != null)
            {
                _fileAdapter = new FileAdapter(_files, _ip, _portNumber, _userName);
                _rvFiles.SetLayoutManager(new GridLayoutManager(this, 4));
                _rvFiles.SetAdapter(_fileAdapter);
            }

            _uploadFileBtn.Click += UploadFileBtn;
            _takePhotoBtn.Click  += TakePhoto;
        }
Exemplo n.º 3
0
        public ChatForm()
        {
            selectedDialog = DefaultSelectedDialog;
            InitializeComponent();

            client                      = new ClientClass(new BinaryMessagesSerializer());
            fileSharingClient           = new FileSharingClient();
            client.ReceiveMessageEvent += ShowReceivedMessage;
            client.UnreadMessageEvent  += UnreadMessageHandler;
            client.ReadMessageEvent    += ReadMessageHandler;
            client.DeleteRoomEvent     += HandleDeletedRoomUi;
            fileSharingClient.UpdateFilesToLoadListEvent += UpdateFilesToLoadList;
            client.SearchServers();
            VisibleSettings(false);
        }
Exemplo n.º 4
0
 private void btConnect_Click(object sender, EventArgs e)
 {
     client            = new Client();
     fileSharingClient = new FileSharingClient();
     fileSharingClient.UpdateFilesListEvent += UpdateAttachedFiles;
     client.MessageReceieved += HandleMess;
     client.SendUDPRequest();
     if (client.IsConnected)
     {
         cbIsConnected.Checked = true;
         tbIPAdress.Text       = ((IPEndPoint)client.TCPsocket.RemoteEndPoint).Address.ToString();
         tbName.ReadOnly       = tbPassword.ReadOnly = true;
         btConnect.Enabled     = false;
         btDisconnect.Enabled  = true;
         int hash = Math.Abs(tbPassword.Text.GetHashCode());
         client.JoinChat(tbName.Text, Math.Abs(tbPassword.Text.GetHashCode()));
     }
 }
Exemplo n.º 5
0
        private void Login(object sender, EventArgs e)
        {
            _userName = string.IsNullOrEmpty(_edtUserName.Text) ? "quoc" : _edtUserName.Text;
            _password = string.IsNullOrEmpty(_edtPassword.Text) ? "123" : _edtPassword.Text;
            _hostIp   = string.IsNullOrEmpty(_edtHostIp.Text) ? "10.0.143.67" : _edtHostIp.Text;
            _port     = string.IsNullOrEmpty(_edtPort.Text) ? 8080 : Convert.ToInt32(_edtPort.Text);

            var result = new FileSharingClient(_hostIp, _port).Login(_userName, _password);

            if ("success".Equals(result))
            {
                var intent = new Intent(this, typeof(HomeView));
                intent.PutExtra(AppConstants.UserName, _userName);
                intent.PutExtra(AppConstants.HostIp, _hostIp);
                intent.PutExtra(AppConstants.PortNumber, _port);
                StartActivity(intent);
            }
        }