Example #1
0
 private void INPUT_GET()
 {
     new Thread(new ThreadStart(() => {
         while (true)
         {
             string[] Messages = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(INPUT.ns));
             e.OnClientGetMessage(Messages);
         }
     })).Start();
 }
Example #2
0
        public void OnLocationChanged(Location location)
        {
            double Lat  = location.Latitude;
            double Long = location.Longitude;

            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { Lat.ToString(), Long.ToString() }));
            string[] Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

            if (Response[0] == "1")
            {
                int i = 1;
                while (Response[i] != "")
                {
                    string NrTel    = Response[i];
                    string Distanta = Response[i + 1];

                    LocationableClient LClient = new LocationableClient(NrTel, Distanta);

                    i += 2;
                }
            }

            string current;

            string path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures) + "/gps.txt";

            FileStream   ReadStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamReader r          = new StreamReader(ReadStream);

            current = r.ReadToEnd();
            r.Close();
            ReadStream.Close();

            FileStream   WriteStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamWriter w           = new StreamWriter(WriteStream);

            w.WriteLine(current + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + "=>" + Lat.ToString() + "    " + Long.ToString() + "    " + location.Accuracy.ToString());
            w.Close();
            WriteStream.Close();
        }
        protected override void OnResume()
        {
            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
            NetworkStream ns     = Client.GetStream();

            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.GetProfilePic, new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));

            int ReadedBytes;

            byte[]       Buffer = new byte[1000];
            MemoryStream ms     = new MemoryStream();

            while ((ReadedBytes = ns.Read(Buffer, 0, Buffer.Length)) > 0)
            {
                ms.Write(Buffer, 0, ReadedBytes);
            }

            Client.Close();
            ns.Dispose();

            Bitmap bitMap = ((BitmapDrawable)DrawableConverter.ByteArrayToDrawable(ms.ToArray(), this)).Bitmap;

            UserProfilePic.SetImageDrawable(new BitmapDrawable(Resources, RoundedBitmap.MakeRound(bitMap, bitMap.Height / 2)));

            TcpClient     client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
            NetworkStream Ns     = client.GetStream();

            _TcpDataExchange.WriteStreamString(Ns, CryptDecryptData.CryptData(new string[] { _Details.GetUserName, new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));
            string NumeUtilizator = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(Ns))[0];

            UserNume.Text = NumeUtilizator;

            client.Close();
            Ns.Dispose();

            base.OnResume();
        }
