private void SetNews(List <News> news)
 {
     foreach (var item in news)
     {
         NewsUc      newsUc = new NewsUc();
         BitmapImage image  = new BitmapImage();
         if (item.Image != null)
         {
             if (!PreName.Equals(item.Image.Name))
             {
                 image = new BitmapImage();
                 Uri uri = new Uri(System.IO.Path.GetFullPath(Utillity.GetInstance().ByteToImage(item.Image)));
                 image       = new BitmapImage(uri);
                 PreviousImg = uri;
             }
             else
             {
                 image = new BitmapImage(PreviousImg);
             }
             newsUc.FillialTb.Text      = CurrentComplex.Name + " " + CurrentComplex.Address.City.Name + " " + CurrentComplex.Address.Street.Name + " " + CurrentComplex.Address.House;
             newsUc.ImgNews.ImageSource = image;
             newsUc.NewsName.Text       = item.Name;
             PreName = item.Image.Name;
         }
         else
         {
             newsUc.NewsName.Text         = item.Name;
             newsUc.FormForImg.Visibility = Visibility.Collapsed;
         }
         NewsPanel.Children.Add(newsUc);
     }
 }
示例#2
0
        private void AddFinallyBtn_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(NewsNameTb.Text) && !string.IsNullOrEmpty(NewsAboutTb.Text))
            {
                NewsNew = new News
                {
                    Name     = NewsNameTb.Text,
                    About    = NewsAboutTb.Text,
                    DateNews = DateTime.Now,
                    Complex  = CurrentComplex
                };

                if (IsSetImage)
                {
                    NewsNew.Image = Utillity.GetInstance().ImageToByte(openFile.FileName);
                }
            }
            else
            {
                return;
            }

            NewRep.Add(NewsNew);
            Close();
        }
示例#3
0
        // TODO: Contrustor vazio pro EF
        public Cliente()
        {
            this.Id = Guid.NewGuid();

            var codPrefixo = Id.ToString().Substring(4, 5);
            var codSufixo  = Utillity.GetCodigo().ToString("0000");

            this.CodigoCliente = codPrefixo + codSufixo;
            Enderecos          = new List <Endereco>();
        }
        public ScheduleOfOneUc(Schedules schedule)
        {
            DataContext = this;
            InitializeComponent();

            Schedule = schedule;
            BitmapImage bit = new BitmapImage(new Uri(Path.GetFullPath(Utillity.GetInstance().ByteToImage(Schedule.Coach.ProfileImg))));

            ProfileImg.ImageSource = bit;
            ProfileNameTb.Text     = $"{Schedule.Coach.Name} {Schedule.Coach.SurName}";
            TimeStart.Text         = Schedule.TimeStart.ToShortTimeString();
            Duration.Text          = Schedule.Duration.ToString() + ".h";
        }
        /// <summary>Creates a new instance of <see cref="NBTWriter"/></summary>
        static NBTWriter()
        {
            NBTWriter.Writers = new Dictionary <NBTTagType, ITagWriter>();

            List <ITagWriter> Writers = Utillity.GetInterfaces <ITagWriter>();
            Int32             Length  = Writers.Count;

            for (Int32 I = 0; I < Length; I++)
            {
                for (Int32 J = 0; J < Writers[I].ForType.Length; J++)
                {
                    NBTWriter.Writers[Writers[I].ForType[J]] = Writers[I];
                }
            }
        }
示例#6
0
        /// <summary>Creates a new instance of <see cref="NBTReader"/></summary>
        static NBTReader()
        {
            NBTReader.Readers = new Dictionary <NBTTagType, ITagReader>();

            List <ITagReader> Readers = Utillity.GetInterfaces <ITagReader>();
            Int32             Length  = Readers.Count;

            for (Int32 I = 0; I < Length; I++)
            {
                for (Int32 J = 0; J < Readers[I].ForType.Length; J++)
                {
                    NBTReader.Readers[Readers[I].ForType[J]] = Readers[I];
                }
            }
        }
