コード例 #1
0
        private void StartMethod()
        {
            Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"New game started"));

            #region Map Size/Blocks

            int size;
            int blocks;
            if (Int32.TryParse(ConfigurationManager.AppSettings["Map_Blocks"], out blocks))
            {
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Map_Blocks loaded from AppConfig - {blocks}"));
            }
            else
            {
                blocks = 20;
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Map_Blocks set as default - {blocks}"));
            }
            if (Int32.TryParse(ConfigurationManager.AppSettings["Map_Size"], out size))
            {
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Map_Size loaded from AppConfig - {size}"));
            }
            else
            {
                size = 20;
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Map_Size set as default - {size}"));
            }
            #endregion
            var tmp = new GanerateServise(size, blocks);
            // make it look like a square
            tmp.ResultGrid.Width = MyModel.GridParent.ActualHeight;
            MyModel.Field        = tmp.ResultGrid;
            _field        = new int[size, size];
            _field        = tmp.Field;
            _gameWinScore = SetGameWinScore(tmp.Field);
            if (IsPacmanDie)
            {
                IsPacmanDie = !IsPacmanDie;
                var s = UI.FindChild <Grid>(MyModel.GridParent, "MainField");
                MyModel.GridParent.Children.Remove(s);
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Old game field removed"));
                _score          = 0;
                _ghostAnimation = new List <PointAnimationHelper>();
                AnimationHelper = new PointAnimationHelper();
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Reset all start params"));
            }
            MyModel.GridParent.Children.Add(tmp.ResultGrid);
            Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Game field Added at main View Model window"));
            pacman           = new PacmanEssence(tmp.StartPoint, ImageCreator.CreateImage($@"Materials\Pacman\state1.png"));
            pacman.NextPoint = pacman.Point;
            Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Pacman assign to game"));
            Draw_pacman(tmp.ResultGrid, pacman, true);
            PointAnimationHelper.FlickerImage(pacman.MainImage, TimeSpan.FromSeconds(0.3));
            //pacman._animationStateImage.Add(ImageCreator.CreateImage($@"Materials\Pacman\state1.png"));
            //pacman._animationStateImage.Add(ImageCreator.CreateImage($@"Materials\Pacman\state2.png"));
            //StartMouthAnimation();
            AbstractGhost.ResetIndex();
            InitGhosts();
            CreateGhosts(_greenGhostCount, _blueGhostCount, _redGhostCount);
        }
コード例 #2
0
 private void CreateButtonShowFilter()
 {
     ImageCreator.CreateImage(MainCanvasStatistics, 26, 26, 490, 4, "Pictures/showFilter.png");
     buttonShowFilter = ButtonCreator.CreateButton(MainCanvasStatistics, "        Pokaż filtry", 114, 30, 13, 484, 2,
                                                   Color.FromArgb(255, 255, 255, 255), Color.FromArgb(0, 0, 0, 0));
     buttonShowFilter.Background           = new SolidColorBrush(Color.FromArgb(35, 2, 53, 101));
     buttonShowFilter.MouseEnter          += Behavior_MouseEnter;
     buttonShowFilter.MouseLeave          += Behavior_MouseLeave;
     buttonShowFilter.MouseLeftButtonDown += buttonShowFilter_MouseLeftButtonDown;
 }
コード例 #3
0
        private void CreateControlPanel()
        {
            new MyRectangle(MainCanvasStatistics, 600, 35, Color.FromArgb(255, 0, 125, 255), 0, 0);
            ImageCreator.CreateImage(MainCanvasStatistics, 40, 50, 4, -8, "Pictures/application.png");
            countTitleApplication = new MyLabel(MainCanvasStatistics, (tempDateCount != null ? tempDateCount[0] : "0"), 60, 30, 14, 45, 2, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(0, 0, 0, 0),
                                                horizontalAlignment: HorizontalAlignment.Left);

            ImageCreator.CreateImage(MainCanvasStatistics, 26, 26, 110, 4, "Pictures/ActivityImages.png");
            countActivityApplication = new MyLabel(MainCanvasStatistics, tempDateCount != null ? tempDateCount[1] : "0", 60, 30, 14, 140, 2, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(0, 0, 0, 0),
                                                   horizontalAlignment: HorizontalAlignment.Left);


            CreateButtonShowFilter();
            CreateFilter();
        }