Example #4
0
        void LoginBtn_Click(object sender, EventArgs e)
        {
            string Nume   = LoginText.Text;
            string Parola = ParolaText.Text;

            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LoginSignUpNewTripPort);
            NetworkStream ns     = Client.GetStream();

            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { "LOGIN", Nume, Parola }));
            string[] Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

            switch (Response[0])
            {
            case "Utilizator":
            {
                if (RememberMe.Checked)
                {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Username, Nume);
                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Password, Parola);

                    Intent StartSignUp = new Intent(this, typeof(Utilizator_Main));

                    StartSignUp.PutExtra("BackgroundUtilizatorMainByteArray", BackID);
                    StartActivity(StartSignUp);
                }
                else
                {
                    Intent StartSignUp = new Intent(this, typeof(Utilizator_Main));

                    StartSignUp.PutExtra("BackgroundUtilizatorMainByteArray", BackID);
                    StartActivity(StartSignUp);
                }
            }
            break;

            case "Organizator":
            {
                if (Response[1] == "1")
                {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Username, Nume);
                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Password, Parola);

                    Intent StartOrganizatorTrip = new Intent(this, typeof(Organizator_Trip));
                    StartOrganizatorTrip.PutExtra("BackgroundByteArray", DrawableConverter.DrawableToByteArray(Backgroud.Background));
                    StartActivity(StartOrganizatorTrip);
                }
                else
                {
                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(this);

                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Username, Nume);
                    Save.Save(SaveUsingSharedPreferences.Tags.Login.Password, Parola);

                    Intent StartOrganizatorMain = new Intent(this, typeof(Organizator_Main));

                    StartOrganizatorMain.PutExtra("BackgroundUtilizatorMainByteArray", DrawableConverter.DrawableToByteArray(Backgroud.Background));
                    StartActivity(StartOrganizatorMain);
                }
            }
            break;

            default:
            {
                Toast.MakeText(this, "Ne pare rau,numele utilizatorului sau parola au fost introduse gresit!", ToastLength.Long).Show();
            }
            break;
            }
        }
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            LayoutInflater inflater = context.LayoutInflater;
            View           v        = inflater.Inflate(Resource.Layout.Organizator_Trip_GridViewAdapter, null, true);

            ImageView Icon_iView = v.FindViewById <ImageView> (Resource.Id.imageView1);

            Icon_iView.SetImageDrawable(Icons[position]);

            Icon_iView.Click += (object sender, EventArgs e) => {
                switch (position)
                {
                case 1: {
                    context.StartActivity(typeof(Organizator_Trip_VizualizareExcursionisti));
                } break;

                case 3:
                {
                    Dialog diag = new Dialog(context);
                    diag.Window.RequestFeature(WindowFeatures.NoTitle);

                    View      CostumView = inflater.Inflate(Resource.Layout.Utilizator_Trip_TripInfo_AlertDialogAdapter, null);
                    TextView  NumeCamp   = CostumView.FindViewById <TextView>(Resource.Id.textView1);
                    ImageView EditInfo   = CostumView.FindViewById <ImageView>(Resource.Id.imageView1);
                    EditText  NewValue   = CostumView.FindViewById <EditText>(Resource.Id.editText1);

                    SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);
                    string Distanta = Save.LoadString(SaveUsingSharedPreferences.Tags.Organizator.Distanta);

                    NumeCamp.Text   = "Valoarea actuala este:" + Distanta;
                    EditInfo.Click += (object sender1, EventArgs e1) =>
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.Organizator.Distanta, NewValue.Text);

                        diag.Cancel();
                    };

                    diag.SetContentView(CostumView);

                    diag.SetCanceledOnTouchOutside(true);
                    diag.Show();
                    diag.Window.SetBackgroundDrawable(context.Resources.GetDrawable(Resource.Drawable.background_MarginiOvaleAlb));
                } break;

                case 4: {
                    PopupMenu popup = new PopupMenu(context, v);
                    popup.MenuItemClick += (object s, PopupMenu.MenuItemClickEventArgs e1) =>
                    {
                        switch (e1.Item.ToString())
                        {
                        case "Adauga intrebare noua":
                        {
                            context.StartActivity(typeof(Organizator_Trip_NewQuestionPool));
                        } break;

                        case "Vezi progresul intrebarilor actuale":
                        {
                            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
                            NetworkStream ns     = Client.GetStream();

                            string TripId = new SaveUsingSharedPreferences(context).LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId);
                            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.RequestVotesQuestionPool, TripId }));

                            string[] Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

                            string[] Intrebari = Response[0].Split(',');
                            string[] Ids       = Response[1].Split(',');

                            var Test = new Organizator_Trip_ViewQuestionPool_Adapters.IntrebarVariante[Intrebari.Length];

                            for (int i = 0; i < Intrebari.Length; i++)
                            {
                                Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns));

                                List <string> Variante = new List <string>();
                                List <string> Procente = new List <string>();

                                for (int j = 0; j < Response.Length; j++)
                                {
                                    if (Response[j] != "")
                                    {
                                        Variante.Add(Response[j].Split(',')[0]);
                                        Procente.Add(Response[j].Split(',')[1]);
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                                var temp = new Organizator_Trip_ViewQuestionPool_Adapters.IntrebarVariante();
                                temp.Intrebare = Intrebari[i];
                                temp.Variante  = Variante.ToArray();
                                temp.Procente  = Procente.ToArray();

                                Test[i] = temp;
                            }

                            Organizator_Trip_ViewQuestionPool_DialogFragment diag = new Organizator_Trip_ViewQuestionPool_DialogFragment(Test);
                            diag.Show(context.FragmentManager, "ViewQuestionPool");
                        } break;
                        }
                    };
                    MenuInflater menuInflater = popup.MenuInflater;
                    menuInflater.Inflate(Resource.Menu.OptiuniQuestionPool, popup.Menu);
                    popup.Show();
                } break;
                }
            };

            return(v);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Layouturi[position], container, false);
            SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);

            switch (position)
            {
            case 0:
            {
                TextView    Nume_TView    = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView    Prenume_TView = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView    Varsta_TView  = v.FindViewById <TextView> (Resource.Id.textView3);
                TextView    Sex_TView     = v.FindViewById <TextView> (Resource.Id.textView4);
                RadioButton Masculin      = v.FindViewById <RadioButton> (Resource.Id.radioButton1);
                RadioButton Feminin       = v.FindViewById <RadioButton> (Resource.Id.radioButton3);
                EditText    Nume_EText    = v.FindViewById <EditText> (Resource.Id.editText1);
                EditText    Prenume_EText = v.FindViewById <EditText> (Resource.Id.editText2);
                EditText    Varsta_EText  = v.FindViewById <EditText> (Resource.Id.editText3);

                Nume_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Nume, Nume_EText.Text);
                };

                Prenume_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Prenume, Prenume_EText.Text);
                };

                Varsta_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Varsta, Varsta_EText.Text);
                };

                Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Masculin");
                Masculin.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                    if (e.IsChecked)
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Masculin");
                    }
                    else
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Feminin");
                    }
                };

                SetTypeface.Normal.SetTypeFace(context, Nume_TView);
                SetTypeface.Normal.SetTypeFace(context, Prenume_TView);
                SetTypeface.Normal.SetTypeFace(context, Varsta_TView);
                SetTypeface.Normal.SetTypeFace(context, Sex_TView);
                SetTypeface.Normal.SetTypeFace(context, Masculin);
                SetTypeface.Normal.SetTypeFace(context, Feminin);
            }
            break;

            case 1:
            {
                TextView    Email_TView        = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView    NumarTelefon_TView = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView    Mark               = v.FindViewById <TextView> (Resource.Id.textView3);
                TextView    TipCont_TView      = v.FindViewById <TextView> (Resource.Id.textView4);
                RadioButton Utilizator         = v.FindViewById <RadioButton> (Resource.Id.radioButton1);
                RadioButton Organizator        = v.FindViewById <RadioButton> (Resource.Id.radioButton3);
                EditText    Email_EText        = v.FindViewById <EditText> (Resource.Id.editText1);
                EditText    NumarTelefon_EText = v.FindViewById <EditText> (Resource.Id.editText2);

                SetTypeface.Normal.SetTypeFace(context, Email_TView);
                SetTypeface.Normal.SetTypeFace(context, NumarTelefon_TView);
                SetTypeface.Normal.SetTypeFace(context, Mark);
                SetTypeface.Normal.SetTypeFace(context, TipCont_TView);
                SetTypeface.Normal.SetTypeFace(context, Utilizator);
                SetTypeface.Normal.SetTypeFace(context, Organizator);

                Save.Save(SaveUsingSharedPreferences.Tags.SetUp.TipCont, "Utilizator");
                Utilizator.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                    if (e.IsChecked)
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.TipCont, "Utilizator");
                    }
                    else
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.TipCont, "Organizator");
                    }
                };

                Email_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Email, Email_EText.Text);
                };

                NumarTelefon_EText.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.SetUp.NumarTelefon, NumarTelefon_EText.Text);
                };
            }
            break;

            case 2:
            {
                ImageView ChaptaView        = v.FindViewById <ImageView> (Resource.Id.imageView1);
                TextView  VIntroducetiCodul = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView  VParola           = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView  VConfParola       = v.FindViewById <TextView> (Resource.Id.textView3);
                Button    Gata             = v.FindViewById <Button> (Resource.Id.button1);
                EditText  Chapta           = v.FindViewById <EditText> (Resource.Id.editText1);
                EditText  Parola_EText     = v.FindViewById <EditText> (Resource.Id.editText2);
                EditText  ConfParola_Etext = v.FindViewById <EditText> (Resource.Id.editText3);

                SetTypeface.Normal.SetTypeFace(context, VIntroducetiCodul);
                SetTypeface.Normal.SetTypeFace(context, Gata);
                SetTypeface.Normal.SetTypeFace(context, VParola);
                SetTypeface.Normal.SetTypeFace(context, VConfParola);

                DisplayChapta displayChapta = new DisplayChapta(5);
                displayChapta.Create();
                string ChaptaText = displayChapta.GetText();
                Bitmap b          = displayChapta.GetBitmap();
                ChaptaView.SetImageBitmap(b);

                Gata.Click += (object sender, EventArgs e) => {
                    string Nume         = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Nume);
                    string Prenume      = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Prenume);
                    string Varsta       = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Varsta);
                    string Sex          = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Sex);
                    string Email        = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.Email);
                    string TipCont      = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.TipCont);
                    string NumarTelefon = Save.LoadString(SaveUsingSharedPreferences.Tags.SetUp.NumarTelefon);
                    string Parola       = Parola_EText.Text;
                    string ConfParola   = ConfParola_Etext.Text;

                    //if (VerificareDate (
                    //	Nume,Prenume,Varsta,Email,NumarTelefon,Parola,ConfParola,Chapta.Text, ChaptaText)) {

                    TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LoginSignUpNewTripPort);
                    NetworkStream ns     = Client.GetStream();

                    _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { "SIGNUP", Nume, Prenume, Varsta, Sex, Email, NumarTelefon, TipCont, Parola }));

                    if (CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns))[0] == "ok")
                    {
                        Toast.MakeText(context, "Ala-i bosssss!", ToastLength.Long).Show();

                        Intent StartLogin = new Intent(context, typeof(Login));
                        StartLogin.PutExtra("BackgroundLoginByteArray", DrawableConverter.DrawableToByteArray(context.Background.Background));
                        context.StartActivity(StartLogin);
                    }
                    else
                    {
                        Toast.MakeText(context, "Fail!", ToastLength.Long).Show();
                        Intent StartLogin = new Intent(context, typeof(Login));
                        StartLogin.PutExtra("BackgroundLoginByteArray", DrawableConverter.DrawableToByteArray(context.Background.Background));
                        context.StartActivity(StartLogin);
                    }

                    //}
                };
            }
            break;
            }

            return(v);
        }
