public List <SpriteRenderer> Display()
        {
            int[]        arr    = new int[9];
            List <PosXY> dPosXY = new List <PosXY>()
            {
                new PosXY(-1, -1), new PosXY(0, -1), new PosXY(1, -1), new PosXY(-1, 0),
                new PosXY(0, 0), new PosXY(1, 0), new PosXY(-1, 1), new PosXY(0, 1), new PosXY(1, 1)
            };

            Tile tile = block.Tile;

            for (int i = 0; i < dPosXY.Count; i++)
            {
                PosXY dp = dPosXY[i] + tile.PosXY;

                Tile tempTile = tile.Board.GetTile(dp.x, dp.y);

                if (OnCheckType?.Invoke(tempTile) ?? false)
                {
                    arr[i] = 1;
                }
                else
                {
                    arr[i] = 0;
                }
            }

            return(SetupBorder(arr));
        }
示例#2
0
 private bool posXYContains(PosXY myPos)
 {
     foreach (PosXY p in posXY)
     {
         if (p.X == myPos.X && p.Y == myPos.Y)
         {
             return(true);
         }
     }
     return(false);
 }
        private void DisplayBorderNear()
        {
            List <PosXY> dPosXY = new List <PosXY>()
            {
                new PosXY(-1, -1), new PosXY(0, -1), new PosXY(1, -1), new PosXY(-1, 0),
                new PosXY(0, 0), new PosXY(1, 0), new PosXY(-1, 1), new PosXY(0, 1), new PosXY(1, 1)
            };

            for (int i = 0; i < dPosXY.Count; i++)
            {
                PosXY dp = dPosXY[i] + Tile.PosXY;

                Block tempBlock = Tile.Board.GetTile(dp.x, dp.y)?.TileBlock.BlockOver;

                if (tempBlock?.Type == Type)
                {
                    tempBlock.DisplayBorder();
                }
            }
        }
示例#4
0
        private void OnLoad(object sender, EventArgs e)
        {
            BackColor       = Color.Gray;
            TransparencyKey = Color.Gray;
            FormBorderStyle = FormBorderStyle.None;

            this.Tag = "__Notifier";

            // Fill the note
            buttonClose.Text = title;
            labelDesc.Text   = desc;
            date.Text        = DateTime.Now + "";

            switch (type)
            {
            case Type.ERROR:
                icon.Image            = global::Notify.Properties.Resources.ko;
                buttonClose.BackColor = Color.FromArgb(200, 60, 70);
                break;

            case Type.INFO:
                icon.Image            = global::Notify.Properties.Resources.info;
                buttonClose.BackColor = Color.FromArgb(90, 140, 230);
                break;

            case Type.WARNING:
                icon.Image            = global::Notify.Properties.Resources.warning;
                buttonClose.BackColor = Color.FromArgb(200, 200, 80);
                break;

            case Type.OK:
                icon.Image            = global::Notify.Properties.Resources.ok;
                buttonClose.BackColor = Color.FromArgb(80, 200, 130);
                break;
            }
            Rectangle rec = Screen.GetWorkingArea(this);

            // Add position
            // Check for a available Position
            int maxNot = rec.Height / this.Height;
            int x_Pos  = rec.Width - this.Width;

            //int x_Shift = this.Width + 5;     // Full visible note (no overlay)
            int  x_Shift       = 25;            // Custom overlay
            int  n_columns     = 0;
            int  n_max_columns = rec.Width / x_Shift;
            bool add           = false;

            myPos = new PosXY(x_Pos, rec.Height - (this.Height * 1));

            while (!add)
            {
                for (int n_not = 1; n_not <= maxNot; n_not++)
                {
                    myPos = new PosXY(x_Pos, rec.Height - (this.Height * n_not));

                    if (!posXYContains(myPos))
                    {
                        add = true; break;
                    }

                    // X shift if no more column space
                    if (n_not == maxNot)
                    {
                        n_columns++;
                        n_not = 0;
                        x_Pos = rec.Width - this.Width - x_Shift * n_columns;
                    }

                    // Last exit condition: the screen is full of note
                    if (n_columns >= n_max_columns)
                    {
                        add = true; break;
                    }
                }
            }

            // Notify position
            this.Location = new Point(myPos.X, myPos.Y);
            posXY.Add(myPos);
        }