コード例 #4
0
        private void CreateCanvasMembershipWithElements()
        {
            Canvas canvasMembership = CanvasCreator.CreateCanvas(MainCanvasCategory, 290, 380, Color.FromArgb(155, 4, 0, 35), 15, 15);

            ImageCreator.CreateImage(canvasMembership, 60, 60, 40, 40, "Pictures/MembershipImages.png");
            new MyLabel(canvasMembership, "Przynależność", 250, 40, 20, 60, 60, Color.FromArgb(255, 255, 255, 255),
                        Color.FromArgb(0, 255, 255, 255));
            MyRectangle r0 = new MyRectangle(canvasMembership, 250, 1, Color.FromArgb(40, 255, 255, 255), 20, 140);


            // przyłącz aplikacje ----------------------------------------------------------------------------------------------
            notJoinedApplications = new MyLabel(canvasMembership, "0", 60, 38, 18, 20, 200, Color.FromArgb(255, 125, 255, 0), Color.FromArgb(255, 255, 255, 255), 0);
            Label buttonJoinApplication = ButtonCreator.CreateButton(canvasMembership, "     Przyłącz Aplikacje", 225, 38, 16, 30, 200,
                                                                     Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);

            buttonJoinApplication.MouseEnter          += buttonJoinApplication_MouseEnter;
            buttonJoinApplication.MouseLeave          += buttonJoinApplication_MouseLeave;
            buttonJoinApplication.MouseLeftButtonDown += buttonJoinApplication_MouseLeftButtonDown;
            MyRectangle r = new MyRectangle(canvasMembership, 200, 1, Color.FromArgb(100, 255, 255, 255), 40, 237);

            //-----------------------------------------------------------------------------------------------------------------

            // przegląd grup
            numberGroups = new MyLabel(canvasMembership, "0", 50, 38, 18, 30, 237, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);
            Label buttonShowGroups = ButtonCreator.CreateButton(canvasMembership, "     Przegląd Grup      ", 225, 38, 16, 30, 237,
                                                                Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);

            buttonShowGroups.MouseEnter          += buttonShowGroups_MouseEnter;
            buttonShowGroups.MouseLeave          += buttonShowGroups_MouseLeave;
            buttonShowGroups.MouseLeftButtonDown += buttonShowGroups_MouseLeftButtonDown;
            MyRectangle r2 = new MyRectangle(canvasMembership, 200, 1, Color.FromArgb(100, 255, 255, 255), 40, 275);

            //------------------------------------------------------------------------------------------------------------------


            // historia aktywności
            numberOfConfiguredGroups = new MyLabel(canvasMembership, "0", 50, 38, 18, 30, 275, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);
            Label buttonConfigurationGroups = ButtonCreator.CreateButton(canvasMembership, "     Konfiguracje Grup", 225, 38, 16, 30, 275,
                                                                         Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);

            buttonConfigurationGroups.MouseEnter          += buttonConfigurationGroups_MouseEnter;
            buttonConfigurationGroups.MouseLeave          += buttonConfigurationGroups_MouseLeave;
            buttonConfigurationGroups.MouseLeftButtonDown += buttonConfigurationGroups_MouseLeftButtonDown;
            MyRectangle r3 = new MyRectangle(canvasMembership, 200, 1, Color.FromArgb(100, 255, 255, 255), 40, 312);
            //------------------------------------------------------------------------------------------------------------------
        }
コード例 #5
0
        private void UpdateViewGraphImage()
        {
            string inputFile = Path.Combine(
                System.Environment.CurrentDirectory, "Graphs/graph.txt");
            string outputFile = Path.Combine(
                System.Environment.CurrentDirectory, "Graphs/image.png");
            string output = ImageCreator.CreateImage(inputFile, outputFile, 1024);

            if (output.Equals(""))
            {
                _view.SetGraphImage(outputFile);
            }
            else
            {
                _view.SetGraphImage("notGenerated.png");
            }
        }
