示例#1
0
        public RegisterView()
        {
            InitializeComponent();
            Login.InputText.Text    = "login";
            Password.InputText.Text = "password";
            Email.InputText.Text    = "e-mail";
            Name.InputText.Text     = "name";
            Surname.InputText.Text  = "surname";
            Age.InputText.Text      = "age";
            City.InputText.Text     = "city";
            Street.InputText.Text   = "street";
            Code.InputText.Text     = "postal code";
            Pesel.InputText.Text    = "PESEL";
            Nip.InputText.Text      = "NIP";
            Regon.InputText.Text    = "REGON";

            Login.SetDefaultText();
            Password.SetDefaultText();
            Email.SetDefaultText();
            Name.SetDefaultText();
            Surname.SetDefaultText();
            Age.SetDefaultText();
            City.SetDefaultText();
            Street.SetDefaultText();
            Code.SetDefaultText();
            Pesel.SetDefaultText();
            Nip.SetDefaultText();
            Regon.SetDefaultText();
        }
示例#2
0
 private void Address_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key != Key.Enter)
     {
         return;
     }
     PreviewChange(); Nip.Focus();
 }
示例#3
0
    private Nip GetRandomNip()
    {
        var rnd           = new System.Random();
        var nips          = missionNips.FindAll(i => i.Grade <= currentGrade);
        var availableNips = nips.FindAll(n => {
            var exists = missions.Find(m => m.Nip.GetName() == n.GetName());
            return(exists == null);
        });
        Nip rndNip = availableNips[rnd.Next(availableNips.Count)];

        return(rndNip);
    }
示例#4
0
 private void ClearAllToDefault()
 {
     Login.Refresh();
     Password.Refresh();
     Email.Refresh();
     Name.Refresh();
     Surname.Refresh();
     Age.Refresh();
     City.Refresh();
     Street.Refresh();
     Code.Refresh();
     Pesel.Refresh();
     Nip.Refresh();
     Regon.Refresh();
 }
示例#5
0
    public void SetMission(Nip nip, Mission.Type type, int count)
    {
        var mission = missions.Find(m => m.Nip.GetName() == nip.GetName() && m.type == type);

        if (mission == null)
        {
            return;
        }

        if (type == Mission.Type.Collect)
        {
            var allNips = new List <GameObject>(GameObject.FindGameObjectsWithTag("nip"));
            var nips    = allNips.FindAll(n => {
                return(n.GetComponent <Nip>().GetName() == nip.GetName());
            });
            mission.count = nips.Count;
        }

        mission.count += count;
        if (mission.count < 0)
        {
            mission.count = 0;
        }
        if (mission.IsComplete())
        {
            var anim   = Resources.Load <GameObject>("Animations/MissionComplete");
            var canvas = GameObject.Find("Canvas");
            if (canvas == null)
            {
                return;
            }

            Instantiate(anim, canvas.transform);
            stars += 1;
            var newGrade = mission.Nip.Grade + 1;
            if (newGrade > currentGrade)
            {
                currentGrade = newGrade;
            }
            missions.Remove(mission);
            GenerateMission();
            var starController = FindObjectOfType <StarController>();
            if (starController)
            {
                starController.clickable = true;
            }
        }
    }
示例#6
0
        public List <Message> Validate()
        {
            var errors = new List <Message>();

            if (CompanyName.Trim() == "" && (VendorName.Trim() == "" && VendorLastName.Trim() == ""))
            {
                errors.Add(new Message("Należy podać nazwe firmy lub imię i nazwisko"));
            }

            var rgx = new Regex("^[0-9]{10}");
            var nip = Nip.Replace("-", "").Replace(" ", "").Trim();

            if (!rgx.IsMatch(nip))
            {
                errors.Add(new Message("Nip jest niepoprawny"));
            }

            return(errors);
        }
示例#7
0
    public void MoveByRay(Ray destination, Nip nip)
    {
        var cell = transform.parent.GetComponent <Cell>();

        if (cell.isPrison)
        {
            return;
        }

        var        pos  = transform.parent.position;
        var        dist = 100;
        List <Ray> rays = new List <Ray>();

        rays.Add(new Ray(pos, new Vector3(pos.x, pos.y + dist, pos.z) - pos));
        rays.Add(new Ray(pos, new Vector3(pos.x - dist, pos.y, pos.z) - pos));
        rays.Add(new Ray(pos, new Vector3(pos.x + dist, pos.y, pos.z) - pos));
        rays.Add(new Ray(pos, new Vector3(pos.x, pos.y - dist, pos.z) - pos));
        rays.Sort((ray1, ray2) => {
            var distance1 = Vector3.Distance(destination.direction, ray1.direction);
            var distance2 = Vector3.Distance(destination.direction, ray2.direction);
            return(distance1.CompareTo(distance2));
        });
        foreach (var ray in rays)
        {
            var hits = GetCellHits(ray);
            if (hits.Length > 0)
            {
                var hit     = GetClosestHit(hits);
                var isValid = IsValidHit(hit, nip);
                if (isValid)
                {
                    prevParent = transform.parent;
                    transform.SetParent(hit.collider.transform);
                    return;
                }
                ;
            }
        }
    }
