public TCInformationPopup()
        {
            InitializeComponent();

            _textBottomButton = new MenuItem
            {
                Text    = "OK",
                Command = new Command(() =>
                {
                    Console.WriteLine("text bottom button Command!!");
                    _textButtonPopUp?.Dismiss();
                    _textButtonPopUp = null;
                })
            };

            _iconBottomButton = new MenuItem
            {
                IconImageSource = ImageSource.FromFile("image/tw_ic_popup_btn_delete.png"),
                Command         = new Command(() =>
                {
                    Console.WriteLine("icon bottom button Command!!");
                    _textButtonPopUp?.Dismiss();
                    _textButtonPopUp = null;
                })
            };

            _textIconBottomButton = new MenuItem
            {
                Text = "OK",
#pragma warning disable CS0618 // Icon is obsolete. This code is for checking backword compatibility.
                Icon = new FileImageSource
#pragma warning restore CS0618
                {
                    File = "image/tw_ic_popup_btn_delete.png",
                },
                Command = new Command(() =>
                {
                    Console.WriteLine("text&icon bottom button Command!!");
                    _textButtonPopUp?.Dismiss();
                    _textButtonPopUp = null;
                })
            };

            _colorBottomButton = new ColorMenuItem
            {
                Text            = "OK",
                BackgroundColor = Color.Blue,
                Command         = new Command(() =>
                {
                    Console.WriteLine("change color of bottom button Command!!");
                    _textButtonPopUp?.Dismiss();
                    _textButtonPopUp = null;
                })
            };

            _longText = @"This is scrollable popup text.
This part is made by adding long text in popup.Popup internally added
scroller to this layout when size of text is greater than total popup
height.This has two button in action area and title text in title area";
        }
Example #2
0
        public PlayerState(Golf game, PlayerSelectArena startState, List <Player> players, List <int> colors)
            : base(game, startState)
        {
            //game.KeyboardInput.IsOSKVisable = true;
            PlayerSelectArena = startState;
            _players          = players;
            _colors           = colors;
            if (_players.Count == 0)
            {
                AddNewPlayer();
            }

            _startNextItem = new MenuItem(game,
                                          Fonts.GameFont.MeasureString(new Vector2(10, 100),
                                                                       ((players.Count == Game.GameSettings.Players)
                                     ? Strings.Start : Strings.Next)),
                                          ((players.Count == Game.GameSettings.Players)
                                     ? Strings.Start : Strings.Next));
            _nameItem = new NameMenuItem(game, Fonts.GameFont.MeasureString(
                                             new Vector2(10, 10 + _startNextItem.Bounds.Y + _startNextItem.Bounds.Height),
                                             _player.Name),
                                         () => _player.Name,
                                         p => { _player.Name = p; }, () => _player.ColorIndex, Strings.Name);
            int       max    = 0;
            int       mindex = 0;
            Rectangle m      = new Rectangle();

            for (var index = 0; index < colors.Count; index++)
            {
                var color = colors[index];
                m = Fonts.GameFont.MeasureString(
                    new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                    GameColors.Colors[color].Name.ToUpperInvariant());
                if (m.Width > max)
                {
                    max    = m.Width;
                    mindex = index;
                }
            }
            _colorItem = new ColorMenuItem(game,
                                           new Rectangle(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height + 10,
                                                         m.Width, m.Height), () => _player.ColorIndex,
                                           delegate(int p) { _player.ColorIndex = p; }, Strings.Color, colors);
            _backItem = new MenuItem(game,
                                     Fonts.GameFont.MeasureString(
                                         new Vector2(10, 10 + _colorItem.Bounds.Y + _colorItem.Bounds.Height),
                                         Strings.Back), Strings.Back);
            _menu = new Menu(game, HandleMenuSelect,
                             _startNextItem,
                             _nameItem,
                             _colorItem,
                             _backItem
                             );
            _invalidName = new Tween(new TimeSpan(0, 0, 0, 1), 1, 0);
            _invalidName.Finish();
        }
        /// <summary>
        /// Load context menu from config
        /// </summary>
        private void GenerateContextMenu()
        {
            ConfigParser cfg = new ConfigParser(Properties.Settings.Default.States);

            foreach (KeyValuePair <string, ColorList> e in cfg.Values)
            {
                ColorMenuItem cm = new ColorMenuItem(controller, e.Key, e.Value);
                menu.MenuItems.Add(cm);
            }
        }