示例#7
0
        public void ChangeDirection(Direction newDirection)
        {
            SnakeHead head = ((SnakeHead)this.Pieces[0]);

            int[] newDirChanges = Utillity.GetCoordDiffByDirection(newDirection);
            if (this.Pieces.Count > 1)
            {
                if (head.X + newDirChanges[0] != this.Pieces[1].X && head.Y + newDirChanges[1] != this.Pieces[1].Y)
                {
                    head.Facing = newDirection;
                }
            }
            else
            {
                head.Facing = newDirection;
            }
        }
        private void AddFinallyBtn_Click(object sender, RoutedEventArgs e)
        {
            AddedNews = new News
            {
                Name     = NewsNameTb.Text,
                About    = NewsAboutTb.Text,
                DateNews = DateTime.Now
            };

            if (openFile != null)
            {
                if (!openFile.FileName.Equals(string.Empty))
                {
                    AddedNews.Image = Utillity.GetInstance().ImageToByte(openFile.SafeFileName);
                }
            }
            NewsRepository.GetInstance().Add(AddedNews);
        }
示例#9
0
    public void ShowPlayerPreview(PlayerInfo[] targetPlayerInfo)
    {
        if (!gameObject.activeSelf)
        {
            gameObject.SetActive(true);
            UIManager.Instance.SwitchUI.OpenPanel(anim);
        }

        GUIHelper.Instance.DestroyChildImmediatly <PlayerPreviewHolder> (layout_PlayerPreviewParent);

        PlayerPreviewHolder[] newPlayerPreviewHolderArr = GUIHelper.Instance.InstantiateTUnderParent <PlayerPreviewHolder, PlayerInfo>
                                                              (targetPlayerInfo, playerPreviewPrefab, layout_PlayerPreviewParent);
        for (int i = 0; i < newPlayerPreviewHolderArr.Length; i++)
        {
            newPlayerPreviewHolderArr [i].Init(i, targetPlayerInfo [i]);
        }

        allSceneInfoArr = Utillity.ShuffleArray(allSceneInfoArr);
    }
示例#10
0
        void update(ref List <double> nodes, ref List <double> nextNodes)
        {                                                                             //this translates the input bits of the current states to the output bits of the next states
            int    input        = Utillity.vectorToBitToInt(ref nodes, inputs, true); // converts the input values into an index (true indicates to reverse order)
            int    outputColumn = 0;
            Random random       = new Random();
            double r            = random.NextDouble(); // r will determine with set of outputs will be chosen

            while (r > table[input][outputColumn])
            {
                r -= table[input][outputColumn]; // this goes across the probability table in row for the given input and subtracts each
                                                 // value in the table from r until r is less than a value it reaches
                outputColumn++;                  // we have not found the correct output so move to the next output
            }
            //convert the int outputcolumn to a binary (2->010)
            for (int i = 0; i < outputs.Count(); i++)                                             //for each output...
            {
                nextNodes[outputs[i]] += 1.0 * ((outputColumn >> (outputs.Count() - 1 - i)) & 1); // convert output (the column number) to bits and pack into next states
            }
            // but always put the last bit in the first input (to maintain consistancy)
        }
示例#11
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            m_pShoot.Shoot();
        }

        Vector3 inputDirection = GetInput();

        if (inputDirection.sqrMagnitude > 0.25f)
        {
            m_pMotor.RotateChassis(inputDirection);
        }
        Vector3 turretDir = Utillity.GetWorldPointFromScreenPoint(Input.mousePosition, m_pMotor.m_turret.position.y) - m_pMotor.m_turret.position;

        m_pMotor.RotateTurret(turretDir);
    }