示例#8
0
    public void MoveToNip(Nip nip)
    {
        if (this == null)
        {
            return;
        }

        var destination = GetClosestNip(nip);

        if (destination == null)
        {
            RandomMove();
            return;
        }
        ;

        var startPoint = transform.parent.position;
        var direction  = destination.transform.parent.position - transform.parent.position;
        var ray        = new Ray(startPoint, direction);

        MoveByRay(ray, nip);
    }
示例#9
0
    private bool IsValidHit(RaycastHit hit, Nip nip)
    {
        var cell = hit.collider.GetComponent <Cell>();

        if (cell && cell.isPrison)
        {
            return(false);
        }

        if (cell.transform.childCount > 0)
        {
            var powder      = cell.GetComponentInChildren <Powder>();
            var mine        = cell.GetComponentInChildren <Mine>();
            var requriedNip = (
                nip == null ?
                false :
                nip.GetName() == cell.GetComponentInChildren <Nip>()?.GetName()
                );
            if (requriedNip && cell.transform.childCount == 1)
            {
            }
            // allow move for specific nips
            else if (powder)
            {
            }
            else if (mine)
            {
            }
            // no allow move
            else
            {
                return(false);
            }
        }
        ;

        return(true);
    }
示例#10
0
    public Nip GetClosestNip(Nip nip)
    {
        var nips = new List <Nip>(GameObject.FindObjectsOfType <Nip>()).FindAll(obj => {
            return(nip.GetName() == obj.GetName());
        });

        if (nips.Count == 0)
        {
            return(null);
        }

        var destination = nips[0];

        foreach (var obj in nips)
        {
            var currentDist = Vector3.Distance(this.transform.parent.position, destination.transform.position);
            var newDist     = Vector3.Distance(this.transform.parent.position, obj.transform.parent.position);
            if (newDist < currentDist)
            {
                destination = obj;
            }
        }
        return(destination);
    }
示例#11
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            bool correct = true;

            //Login
            if (!Regex.IsMatch(Login.GetText(), "^[a-z]{1,}"))
            {
                Login.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //Password
            //if (!Regex.IsMatch(Login.GetText(), "^[A-Z]{1}[a-z]{2,}"))
            //{
            //    Login.InputText.Foreground = Brushes.Red;
            //    correct = false;
            //}
            //Email
            if (!Regex.IsMatch(Email.GetText(), "^[a-z]{1}\\w+[@]{1}\\w{2,}[.]{1}\\w{2,3}"))
            {
                Email.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //Name
            if (!Regex.IsMatch(Name.GetText(), "^[A-Z]{1}[a-z]{2,}"))
            {
                Name.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //Surname
            if (!Regex.IsMatch(Surname.GetText(), "^[A-Z]{1}[a-z]{2,}"))
            {
                Surname.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //Age
            if (!Regex.IsMatch(Age.GetText(), "^\\d{2}$"))
            {
                Age.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //City
            if (!Regex.IsMatch(City.GetText(), "^[A-Z]{1}[a-z]+(\\s[A-Z]{1}[a-z]+){0,1}$"))
            {
                City.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //Street
            if (!Regex.IsMatch(Street.GetText(), "^[A-Z]{1}[a-z]+(\\s[A-Z]{1}[a-z]+){0,1}$"))
            {
                Street.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //Code
            if (!Regex.IsMatch(Code.GetText(), "^\\d{2}[-]{1}\\d{3}"))
            {
                Code.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //PESEL
            if (!Regex.IsMatch(Pesel.GetText(), "^\\d{11}$"))
            {
                Pesel.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //NIP
            if (!Regex.IsMatch(Nip.GetText(), "^\\d{10}$"))
            {
                Nip.InputText.Foreground = Brushes.Red;
                correct = false;
            }
            //REGON
            if (!Regex.IsMatch(Regon.GetText(), "^\\d{9}$"))
            {
                Regon.InputText.Foreground = Brushes.Red;
                correct = false;
            }


            if (correct)
            {
                User user = new User(0, Login.GetText(), Password.GetText(), Email.GetText(),
                                     Name.GetText(), Surname.GetText(), Convert.ToInt32(Age.GetText()), 1, City.GetText(),
                                     Street.GetText(), Code.GetText(), Pesel.GetText(), Nip.GetText(), Regon.GetText(), "0");

                User.Insert(user);
                ClearAllToDefault();
            }
            else
            {
                MessageBox.Show("Niepoprawne dane!");
            }
        }
示例#12
0
        public override string ToString()
        {
            string text = String.Format("ID klienta: {1}{0}", Environment.NewLine, IdClient.ToString()) +
                          "====================================" +
                          String.Format("Dane:{0}{0}{1}", Environment.NewLine, Data.ToString()) +
                          "====================================" +
                          String.Format("Adres:{0}{0}{1}", Environment.NewLine, Localisation.ToString()) +
                          "====================================" +
                          String.Format("Regon, NIP:{0}{1}{0}{2}", Environment.NewLine, Regon.ToString(), Nip.ToString()) +
                          "====================================" +
                          String.Format("Kontakt:{0}{1}{0}{2}", Environment.NewLine, MailToClient.ToString(), NumberOfPhone.ToString()) +
                          "====================================" +
                          String.Format("Zniżki:{0}", Environment.NewLine);

            foreach (Discount a in ListOfDiscount)
            {
                text += a.ToString() + "------------------------------------";
            }

            return(text);
        }