예제 #1
0
        public void Send(Context context, string file)
        {
            SaveSettings settings = new SaveSettings();

            settings.Load();
            if (string.IsNullOrWhiteSpace(settings.IPAdress))
            {
                Toast.MakeText(context, "Please enter your PS4's IP Adress in the Settings Section!", ToastLength.Short).Show();
                return;
            }
            if (string.IsNullOrWhiteSpace(settings.port))
            {
                Toast.MakeText(context, "Please enter a Port in the Settings Section!", ToastLength.Short).Show();
                return;
            }
            try
            {
                Socket     client     = new Socket(SocketType.Stream, ProtocolType.Tcp);
                int        port       = int.Parse(settings.port);
                IPAddress  IPAdress   = IPAddress.Parse(settings.IPAdress);
                IPEndPoint ipEndpoint = new IPEndPoint(IPAdress, port);

                client.Connect(ipEndpoint);
                Toast.MakeText(context, "Sending...", ToastLength.Short).Show();
                client.SendFile(pathToFolder + file);
                client.Shutdown(SocketShutdown.Both);
                client.Close();
            }
            catch
            {
                Toast.MakeText(context, "Can't connect to PS4!", ToastLength.Short).Show();
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestPermissions();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.main);

            SaveSettings settings = new SaveSettings();

            settings.Load();
            Port     = settings.port;
            IPAdress = settings.IPAdress;

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            if (toolbar != null)
            {
                SetSupportActionBar(toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);
            }

            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            //Set hamburger items menu
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);

            //setup navigation view
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            //handle navigation
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                if (previousItem != null)
                {
                    previousItem.SetChecked(false);
                }

                navigationView.SetCheckedItem(e.MenuItem.ItemId);

                previousItem = e.MenuItem;

                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_home:
                    ListItemClicked(0);
                    break;

                case Resource.Id.nav_fan_control:
                    ListItemClicked(1);
                    break;

                case Resource.Id.nav_settings:
                    ListItemClicked(2);
                    break;

                case Resource.Id.nav_credits:
                    ListItemClicked(3);
                    break;
                }


                drawerLayout.CloseDrawers();
            };


            //if first time you will want to go ahead and click first item.
            if (savedInstanceState == null)
            {
                navigationView.SetCheckedItem(Resource.Id.nav_home);
                ListItemClicked(0);
            }
        }