Esempio n. 1
0
 public void DodajPunkty(PictureBox x, PictureBox y, Label z, ProgressBar o)
 {
     if (y.Enabled == true)
     {
         if ((y.BackColor == System.Drawing.Color.Red) && (x.Right > y.Left - 3.5 && x.Left < y.Right - x.Width / 2 && x.Bottom > y.Top && x.Top < y.Bottom))
         {
             if (o.Value < 4 && licznik_grafik_zycia == 5)
             {
                 o.Value += 1;
             }
             y.Hide();
             y.Enabled = false;
             y.Visible = false;
             wynik    += 100;
             z.Text    = Convert.ToString(wynik);
             licznik_grafik_kolek++;
             licznik_grafik_zycia++;
         }
     }
 }
Esempio n. 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            selection.Hide();
            if (e.X < 208)
            {
                selection.Location = new Point(e.X / 16 * 16, e.Y / 16 * 16);
            }
            else
            {
                selection.Location = new Point(224, 24);
            }
            selection.Show();

            if (ColorSelected != null)
            {
                ColorSelected(this, new EventArgs());
            }
        }
Esempio n. 3
0
        private void InitilizePictureBoxes()
        {
            Rectangle horizontalRect = new Rectangle(210, 40, 300, 200);
            Rectangle verticalRect   = new Rectangle(270, 30, 180, 220);

            pictureBoxHorizontal             = new PictureBox();
            pictureBoxHorizontal.Location    = horizontalRect.Location;
            pictureBoxHorizontal.Size        = horizontalRect.Size;
            pictureBoxHorizontal.SizeMode    = PictureBoxSizeMode.StretchImage;
            pictureBoxHorizontal.BorderStyle = BorderStyle.FixedSingle;
            pictureBoxHorizontal.Hide();
            this.Controls.Add(pictureBoxHorizontal);

            pictureBoxVertical             = new PictureBox();
            pictureBoxVertical.Location    = verticalRect.Location;
            pictureBoxVertical.Size        = verticalRect.Size;
            pictureBoxVertical.SizeMode    = PictureBoxSizeMode.StretchImage;
            pictureBoxVertical.BorderStyle = BorderStyle.FixedSingle;
            pictureBoxVertical.Hide();
            this.Controls.Add(pictureBoxVertical);
        }
 public void endGame()
 {
     // updateHighScore(topScoreNames(), topScores());
     // kill gameControl
     // gc = null;
     // hide all images
     player.Hide();
     bat.Hide();
     pit.Hide();
     wumpus.Hide();
     room.Hide();
     door.Hide();
     gold.Hide();
     arrow.Hide();
     secret.Hide();
     // remove projectiles from form
     arrowList.RemoveRange(0, arrowList.Count);
     fireballList.RemoveRange(0, fireballList.Count);
     // show button that takes the user to main menu
     gameForm.Controls.Add(mainMenu);
 }
        private void pengecekanLife()
        {
            if (life == 3)
            {
                listofheart.Image = Properties.Resources._3_life;

                this.Refresh();
            }
            else if (life == 2)
            {
                listofheart.Image = Properties.Resources._2life;

                this.Refresh();
            }
            else if (life == 1)
            {
                listofheart.Image = Properties.Resources._1life;

                this.Refresh();
            }
            else if (life == 0)
            {
                listofheart.Hide();
                timerEnemy1Generator.Enabled = false;
                timerEnemy2Generator.Enabled = false;
                timerLaserMove.Enabled       = false;
                timerGame.Enabled            = false;
                this.Refresh();
                DialogResult userSelection = MessageBox.Show("Life Habis Kamu Kalah!", "Game Over!", MessageBoxButtons.OK);

                if (userSelection == DialogResult.OK)
                {
                    Main_Menu mainmenu = new Main_Menu();
                    mainmenu.Owner = this;
                    mainmenu.Show();
                    this.Close();
                    this.Dispose();
                }
            }
        }
Esempio n. 6
0
        private void UpdateView()
        {
            ContentTextBox.Text = ResourceManager.Map.Segments[_current].Content;
            //PictureBox.ImageLocation = ResourceManager.Map.Segments[_current].ImageName;
            if (ResourceManager.Map.Segments[_current].ImageName == null ||
                ResourceManager.Map.Segments[_current].ImageName == String.Empty)
            {
                PictureBox.Hide();
            }
            else
            {
                PictureBox.Image = Utils.ImageHandler.Base64ToImage(ResourceManager.Map.Segments[_current].ImageName);
                PictureBox.Show();
            }

            SegmentNumericUpDown.Value = _current;

            if (ResourceManager.Map.Segments[_current].IsSpecial &&
                ResourceManager.Map.Segments[_current].Options.Count != 1)
            {
                OptionsPanel.BackColor = System.Drawing.Color.Red;
            }
            else
            {
                OptionsPanel.BackColor = System.Drawing.Color.White;
            }

            OptionsPanel.Controls.Clear();
            for (Int32 i = 0; i < ResourceManager.Map.Segments[_current].Options.Count; ++i)
            {
                MoveOptionControl moc = new MoveOptionControl(_current, i);
                moc.GoToAction   += new EventHandler <Utils.IdEventArgs>(MoveOption_GoToAction);
                moc.RemoveAction += new EventHandler(MoveOption_RemoveAction);

                moc.Location = new System.Drawing.Point(0, 10 + i * moc.Height + moc.Margin.Top);

                OptionsPanel.Controls.Add(moc);
            }
        }
Esempio n. 7
0
 private void NextBtn_Click(object sender, EventArgs e)
 {
     if (time.SelectedItem != null && saal.SelectedItem != null)
     {
         this.Size = new Size(650, 450);
         for (int i = 0; i < 4; i++)
         {
             infoLabel[i].Hide();
         }
         datetime_.Hide();
         saal.Hide();
         nextBtn.Hide();
         data_.Hide();
         poster.Hide();
         time.Hide();
         seats_load();
     }
     else
     {
         MessageBox.Show("Нужно выбрать время и зал");
     }
 }
Esempio n. 8
0
        public PictureBox CreateAgentIcon()
        {
            PictureBox agentIcon = new PictureBox();

            agentIcon.SizeMode  = PictureBoxSizeMode.Zoom;
            agentIcon.BackColor = Color.Transparent;
            agentIcon.Image     = IconPath.agentIcon;
            agentIcon.Size      = new Size(15, 15);
            agentIcon.BringToFront();
            agentIcon.Hide();

            if (panel_Map.InvokeRequired)
            {
                panel_Map.Invoke((MethodInvoker) delegate { panel_Map.Controls.Add(agentIcon); });
            }
            else
            {
                panel_Map.Controls.Add(agentIcon);
            }

            return(agentIcon);
        }
Esempio n. 9
0
        /// <summary>
        /// Создает контроллер создания и управления картой
        /// </summary>
        /// <param name="pb"></param>
        /// <param name="panel"></param>
        /// <param name="font"></param>
        private MakeMap(PictureBox pb, Panel panel, Font font, ToolStripStatusLabel statusLabel)
        {
            {
                StaticViewer.CreateViewer(font);

                this.StatusLabel = statusLabel;

                MapLocationX = 0;
                MapLocationY = 0;

                StaticViewer.Width = 10;

                ZoomCurValue = 1;
                view         = pb;
                substrate    = panel;
                view.Hide();
                view.Enabled = false;

                StaticViewer.Viewer.Resize();
                ViewPort = this;
            }
        }
Esempio n. 10
0
        private void DelayTimer_Tick(object sender, EventArgs e)
        {
            if (card1 != null && card2 != null)
            {
                if (card1.Number == card2.Number && card1.Suit != card2.Suit)
                {
                    picBox2.Hide();
                    picBox1.Hide();
                    matched = matched + 2;
                }
            }

            card1.Flip();
            card2.Flip();
            picBox2.Image = card2.CurrentImage;
            picBox1.Image = card1.CurrentImage;
            card1         = null;
            card2         = null;
            DelayTimer.Stop();
            foreach (PictureBox box in boxes)
            {
                box.Enabled = true;
            }
        }
        // START POINT
        public LazyPictureScrolling()
        {
            InitializeComponent();

            #region Init fields
            listAllPictureBoxs    = new List <PictureBox>();
            lastPicbxIndexShowing = -1;
            #endregion

            #region Init UC's controls properties
            flowlpnlPicsContainer.Dock          = DockStyle.Fill;
            flowlpnlPicsContainer.FlowDirection = FlowDirection.LeftToRight;
            flowlpnlPicsContainer.AutoScroll    = true;
            flowlpnlPicsContainer.WrapContents  = true;
            #endregion

            #region Init events
            flowlpnlPicsContainer.MouseWheel += flowlpnlPicsContainer_MouseWheel;
            flowlpnlPicsContainer.Scroll     += flowlpnlPicsContainer_Scroll;
            #endregion

            #region Init all pictureboxs, and hide them
            for (int i = 0; i < NUMBER_OF_MAX_PICS; i++)
            {
                PictureBox picBox = new PictureBox();
                picBox.Width  = 100;    // 320 ratio
                picBox.Height = 75;     // 240 ratio
                picBox.Hide();
                picBox.ImageLocation = null;
                picBox.SizeMode      = PictureBoxSizeMode.StretchImage;
                picBox.Click        += picBox_Click;
                listAllPictureBoxs.Add(picBox);
                flowlpnlPicsContainer.Controls.Add(picBox);
            }
            #endregion
        }
Esempio n. 12
0
 public void HideClose()
 {
     bt_close.Hide();
 }
Esempio n. 13
0
 private void HideLoading()
 {
     mLoadingBox.Hide();
     pnlCharacters.Controls.Clear();
 }