示例#12
0
        private void OpenDashboard()
        {
            SolidColorBrush brush = new SolidColorBrush(Color.FromRgb(244, 67, 54));

            if (emailTb.Text.Equals(string.Empty))
            {
                packIcon1.Foreground = brush;
                packIcon1.Opacity    = 1;
                return;
            }
            else if (passBox.Password.Equals(string.Empty))
            {
                packIcon2.Foreground = brush;
                packIcon2.Opacity    = 1;
                return;
            }
            else
            {
                AccountRepository accountRepository = AccountRepository.GetInstance();
                var account = accountRepository.Get(emailTb.Text);
                if (account != null)
                {
                    if (account.Password.Equals(Utillity.GetInstance().GetHash(passBox.Password)))
                    {
                        Complex cmpl = new Complex();

                        var cmplx = ComplexRepository.GetInstance().GetAll();
                        foreach (var item in cmplx)
                        {
                            var staff = item.Staffs.ToList();
                            foreach (var s in staff)
                            {
                                if (s.Account.Login.Equals(account.Login))
                                {
                                    cmpl = item;
                                    break;
                                }
                            }
                        }

                        Main = new MainWindow {
                            CurrentComplex = cmpl
                        };
                        Main.StatusBar.Items.Add(new TextBlock
                        {
                            Text = $"{cmpl.Name + " " + cmpl.Address.City.Name + " " + cmpl.Address.Street.Name + " " + cmpl.Address.House}",
                            HorizontalAlignment = HorizontalAlignment.Right,
                            Margin = new Thickness(500, 0, 0, 0)
                        });
                        Main.Show();
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Wrong password!\nPlease try again", "Error", MessageBoxButton.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Wrong email!\nPlease try again", "Error", MessageBoxButton.OK);
                }
            }
        } //открытие главного окна