コード例 #6
0
        private void CreateCanvasActivityWithElements()
        {
            Canvas canvasActivity = CanvasCreator.CreateCanvas(MainCanvasCategory, 290, 380, Color.FromArgb(155, 4, 0, 35), 320, 15);

            ImageCreator.CreateImage(canvasActivity, 60, 60, 40, 40, "Pictures/ActivityImages.png");
            new MyLabel(canvasActivity, "Aktywność", 250, 40, 20, 60, 60, Color.FromArgb(255, 255, 255, 255),
                        Color.FromArgb(0, 255, 255, 255));
            MyRectangle r0 = new MyRectangle(canvasActivity, 250, 1, Color.FromArgb(40, 255, 255, 255), 20, 140);


            // przypisz aktywności----------------------------------------------------------------------------------------------
            notAssignedApplications = new MyLabel(canvasActivity, "0", 60, 38, 18, 20, 200, Color.FromArgb(255, 125, 255, 0), Color.FromArgb(255, 255, 255, 255), 0);
            Label buttonAssignActivity = ButtonCreator.CreateButton(canvasActivity, "     Przypisz Aktywności", 225, 38, 16, 30, 200,
                                                                    Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);

            buttonAssignActivity.MouseEnter          += buttonAssignActivity_MouseEnter;
            buttonAssignActivity.MouseLeave          += buttonAssignActivity_MouseLeave;
            buttonAssignActivity.MouseLeftButtonDown += buttonAssignActivity_MouseLeftButtonDown;
            MyRectangle r = new MyRectangle(canvasActivity, 200, 1, Color.FromArgb(100, 255, 255, 255), 40, 237);

            //-----------------------------------------------------------------------------------------------------------------

            // przegląd aktywności
            numberActivity = new MyLabel(canvasActivity, "0", 50, 38, 18, 30, 237, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);
            Label buttonShowActivity = ButtonCreator.CreateButton(canvasActivity, "     Przegląd Aktywności", 225, 38, 16, 30, 237,
                                                                  Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);

            buttonShowActivity.MouseEnter          += buttonShowActivity_MouseEnter;
            buttonShowActivity.MouseLeave          += buttonShowActivity_MouseLeave;
            buttonShowActivity.MouseLeftButtonDown += buttonShowActivity_MouseLeftButtonDown;
            MyRectangle r2 = new MyRectangle(canvasActivity, 200, 1, Color.FromArgb(100, 255, 255, 255), 40, 275);

            //------------------------------------------------------------------------------------------------------------------

            // historia aktywności
            daysHistoryActivity = new MyLabel(canvasActivity, "0", 50, 38, 18, 30, 275, Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);
            Label buttonHistoryActivity = ButtonCreator.CreateButton(canvasActivity, "     Historia Aktywności", 225, 38, 16, 30, 275,
                                                                     Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 255, 255), 0);

            buttonHistoryActivity.MouseEnter          += buttonHistoryActivity_MouseEnter;
            buttonHistoryActivity.MouseLeave          += buttonHistoryActivity_MouseLeave;
            buttonHistoryActivity.MouseLeftButtonDown += buttonHistoryActivity_MouseLeftButtonDown;
            MyRectangle r3 = new MyRectangle(canvasActivity, 200, 1, Color.FromArgb(100, 255, 255, 255), 40, 312);
            //------------------------------------------------------------------------------------------------------------------
        }