Example #4
0
 public void OnChangeColor2(object sender, EventArgs args)
 {
     if (SecondButton != null)
     {
         var newItem = new ColorMenuItem
         {
             IconImageSource = ImageSource.FromFile("image/b_option_list_icon_share.png"),
             BackgroundColor = Color.Blue,
             Command         = _viewModel.Command2
         };
         SecondButton = newItem;
     }
 }
Example #5
0
        public void OnChangeColor1(object sender, EventArgs args)
        {
            if (FirstButton != null)
            {
                var newItem = new ColorMenuItem
                {
                    IconImageSource = ImageSource.FromFile("image/b_option_list_icon_delete.png"),
                    BackgroundColor = Color.Green,
                    Command         = _viewModel.Command1
                };

                FirstButton = newItem;
            }
        }
        private void HandleColorButtonClicked(object sender, EventArgs e)
        {
            if (sender == null)
            {
                Debug.Assert(false); return;
            }
            ColorMenuItem mi = (sender as ColorMenuItem);

            if (mi == null)
            {
                Debug.Assert(false); return;
            }

            m_clr = mi.Color;
            UIUtil.SetButtonImage(m_btnColor, PwEntryForm.CreateColorButtonImage(
                                      m_btnColor, m_clr), false);
        }
        private void HandleColorButtonClicked(object sender, EventArgs e)
        {
            if (sender == null)
            {
                Debug.Assert(false); return;
            }
            ColorMenuItem mi = (sender as ColorMenuItem);

            if (mi == null)
            {
                Debug.Assert(false); return;
            }

            m_clr = mi.Color;
            UIUtil.OverwriteButtonImage(m_btnColor, ref m_imgColor,
                                        UIUtil.CreateColorBitmap24(m_btnColor, m_clr));
        }
        private void OnChangeColorRightClicked(object sender, EventArgs e)
        {
            createPopup1();

            _colorRightButton = new ColorMenuItem
            {
                IconImageSource = ImageSource.FromFile("image/b_option_list_icon_delete.png"),
                BackgroundColor = Color.Blue,
                Command         = new Command(() =>
                {
                    Console.WriteLine("right button1 Command!!");
                    _popUp1?.Dismiss();
                    _popUp1 = null;
                })
            };

            _popUp1.FirstButton  = _leftButton;
            _popUp1.SecondButton = _colorRightButton;
            _popUp1.Show();
        }
        private void OnChangeColorLeftClicked(object sender, EventArgs e)
        {
            createPopup1();

            _colorleftButton = new ColorMenuItem
            {
                Icon = new FileImageSource
                {
                    File = "image/b_option_list_icon_share.png",
                },
                BackgroundColor = Color.Green,
                Command         = new Command(() =>
                {
                    Console.WriteLine("left button1 Command!!");
                    _popUp1?.Dismiss();
                    _popUp1 = null;
                })
            };

            _popUp1.FirstButton  = _colorleftButton;
            _popUp1.SecondButton = _rightButton;
            _popUp1.Show();
        }