示例#13
0
        protected override void Seed(DBContext context)
        {
            {
                #region Инициализация комплекса полностью


                Position position = new Position
                {
                    Name = "Тренер"
                };

                Position position2 = new Position
                {
                    Name = "Администартор"
                };



                City city = new City
                {
                    Name = "Днепр"
                };

                City city2 = new City
                {
                    Name = "Киев"
                };

                StreetType streetType = new StreetType
                {
                    NameType = "Проспект"
                };

                streetType = new StreetType
                {
                    NameType = "Улица"
                };

                Streets street = new Streets
                {
                    Name       = "Дмитрия Яворницкого",
                    StreetType = streetType
                };
                context.Entry(city).State       = EntityState.Added;
                context.Entry(city2).State      = EntityState.Added;
                context.Entry(streetType).State = EntityState.Added;
                context.Entry(street).State     = EntityState.Added;
                context.SaveChanges();

                Complex complex = new Complex
                {
                    Name               = "Sport Fit",
                    Images             = new List <Images>(),
                    News               = new List <News>(),
                    AdditionalServices = new List <AdditionalServices>(),
                    Address            = new Address
                    {
                        City   = city,
                        Street = street,
                        House  = "3"
                    }
                };

                Images images = new Images();

                string   path = @"gym.ipg";
                FileInfo fi   = new FileInfo(path);

                images.Name      = fi.Name.Substring(0, fi.Name.LastIndexOf('.'));
                images.Extension = fi.Extension;

                byte[] img;
                using (FileStream fs = new FileStream("gym.jpg", FileMode.Open))
                {
                    img = new byte[fs.Length];
                    fs.Read(img, 0, img.Length);
                }

                images.Link = img;

                complex.Images.Add(images);
                context.Entry(complex).State = EntityState.Added;
                context.SaveChanges();

                #endregion

                #region Инициализация сотрудников

                var pass = Utillity.GetInstance().GetHash("admin");

                Staff admin = new Staff
                {
                    Name           = "Павел",
                    SurName        = "Дуров",
                    PhoneNumber    = "0950505055",
                    WorkExperience = 1.5f,
                    Position       = position2,
                    Account        = new Accounts
                    {
                        Login    = "******",
                        Password = pass
                    },
                    Complex = complex
                };
                context.Entry(admin).State = EntityState.Added;
                context.SaveChanges();

                Staff coach = new Staff
                {
                    Name           = "Oleg",
                    SurName        = "Melnik",
                    PhoneNumber    = "0505555551",
                    WorkExperience = 10,
                    Position       = position,
                    Account        = new Accounts
                    {
                        Login    = "******",
                        Password = "******"
                    },
                    Complex    = complex,
                    ProfileImg = Utillity.GetInstance().ImageToByte(Path.GetFullPath("prof1.jpg"))
                };
                context.Entry(coach).State = EntityState.Added;
                context.SaveChanges();

                coach = new Staff
                {
                    Name           = "Kirill",
                    SurName        = "Goyda",
                    PhoneNumber    = "0505555553",
                    WorkExperience = 2,
                    Position       = position,
                    Account        = new Accounts
                    {
                        Login    = "******",
                        Password = "******"
                    },
                    Complex    = complex,
                    ProfileImg = Utillity.GetInstance().ImageToByte(Path.GetFullPath("prof.jpg"))
                };
                context.Entry(coach).State = EntityState.Added;
                context.SaveChanges();

                AdditionalServices additionalServices = new AdditionalServices
                {
                    Name  = "Pool",
                    Price = 150
                };
                AdditionalServices additionalServices1 = new AdditionalServices
                {
                    Name  = "Yoga",
                    Price = 150
                };
                AdditionalServices additionalServices2 = new AdditionalServices
                {
                    Name  = "Fitnes",
                    Price = 150
                };
                AdditionalServices additionalServices3 = new AdditionalServices
                {
                    Name  = "SPA",
                    Price = 150
                };
                AdditionalServices additionalServices4 = new AdditionalServices
                {
                    Name  = "Sauna",
                    Price = 250
                };
                AdditionalServices additionalServices5 = new AdditionalServices
                {
                    Name  = "Pilates",
                    Price = 255
                };

                context.Entry(additionalServices).State  = EntityState.Added;
                context.Entry(additionalServices1).State = EntityState.Added;
                context.Entry(additionalServices2).State = EntityState.Added;
                context.Entry(additionalServices3).State = EntityState.Added;
                context.Entry(additionalServices4).State = EntityState.Added;
                context.Entry(additionalServices5).State = EntityState.Added;

                context.SaveChanges();

                SubscriptionType subscriptionType = new SubscriptionType
                {
                    Name = "Безлимит"
                };

                Subscriptions subscriptions = new Subscriptions
                {
                    Price            = 350,
                    SubscriptionType = subscriptionType,
                    StartDate        = new DateTime(2018, 12, 04),
                    EndDate          = new DateTime(2019, 01, 04)
                };

                context.Entry(subscriptionType).State = EntityState.Added;
                context.Entry(subscriptions).State    = EntityState.Added;
                context.SaveChanges();

                Schedules schedules = new Schedules
                {
                    TimeStart = new DateTime(2018, 04, 12, 12, 10, 00),
                    Date      = DateTime.Now,
                    Duration  = 1,
                    Coach     = coach,
                    Services  = additionalServices
                };
                context.Entry(schedules).State = EntityState.Added;
                context.SaveChanges();

                schedules = new Schedules
                {
                    TimeStart = new DateTime(2018, 04, 12, 12, 10, 00),
                    Date      = DateTime.Now,
                    Duration  = 1,
                    Coach     = new Staff
                    {
                        Name           = "Oleg",
                        SurName        = "Melnik",
                        PhoneNumber    = "0505555551",
                        WorkExperience = 10,
                        Position       = position,
                        Account        = new Accounts
                        {
                            Login    = "******",
                            Password = "******"
                        },
                        Complex    = complex,
                        ProfileImg = Utillity.GetInstance().ImageToByte(Path.GetFullPath("prof1.jpg"))
                    },
                    Services = additionalServices
                };
                context.Entry(schedules).State = EntityState.Added;
                context.SaveChanges();



                #endregion

                #region Инициализация клиента



                Clients client = new Clients
                {
                    Name        = "Name1",
                    SurName     = "Surname1",
                    PhoneNumber = "05035353535",
                };

                context.Entry(client).State = EntityState.Added;
                context.SaveChanges();



                #endregion

                #region Инициализация Новостей
                Images iMg = Utillity.GetInstance().ImageToByte("gym.jpg");

                context.Entry(iMg).State = EntityState.Added;

                News news = new News
                {
                    Name     = "gick pau",
                    About    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae vestibulum ex. Donec nec ipsum ac ligula pharetra convallis vel at purus. Fusce dignissim ultricies gravida. Duis risus mi, mollis sit amet pulvinar ut, dignissim vitae ex. Vestibulum placerat ligula at aliquam posuere. Nullam vel sagittis libero.",
                    Complex  = complex,
                    DateNews = new DateTime(2018, 12, 05, 13, 11, 00),
                    Image    = iMg
                };
                context.Entry(news).State = EntityState.Added;

                news = new News
                {
                    Name     = "Sale, sale, sale!!!",
                    About    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae vestibulum ex. Donec nec ipsum ac ligula pharetra convallis vel at purus. Fusce dignissim ultricies gravida. Duis risus mi, mollis sit amet pulvinar ut, dignissim vitae ex. Vestibulum placerat ligula at aliquam posuere. Nullam vel sagittis libero.",
                    Complex  = complex,
                    DateNews = new DateTime(2018, 12, 05, 13, 11, 00),
                    Image    = iMg
                };
                context.Entry(news).State = EntityState.Added;

                news = new News
                {
                    Name     = "Sale, sale, sale!!!",
                    About    = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae vestibulum ex. Donec nec ipsum ac ligula pharetra convallis vel at purus. Fusce dignissim ultricies gravida. Duis risus mi, mollis sit amet pulvinar ut, dignissim vitae ex. Vestibulum placerat ligula at aliquam posuere. Nullam vel sagittis libero.",
                    Complex  = complex,
                    DateNews = new DateTime(2018, 12, 05, 13, 11, 00),
                    Image    = iMg
                };
                context.Entry(news).State = EntityState.Added;

                context.SaveChanges();
                #endregion

                #region Инициализация Акций
                Stocks stock = new Stocks
                {
                    Name              = "Stock1",
                    AmountOfDiscount  = 25,
                    AdditionalService = additionalServices,
                    About             = "About",
                    StartDate         = new DateTime(2018, 12, 05),
                    EndDate           = new DateTime(2018, 12, 15)
                };
                context.Entry(stock).State = EntityState.Added;
                context.SaveChanges();
                #endregion

                #region Инициализация Заметок
                Tasks task1 = new Tasks
                {
                    Name  = "Task1",
                    About = "About About About About"
                };

                Tasks task2 = new Tasks
                {
                    Name  = "Task2",
                    About = "About About About About About HelloWorld"
                };
                Tasks task3 = new Tasks
                {
                    Name  = "Task3",
                    About = "About About About About About Hello"
                };
                Tasks task4 = new Tasks
                {
                    Name  = "Task4",
                    About = "About About About About About Oleg"
                };
                context.Entry(task1).State = EntityState.Added;
                context.Entry(task2).State = EntityState.Added;
                context.Entry(task3).State = EntityState.Added;
                context.Entry(task4).State = EntityState.Added;
                context.SaveChanges();
                #endregion
                //продолжить инициализацию...
            }
        }