コード例 #7
0
        private void CreateGhosts(int Green, int Blue, int Red)
        {
            try
            {
                var dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName + "\\Plugins\\";
                if (Directory.Exists(dir))
                {
                    foreach (string fileName in Directory.GetFiles(dir))
                    {
                        if (fileName.Contains(".dll"))
                        {
                            if (fileName.Contains("Core") || fileName.Contains("Prism") || fileName.Contains("Logs") || fileName.Contains("ValueTuple"))
                            {
                                continue;
                            }
                            Type[] file = Assembly.LoadFrom(fileName).GetTypes();
                            var    AIfromConfiguration = ConfigurationManager.AppSettings["AI_behavior"];
                            int    AI_index            = 0;
                            Int32.TryParse(AIfromConfiguration.Substring(0, 1), out AI_index);
                            dynamic sAI = Activator.CreateInstance(file[AI_index], _field);
                            for (int i = 0; i < Blue; i++)
                            {
                                var tmpGhost = new BlueGhost(sAI, ImageCreator.CreateImage($@"Materials\Ghosts\BlueGhost.png"));
                                tmpGhost.FieldPointNow    = sAI.RandomPoint();
                                tmpGhost.FieldPointTarget = sAI.RandomPoint();
                                tmpGhost.Path             = new PathCreator(_field).GetWay(tmpGhost.FieldPointNow, tmpGhost.FieldPointTarget);
                                tmpGhost.Speed            = _blueGhostSpeed;

                                DrawGhost(MyModel.Field, tmpGhost);
                                _ghostAnimation.Add(new PointAnimationHelper());
                                _ghostAnimation[tmpGhost.Index].PointAnimationHelperNotify += GhostMoving;
                                _ghostAnimation[tmpGhost.Index].PacmanPosition             += PacmanCatchUp;
                                _ghostAnimation[tmpGhost.Index].MoveGost(tmpGhost, tmpGhost.Speed);
                            }
                            for (int i = 0; i < Red; i++)
                            {
                                var tmpGhost = new RedGhost(sAI, ImageCreator.CreateImage($@"Materials\Ghosts\RedGhost.png"));
                                tmpGhost.FieldPointNow    = sAI.RandomPoint();
                                tmpGhost.FieldPointTarget = sAI.RandomPoint();
                                tmpGhost.Path             = new PathCreator(_field).GetWay(tmpGhost.FieldPointNow, tmpGhost.FieldPointTarget);
                                tmpGhost.Speed            = _redGhostSpeed;

                                DrawGhost(MyModel.Field, tmpGhost);
                                _ghostAnimation.Add(new PointAnimationHelper());
                                _ghostAnimation[tmpGhost.Index].PointAnimationHelperNotify += GhostMoving;
                                _ghostAnimation[tmpGhost.Index].PacmanPosition             += PacmanCatchUp;
                                _ghostAnimation[tmpGhost.Index].MoveGost(tmpGhost, tmpGhost.Speed);
                            }
                            for (int i = 0; i < Green; i++)
                            {
                                var tmpGhost = new GreenGhost(sAI, ImageCreator.CreateImage($@"Materials\Ghosts\GreenGhost.png"));
                                tmpGhost.FieldPointNow    = sAI.RandomPoint();
                                tmpGhost.FieldPointTarget = sAI.RandomPoint();
                                tmpGhost.Path             = new PathCreator(_field).GetWay(tmpGhost.FieldPointNow, tmpGhost.FieldPointTarget);
                                tmpGhost.Speed            = _greenGhostSpeed;

                                DrawGhost(MyModel.Field, tmpGhost);
                                _ghostAnimation.Add(new PointAnimationHelper());
                                _ghostAnimation[tmpGhost.Index].PointAnimationHelperNotify += GhostMoving;
                                _ghostAnimation[tmpGhost.Index].PacmanPosition             += PacmanCatchUp;
                                _ghostAnimation[tmpGhost.Index].MoveGost(tmpGhost, tmpGhost.Speed);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Plugins folder not found", "Worning", MessageBoxButton.OK);
                }
            }
            catch (Exception ex)
            {
                Logger.Add(new Log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, $"Error", ex));
            }
        }
コード例 #8
0
        private void LoadGroups()
        {
            List <Membership> allGroups = Membership_db.GetAllGroups(new CommandParameters());

            Application.Current.Dispatcher.Invoke(() => {
                activationGroup      = new Image[allGroups.Count];
                contentCanvas.Height = 310;
                for (int i = 0; i < allGroups.Count; i++)
                {
                    new MyRectangle(contentCanvas, 600, 40, Color.FromArgb((byte)(50 + (i % 2 * 30)), 0, 125, 255), 0, i * 39, 2).SetStroke(Color.FromArgb(255, 30, 39, 93));
                    new MyLabel(contentCanvas, (i + 1).ToString(), 30, 30, 12, 7, 7 + (i * 39), Color.FromArgb(200, 220, 220, 220), Color.FromArgb(230, 230, 0, 0));
                    new MyLabel(contentCanvas, allGroups[i].Title, 200, 30, 12, 35, 7 + (i * 39), Color.FromArgb(200, 220, 220, 220), Color.FromArgb(230, 230, 0, 0));
                    new MyLabel(contentCanvas, allGroups[i].Date.Remove(16), 100, 30, 10, 445, 9 + (i * 39), Color.FromArgb(200, 220, 220, 220), Color.FromArgb(230, 230, 0, 0));

                    ImageCreator.CreateImage(contentCanvas, 20, 20, 245, 10 + (i * 39), "Pictures/rubbishBin.png");
                    buttonDeleteGroup                      = ButtonCreator.CreateButton(contentCanvas, "", 30, 30, 10, 240, 5 + (i * 39), Color.FromArgb(0, 0, 0, 0), Color.FromArgb(0, 0, 0, 0));
                    buttonDeleteGroup.Name                 = "ID_" + allGroups[i].ID.ToString();
                    buttonDeleteGroup.MouseEnter          += buttonGroup_MouseEnter;
                    buttonDeleteGroup.MouseLeave          += buttonGroup_MouseLeave;
                    buttonDeleteGroup.MouseLeftButtonDown += buttonDeleteGroup_MouseLeftButtonDown;

                    ImageCreator.CreateImage(contentCanvas, 20, 20, 295, 10 + (i * 39), "Pictures/eye.png");
                    buttonShowApplications                      = ButtonCreator.CreateButton(contentCanvas, "", 30, 30, 10, 290, 5 + (i * 39), Color.FromArgb(0, 0, 0, 0), Color.FromArgb(0, 0, 0, 0));
                    buttonShowApplications.Name                 = "ID_" + allGroups[i].ID.ToString();
                    buttonShowApplications.MouseEnter          += buttonGroup_MouseEnter;
                    buttonShowApplications.MouseLeave          += buttonGroup_MouseLeave;
                    buttonShowApplications.MouseLeftButtonDown += buttonShowApplications_MouseLeftButtonDown;

                    string loadPictures = string.Empty;
                    if (allGroups[i].IfConfiguration)
                    {
                        loadPictures = "Pictures/checkSymbol.png";
                    }
                    else
                    {
                        loadPictures = "Pictures/cancel.png";
                    }

                    ImageCreator.CreateImage(contentCanvas, 20, 20, 380, 10 + (i * 39), loadPictures);

                    if (allGroups[i].IfActive)
                    {
                        loadPictures = "Pictures/checkSymbol.png";
                    }
                    else
                    {
                        loadPictures = "Pictures/cancel.png";
                    }

                    activationGroup[i]                         = ImageCreator.CreateImage(contentCanvas, 20, 20, 565, 10 + (i * 39), loadPictures);
                    activationGroup[i].Name                    = "ID_" + allGroups[i].ID.ToString();
                    buttonActivationGroup                      = ButtonCreator.CreateButton(contentCanvas, "", 30, 30, 10, 560, 5 + (i * 39), Color.FromArgb(0, 0, 0, 0), Color.FromArgb(0, 0, 0, 0));
                    buttonActivationGroup.Name                 = "ID_" + allGroups[i].ID.ToString();
                    buttonActivationGroup.MouseEnter          += buttonGroup_MouseEnter;
                    buttonActivationGroup.MouseLeave          += buttonGroup_MouseLeave;
                    buttonActivationGroup.MouseLeftButtonDown += buttonActivationGroup_MouseLeftButtonDown;

                    contentCanvas.Height += 39;
                }
            });

            Application.Current.Dispatcher.Invoke(() =>
            {
                contentCanvas.Height = ((contentCanvas.Height - 310) < 310) ? 310 : contentCanvas.Height - 309;
            });
        }