Example #10
0
        private void OnBtnColor(object sender, EventArgs e)
        {
            // Color? clr = UIUtil.ShowColorDialog(m_clr);
            // if(clr.HasValue)
            // {
            //	float h, s, v;
            //	UIUtil.ColorToHsv(clr.Value, out h, out s, out v);
            //	m_clr = UIUtil.ColorFromHsv(h, 1.0f, 1.0f);
            //	UIUtil.SetButtonImage(m_btnColor, PwEntryForm.CreateColorButtonImage(
            //		m_btnColor, m_clr), false);
            // }

            if (m_ctxColor == null)
            {
                m_ctxColor = new ContextMenu();

                int qSize = (int)((20.0f * m_btnColor.Height) / 23.0f + 0.01f);

                const int nMaxColors = 64;
                int       nBreakAt   = (int)Math.Sqrt(0.1 + nMaxColors);

                // m_ctxColor.LayoutStyle = ToolStripLayoutStyle.Flow;
                // FlowLayoutSettings fls = (m_ctxColor.LayoutSettings as FlowLayoutSettings);
                // if(fls == null) { Debug.Assert(false); return; }
                // fls.FlowDirection = FlowDirection.LeftToRight;

                // m_ctxColor.LayoutStyle = ToolStripLayoutStyle.Table;
                // TableLayoutSettings tls = (m_ctxColor.LayoutSettings as TableLayoutSettings);
                // if(tls == null) { Debug.Assert(false); return; }
                // tls.ColumnCount = nBreakAt;
                // tls.RowCount = nBreakAt;

                // m_ctxColor.SuspendLayout();

                for (int i = 0; i < nMaxColors; ++i)
                {
                    float fHue = ((float)i * 360.0f) / (float)nMaxColors;
                    Color clr  = UIUtil.ColorFromHsv(fHue, 1.0f, 1.0f);

                    // Image img = UIUtil.CreateColorBitmap24(16, 16, clr);
                    // ToolStripButton btn = new ToolStripButton(string.Empty, img);
                    // btn.DisplayStyle = ToolStripItemDisplayStyle.Image;
                    // btn.ImageAlign = ContentAlignment.MiddleCenter;
                    // btn.AutoSize = true;

                    ColorMenuItem mi = new ColorMenuItem(clr, qSize);

                    if ((i > 0) && ((i % nBreakAt) == 0))
                    {
                        mi.Break = true;
                    }
                    //	fls.SetFlowBreak(btn, true);

                    mi.Click += this.HandleColorButtonClicked;

                    // m_ctxColor.Items.Add(btn);
                    m_vColorItems.Add(mi);
                }

                m_ctxColor.MenuItems.AddRange(m_vColorItems.ToArray());

                // m_ctxColor.ResumeLayout(true);
                // this.Controls.Add(m_ctxColor);
                // m_ctxColor.BringToFront();
            }

            // m_ctxColor.Show(m_btnColor, new Point(0, m_btnColor.Height));
            // m_ctxColor.Location = new Point(m_btnColor.Location.X,
            //	m_btnColor.Location.Y - m_btnColor.Height - m_ctxColor.Height);
            // m_ctxColor.Visible = true;
            // m_ctxColor.Show();

            m_ctxColor.Show(m_btnColor, new Point(0, m_btnColor.Height));
        }
Example #11
0
        public PlayerState(BaseGame game, StartState startState, List <Player> players, List <int> colors)
            : base(game, startState)
        {
            //game.KeyboardInput.IsOSKVisable = true;
            _startState = startState;
            _players    = players;
            _colors     = colors;
            _player     = new Player
            {
                Color = colors[0],
                Name  = game.GameData.Data.PlayerNames[players.Count],
                Score = 0,
                Type  = players.Count == 0 ? PlayerType.Human : PlayerType.Computer
            };
            _startNextItem = new MenuItem(game,
                                          game.Font.MeasureString(new Vector2(10, 100),
                                                                  ((players.Count == startState.GameType.Players - 1)
                                     ? Strings.Start : Strings.Next)),
                                          ((players.Count == startState.GameType.Players - 1)
                                     ? Strings.Start : Strings.Next));
            _nameItem = new NameMenuItem(game, game.Font.MeasureString(
                                             new Vector2(10, _startNextItem.Bounds.Y + _startNextItem.Bounds.Height),
                                             _player.Name),
                                         () => _player.Name,
                                         p => { _player.Name = p; }, () => _player.Color, Strings.Name);
            int max    = 0;
            int mindex = 0;

            for (var index = 0; index < colors.Count; index++)
            {
                var color = colors[index];
                var m     = game.Font.MeasureString(
                    new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                    GameColors.Colors[color].Name.ToUpperInvariant());
                if (m.Width > max)
                {
                    max    = m.Width;
                    mindex = index;
                }
            }
            _colorItem = new ColorMenuItem(game,
                                           game.Font.MeasureString(
                                               new Vector2(10, _nameItem.Bounds.Y + _nameItem.Bounds.Height),
                                               GameColors.Colors[colors[mindex]].Name.ToUpperInvariant()), () => _player.Color,
                                           delegate(int p) { _player.Color = p; }, Strings.Color, colors);
            _typeItem = new PlayerTypeMenuItem(game,
                                               game.Font.MeasureString(
                                                   new Vector2(10, _colorItem.Bounds.Y + _colorItem.Bounds.Height),
                                                   Strings.Computer), () => _player.Type, p =>
            {
                _player.Type = p;
            }, Strings.Type);
            _backItem = new MenuItem(game,
                                     game.Font.MeasureString(
                                         new Vector2(10, _typeItem.Bounds.Y + _typeItem.Bounds.Height),
                                         Strings.Back), Strings.Back);
            _menu = new Menu(game, HandleMenuSelect,
                             _startNextItem,
                             _nameItem,
                             _colorItem,
                             _typeItem,
                             _backItem
                             );
            _invalidName = new Tween(new TimeSpan(0, 0, 0, 1), 1, 0);
            _invalidName.Finish();
        }