示例#5
0
        private void setNotifier(string _desc, Type noteType, string _title, bool isUpdate = false)
        {
            // Fill the Notifier data
            titleText.Text = _title;
            labelDesc.Text = _desc;
            date.Text      = DateTime.Now + "";

            // set defaults
            title       = _title;
            description = _desc;
            type        = noteType;

            #region ADJUST COLORS
            Color Hover = Color.FromArgb(0, 0, 0);
            Color Leave = Color.FromArgb(0, 0, 0);

            switch (noteType)
            {
            case Type.ERROR:
                icon.Image = global::Notify.Properties.Resources.ko;
                Leave      = Color.FromArgb(200, 60, 70);
                Hover      = Color.FromArgb(240, 80, 90);
                break;

            case Type.INFO:
                icon.Image = global::Notify.Properties.Resources.info;
                Leave      = Color.FromArgb(90, 140, 230);
                Hover      = Color.FromArgb(110, 160, 250);
                break;

            case Type.WARNING:
                icon.Image = global::Notify.Properties.Resources.warning;
                Leave      = Color.FromArgb(200, 200, 80);
                Hover      = Color.FromArgb(220, 220, 80);
                break;

            case Type.OK:
                icon.Image = global::Notify.Properties.Resources.ok;
                Leave      = Color.FromArgb(80, 200, 130);
                Hover      = Color.FromArgb(80, 240, 130);
                break;
            }

            // Init color
            buttonClose.BackColor = Leave;
            buttonMenu.BackColor  = Leave;
            titleText.BackColor   = Leave;

            // Mouse over
            this.buttonClose.MouseHover += (s, e) =>
            {
                this.buttonClose.BackColor = Hover;
                this.buttonMenu.BackColor  = Hover;
                this.titleText.BackColor   = Hover;
            };
            this.buttonMenu.MouseHover += (s, e) =>
            {
                this.buttonMenu.BackColor  = Hover;
                this.buttonClose.BackColor = Hover;
                this.titleText.BackColor   = Hover;
            }; this.titleText.MouseHover += (s, e) =>
            {
                this.buttonMenu.BackColor  = Hover;
                this.buttonClose.BackColor = Hover;
                this.titleText.BackColor   = Hover;
            };

            // Mouse leave
            this.buttonClose.MouseLeave += (s, e) =>
            {
                this.buttonClose.BackColor = Leave;
                this.buttonMenu.BackColor  = Leave;
                this.titleText.BackColor   = Leave;
            };
            this.buttonMenu.MouseLeave += (s, e) =>
            {
                this.buttonMenu.BackColor  = Leave;
                this.buttonClose.BackColor = Leave;
                this.titleText.BackColor   = Leave;
            };
            this.titleText.MouseLeave += (s, e) =>
            {
                this.buttonMenu.BackColor  = Leave;
                this.buttonClose.BackColor = Leave;
                this.titleText.BackColor   = Leave;
            };

            if (isDialog)
            {
                // Add Buttons
                Button ok_button = new Button();
                ok_button.FlatStyle = FlatStyle.Flat;
                ok_button.BackColor = Leave;
                ok_button.ForeColor = Color.White;
                this.Size           = new Size(this.Size.Width, this.Size.Height + 50);
                ok_button.Size      = new Size(80, 40);
                ok_button.Location  = new Point(this.Size.Height / 2 + 40, this.Size.Height - 50);
                ok_button.Text      = "OK";
                ok_button.Click    += onClickButtonOK;
                this.Controls.Add(ok_button);
            }
            #endregion

            #region ADJUST LOCATION
            if (!isUpdate)
            {
                Rectangle rec = Screen.GetWorkingArea(Screen.PrimaryScreen.Bounds);

                // Add position
                // Check for a available Position
                int maxNot = rec.Height / this.Height;
                int x_Pos  = rec.Width - this.Width;

                //int x_Shift = this.Width + 5;     // Full visible note (no overlay)
                int  x_Shift       = 25;            // Custom overlay
                int  n_columns     = 0;
                int  n_max_columns = rec.Width / x_Shift;
                bool add           = false;
                if (!isDialog)
                {
                    myPos = new PosXY(x_Pos, rec.Height - (this.Height * 1));

                    while (!add)
                    {
                        for (int n_not = 1; n_not <= maxNot; n_not++)
                        {
                            myPos = new PosXY(x_Pos, rec.Height - (this.Height * n_not));

                            if (!posXYContains(myPos))
                            {
                                add = true; break;
                            }

                            // X shift if no more column space
                            if (n_not == maxNot)
                            {
                                n_columns++;
                                n_not = 0;
                                x_Pos = rec.Width - this.Width - x_Shift * n_columns;
                            }

                            // Last exit condition: the screen is full of note
                            if (n_columns >= n_max_columns)
                            {
                                add = true; break;
                            }
                        }
                    }
                }
                else
                {
                    // Positioning
                    switch (backDialogStyle)
                    {
                    case BackDialogStyle.FadedScreen:
                    case BackDialogStyle.None:
                        // Center Screen position
                        int X = 0, Y = 0;
                        X     = (rec.Width - this.Width) / 2;
                        Y     = (rec.Height - this.Height) / 2;
                        myPos = new PosXY(X, Y);
                        break;

                    case BackDialogStyle.FadedApplication:
                        // Center of myCallerApp
                        int px = myCallerApp.Location.X + myCallerApp.Size.Width / 2;
                        int py = myCallerApp.Location.Y + myCallerApp.Size.Height / 2;
                        px    = px - this.Width / 2;
                        py    = py - this.Height / 2;
                        myPos = new PosXY(px, py);
                        break;
                    }
                }

                // Notifier position
                this.Location = new Point(myPos.X, myPos.Y);

                posXY.Add(myPos);
                #endregion
            }
        }