示例#14
0
    void shuffleCard()
    {
        thisPlayerGenerateCardArr = Utillity.ShuffleArray(thisPlayerGenerateCardArr);

        dealCard();
    }
示例#15
0
        public void MoveForward()
        {
            SnakeHead head = (SnakeHead)this.Pieces[0];

            int[] dirChange = Utillity.GetCoordDiffByDirection(head.Facing);
            int   xChange   = dirChange[0];
            int   yChange   = dirChange[1];

            int nextHeadX = head.X + xChange;
            int nextHeadY = head.Y + yChange;

            if (nextHeadX < Program.WindowWidth - 1 && nextHeadY < Program.WindowHeight && nextHeadX > 0 && nextHeadY > 0)
            {
                //check collisions
                //NOTE TO FUTURE ME!
                //It appears doing this loop with a foreach causes the Logic thread to crash
                //as Enumerators don't like it when the thing they are enumerating changes.
                for (int i = 0; i < Program.Food.Count; i++)
                {
                    Food food = Program.Food[i];
                    if (food.X == nextHeadX && food.Y == nextHeadY)
                    {
                        Program.Logic.EatFoodAtLocation(nextHeadX, nextHeadY, this);
                    }
                }

                //if (this.AnyPieceAtCoords(head.X, head.Y)) Program.Logic.GameOver();
                for (int i = 1; i < this.Pieces.Count; i++)
                {
                    if (nextHeadX == this.Pieces[i].X && nextHeadY == this.Pieces[i].Y)
                    {
                        Program.Logic.GameOver();
                    }
                }

                //first, update the previous coords
                //shift the closest previous coord to the latest
                this.PreviousTailCoords[1] = this.PreviousTailCoords[0];
                //and now, set the new closest previous coord
                this.PreviousTailCoords[0] = new int[] { this.Pieces[this.Pieces.Count - 1].X, this.Pieces[this.Pieces.Count - 1].Y };

                //move the last body piece to the position of the next last and so on, finally move the head.
                //it seems counter intuitive, I know, but if you do it head first, all the pieces bunch up together,
                //as the latter pieces have to move to the former pieces, and if the former piece has already moved,
                //the latter will just be exactly where the former piece moved to, as I discovered during the creation
                //of the previous iteration.
                //theoretically you could reference a copy but that's really messy, prone to bugs and inefficient
                if (this.Pieces.Count > 1)
                {
                    for (int i = this.Pieces.Count - 1; i > 0; i--)
                    {
                        this.Pieces[i].X = this.Pieces[i - 1].X;
                        this.Pieces[i].Y = this.Pieces[i - 1].Y;
                    }
                }

                //finally, move the head
                Program.DebugLog($"New Head X: {nextHeadX}, New Head Y: {nextHeadY}");
                head.X = nextHeadX;
                head.Y = nextHeadY;
            }
            else
            {
                //Game over if you crash into a wall
                Program.Logic.GameOver();
            }
        }