Esempio n. 14
0
        /// <summary>
        /// Update function of map. Calls Bayes filtering and handles the rotation and translation of all map objects.
        /// </summary>
        private void Update(object sender, EventArgs e)
        {
            lock (robot.mapLock)
            {
                Bayes(true, preySensor, ref preyProbability);
                Bayes(false, obstacleSensor, ref obstacleProbability);
                bBayes = new Bitmap(bMap.Size.Width, bMap.Size.Height);
                SetNewRovioPosition();

                // Run AStar if there is a suitable destination and draw it on the map.
                using (graphics = Graphics.FromImage(bBayes))
                {
                    AStar astar = new AStar(finalMap.GetLength(0), finalMap.GetLength(1));
                    astar.Build(finalMap, new DPoint(destination.X, destination.Y), new DPoint((picBoxRovio.Location.X / 10) + (picBoxRovio.Width / 10 / 2), picBoxRovio.Location.Y / 10));
                    aStarPath = astar.path;
                    for (int i = 0; i < maxX; i++)
                    {
                        for (int j = 0; j < maxY; j++)
                        {
                            graphics.FillRectangle(new SolidBrush(DColor.FromArgb((int)(preyProbability[i, j] * 255), System.Drawing.Color.DarkRed)), new DRectangle(i * 10, j * 10, 10, 10));
                            graphics.FillRectangle(new SolidBrush(DColor.FromArgb((int)(obstacleProbability[i, j] * 255), System.Drawing.Color.DarkBlue)), new DRectangle(i * 10, j * 10, 10, 10));
                            if (astar.inPath[i, j])
                            {
                                graphics.FillRectangle(new SolidBrush(DColor.Red), new DRectangle(i * 10, j * 10, 10, 10));
                            }
                        }
                    }
                }
                picBoxBayes.Image = bBayes;

                // Check which cells are within the viewing cone.
                if (viewConePoints != null)
                {
                    for (int i = 0; i < maxX; i++)
                    {
                        for (int j = 0; j < maxY; j++)
                        {
                            DPoint a = new DPoint(i * 10 + 1, j * 10 + 1);             // Top left
                            DPoint b = new DPoint((i + 1) * 10 - 1, j * 10 + 1);       // Top right
                            DPoint c = new DPoint(i * 10 + 1, (j + 1) * 10 - 1);       // Bottom left
                            DPoint d = new DPoint((i + 1) * 10 - 1, (j + 1) * 10 - 1); // Bottom right
                            if (!(PointInPolygon(a, viewConePoints) || PointInPolygon(b, viewConePoints) ||
                                  PointInPolygon(c, viewConePoints) || PointInPolygon(d, viewConePoints)))
                            {
                                isCellVisible[i, j] = false;
                            }
                            else
                            {
                                preySensor[i, j]     = false;
                                obstacleSensor[i, j] = false;
                                isCellVisible[i, j]  = true;
                            }
                        }
                    }
                }

                if (robot.GetType() == typeof(Rovio.PredatorMap))
                {
                    if (robot.IsPreySeen())
                    {
                        FindRelativeLocation(picBoxPrey, robot.preyRectangle, robot.GetPreyDistance(), 1, 1);

                        try
                        {
                            preySensor[(int)((picBoxPrey.Location.X / 10) + 1.5), (int)((picBoxPrey.Location.Y / 10) + 1.5)] = true;
                        } catch { }
                    }
                    else
                    {
                        picBoxPrey.Hide();
                    }

                    if ((robot as Rovio.BaseArena).IsObstacleSeen())
                    {
                        // Find obstacle position relative to the Rovio's position.
                        FindRelativeLocation(picBoxObstacle, robot.obstacleRectangle, robot.GetObstacleDistance(), 40, 3);
                        try
                        {
                            int p = (int)((picBoxObstacle.Location.X / 10) + 0.5);
                            int q = (int)((picBoxObstacle.Location.Y / 10) + 0.5);

                            // Populate 3x3 area with the obstacle.
                            for (int i = -1; i <= 1; i++)
                            {
                                for (int j = -1; j <= 1; j++)
                                {
                                    obstacleSensor[(int)((picBoxObstacle.Location.X / 10) + i), (int)((picBoxObstacle.Location.Y / 10) + j)] = true;
                                }
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        picBoxObstacle.Hide();
                    }
                }


                // Rotate the Rovio icon to the angle that the robot physically faces.
                System.Drawing.Drawing2D.Matrix matrixRovio = new System.Drawing.Drawing2D.Matrix();
                matrixRovio.RotateAt((float)robot.cumulativeAngle, new System.Drawing.Point(picBoxRovio.Location.X + (picBoxRovio.Size.Width / 2), picBoxRovio.Location.Y + (picBoxRovio.Size.Height / 2)));
                matrixRovio.Translate(0f, -0f);
                DPoint[] rovioMovementPoints = { new DPoint(picBoxRovio.Location.X + (picBoxRovio.Size.Width / 2),      picBoxRovio.Location.Y + (picBoxRovio.Size.Height / 2)),
                                                 new DPoint(picBoxRovio.Location.X + (picBoxRovio.Size.Width / 2) - 69, picBoxRovio.Location.Y - 150),
                                                 new DPoint(picBoxRovio.Location.X + (picBoxRovio.Size.Width / 2) + 69, picBoxRovio.Location.Y - 150) };
                matrixRovio.TransformPoints(rovioMovementPoints);

                if ((robot as Rovio.BaseArena).IsObstacleSeen())
                {
                    // Get the left and right points of the obstacle in the viewing cone and orientate accordingly.
                    DPoint leftPoint  = new DPoint(picBoxObstacle.Location.X - (picBoxObstacle.Width / 2), picBoxObstacle.Location.Y - 15);
                    DPoint rightPoint = leftPoint;
                    using (matrix = new System.Drawing.Drawing2D.Matrix())
                    {
                        matrix.RotateAt((float)robot.cumulativeAngle, leftPoint);
                        matrix.Translate(0, -0f);

                        DPoint[] tempPointArr = { leftPoint };
                        matrix.TransformPoints(tempPointArr);
                        leftPoint = tempPointArr[0];

                        // Transform the right point relative to the position of the left.
                        matrix = new System.Drawing.Drawing2D.Matrix();
                        matrix.RotateAt((float)robot.cumulativeAngle, leftPoint);
                        matrix.Translate(30, 0);
                        tempPointArr[0] = new DPoint(0, 0);
                        matrix.TransformPoints(tempPointArr);
                        rightPoint = tempPointArr[0];
                    }

                    // Check if all points are still within the viewing cone. If not, skip over them.
                    if (PointInPolygon(leftPoint, rovioMovementPoints) && PointInPolygon(rightPoint, rovioMovementPoints))
                    {
                        rovioMovementPoints = new DPoint[] { rovioMovementPoints[0], rovioMovementPoints[1], leftPoint, rightPoint, rovioMovementPoints[2] }
                    }
                    ;
                }


                viewConePoints = rovioMovementPoints;
                Bitmap rotated = new Bitmap(bRovio.Width + 70, bRovio.Height + 70);
                rotated.SetResolution(bRovio.HorizontalResolution, bRovio.VerticalResolution);

                using (graphics = Graphics.FromImage(rotated))
                {
                    graphics.TranslateTransform(bRovio.Width / 2, bRovio.Height / 2);
                    graphics.RotateTransform((float)robot.cumulativeAngle);
                    graphics.TranslateTransform(-bRovio.Width / 2, -bRovio.Height / 2);
                    graphics.DrawImage(bRovio, new DPoint(0, 0));

                    picBoxRovio.Size  = new Size(27, 24);
                    picBoxRovio.Image = rotated;

                    picBoxCone.Location = new DPoint(picBoxRovio.Location.X - (bCone.Width / 2) + (bRovio.Width / 2), picBoxRovio.Location.Y - bCone.Height + (bRovio.Height / 2));
                    picBoxCone.Size     = new Size(900, 500);
                    picBoxCone.Image    = rotated;

                    picBoxCone.Location = new DPoint(0, 0);
                    picBoxCone.Size     = new Size(260, 300);
                }

                Bitmap newCone = new Bitmap(260, 300);
                using (graphics = Graphics.FromImage(newCone))
                {
                    graphics.FillPolygon(new SolidBrush(DColor.FromArgb(100, DColor.ForestGreen)), viewConePoints);
                    picBoxCone.Image = newCone;
                }
            }
        }
 public frmDynamicPic()
 {
     InitializeComponent();
     lblClickOnPic.Hide();
     PictureBox.Hide();
 }
Esempio n. 16
0
 public void HideButton()
 {
     btDelete.Hide();
     btFix.Hide();
 }
Esempio n. 17
0
File: Form1.cs Progetto: NTYK/Class
        private int create(string content)
        {
            //何×何か
            int  width_max = 0, height_max = 0, start_x = 0, start_y = 0;
            bool two_flag = false, three_flag = false;

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            System.IO.StringReader       rs = new System.IO.StringReader(content);
            //1行ずつ読み込む
            while (rs.Peek() > -1)
            {
                int    count = 0;
                string t     = rs.ReadLine();
                for (int i = 0; i < t.Length; i++)
                {
                    if (!Char.IsDigit(t[i]))
                    {
                        //0,1,2,3以外の文字が含まれていないか
                        if (!(t[i] == ' ' || t[i] == ','))
                        {
                            return(3);
                        }
                    }
                    else
                    {
                        count++;
                        if (t[i] == '2')
                        {
                            two_flag = true;
                        }
                        if (t[i] == '3')
                        {
                            three_flag = true;
                        }
                    }
                }
                //更新
                if (width_max < count)
                {
                    width_max = count;
                }
                if (count != 0)
                {
                    height_max++;
                }
                else
                {
                    //空行が含まれているか
                    if (width_max == 0)
                    {
                        return(4);
                    }
                }
            }
            //2,3を含んでいたか
            if (two_flag == false || three_flag == false)
            {
                return(1);
            }

            //ボタン設定
            bt6.Show();
            bt7.Show();
            bt8.Show();

            //タブコントロールを表示
            tab          = new TabControl();
            tab.Size     = new Size(460, 385);
            tab.Location = new Point(10, 35);
            TabPage tab1 = new TabPage("木構造");

            tab.TabPages.Add(tab1);
            TabPage tab2 = new TabPage("迷路回答");

            tab.TabPages.Add(tab2);
            this.Controls.Add(tab);

            //パネルの設定
            panel1             = new Panel();
            panel1.BorderStyle = BorderStyle.Fixed3D;
            panel1.Location    = new Point(5, 5);
            panel1.Size        = new Size(440, 350);
            panel1.BackColor   = Color.White;
            panel1.AutoScroll  = true;
            tab1.Controls.Add(panel1);

            panel2             = new Panel();
            panel2.BorderStyle = BorderStyle.Fixed3D;
            panel2.Location    = new Point(5, 5);
            panel2.Size        = new Size(440, 350);
            panel2.BackColor   = Color.White;
            panel2.AutoScroll  = true;
            tab2.Controls.Add(panel2);

            //ピクチャーボックスの設定
            pb1           = new PictureBox();
            pb1.Location  = new Point(0, 0);
            pb1.Size      = new Size(400, 345);
            pb1.BackColor = Color.White;
            panel1.Controls.Add(pb1);

            pb2           = new PictureBox();
            pb2.Location  = new Point(0, 0);
            pb2.BackColor = Color.White;
            panel2.Controls.Add(pb2);

            pb3           = new PictureBox();
            pb3.Location  = new Point(0, 0);
            pb3.Size      = new Size(400, 345);
            pb3.BackColor = Color.White;
            panel1.Controls.Add(pb3);
            pb3.Hide();

            pb4           = new PictureBox();
            pb4.Location  = new Point(0, 0);
            pb4.BackColor = Color.White;
            panel2.Controls.Add(pb4);
            pb4.Hide();

            //マップの土台になるピクチャーボックスの設定
            if (width_max > 7)
            {
                pb2.Width = 10 + 10 * width_max + 40 * width_max;
                pb4.Width = 10 + 10 * width_max + 40 * width_max;
            }
            else
            {
                pb2.Width = 400;
                pb4.Width = 400;
            }
            if (height_max > 5)
            {
                pb2.Height = 10 + 10 * height_max + 40 * height_max;
                pb4.Height = 10 + 10 * height_max + 40 * height_max;
            }
            else
            {
                pb2.Height = 345;
                pb4.Height = 345;
            }

            //描画設定
            Bitmap   canvas2 = new Bitmap(pb2.Width, pb2.Height);
            Graphics g2      = Graphics.FromImage(canvas2);
            Bitmap   canvas4 = new Bitmap(pb4.Width, pb4.Height);
            Graphics g4      = Graphics.FromImage(canvas4);

            //動的配列
            data         = new int[height_max + 1, width_max + 1];
            d_node_count = new int[100];
            b_node_count = new int[100];

            //ルート(木構造)
            Node root1 = null, root2 = null;

            //データ格納変数に値を入れる
            int y = 0;

            rs = new System.IO.StringReader(content);
            while (rs.Peek() > -1)
            {
                int    x = 0;
                string t = rs.ReadLine();
                for (int k = 0; k < t.Length; k++)
                {
                    if (Char.IsDigit(t[k]))
                    {
                        if (t[k] == '0')
                        {
                            data[y, x++] = 1;
                        }
                        else if (t[k] == '1')
                        {
                            data[y, x++] = 0;
                        }
                        else
                        {
                            data[y, x++] = t[k] - 48;
                        }
                        if (t[k] == '2')
                        {
                            start_x = x - 1;
                            start_y = y;
                        }
                    }
                }
                while (x < width_max)
                {
                    data[y, x++] = 0;
                }
                y++;
            }
            //一度通っているか記録するbool配列の定義
            bool[,,] width  = width = new bool[1, height_max + 1, width_max];
            bool[,,] height = height = new bool[1, height_max, width_max + 1];

            Pen         pen     = new Pen(Color.FromArgb(255, 255, 0, 0), 10);
            Queue <int> queue_x = new Queue <int>();
            Queue <int> queue_y = new Queue <int>();
            Queue <int> Parents = new Queue <int>();

            queue_x.Enqueue(start_x);
            queue_y.Enqueue(start_y);
            Parents.Enqueue(4);

            //時間計測開始
            sw.Start();
            //深さ優先探索
            if (!depth_first_search(start_x, start_y, width, height, 0, null, ref root1, g2, pen))
            {
                return(2);
            }
            //時間計測終了
            sw.Stop();
            label3.Text = "探索時間 " + sw.Elapsed;

            sw = new System.Diagnostics.Stopwatch();

            //一度通っているか記録するbool配列を再定義
            width  = new bool[1, height_max + 1, width_max];
            height = new bool[1, height_max, width_max + 1];
            Node[] n = new Node[1];
            n[0] = null;

            //時間計測開始
            sw.Start();
            //幅優先探索
            breadth_first_search(queue_x, queue_y, width, height, width_max, height_max, 0, Parents, n, ref root2, g4, pen);
            //時間計測終了
            sw.Stop();
            label4.Text = "探索時間 " + sw.Elapsed;

            root1.button.BackColor = Color.Blue;
            root2.button.BackColor = Color.Blue;

            //描画設定
            Bitmap   canvas1 = new Bitmap(pb1.Width, pb1.Height);
            Graphics g1      = Graphics.FromImage(canvas1);
            Bitmap   canvas3 = new Bitmap(pb3.Width, pb3.Height);
            Graphics g3      = Graphics.FromImage(canvas3);

            pen = new Pen(Color.FromArgb(255, 0, 0, 0), 3);
            d_branch_draw(root1, g1, pen);
            b_branch_draw(root2, g3, pen);

            d_maze(width_max, height_max);
            b_maze(width_max, height_max);

            g1.Dispose();
            g2.Dispose();
            g3.Dispose();
            g4.Dispose();
            pb1.Image = canvas1;
            pb2.Image = canvas2;
            pb3.Image = canvas3;
            pb4.Image = canvas4;

            //ラベルの設定
            label3.Show();

            //フォームをリサイズ
            this.Size = new Size(500, 500);

            //ウィンドウ上にあるコントロールをすべて非表示
            label1.Hide();
            label2.Hide();
            tb.Hide();
            bt3.Hide();
            bt4.Hide();
            bt5.Hide();
            bt9.Hide();

            //作成成功時に表示するメッセージ
            MessageBox.Show("木構造と迷路の回答を表示します",
                            "成功",
                            MessageBoxButtons.OK);

            return(0);
        }
Esempio n. 18
0
        private void timerKorttiAika_Tick(object sender, EventArgs e)               // Tarkistaa ovatko käännetyt kuvat samat. Jos kuvat ovat samat sovellus piilottaa ne näkyvistä.
        {                                                                           // Tässä kohtaa korttien kääntöä laskeva ajastin pysähtyy tarkistuksen ajaksi.
            timerKorttiAika.Enabled = false;                                        //Kun sovellus on käynyt silmukan läpi klikkausten määrä muuttuu jälleen nollaksi ja laskuri aloittaa alusta.
                                                                                    //Sovellus vaihtaa vuoron toiselle pelaajalle, jos korttien kuvat eivät olleet samat ja silmukka alkaa alusta .
            if (((Image)p1.Tag).Tag.ToString() != ((Image)p2.Tag).Tag.ToString())   //Jos kortit ovat samat vuoro pysyy oikean parin kääntäneellä pelaajalla.
            {
                p1.Image = (Image)muistipeli.Properties.Resources.tausta;
                p2.Image = (Image)muistipeli.Properties.Resources.tausta;

                if (pelaaja1 == true)
                {
                    pelaaja1 = false;
                    pelaaja2 = true;
                    lbNimimerkki1.BackColor = System.Drawing.SystemColors.Control;
                    labelNimi1.BackColor    = System.Drawing.SystemColors.Control;
                    lbNimimerkki2.BackColor = System.Drawing.Color.LightSeaGreen;
                    labelNimi2.BackColor    = System.Drawing.Color.LightSeaGreen;
                }
                else if (pelaaja2 == true)
                {
                    pelaaja1 = true;
                    pelaaja2 = false;
                    lbNimimerkki1.BackColor = System.Drawing.Color.LightSeaGreen;
                    labelNimi1.BackColor    = System.Drawing.Color.LightSeaGreen;
                    lbNimimerkki2.BackColor = System.Drawing.SystemColors.Control;
                    labelNimi2.BackColor    = System.Drawing.SystemColors.Control;
                }
            }
            klikkaus = 0;

            if (((Image)p1.Tag).Tag.ToString() == ((Image)p2.Tag).Tag.ToString())
            {
                p1.Hide();
                p2.Hide();
                if (pelaaja1 == true)
                {
                    pistelaskuri1++;
                    lbPisteLaskuri1.Text = pistelaskuri1.ToString();
                }
                else
                {
                    pistelaskuri2++;
                    lbPisteLaskuri2.Text = pistelaskuri2.ToString();
                }
            }
            if (pistelaskuri1 + pistelaskuri2 == loppupisteet) //Pistelaskuri tarkistaa maksimipistemäärän Form1 saadun comboboxin lukumäärästä ja vertaa sitä pelaajien yhteispistemäärään.
            {                                                  //Kun pistemäärät ovat samat, eli kaikki parit on löydetty peliaikalaskuri pysähtyy, peli päättyy ja
                timerPeliAika.Enabled = false;                 //sovellus lukee tiedostoon pelin tulokset (pelaajan nimimerkki, aika ja löydettyjen parein lukumäärä)

                PeliTiedot p = new PeliTiedot();
                p.nimi1       = Form3.pelaajanimi1;
                p.nimi2       = Form3.pelaajanimi2;
                p.pelattuAika = lbPeliAika.Text;
                p.parit1      = lbPisteLaskuri1.Text;
                p.parit2      = lbPisteLaskuri2.Text;

                StreamWriter sw = new StreamWriter(form1.tiedostoKaksinpeli, true);

                sw.WriteLine("Pelaaja 1: {0} \nAika: {1} s \nParit: {2}", p.nimi1, p.pelattuAika, p.parit1);
                sw.WriteLine("Pelaaja 2: {0} \nAika: {1} s \nParit: {2}", p.nimi2, p.pelattuAika, p.parit2);
                sw.WriteLine();
                sw.Close();

                if (MessageBox.Show("Haluatko aloittaa uuden pelin?",
                                    "Muistipeli",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Information) == DialogResult.No)
                {
                    this.Close();
                    Form2.ActiveForm.Dispose();
                }
                else
                {
                    pistelaskuri1        = 0;
                    pistelaskuri2        = 0;
                    lbPisteLaskuri1.Text = pistelaskuri1.ToString();
                    lbPisteLaskuri2.Text = pistelaskuri2.ToString();
                    Form5_Load(sender, e);
                }
            }
        }
Esempio n. 19
0
 public void Hide()
 {
     picBoxMap.Hide();
 }
Esempio n. 20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // open form in Full Screen
            this.TopMost         = true;
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState     = FormWindowState.Maximized;

            // add emergency center picture
            PictureBox emergencyBox = new PictureBox();

            emergencyBox.Location  = new System.Drawing.Point(420, 40);
            emergencyBox.Name      = "emergencyBox";
            emergencyBox.Size      = new System.Drawing.Size(428, 80);
            emergencyBox.BackColor = clr2;
            Controls.Add(emergencyBox);
            emergencyBox.Load("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\emergency.png");

            // add color box
            PictureBox colorBox = new PictureBox();

            colorBox.Location  = new System.Drawing.Point(160, 240);
            colorBox.Name      = "colorBox";
            colorBox.Size      = new System.Drawing.Size(1045, 495);
            colorBox.BackColor = clr1;
            colorBox.BringToFront();
            Controls.Add(colorBox);

            // add police department picture
            PictureBox policeBox = new PictureBox();

            policeBox.Location  = new System.Drawing.Point(158, 175);
            policeBox.Name      = "policeBox";
            policeBox.Size      = new System.Drawing.Size(88, 65);
            policeBox.BackColor = clr2;
            Controls.Add(policeBox);
            policeBox.Load("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\p-station.png");

            // add fire department picture
            PictureBox fireBox = new PictureBox();

            fireBox.Location  = new System.Drawing.Point(1095, 175);
            fireBox.Name      = "fireBox";
            fireBox.Size      = new System.Drawing.Size(111, 65);
            fireBox.BackColor = clr2;
            Controls.Add(fireBox);
            fireBox.Load("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\f-station.png");

            // map parameters
            const int tileSize   = 55;
            const int gridRows   = 19;
            const int gridCols   = 9;
            const int alignTop   = 0;
            const int alignRight = 0;

            Random rnd = new Random();

            // initialize the city map
            mapPanels    = new Panel[gridRows, gridCols];
            mapLocations = new string[gridRows, gridCols];

            // double for loop to handle all rows and columns
            for (var n = 0; n < gridRows; n++)
            {
                for (var m = 0; m < gridCols; m++)
                {
                    // create new Panel control
                    var newPanel = new Panel
                    {
                        Size     = new Size(tileSize, tileSize),
                        Location = new Point(alignRight + tileSize * n, alignTop + tileSize * m),
                    };

                    // add to Form's Controls so that they show up
                    Controls.Add(newPanel);

                    // bring panel to front
                    newPanel.BringToFront();
                    newPanel.Parent = colorBox;
                    // add to our 2d array of panels for future use
                    mapPanels[n, m] = newPanel;

                    // color the backgrounds
                    if (n == 0 || n == gridRows - 1 || m == 0 || m == gridCols - 1)
                    {
                        newPanel.BackColor             = clr1;
                        newPanel.BackgroundImageLayout = ImageLayout.Stretch;

                        if (m == 0 && n == 0)
                        {
                            newPanel.BackgroundImage = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\top-left.png");
                            mapLocations[n, m]       = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\top-left.png";
                        }
                        else if (m == 0 && n == gridRows - 1)
                        {
                            newPanel.BackgroundImage = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\top-right.png");
                            mapLocations[n, m]       = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\top-right.png";
                        }
                        else if (m == gridCols - 1 && n == 0)
                        {
                            newPanel.BackgroundImage = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\down-left.png");
                            mapLocations[n, m]       = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\down-left.png";
                        }
                        else if (m == gridCols - 1 && n == gridRows - 1)
                        {
                            newPanel.BackgroundImage = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\down-right.png");
                            mapLocations[n, m]       = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\down-right.png";
                        }
                        else if (m == 0 || m == gridCols - 1)
                        {
                            newPanel.BackgroundImage = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line2.png");
                            mapLocations[n, m]       = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line2.png";
                        }
                        else
                        {
                            newPanel.BackgroundImage = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line.png");
                            mapLocations[n, m]       = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line.png";
                        }
                    }
                    else
                    {
                        if (n % 2 == 1)
                        {
                            if (m % 2 == 1)
                            {
                                newPanel.BackColor             = clr2;
                                newPanel.BackgroundImageLayout = ImageLayout.Stretch;
                                newPanel.BackgroundImage       = Image.FromFile($"C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\house{rnd.Next(1, 17)}.png");
                            }
                            else
                            {
                                newPanel.BackColor             = clr1;
                                newPanel.BackgroundImageLayout = ImageLayout.Stretch;
                                newPanel.BackgroundImage       = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line2.png");
                                mapLocations[n, m]             = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line2.png";
                            }
                        }
                        else
                        {
                            newPanel.BackColor             = clr1;
                            newPanel.BackgroundImageLayout = ImageLayout.Stretch;
                            newPanel.BackgroundImage       = Image.FromFile("C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line.png");
                            mapLocations[n, m]             = "C:\\Users\\i.Gerov\\source\\repos\\Emergency Center\\Emergency Center\\Images\\white line.png";
                        }
                    }
                }
            }

            // create random amount of objects

            // create start police patrolling button
            this.Controls.Add(buttonOne);
            buttonOne.Size     = new Size(200, 80);
            buttonOne.Location = new Point(100, 60);
            buttonOne.TabStop  = false;
            buttonOne.Text     = "Start";
            buttonOne.Font     = new Font("Arial", 24, FontStyle.Bold);
            buttonOne.Click   += new EventHandler(this.btn_Click);

            // create start fire patrolling button
            this.Controls.Add(buttonTwo);
            buttonTwo.Size     = new Size(200, 80);
            buttonTwo.Location = new Point(1050, 60);
            buttonTwo.TabStop  = false;
            buttonTwo.Text     = "Start";
            buttonTwo.Font     = new Font("Arial", 24, FontStyle.Bold);
            buttonTwo.Click   += new EventHandler(this.btn2_Click);

            // hide buttons
            buttonOne.Hide();
            buttonTwo.Hide();
            emergencyBox.Hide();

            // create action button
            this.Controls.Add(buttonThree);
            buttonThree.Size     = new Size(140, 60);
            buttonThree.Location = new Point(558, 150);
            buttonThree.TabStop  = false;
            buttonThree.Text     = "Action";
            buttonThree.Font     = new Font("Arial", 24, FontStyle.Bold);
            buttonThree.Click   += new EventHandler(this.btn3_Click);

            // create timer label
            this.Controls.Add(label1);
            label1.Text     = "00:00:00";
            label1.Visible  = true;
            label1.Font     = new Font("MS UI Gothic", 42, FontStyle.Regular);
            label1.Location = new Point(740, 152);
            label1.Size     = new Size(220, 60);
        }
        public async void Simulation(int ii, int jj, int vitesse)
        {
            DesactiverEchiquier();
            InitialiserEchiquier();

            /*--------------------------------------------------------------------*/
            /*            Définitions et déclarations                             */
            /*--------------------------------------------------------------------*/

            int nb_fuite, min_fuite, lmin_fuite = 0;
            int i, j, k, l;


            /*--------------------------------------------------------------------*/
            /*                          Initialisation                            */
            /*--------------------------------------------------------------------*/
            for (i = 0; i < 12; i++)
            {
                for (j = 0; j < 12; j++)
                {
                    echec[i, j] = ((i < 2 | i > 9 | j < 2 | j > 9) ? -1 : 0);
                }
            }


            /*--------------------------------------------------------------------*/
            /*                Parcours du cavalier sur l'échiquier                */
            /*--------------------------------------------------------------------*/

            i                         = ii + 1; j = jj + 1;
            echec[i, j]               = 1;
            Echiquier[i, j].Text      = "1";
            Echiquier[i, j].BackColor = Color.Green;


            pictureBox1.Location = Echiquier[i, j].Location;

            for (k = 2; k <= 64; k++)
            {
                for (l = 0, min_fuite = 11; l < 8; l++)
                {
                    ii = i + depi[l]; jj = j + depj[l];

                    nb_fuite = ((echec[ii, jj] != 0) ? 10 : fuite(ii, jj));

                    if (nb_fuite < min_fuite)
                    {
                        min_fuite = nb_fuite; lmin_fuite = l;
                    }
                }
                if (min_fuite == 9 & k != 64)
                {
                    MessageBox.Show("Impasse !");

                    break;
                }
                i          += depi[lmin_fuite]; j += depj[lmin_fuite];
                echec[i, j] = k;
                await Task.Delay(vitesse);

                //Addapter la couleur du cavalier
                if (Echiquier[i, j].BackColor == Color.NavajoWhite)
                {
                    pictureBox1.BackColor = Color.NavajoWhite;
                }
                else
                {
                    pictureBox1.BackColor = Color.SaddleBrown;
                }


                Echiquier[i, j].Text      = k.ToString();
                Echiquier[i, j].FlatStyle = FlatStyle.Flat;
                Echiquier[i, j].FlatAppearance.BorderColor = Color.Blue;
                Echiquier[i, j].FlatAppearance.BorderSize  = 5;
                pictureBox1.Location = Echiquier[i, j].Location;
                pictureBox1.Show();


                if (ButtonClicked == true)
                {
                    InitialiserEchiquier();
                    compteur = 0;
                    DesactiverEchiquier();
                    Simulation_Button.Enabled = true;
                    Jouer_Button.Enabled      = true;
                    pictureBox1.Hide();
                    break;
                }
                while (IsStopped == true)
                {
                    await Task.Delay(1);
                }
            }
        }
Esempio n. 22
0
        private async void pictureBox_click(object sender, EventArgs e)
        {
            socarddangmo++;
            if (socarddangmo >= 3)
            {
                socarddangmo = 0;
                return;
            }

            PictureBox P = (PictureBox)(sender);

            int cardnum = Int32.Parse((P.Name.Substring(4)));

            if (LISTCARD.getCard(cardnum).getcardstatus() == 0 && PrePic == null || PrePic != null && PrePic.Name != P.Name)
            {
                object o = Properties.Resources.ResourceManager.GetObject(LISTCARD.getCard(cardnum).getcardimagename() + typeCard);
                P.Image = (Image)o;
                LISTCARD.getCard(cardnum).setcardstatus(1);



                if (cardmo1 != 0 && cardmo2 == 0)
                {
                    cardmo2 = cardnum;
                }
                else if (cardmo1 == 0)
                {
                    cardmo1 = cardnum;
                }
                //check 2 cai neu giong nhau thi...
                if (cardmo1 != 0 && cardmo2 != 0 && LISTCARD.getCard(cardmo1).getcardimagename() == LISTCARD.getCard(cardmo2).getcardimagename())
                {
                    await Task.Delay(300);

                    //SoundPlayer sp = new SoundPlayer(@"C:\Users\abc\Desktop\item lol\Ys.wav");
                    //sp.Play();

                    P.Hide();
                    PrePic.Hide();

                    socarddangmo = 0;

                    cardmo1     = 0;
                    cardmo2     = 0;
                    PrePic      = null;
                    socardxong += 2;
                    if (socardxong == _NUMCOLUMN_ * _NUMROW_)
                    {
                        ((SoloMultiplay)this.MdiParent).Win();
                    }
                }
                if (cardmo1 != 0 && cardmo2 != 0 && LISTCARD.getCard(cardmo1).getcardimagename() != LISTCARD.getCard(cardmo2).getcardimagename())
                {
                    await Task.Delay(200);

                    covercard(P);
                    covercard(PrePic);
                    socarddangmo = 0;

                    LISTCARD.getCard(cardmo1).setcardstatus(0);
                    LISTCARD.getCard(cardmo2).setcardstatus(0);
                    cardmo1 = 0;
                    cardmo2 = 0;
                    PrePic  = null;
                }
                if ((cardmo1 == 0 || cardmo2 == 0) && cardmo1 != cardmo2)
                {
                    PrePic = (PictureBox)(sender);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Management of the clicks on the pictureboxes
        /// </summary>
        /// <param name="sender">Clicked picturebox</param>
        private void ClickImage(object sender)
        {
            currentPlayer = frmGameInstance.GetCurrentPlayer();

            // Refresh the labels with the new current player stats
            frmGameInstance.SetTextForLabel(frmGameInstance.GetCurrentPlayer());

            ShowCard((PictureBox)sender); // Turns the card around to show the image
            switch (clickCount)
            {
            // First image clicked
            case 0:
                pbClicked1 = (PictureBox)sender;
                clickCount++;
                break;

            // Second image clicked
            case 1:
                // Do not allow click on the same picturebox by checking the tags
                if (pbClicked1.Tag != ((PictureBox)sender).Tag)
                {
                    currentPlayer.playerAttempts++;     // Count the attempt anyway
                    clickCount = 0;
                    pbClicked2 = (PictureBox)sender;

                    if (CompareCards(pbClicked1.Name, pbClicked2.Name))     // Same images
                    {
                        System.Threading.Thread.Sleep(750);
                        pbClicked1.Hide();
                        pbClicked2.Hide();
                        currentPlayer.playerScore++;

                        if (!frmGameInstance.CheckGameFinished())
                        {
                            // Initiate the click again if the computer found a pair
                            if (ComputerPlays)
                            {
                                ProcessClickedImage(null, null);
                            }
                        }
                        else
                        {
                            frmGameInstance.ShowScore();
                        }
                    }
                    else                                     // Different images so hide them again
                    {
                        System.Threading.Thread.Sleep(1000); // Let the cards visible for a moment to remember the image
                        HideCards(pbClicked1, pbClicked2);
                        frmGameInstance.ChangePlayer();
                        if (frmGameInstance.GetCurrentPlayer() is PlayerIA)
                        {
                            ComputerPlays = true;
                            ProcessClickedImage(null, null);
                        }
                        else
                        {
                            ComputerPlays = false;
                        }
                    }
                }
                break;

            default:
                break;
            }

            // Refresh the labels with the new current player stats
            frmGameInstance.SetTextForLabel(frmGameInstance.GetCurrentPlayer());
        }
Esempio n. 24
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            PictureBox resim_ilk = sender as PictureBox;

            resim_ilk.Image = imageList1.Images[(int)resim_ilk.Tag];
            panel1.Refresh();



            if (tıklanan == 0)
            {
                resim_ikinci = resim_ilk;
                tıklanan++;
                Thread.Sleep(1000);
                return;
            }
            else if (tıklanan == 1)
            {
                if (oyuncuSıra == true)
                {
                    if (resim_ikinci.Tag.ToString() == resim_ilk.Tag.ToString())
                    {
                        oyuncu1++;
                        label5.Text = "" + oyuncu1;
                    }
                    label2.Text = "Sıra Oyuncu 2 de ";


                    oyuncuSıra = false;
                }
                else
                {
                    oyuncuSıra = true;

                    if (resim_ikinci.Tag.ToString() == resim_ilk.Tag.ToString())
                    {
                        oyuncu2++;
                        label6.Text = "" + oyuncu2;
                    }

                    label2.Text = "Sıra Oyuncu 1 de ";
                }
                MessageBox.Show(label2.Text);


                Thread.Sleep(1500);
                if (resim_ikinci.Tag.ToString() == resim_ilk.Tag.ToString())
                {
                    if (resim_ilk == resim_ikinci)
                    {
                        return;
                    }
                    resim_ilk.Hide();
                    resim_ikinci.Hide();
                }
                else
                {
                    gizle();
                }



                tıklanan = 0;
            }
        }
Esempio n. 25
0
        protected void populate(DirectoryInfo path)
        {
            loading = false;
            Thread.Sleep(100);
            loading = true;
            this.runOnUiThread(() => {
                Text = path.FullName;
                if (!backButton.Visible)
                {
                    backButton.Visible = true;
                }
                loadingImage.Visible = true;
                setAnimations(false);
                Invalidate();
            });
            currentPath = path.FullName;
            //SuspendLayout();
            list.Controls.Clear();
            F.async(() => {
                try {
                    MouseEventHandler click = delegate(object o, MouseEventArgs args) {
                        try {
                            if ((ModifierKeys & Keys.Control) != Keys.Control && (ModifierKeys & Keys.Shift) != Keys.Shift)
                            {
                                foreach (Control c in list.Controls)
                                {
                                    if (c is FolderButton)
                                    {
                                        ((FolderButton)c).setSelected(false);
                                    }
                                }
                            }
                            if ((ModifierKeys & Keys.Shift) == Keys.Shift)
                            {
                                if (mostRecent == -1)
                                {
                                    goto selectSingle;
                                }
                                int curr = list.Controls.IndexOf((Control)o);
                                if (curr > mostRecent)
                                {
                                    for (int i = mostRecent; i <= curr; i++)
                                    {
                                        ((FolderButton)list.Controls[i]).setSelected();
                                    }
                                }
                                else
                                {
                                    for (int i = mostRecent; i >= curr; i--)
                                    {
                                        ((FolderButton)list.Controls[i]).setSelected();
                                    }
                                }
                            }
                            else if (o is FolderButton)
                            {
                                goto selectSingle;
                            }
                            return;

                            selectSingle:
                            ((FolderButton)o).setSelected();
                            mostRecent = list.Controls.IndexOf((Control)o);
                        } catch (Exception e) {
                        }
                    };
                    IEnumerable <string> items = Directory.EnumerateFileSystemEntries(path.FullName, "*", SearchOption.TopDirectoryOnly);
                    byte x = 0;
                    foreach (string info in items)
                    {
                        if (x++ >= 5)
                        {
                            this.runOnUiThread(() => {
                                list.PerformLayout();
                            });
                            x = 0;
                        }
                        if (!loading)
                        {
                            return;
                        }
                        Thread.Sleep(5);
                        this.runOnUiThread(() => {
                            try {
                                FolderButton button      = new FolderButton(info);
                                button.AutoSize          = true;
                                button.showAnimations    = false;
                                button.MinimumSize       = new Size(Math.Max(500, (Width - 50) / 2), button.MinimumSize.Height);
                                button.MouseClick       += click;
                                button.MouseDoubleClick += delegate(object o, MouseEventArgs args) {
                                    if (args.Button == MouseButtons.Left)
                                    {
                                        if (File.Exists(info))
                                        {
                                            this._(() => { ((FolderButton)o).setSelected(false); });
                                            Process.Start(info);
                                        }
                                        else
                                        {
                                            populate(info);
                                        }
                                    }
                                };
                                list.Controls.Add(button);
                                add(button, false);
                            } catch (Exception e) {
                            }
                        });
                    }
                } catch (Exception) {
                }
                this.runOnUiThread(() => {
                    loadingImage.Hide();
                    setAnimations();
                });
            });
        }
Esempio n. 26
0
 internal void HelpOffSound(PictureBox picHelp)
 {
     ayudaSound = new SoundPlayer(Properties.Resources.Help1);
     ayudaSound.Stop();
     picHelp.Hide();
 }
Esempio n. 27
0
        private PictureBox setPicture(OpcioMenu om, int posicio)
        {
            Logger.Info("Añadiendo elemento en posicion {0}", posicio);
            PictureBox pic = CreatePicture(posicio);
            ToolTip    tt  = new ToolTip();

            if (om.fileIcon == null || !File.Exists(om.fileIcon))
            {
                pic.Image = Properties.Resources.programDefault;
            }
            else
            {
                pic.Image = Image.FromFile(om.fileIcon);
            }
            if (om.label == null)
            {
                tt.SetToolTip(pic, $"Executable: {om.fileName}");
            }
            else
            {
                tt.SetToolTip(pic, om.label);
            }
            pic.Tag         = new { posicio = posicio, commandLine = om.fileName, id = om.dynId };
            pic.MouseClick += new MouseEventHandler((s, ev) => {
                PictureBox picx = s as PictureBox;
                dynamic tag     = picx.Tag;
                OpcioMenu omx   = configMenu.getProgram(tag.posicio);
                if (ev.Button == MouseButtons.Left)
                {
                    System.Diagnostics.Process.Start(tag.commandLine);
                }
                if (ev.Button == MouseButtons.Right && Control.ModifierKeys == Keys.None)
                {
                    frmPrograma prg = new frmPrograma(configMenu, omx, tag.posicio);
                    if (prg.ShowDialog() == DialogResult.OK)
                    {
                        configMenu.Save(this.fileName);
                        picx.Hide();
                        omx = configMenu.getProgram(tag.posicio);
                        PictureBox picNew = this.setPicture(omx, (int)tag.posicio);
                        this.Controls.Add(picNew);
                    }
                }
                if (ev.Button == MouseButtons.Right &&
                    (ModifierKeys & Keys.Control) == Keys.Control &&
                    (Keys.Alt & Control.ModifierKeys) != Keys.Alt
                    )
                {
                    DialogResult delete = MessageBox.Show("Borrar programa", "Borrar", MessageBoxButtons.OKCancel);
                    if (delete == DialogResult.OK)
                    {
                        configMenu.RemoveOpcio((Guid)tag.id);
                        configMenu.Save(this.fileName);
                        picx.Hide();
                        PictureBox picNew = setEmptyPicture(tag.posicio);
                        this.Controls.Add(picNew);
                    }
                }
            });
            pic.Show();
            return(pic);
        }
Esempio n. 28
0
        private void InitializeMainMenu()
        {
            #region Initialize Controls

            // About Button - Links to further reading about Shadowmask.
            Button aboutButton = new Button();
            aboutButton.Anchor                            = (AnchorStyles.Bottom | AnchorStyles.Right);
            aboutButton.AutoSize                          = false;
            aboutButton.BackColor                         = this.BackColor;
            aboutButton.BackgroundImage                   = Properties.Resources.QuestionMark_Dark;
            aboutButton.BackgroundImageLayout             = ImageLayout.Center;
            aboutButton.Cursor                            = Cursors.Hand;
            aboutButton.FlatAppearance.CheckedBackColor   = aboutButton.BackColor;
            aboutButton.FlatAppearance.MouseOverBackColor = aboutButton.BackColor;
            aboutButton.FlatAppearance.BorderSize         = 0;
            aboutButton.FlatStyle                         = FlatStyle.Flat;
            aboutButton.Size    = aboutButton.BackgroundImage.Size;
            aboutButton.TabStop = false;

            // Activity Indicator - Displays if the configuration application is performing sensative operations (writing to files, lengthy computions).
            PictureBox activityIndicator = new PictureBox();
            activityIndicator.Image    = Properties.Resources.Spinner;
            activityIndicator.Name     = "progressSpinner";
            activityIndicator.Size     = new Size(48, 48);
            activityIndicator.SizeMode = PictureBoxSizeMode.StretchImage;
            activityIndicator.Hide();

            TextBox addressIntake = new TextBox();
            addressIntake.Multiline                = true;
            addressIntake.MinimumSize              = new Size(this.Width / 3, 24);
            addressIntake.Multiline                = false;
            addressIntake.Text                     = "https://example.com";
            addressIntake.BorderStyle              = BorderStyle.FixedSingle;
            addressIntake.TextAlign                = HorizontalAlignment.Center;
            addressIntake.TabStop                  = false;
            addressIntake.Enabled                  = true;
            addressIntake.AutoCompleteMode         = AutoCompleteMode.SuggestAppend;
            addressIntake.AutoCompleteSource       = AutoCompleteSource.CustomSource;
            addressIntake.AutoCompleteCustomSource = Pull_Chrome__Address_History();

            // Content Type Dropdown - Allows the user to select the type of wallpaper source material.
            ComboBox contentType = new ComboBox();
            contentType.DataSource = new BindingSource(new Dictionary <string, string>
            {
                { "Image", "Image Files (*.PNG;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF" },
                //{ "Video", "Video Files (*.MP4)|*.MP4" },
                { "Webpage", "" },
                //{ "YouTube Video", "" }
            }, null);
            contentType.DisplayMember = "Key";
            contentType.DropDownStyle = ComboBoxStyle.DropDownList;
            contentType.FlatStyle     = FlatStyle.Flat;
            contentType.ValueMember   = "Value";

            // Content Type Dropdown - Instruction Label
            Label contentType_Label = new Label();
            contentType_Label.Anchor    = AnchorStyles.Top;
            contentType_Label.AutoSize  = true;
            contentType_Label.ForeColor = Color.White;
            contentType.TabStop         = false;
            contentType_Label.Text      = "Please select the type of content you wish to display.";
            contentType_Label.TextAlign = ContentAlignment.MiddleCenter;

            // Exit Button - Closes the configuration pane (not the entire application).
            Button exitButton = new Button();
            exitButton.Anchor                            = (AnchorStyles.Bottom | AnchorStyles.Left);
            exitButton.AutoSize                          = false;
            exitButton.BackColor                         = this.BackColor;
            exitButton.BackgroundImage                   = Properties.Resources.Exit;
            exitButton.BackgroundImageLayout             = ImageLayout.Center;
            exitButton.Cursor                            = Cursors.Hand;
            exitButton.FlatAppearance.CheckedBackColor   = exitButton.BackColor;
            exitButton.FlatAppearance.MouseOverBackColor = exitButton.BackColor;
            exitButton.FlatAppearance.BorderSize         = 0;
            exitButton.FlatStyle                         = FlatStyle.Flat;
            exitButton.Size    = exitButton.BackgroundImage.Size;
            exitButton.TabStop = false;

            // File Selection Dialog - A explorer dialog that allows the user to input images,videos,etc as wallpaper content.
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Multiselect = false;
            fileDialog.Title       = "Please select the desired wallpaper source...";

            // File Selection Button - Launches the File Selection Dialog.
            Button fileIntake = new Button();
            fileIntake.AutoSize  = false;
            fileIntake.BackColor = Color.LightGray;
            fileIntake.FlatAppearance.BorderSize = 0;
            fileIntake.FlatStyle = FlatStyle.Flat;
            fileIntake.TabStop   = false;
            fileIntake.Text      = "No File";
            fileIntake.TextAlign = ContentAlignment.MiddleCenter;

            // Content Selection Instructions - Assist user with content selection.
            Label intakeLabel = new Label();
            intakeLabel.Anchor    = AnchorStyles.Top;
            intakeLabel.AutoSize  = true;
            intakeLabel.ForeColor = Color.White;
            intakeLabel.Text      = "Please select either the URL hosting the content, or the content's source file";
            intakeLabel.TextAlign = ContentAlignment.MiddleCenter;

            // Screen Selection Instructions - Assist user with monitor selection.
            Label instructionsLabel = new Label();
            instructionsLabel.Anchor    = AnchorStyles.Top;
            instructionsLabel.AutoSize  = true;
            instructionsLabel.ForeColor = Color.White;
            instructionsLabel.Text      = "Please select a screen to configure:";
            instructionsLabel.TextAlign = ContentAlignment.MiddleCenter;

            // Content Layout Selection - Instructions
            Label layoutLabel = new Label();
            layoutLabel.Anchor    = AnchorStyles.Top;
            layoutLabel.AutoSize  = true;
            layoutLabel.ForeColor = Color.White;
            layoutLabel.Text      = "Please select a display layout";
            layoutLabel.TextAlign = ContentAlignment.MiddleCenter;

            // Content Layout Dropdown - Allows the user to select how their content will be displayed (fill, tile, etc).
            ComboBox layoutType = new ComboBox();
            layoutType.DropDownStyle = ComboBoxStyle.DropDownList;
            layoutType.FlatStyle     = FlatStyle.Flat;
            layoutType.Items.Add("Fill");
            layoutType.SelectedIndex = 0;
            layoutType.TabStop       = false;

            // Monitor Selection - Allows the user to select a monitor to adjust wallpaper settings on. Dynamically built based on currently attached monitors.
            FlowLayoutPanel monitorSelection_Panel = new FlowLayoutPanel();
            monitorSelection_Panel.Anchor       = AnchorStyles.None;
            monitorSelection_Panel.AutoSize     = true;
            monitorSelection_Panel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            monitorSelection_Panel.BackColor    = this.BackColor;

            int screenCount = 1;
            foreach (Screen activeDisplay in Screen.AllScreens.OrderBy(screen => screen.Bounds.X))
            {
                RadioButton monitorButton = new RadioButton();
                monitorButton.Anchor     = AnchorStyles.None;
                monitorButton.Appearance = Appearance.Button;
                monitorButton.BackColor  = Color.LightGray;
                monitorButton.Cursor     = Cursors.Hand;
                monitorButton.Dock       = DockStyle.None;
                monitorButton.FlatAppearance.BorderSize         = 0;
                monitorButton.FlatAppearance.MouseOverBackColor = System.Drawing.ColorTranslator.FromHtml("#2d89ef");
                monitorButton.FlatStyle = FlatStyle.Flat;
                monitorButton.Size      = new Size(activeDisplay.WorkingArea.Width / 10, activeDisplay.WorkingArea.Height / 10);
                monitorButton.TabStop   = true;
                monitorButton.Text      = screenCount.ToString();
                monitorButton.TextAlign = ContentAlignment.MiddleCenter;

                monitorButton.CheckedChanged += MonitorButton_Checked;

                void MonitorButton_Checked(object sender, EventArgs e)
                {
                    if (monitorButton.Checked)
                    {
                        monitorButton.BackColor = System.Drawing.ColorTranslator.FromHtml("#2d89ef");
                        monitorButton.FlatAppearance.BorderSize = 0;
                    }
                    else
                    {
                        monitorButton.BackColor = Color.LightGray;
                        monitorButton.FlatAppearance.BorderSize = 0;
                    }

                    Settings_Changed(sender, e, false, true);
                }

                monitorSelection_Panel.Controls.Add(monitorButton);

                screenCount++;
            }

            // Advanced Settings Button - Brings the user to an advanced configuration window.
            Button settingsButton = new Button();
            settingsButton.Anchor                            = (AnchorStyles.Bottom | AnchorStyles.Left);
            settingsButton.AutoSize                          = false;
            settingsButton.BackColor                         = this.BackColor;
            settingsButton.BackgroundImage                   = Properties.Resources.Gear_Dark;
            settingsButton.BackgroundImageLayout             = ImageLayout.Center;
            settingsButton.Cursor                            = Cursors.Hand;
            settingsButton.FlatAppearance.BorderSize         = 0;
            settingsButton.FlatAppearance.CheckedBackColor   = settingsButton.BackColor;
            settingsButton.FlatAppearance.MouseOverBackColor = settingsButton.BackColor;
            settingsButton.FlatStyle                         = FlatStyle.Flat;
            settingsButton.Size    = settingsButton.BackgroundImage.Size;
            settingsButton.TabStop = false;

            // Version Label  - Display's the application's current version.
            Label versionLabel = new Label();
            versionLabel.Anchor    = AnchorStyles.Bottom;
            versionLabel.AutoSize  = false;
            versionLabel.Dock      = DockStyle.Bottom;
            versionLabel.ForeColor = Color.White;
            versionLabel.Text      = ProductName + " - " + ProductVersion;
            versionLabel.TextAlign = ContentAlignment.MiddleCenter;

            // ToolTip - Enables control tooltip functionality.
            ToolTip toolTip = new ToolTip();
            toolTip.BackColor = Color.White;
            toolTip.SetToolTip(exitButton, "Save & Exit");
            toolTip.SetToolTip(settingsButton, "Advanced Settings");
            #endregion

            #region Add Controls to Form

            this.Controls.Add(aboutButton);
            this.Controls.Add(activityIndicator);
            this.Controls.Add(addressIntake);
            this.Controls.Add(contentType);
            this.Controls.Add(contentType_Label);
            this.Controls.Add(exitButton);
            this.Controls.Add(intakeLabel);
            this.Controls.Add(instructionsLabel);
            this.Controls.Add(fileIntake);
            this.Controls.Add(layoutLabel);
            this.Controls.Add(layoutType);
            this.Controls.Add(monitorSelection_Panel);
            this.Controls.Add(settingsButton);
            this.Controls.Add(versionLabel);

            #endregion

            #region Align Controls on Form

            // Independent Controls
            aboutButton.Location       = new Point(this.Width - aboutButton.Width - 10, this.Height - aboutButton.Height - 10);
            activityIndicator.Location = new Point((this.Width / 2 - (activityIndicator.Width / 2)), this.Height - activityIndicator.Height - 50);
            exitButton.Location        = new Point((this.Width - exitButton.Width - 10), 10);
            settingsButton.Location    = new Point(10, this.Height - settingsButton.Height - 10);
            versionLabel.Location      = new Point((this.Width / 2) - (versionLabel.Width / 2), this.Height - versionLabel.Height);

            // Location Dependent Controls
            instructionsLabel.Location      = new Point((this.Width / 2) - (instructionsLabel.Width / 2), instructionsLabel.Height + exitButton.Height);
            monitorSelection_Panel.Location = new Point((this.Width / 2 - (monitorSelection_Panel.Width / 2)), (instructionsLabel.Location.Y + instructionsLabel.Height + 10));
            contentType_Label.Location      = new Point((this.Width / 2) - (contentType_Label.Width / 2), (monitorSelection_Panel.Location.Y + monitorSelection_Panel.Height + 20));
            contentType.Location            = new Point((this.Width / 2 - (contentType.Width / 2)), (contentType_Label.Location.Y + contentType_Label.Height + 10));
            intakeLabel.Location            = new Point((this.Width / 2) - (intakeLabel.Width / 2), (contentType.Location.Y + contentType.Height + 20));
            addressIntake.Location          = new Point(intakeLabel.Location.X + 5, (intakeLabel.Location.Y + intakeLabel.Height + 15));
            fileIntake.Location             = new Point(intakeLabel.Location.X + intakeLabel.Width - fileIntake.Width - 5, (intakeLabel.Location.Y + intakeLabel.Height + 15));
            layoutLabel.Location            = new Point((this.Width / 2) - (layoutLabel.Width / 2), (fileIntake.Location.Y + fileIntake.Height + 10));
            layoutType.Location             = new Point((this.Width / 2 - (layoutType.Width / 2)), (layoutLabel.Location.Y + layoutLabel.Height + 10));
            #endregion

            #region Handle Control Actions

            /* Opens the project github on the default system web browser.
             * Triggered by a click to the "About" Button. */
            void AboutButton_Click(object sender, EventArgs e)
            {
                System.Diagnostics.Process.Start("https://github.com/ProperEmergency/Shadowmask");
            }

            aboutButton.Click += AboutButton_Click;

            /* Detects if a url was entered or modified, and triggers a Settings_Changed event.
             * Triggered by loss of focus to the address bar.*/
            void AddressIntake_LostFocus(object sender, EventArgs e)
            {
                if (addressIntake.Modified)
                {
                    addressIntake.Modified = false;
                    Settings_Changed(sender, e);
                }
            }

            addressIntake.LostFocus += AddressIntake_LostFocus;


            /* Hides the configuration pane, and refreshes the wallpaper engine.
             * Triggered by a click to the exit button */
            void ExitButton_Click(object sender, EventArgs e)
            {
                this.Hide();
                Task.Run(() => wallpaperEngine.Change_Displayed_Content());
            }

            exitButton.Click += ExitButton_Click;

            /* Opens a file selection dialog.
             * Once a file is selected, a wallpaper template is built and the Settings_Changed event triggered.
             * Triggered by a click to the file selection button.*/
            void FileIntake_Click(object sender, EventArgs e)
            {
                fileDialog.Filter = contentType.SelectedValue.ToString();

                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    TemplateEngine templateEngine = new TemplateEngine();

                    fileIntake.Text = templateEngine.Build_Custom_Template(fileDialog.FileName, fileDialog.SafeFileName, contentType.Text, layoutType.Text);

                    Settings_Changed(sender, e);
                }
            }

            fileIntake.Click += FileIntake_Click;

            /* Pulls autocomplete history from typed Chrome URLs.
             * Used in addressIntake ComboBox.*/
            AutoCompleteStringCollection Pull_Chrome__Address_History()
            {
                AutoCompleteStringCollection urlCollection = new AutoCompleteStringCollection();

                try
                {
                    File.Copy(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\History", Path.GetTempPath() + "Chrome_URL_Entry_History.db", true);

                    string queryString      = "SELECT url FROM urls WHERE typed_count > 0;";
                    string connectionString = "Data Source=" + Path.GetTempPath() + "Chrome_URL_Entry_History.db" + "; Version=3";

                    using (SQLiteConnection connection = new SQLiteConnection(connectionString))
                    {
                        SQLiteCommand command = new SQLiteCommand(queryString, connection);

                        connection.Open();
                        SQLiteDataReader reader = command.ExecuteReader();

                        try
                        {
                            while (reader.Read())
                            {
                                urlCollection.Add(reader.GetString(0));
                            }
                        }
                        finally
                        {
                            reader.Close();
                        }

                        connection.Close();
                    }
                }
                catch (Exception)
                {
                    //
                }
                return(urlCollection);
            }

            /* Disables GUI to process settings changes, and writes/reads new settings values from the user config file.
             * Triggered by all user-modifiable controls.*/
            void Settings_Changed(object sender, EventArgs e, bool writeRequired = true, bool readRequired = false)
            {
                activityIndicator.Show();

                foreach (Control formControl in this.Controls.Cast <Control>().Where(c => !(c is Label) && !(c is PictureBox)))
                {
                    formControl.Enabled = false;
                }

                if (readRequired)
                {
                    Task.Run(() => Read_Settings());
                }

                if (writeRequired)
                {
                    Task.Run(() => Write_Settings());
                }
            }

            contentType.SelectedIndexChanged += (sender, e) => Settings_Changed(sender, e);
            layoutType.SelectedIndexChanged  += (sender, e) => Settings_Changed(sender, e);

            /* Reads new wallpaper configuration from user config, and updates GUI to match.
             * Triggered by Settings_Change event.*/
            void Read_Settings()
            {
                var selectedMonitor = monitorSelection_Panel.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                int monitorIndex    = Int32.Parse(selectedMonitor.Text) - 1;

                String[] currentTheme;

                try
                {
                    currentTheme = Properties.Settings.Default.ThemeLayout[monitorIndex].Split(';');
                }

                catch
                {
                    currentTheme = new string[] { selectedMonitor.Text, "Webpage", Properties.Settings.Default.DefaultContent, "Fill" };
                }

                contentType.Invoke((MethodInvoker) delegate { contentType.Text = currentTheme[1]; });
                if (currentTheme[1] == "Webpage")
                {
                    addressIntake.Invoke((MethodInvoker) delegate { addressIntake.Text = currentTheme[2]; });
                    fileIntake.Invoke((MethodInvoker) delegate { fileIntake.Text = "No File"; fileIntake.Enabled = false; });
                }
                else
                {
                    fileIntake.Invoke((MethodInvoker) delegate { fileIntake.Text = currentTheme[2]; });
                    addressIntake.Invoke((MethodInvoker) delegate { addressIntake.Clear(); addressIntake.Enabled = false; });
                }

                Restore_GUI();
            }

            /* Writes new wallpaper configuration to user config based off of GUI status.
             * Triggered by Settings_Change event.*/
            void Write_Settings()
            {
                var selectedMonitor = monitorSelection_Panel.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                int monitorIndex    = Int32.Parse(selectedMonitor.Text) - 1;

                string displayTheme = "";

                string type    = "";
                string content = "";
                string layout  = "";

                contentType.Invoke((MethodInvoker) delegate { type = contentType.Text; });
                layoutType.Invoke((MethodInvoker) delegate { layout = layoutType.Text; });

                if (type == "Webpage")
                {
                    content = addressIntake.Text;
                }
                else
                {
                    content = fileIntake.Text;
                }

                displayTheme = selectedMonitor.Text + ";" + type + ";" + content + ";" + layout;

                try
                {
                    if (Properties.Settings.Default.ThemeLayout.Count > monitorIndex)
                    {
                        Properties.Settings.Default.ThemeLayout.RemoveAt(monitorIndex);
                    }
                    Properties.Settings.Default.ThemeLayout.Insert(monitorIndex, displayTheme);
                }
                catch (NullReferenceException)
                {
                    Properties.Settings.Default.ThemeLayout = new System.Collections.Specialized.StringCollection();
                    Properties.Settings.Default.ThemeLayout.Add(displayTheme);
                }

                Properties.Settings.Default.Save();

                Restore_GUI();
            }

            /* Restores controls disabled by Settings_Changed event.
             * Triggered by Read_Settings or Write_Settings.*/
            void Restore_GUI()
            {
                if (contentType.InvokeRequired)
                {
                    string currentType = "";
                    contentType.Invoke((MethodInvoker) delegate { currentType = contentType.Text; });

                    if (currentType == "Webpage")
                    {
                        addressIntake.Invoke((MethodInvoker) delegate { addressIntake.Enabled = true; });
                    }
                    else
                    {
                        fileIntake.Invoke((MethodInvoker) delegate { fileIntake.Enabled = true; });
                    }

                    foreach (Control formControl in this.Controls.Cast <Control>().Where(c => (c != addressIntake) && (c != fileIntake)))
                    {
                        formControl.Invoke((MethodInvoker) delegate { formControl.Enabled = true; });
                    }
                }

                if (activityIndicator.InvokeRequired)
                {
                    activityIndicator.Invoke((MethodInvoker) delegate { activityIndicator.Hide(); });
                }
            }

            #endregion
        }
Esempio n. 29
0
        void AddContextMenu()
        {
            // The context menu
            #region Picture Preview
            Pic = new PictureBox(300, 300);
            listResult.SelectedIndexChanged += (s, o) =>
            {
                if (ModifierKeys == Keys.Alt  && listResult.SelectedIndices.Count == 1)
                {
                    Pic.Location = new Point(Right, Top);
                    Pic.DisplayImage(DirectoryPath + listResult.SelectedItem);
                }
                else if (Pic != null)
                {
                    Pic.Hide();
                }
            };
            #endregion

            var ctxMenu   = new ContextMenuStrip();

            #region Launch External
            // Select ALL entry
            var mnuLaunch = new ToolStripMenuItem("Launch External")
            {
                Image = new Bitmap(Properties.Resources.@launch)
            };
            mnuLaunch.Click += LaunchExternal;
            ctxMenu.Items.Add(mnuLaunch);
            #endregion

            ctxMenu.Items.Add(new ToolStripSeparator());

            #region SelectAll
            // Select ALL entry
            var mnuSelect = new ToolStripMenuItem("Select All")
            {
                Image = new Bitmap(Properties.Resources.@select)
            };
            mnuSelect.Click += (sender, args) =>
            {
                for (int i = 0; i < listResult.Items.Count; i++)
                {
                    listResult.SetSelected(i, true);
                }
            };
            ctxMenu.Items.Add(mnuSelect);
            #endregion

            #region Invert Selection
            // Select ALL entry
            var mnuInvert = new ToolStripMenuItem("Select Other")
            {
                Image = new Bitmap(Properties.Resources.invert)
            };
            mnuInvert.Click += (sender, args) =>
            {
                for (int i = 0; i < listResult.Items.Count; i++)
                {
                    listResult.SetSelected(i, !listResult.SelectedIndices.Contains(i));
                }
            };
            ctxMenu.Items.Add(mnuInvert);
            #endregion

            ctxMenu.Items.Add(new ToolStripSeparator());

            #region Export
            // Export entry
            var mnuExport = new ToolStripMenuItem("Export Selection")
            {
                Image = new Bitmap(Properties.Resources.save)
            };
            mnuExport.Click += ExportFiles;

            ctxMenu.Items.Add(mnuExport);
            #endregion

            #region Delete
            // Delete entry
            var mnuDelete = new ToolStripMenuItem("Delete Selection")
            {
                Image = new Bitmap(Properties.Resources.delete)
            };
            mnuDelete.Click += DeleteFiles;
            ctxMenu.Items.Add(mnuDelete);
            #endregion

            ctxMenu.Items.Add(new ToolStripSeparator());

            #region Explore
            // Explore entry
            var mnuExplore = new ToolStripMenuItem("Explore Here")
            {
                Image = new Bitmap(Properties.Resources.explore)
            };
            mnuExplore.Click += ExploreHere;

            ctxMenu.Items.Add(mnuExplore);
            #endregion

            #region Open Tests
            // Tests to hide context menu items
            ctxMenu.Opening += (s, o) =>
            {
                mnuSelect.Enabled  = (listResult.Items.Count > 0);
                mnuInvert.Enabled  = (listResult.Items.Count > 0);
                mnuExplore.Enabled = (listResult.SelectedItems.Count == 1);

                if (listResult.SelectedItems.Count == 0)
                {
                    mnuExport.Enabled = false;
                    mnuDelete.Enabled = false;
                }
                else
                {
                    mnuExport.Enabled = true;
                    mnuDelete.Enabled = true;
                }
            };
            #endregion

            #region Package
            if (IsPackage)
            {
                // Main entry
                var mnuFind = new ToolStripMenuItem("Verify Selection")
                {
                    Image = new Bitmap(Properties.Resources.search)
                };

                ctxMenu.Opening += (s, o) =>
                {
                    if (listResult.SelectedItems.Count == 0)
                    {
                        mnuFind.Enabled = false;
                    }
                    else
                    {
                        mnuFind.Enabled = true;
                    }
                };

                // Search submenu: Project
                var mnuSearchProject = new ToolStripMenuItem("Exists In Project")
                {
                    Image = new Bitmap(Properties.Resources.project)
                };
                mnuSearchProject.Click += (s, o) =>
                {
                    var pattern  = string.Empty;
                    GetSelectedItems()
                        .ForEach(i =>
                    {
                            var name = Path.GetFileName(i);
                        if (!string.IsNullOrEmpty(name))
                        {
                            pattern += string.Format("{0}|", Regex.Escape(name));
                        }
                        });

                    Find(string.Format("({0})", pattern.Substring(0, pattern.Length - 1)), vsFindTarget.vsFindTargetCurrentProject);
                };

                // Search submenu: Solution
                var mnuSearchSolution = new ToolStripMenuItem("Exists In Solution")
                {
                    Image = new Bitmap(Properties.Resources.solution)
                };
                mnuSearchSolution.Click += (s, o) =>
                {
                    var pattern  = string.Empty;
                    GetSelectedItems()
                        .ForEach(i =>
                        {
                            var name = Path.GetFileName(i);
                            if (!string.IsNullOrEmpty(name))
                            {
                                pattern += string.Format("{0}|", Regex.Escape(name));
                            }
                        });

                    Find(string.Format("({0})", pattern.Substring(0, pattern.Length - 1)), vsFindTarget.vsFindTargetSolution);
                };

                // Add all items
                mnuFind.DropDownItems.Add(mnuSearchProject);
                mnuFind.DropDownItems.Add(mnuSearchSolution);

                ctxMenu.Items.Add(mnuFind);
            }
            #endregion

            listResult.ContextMenuStrip = ctxMenu;
        }
        public void DessinerEchiquier()
        {
            Jouer_Recommencer = false;
            Echiquier         = new Button[12, 12];
            compteur          = 0;

            //assioation des boutons au clicks
            Simulation_Button.Click    += new EventHandler(Simulation_event);
            Jouer_Button.Click         += new EventHandler(Jouer_event);
            Reinitialiser_Button.Click += new EventHandler(Effacer_event);
            Arreter_Button.Click       += new EventHandler(Arreter_event);
            Score_Button.Click         += new EventHandler(Score_event);
            Quitter_Button.Click       += new EventHandler(Quitter_event);


            pictureBox1          = new PictureBox();
            pictureBox1.Image    = Image.FromFile(@"Image/Chess-Knight.png");
            pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
            pictureBox1.Hide();
            pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
            pictureBox1.Size     = new Size(60, 60);



            Reinitialiser_Button.Enabled = false;
            Arreter_Button.Enabled       = false;

            this.Controls.Add(pictureBox1);
            int ButtonSize = 60;
            int i, j;

            for (i = 2; i < 10; i++)
            {
                for (j = 2; j < 10; j++)
                {
                    Button b = new Button();
                    b.Location = new Point((i - 2) * ButtonSize, (j - 2) * ButtonSize);
                    b.Size     = new Size(ButtonSize, ButtonSize);
                    b.UseVisualStyleBackColor = true;
                    b.Click += new EventHandler(Jouer);
                    b.Text   = "";
                    b.Font   = new Font("Lucida Console", 18F, FontStyle.Bold);

                    this.Controls.Add(b);

                    Echiquier[i, j] = b;

                    if (i % 2 == 0)
                    {
                        if (j % 2 == 0)
                        {
                            b.BackColor = Color.SaddleBrown;
                        }
                        else
                        {
                            b.BackColor = Color.NavajoWhite;
                        }
                    }
                    if (i % 2 != 0)
                    {
                        if (j % 2 != 0)
                        {
                            b.BackColor = Color.SaddleBrown;
                        }
                        else
                        {
                            b.BackColor = Color.NavajoWhite;
                        }
                    }
                }
            }

            DesactiverEchiquier();
        }
Esempio n. 31
0
        private void pengecekanLife()
        {
            if (life == 3)
            {
                listofheart.Image = Properties.Resources._3_life;

                this.Refresh();
            }
            else if (life == 2)
            {
                listofheart.Image = Properties.Resources._2life;

                this.Refresh();
            }
            else if (life == 1)
            {
                listofheart.Image = Properties.Resources._1life;

                this.Refresh();
            }
            else if (life == 0)
            {
                listofheart.Hide();
                timerEnemy1Generator.Enabled = false;
                timerEnemy2Generator.Enabled = false;
                timerLaserMove.Enabled       = false;
                timerGame.Enabled            = false;
                this.Refresh();
                DialogResult userSelection = MessageBox.Show("You have survived for : " + minutes + " Minutes " + " and " + seconds + " Seconds " + "\nBack to mode select", "\t" + "Game Over", MessageBoxButtons.OK);


                List <int>   listOfHighScore = new List <int>();
                StreamReader sr = new StreamReader(Application.StartupPath + "/HighscoreSurvival.txt");

                //membaca line
                string line = sr.ReadLine();

                //baca sampe akhir
                while (line != null)
                {
                    //masukan line ke dalam list
                    listOfHighScore.Add(int.Parse(line));
                    //lanjut ke line berikutnya
                    line = sr.ReadLine();
                }
                sr.Close();
                int totalSecond = 60 * minutes + seconds;

                listOfHighScore.Add(totalSecond);
                listOfHighScore.Sort();
                listOfHighScore.Reverse();

                //menulis score ke dalam txt files
                StreamWriter sw;
                sw = new StreamWriter(Application.StartupPath + "/HighscoreSurvival.txt");
                for (int i = 0; i < listOfHighScore.Count - 1; i++)
                {
                    sw.WriteLine(listOfHighScore[i].ToString());
                }
                sw.Close();

                if (userSelection == DialogResult.OK)
                {
                    Main_Menu mainmenu = new Main_Menu();
                    mainmenu.Owner = this;
                    mainmenu.Show();
                    this.Close();
                    this.Dispose();
                }
            }
        }