Example #7
0
        public GameLayer(Activity context, float Size_X, float Size_Y, string IntentType, string NrTel, string GameId)
            : base(CCColor4B.Black)
        {
            this.context = context;

            this.Size_X     = Size_X;
            this.Size_Y     = Size_Y;
            this.IntentType = IntentType;
            SendPackets     = new Thread(new ThreadStart(Test));

            _player2Board             = new CCSprite("Board1.png");
            _player2Board.PositionX   = 500;
            _player2Board.PositionY   = Size_Y - (Size_Y / 40) * 3;
            _player2Board.ContentSize = new CCSize(Size_X / 7, Size_Y / 40);

            _player1Board             = new CCSprite("Board1");
            _player1Board.PositionX   = 100;
            _player1Board.PositionY   = (Size_Y / 40) * 3;
            _player1Board.ContentSize = new CCSize(Size_X / 7, Size_Y / 40);

            Ball             = new CCSprite("Ball1");
            Ball.Visible     = false;
            Ball.AnchorPoint = CCPoint.AnchorMiddle;
            Ball.ContentSize = new CCSize(Size_Y / 20, Size_Y / 20);
            Ball.PositionX   = Size_X / 2;
            Ball.PositionY   = Size_Y / 2;

            Score_P1             = new CCLabel("0", "Arial", 150, CCLabelFormat.SystemFont);
            Score_P1.PositionX   = Size_X / 40;
            Score_P1.PositionY   = (Size_Y / 4);
            Score_P1.Color       = CCColor3B.White;
            Score_P1.AnchorPoint = CCPoint.AnchorLowerLeft;

            Score_P2             = new CCLabel("0", "Arial", 150, CCLabelFormat.SystemFont);
            Score_P2.PositionX   = Size_X / 40;
            Score_P2.PositionY   = (Size_Y / 4) * 3;
            Score_P2.Color       = CCColor3B.White;
            Score_P2.AnchorPoint = CCPoint.AnchorUpperLeft;

            CountDownTimer             = new CCLabel("0", "Arial", 400, CCLabelFormat.SystemFont);
            CountDownTimer.ContentSize = new CCSize(Size_Y / 20, Size_Y / 20);
            CountDownTimer.PositionX   = Size_X / 2;
            CountDownTimer.PositionY   = Size_Y / 2;
            CountDownTimer.Color       = CCColor3B.White;
            CountDownTimer.AnchorPoint = CCPoint.AnchorMiddle;
            CountDownTimer.Text        = "3";

            AddChild(Score_P1);
            AddChild(Score_P2);
            AddChild(_player1Board);
            AddChild(_player2Board);
            AddChild(Ball);
            AddChild(CountDownTimer);

            if (IntentType == "CREATE")
            {
                TcpClient     client = new TcpClient(_Details.ServerIP, _Details.GamesHostPort);
                NetworkStream ns     = client.GetStream();
                Client = new Client(client, ns);

                _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.Game_Bounce, "CREATE", Utilizator_Trip.Me.NumarTelefon, NrTel }));
                string Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns))[0];

                if (Response == "1")
                {
                    SendPackets.Start();
                    System.Timers.Timer T = new System.Timers.Timer();
                    T.Interval = 1000;
                    T.Elapsed += T_Elapsed;
                    T.Start();
                }
                else
                {
                    context.Finish();
                }
            }
            else
            {
                TcpClient     client = new TcpClient(_Details.ServerIP, _Details.GamesHostPort);
                NetworkStream ns     = client.GetStream();
                Client = new Client(client, ns);

                _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.Game_Bounce, "JOIN", GameId, NrTel }));
                string Response = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns))[0];

                if (Response == "1")
                {
                    SendPackets.Start();
                    System.Timers.Timer T = new System.Timers.Timer();
                    T.Interval = 1000;
                    T.Elapsed += T_Elapsed;
                    T.Start();
                }
                else
                {
                    context.Finish();
                }
            }
        }
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Layouturi[position], null, true);
            SaveUsingSharedPreferences Save = new SaveUsingSharedPreferences(context);

            switch (position)
            {
            case 0:
            {
                TextView    TViewDestinatiePrincipala = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView    TViewTipulParticipantilor = v.FindViewById <TextView> (Resource.Id.textView4);
                EditText    DestinatiePrincipala      = v.FindViewById <EditText> (Resource.Id.editText1);
                RadioButton Elevi           = v.FindViewById <RadioButton> (Resource.Id.radioButton1);
                RadioButton PersoanePrivate = v.FindViewById <RadioButton> (Resource.Id.radioButton3);

                SetTypeface.Normal.SetTypeFace(context, TViewDestinatiePrincipala);
                SetTypeface.Normal.SetTypeFace(context, TViewTipulParticipantilor);
                SetTypeface.Normal.SetTypeFace(context, DestinatiePrincipala);
                SetTypeface.Normal.SetTypeFace(context, Elevi);
                SetTypeface.Normal.SetTypeFace(context, PersoanePrivate);

                DestinatiePrincipala.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DestinatiePrincipala, DestinatiePrincipala.Text);
                };

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.TipulParticipantilor, "Elevi");
                Elevi.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                    if (e.IsChecked)
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Elevi");
                    }
                    else
                    {
                        Save.Save(SaveUsingSharedPreferences.Tags.SetUp.Sex, "Persoane private");
                    }
                };
            }
            break;

            case 1:
            {
                TextView   PerioadaExcursieiTView = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView   DataPlecareTView       = v.FindViewById <TextView> (Resource.Id.textView2);
                TextView   DataIntoarcereTView    = v.FindViewById <TextView> (Resource.Id.textView3);
                DatePicker DataPlecare            = v.FindViewById <DatePicker> (Resource.Id.datePicker1);
                DatePicker DataIntoarcere         = v.FindViewById <DatePicker> (Resource.Id.datePicker2);

                SetTypeface.Normal.SetTypeFace(context, PerioadaExcursieiTView);
                SetTypeface.Normal.SetTypeFace(context, DataPlecareTView);
                SetTypeface.Normal.SetTypeFace(context, DataIntoarcereTView);

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataPlecare, System.DateTime.Now.Day.ToString() + "." + System.DateTime.Now.Month.ToString() + "." + System.DateTime.Now.Year.ToString());
                DataPlecare.CalendarView.DateChange += (object sender, CalendarView.DateChangeEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataPlecare, e.DayOfMonth.ToString() + "." + e.Month.ToString() + "." + e.Year.ToString());
                };

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataIntoarcere, System.DateTime.Now.Day.ToString() + "." + System.DateTime.Now.Month.ToString() + "." + System.DateTime.Now.Year.ToString());
                DataIntoarcere.CalendarView.DateChange += (object sender, CalendarView.DateChangeEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.DataIntoarcere, e.DayOfMonth.ToString() + "." + e.Month.ToString() + "." + e.Year.ToString());
                };
            }
            break;

            case 2:
            {
                TextView   LocatiePlecareTView = v.FindViewById <TextView> (Resource.Id.textView1);
                TextView   OraPlecareTview     = v.FindViewById <TextView> (Resource.Id.textView2);
                EditText   LocatiePlecare      = v.FindViewById <EditText> (Resource.Id.editText1);
                TimePicker OraPlecare          = v.FindViewById <TimePicker> (Resource.Id.timePicker1);

                OraPlecare.SetIs24HourView(Java.Lang.Boolean.True);

                SetTypeface.Normal.SetTypeFace(context, LocatiePlecareTView);
                SetTypeface.Normal.SetTypeFace(context, OraPlecareTview);
                SetTypeface.Normal.SetTypeFace(context, LocatiePlecare);

                LocatiePlecare.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.LocatiePlecare, LocatiePlecare.Text);
                };

                Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.OraPlecare, System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Hour.ToString());
                OraPlecare.TimeChanged += (object sender, TimePicker.TimeChangedEventArgs e) => {
                    Save.Save(SaveUsingSharedPreferences.Tags.NewTrip.OraPlecare, e.Minute.ToString() + ":" + e.HourOfDay.ToString());
                };
            }
            break;

            case 3:
            {
                Button   Finalizare      = v.FindViewById <Button> (Resource.Id.button1);
                TextView ObservatiiTView = v.FindViewById <TextView> (Resource.Id.textView1);
                EditText ObservatiiEText = v.FindViewById <EditText> (Resource.Id.editText1);

                SetTypeface.Normal.SetTypeFace(context, Finalizare);
                SetTypeface.Normal.SetTypeFace(context, ObservatiiTView);
                SetTypeface.Normal.SetTypeFace(context, ObservatiiEText);

                Finalizare.Click += (object sender, EventArgs e) => {
                    string DestinatiePrincipala = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.DestinatiePrincipala);
                    string TipulParticipantilor = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.TipulParticipantilor);
                    string DataPlecare          = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.DataPlecare);
                    string DataIntoarcere       = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.DataIntoarcere);
                    string LocatiePlecare       = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.LocatiePlecare);
                    string OraPlecare           = Save.LoadString(SaveUsingSharedPreferences.Tags.NewTrip.OraPlecare);
                    string Observatii           = ObservatiiEText.Text;
                    string NumeOrganizator      = "numeOrganizator";
                    string NumarTelefon         = new SaveUsingSharedPreferences(context).LoadString(SaveUsingSharedPreferences.Tags.Login.Username);

                    if (VerificareDate(DestinatiePrincipala, LocatiePlecare))
                    {
                        TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.TripPort_INPUT);
                        NetworkStream ns     = Client.GetStream();

                        _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] {
                                "NEWTRIP",
                                DestinatiePrincipala,
                                TipulParticipantilor,
                                DataPlecare,
                                DataIntoarcere,
                                LocatiePlecare,
                                OraPlecare,
                                Observatii,
                                NumeOrganizator,
                                NumarTelefon
                            }));

                        if (CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns)) [0] == "1")
                        {
                            Toast.MakeText(context, "Ala-i bosssss!", ToastLength.Long).Show();

                            TcpClient     client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
                            NetworkStream Ns     = client.GetStream();

                            _TcpDataExchange.WriteStreamString(Ns, CryptDecryptData.CryptData(new string[] { _Details.GetTripId, new SaveUsingSharedPreferences(context).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));
                            string TripId = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(Ns))[0];
                            new SaveUsingSharedPreferences(context).Save(SaveUsingSharedPreferences.Tags.Trip.TipId, TripId);

                            ns.Dispose();
                            client.Close();

                            Intent StartOrganizatorTrip = new Intent(context, typeof(Organizator_Trip));
                            StartOrganizatorTrip.PutExtra("BackgroundByteArray", DrawableConverter.DrawableToByteArray(Background));
                            context.StartActivity(StartOrganizatorTrip);
                        }
                        else
                        {
                            Toast.MakeText(context, "Fail!", ToastLength.Long).Show();
                            context.Finish();
                        }
                    }
                };
            }
            break;
            }

            return(v);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            Bundle Extras = Intent.Extras;
            int    BackgroundByteArray = Extras.GetInt("BackgroundUtilizatorMainByteArray");

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Utilizator_Main);

            Background       = FindViewById <RelativeLayout> (Resource.Id.relativeLayout1);
            LeftDrawer       = FindViewById <ListView> (Resource.Id.left_drawer_listview);
            Next             = FindViewById <Button> (Resource.Id.button1);
            Container        = FindViewById <RelativeLayout> (Resource.Id.relativeLayout3);
            Cod              = FindViewById <EditText> (Resource.Id.editText1);
            IntroducetiCodul = FindViewById <TextView> (Resource.Id.textView2);
            UserProfilePic   = FindViewById <ImageView> (Resource.Id.imageView1);
            UserNume         = FindViewById <TextView> (Resource.Id.textView1);

            List <Drawable> DrawableList = new List <Drawable>();

            for (int i = 1; i < 5; i++)
            {
                DrawableList.Add(DrawableConverter.GetDrawableFromAssets("LB/img" + i.ToString() + ".jpg", this));
            }
            for (int i = 1; i < 8; i++)
            {
                DrawableList.Add(DrawableConverter.GetDrawableFromAssets("LoadingBackgrounds/img" + i.ToString() + ".jpg", this));
            }
            Background.Background = DrawableList[BackgroundByteArray];

            Cod.Text = new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Trip.TipId);
            //Cod.Text = "c41z1zb6xc";

            SetTypeface.Normal.SetTypeFace(this, IntroducetiCodul);
            SetTypeface.Normal.SetTypeFace(this, Next);
            SetTypeface.Normal.SetTypeFace(this, Cod);

            TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
            NetworkStream ns     = Client.GetStream();

            _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.GetProfilePic, new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));

            int ReadedBytes;

            byte[]       Buffer = new byte[1000];
            MemoryStream ms     = new MemoryStream();

            while ((ReadedBytes = ns.Read(Buffer, 0, Buffer.Length)) > 0)
            {
                ms.Write(Buffer, 0, ReadedBytes);
            }

            Client.Close();
            ns.Dispose();

            Bitmap bitMap = ((BitmapDrawable)DrawableConverter.ByteArrayToDrawable(ms.ToArray(), this)).Bitmap;

            UserProfilePic.SetImageDrawable(new BitmapDrawable(Resources, RoundedBitmap.MakeRound(bitMap, bitMap.Height / 2)));

            TcpClient     client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
            NetworkStream Ns     = client.GetStream();

            _TcpDataExchange.WriteStreamString(Ns, CryptDecryptData.CryptData(new string[] { _Details.GetUserName, new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username) }));
            string NumeUtilizator = CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(Ns))[0];

            UserNume.Text = NumeUtilizator;

            client.Close();
            Ns.Dispose();

            SetTypeface.Normal.SetTypeFace(this, UserNume);
            LeftDrawer.Adapter = new Utilizator_Main_LeftDrawerAdapter(this, new string[] { "Logout" }, Background.Background);

            Next.Click += (object sender, EventArgs e) => {
                TcpClient     OUTPUT_Client = new TcpClient(_Details.ServerIP, _Details.TripPort_INPUT);
                NetworkStream OUTPUT_ns     = OUTPUT_Client.GetStream();
                OUTPUT = new Client(OUTPUT_Client, OUTPUT_ns);

                string NumePrenume  = "nume Prenume";
                string NumarTelefon = new SaveUsingSharedPreferences(this).LoadString(SaveUsingSharedPreferences.Tags.Login.Username);
                string TripId       = Cod.Text;

                _TcpDataExchange.WriteStreamString(OUTPUT_ns, CryptDecryptData.CryptData(new String [] { "TRIPENTER", NumePrenume, NumarTelefon, TripId }));

                List <string> Messages = new List <string>();
                Messages.AddRange(CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(OUTPUT_ns)));
                Messages.Add(TripId);

                TcpClient     INPUT_Client = new TcpClient(_Details.ServerIP, _Details.TripPort_OUTPUT);
                NetworkStream INPUT_ns     = INPUT_Client.GetStream();
                INPUT = new Client(INPUT_Client, INPUT_ns);

                _TcpDataExchange.WriteStreamString(INPUT_ns, CryptDecryptData.CryptData(new String [] { NumePrenume, NumarTelefon, TripId }));

                new SaveUsingSharedPreferences(this).Save(SaveUsingSharedPreferences.Tags.Trip.TipId, TripId);
                Intent StartUtilizatorTrip = new Intent(this, typeof(Utilizator_Trip));
                StartUtilizatorTrip.PutExtra("BackgroundByteArray", DrawableConverter.DrawableToByteArray(Background.Background));
                StartUtilizatorTrip.PutStringArrayListExtra("TripData", Messages);
                StartActivity(StartUtilizatorTrip);
            };
        }
        void RightArrow_Click(object sender, EventArgs e)
        {
            if (current < 2)
            {
                var trans = ChildFragmentManager.BeginTransaction();

                trans.SetCustomAnimations(
                    Resource.Animation.TranslationNext,
                    Resource.Animation.TranslateForward,
                    Resource.Animation.TranslationNext,
                    Resource.Animation.TranslateForward
                    );

                trans.Hide(Frags[current]);
                trans.Show(Frags[current + 1]);
                trans.Commit();

                current++;

                ActualFragment.Text = (current + 1).ToString() + "/3";
            }
            else
            {
                string Nume         = DateUtilizatorNou[0];
                string Prenume      = DateUtilizatorNou[1];
                string Sex          = DateUtilizatorNou[2];
                string Varsta       = DateUtilizatorNou[3];
                string Email        = DateUtilizatorNou[4];
                string PhotoURL     = DateUtilizatorNou[5];
                string NumarTelefon = ((Login_SignUpUsingFacebook_NumarTelefon)Frags[0]).NumarTelefon.Text;
                string Parola       = ((Login_SignUpUsingFacebook_Parola)Frags[2]).Parola.Text;
                string TipCont      = string.Empty;

                if (((Login_SignUpUsingFacebook_TipCont)Frags[1]).Utilizator.Checked)
                {
                    TipCont = "Organizator";
                }
                else
                {
                    TipCont = "Utilizator";
                }

                TcpClient     Client = new TcpClient(_Details.ServerIP, _Details.LoginSignUpNewTripPort);
                NetworkStream ns     = Client.GetStream();

                _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { "SIGNUP", Nume, Prenume, Varsta, Sex, Email, NumarTelefon, TipCont, Parola }));

                if (CryptDecryptData.DecryptData(_TcpDataExchange.ReadStreamString(ns))[0] == "ok")
                {
                    Client = new TcpClient(_Details.ServerIP, _Details.LargeFilesPort);
                    ns     = Client.GetStream();

                    MemoryStream          m = new MemoryStream();
                    ByteArrayOutputStream s = new ByteArrayOutputStream();
                    ProfilePic.Compress(Bitmap.CompressFormat.Png, 100, m);


                    using (MemoryStream ms = new MemoryStream(m.ToArray()))
                    {
                        int PackSize    = 1000;
                        int TotalLength = (int)ms.Length;
                        int NoOfPackets = (int)System.Math.Ceiling((double)ms.Length / (double)PackSize);
                        int CurrentPackSize;

                        _TcpDataExchange.WriteStreamString(ns, CryptDecryptData.CryptData(new string[] { _Details.UpdateProfilePic, NumarTelefon }));

                        for (int i = 0; i < NoOfPackets; i++)
                        {
                            if (TotalLength > PackSize)
                            {
                                TotalLength    -= PackSize;
                                CurrentPackSize = PackSize;
                            }
                            else
                            {
                                CurrentPackSize = TotalLength;
                            }

                            byte[] CurrentBytes = new byte[CurrentPackSize];
                            int    ReadedLength = ms.Read(CurrentBytes, 0, CurrentBytes.Length);

                            ns.Write(CurrentBytes, 0, ReadedLength);
                        }

                        Client.Close();
                    }

                    Toast.MakeText(Activity, "Ala-i bosssss!", ToastLength.Long).Show();
                    Dialog.Cancel();
                }
                else
                {
                    Toast.MakeText(Activity, "Fail!", ToastLength.Long).Show();
                }
            }
        }