示例#16
0
        private int ReferenceTest(Func <int, int> method, int input)
        {
            int x = Utillity.Clamp(method(input), 0, 7);

            return(x);
        }
        private void SetCoach()
        {
            CoachesPanel.Children.Clear();
            var schedule = SchedulesRepository.GetInstance().GetAll();

            list      = new List <Schedules>();
            coachList = new List <Staff>();

            foreach (var item in schedule)
            {
                if (item.Date == CalendarSmall.SelectedDate)
                {
                    coachList.Add(item.Coach);
                    list.Add(item);
                }
            }

            foreach (var l in list)
            {
                Expander         exp;
                StackPanel       spCoach = null;
                List <Schedules> listOne;
                foreach (var c in coachList)
                {
                    listOne = list.Where(item => item.Coach.Id == c.Id).ToList();

                    if (l.Coach.Id == c.Id)
                    {
                        if (spCoach is null)
                        {
                            spCoach = new StackPanel {
                                Orientation = Orientation.Horizontal
                            };

                            BitmapImage bitmap;
                            if (File.Exists(c.ProfileImg.Name + c.ProfileImg.Extension))
                            {
                                bitmap = new BitmapImage(new Uri(System.IO.Path.GetFullPath(c.ProfileImg.Name + c.ProfileImg.Extension)));
                            }
                            else
                            {
                                bitmap = new BitmapImage(new Uri(System.IO.Path.GetFullPath(Utillity.GetInstance().ByteToImage(c.ProfileImg))));
                            }

                            spCoach.Children.Add(new Ellipse
                            {
                                Width  = 60,
                                Height = 60,
                                Fill   = new ImageBrush(bitmap)
                            });

                            spCoach.Children.Add(new TextBlock
                            {
                                Text = c.Name + " " + c.SurName,
                                VerticalAlignment = VerticalAlignment.Center,
                                Margin            = new Thickness(15, 0, 0, 0),
                                FontSize          = 18,
                            });
                        }

                        exp = new Expander
                        {
                            Header      = spCoach,
                            Content     = SetGraficOfOne(listOne),
                            DataContext = c.Id
                        };
                        CoachesPanel.Children.Add(exp);
                    }
                }
            }
        }