Esempio n. 1
0
        public override void HandleInput(InputHelper input, Microsoft.Xna.Framework.GameTime gameTime)
        {
            supers.Clear();
#if WINDOWS
            var surfacetouches = input.SurfaceTouches;
            if (surfacetouches.Count > 0)
            {
                //Surface
                for (int i = 0; i < surfacetouches.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(new Vector2(surfacetouches[i].X, surfacetouches[i].Y));

                    supers[i] = new Individual(i, ((double)position.X),
                                               ((double)position.Y),
                                               0.0, 0.0, new Parameters());
                }
            }
            else
#endif
            if (input.Touches.Count > 0)
            {
                //Everthing else touch
                for (int i = 0; i < input.Touches.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(new Vector2(input.Touches[i].Position.X, input.Touches[i].Position.Y));

                    supers[i] = new Individual(i, ((double)position.X),
                                               ((double)position.Y),
                                               0.0, 0.0, new SuperParameters());
                }
            }
            else if (supers.Count <= 0 &&
                     (input.Cursor != Vector2.Zero) &&
                     input.MouseState.LeftButton == ButtonState.Pressed)
            {
                //Mouse
                supers.Add(0, new Individual());
                for (int i = 0; i < supers.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(input.Cursor);

                    supers[i] = new Individual(i, ((double)position.X),
                                               ((double)position.Y),
                                               0, 0, new SuperParameters());
                }
            }

            if (input.IsNewKeyPress(Keys.A))
            {
                controlClient.ToggleAnalyze();
            }

            if (input.IsNewKeyPress(Keys.C))
            {
                debugComponent.SetVisiblity();
            }

            ButtonSection.HandleInput(input, gameTime);
            base.HandleInput(input, gameTime);
        }
Esempio n. 2
0
 public SwarmScreenBase(IEmitterComponent emitterComponent, IAnalysisComponent analysisComponent, PopulationSimulator populationSimulator)
 {
     ButtonSection            = new ButtonSection(false, this, "");
     swarmInXOrder            = new List <Individual>();
     supers                   = new Dictionary <int, Individual>();
     groups                   = new ControlGroups();
     this.emitterComponent    = emitterComponent;
     this.populationSimulator = populationSimulator;
     this.analysisComponent   = analysisComponent;
 }
Esempio n. 3
0
        protected void Create(int height)
        {
            Wrapper.AppendChild(QuestionDiv);
            Wrapper.AppendChild(new HTMLBRElement());
            Wrapper.AppendChild(AnswerDiv);
            Body.AppendChild(Wrapper);

            ButtonSection.AppendChildrenTabIndex(_buttonCollection.ToArray());

            Height          = height.ToPx();
            AllowSizeChange = false;
        }
        public DataRowEditForm(DataRow _dataRow, GridView _gridView, bool _liveData = true) : base()
        {
            prevData = new object[_dataRow.ParentTable.ColumnCount];

            for (int i = 0; i < _dataRow.ParentTable.ColumnCount; i++)
            {
                prevData[i] = _dataRow[i];
            }

            DataRow  = _dataRow;
            GridView = _gridView;
            LiveData = _liveData;

            this.Text   = "Row Edit Form";
            this.Width  = "400px"; // 25px - 25px 350px width;
            this.Height = "600px";
            this.Body.style.overflowY = "auto";

            Panel = Div();
            Panel.style.overflowY = "auto";
            Panel.SetBounds("0", "0", "100%", "(100% - 60px)");
            Body.style.backgroundColor = "white";

            _buttonCollection = new List <SimpleDialogButton>()
            {
                new SimpleDialogButton(this, DialogResultEnum.Cancel)
                {
                    Text = "Cancel", Location = new Vector2("(100% - 85px)", "(100% - 35px)"), ItemClick = (ev) => {
                        for (int i = 0; i < DataRow.ParentTable.ColumnCount; i++)
                        {
                            _dataRow[i] = prevData[i];
                        }

                        GridView.RenderGrid();
                    }
                },
                new SimpleDialogButton(this, DialogResultEnum.OK)
                {
                    Text = "OK", Location = new Vector2("(100% - 170px)", "(100% - 35px)")
                }
            };

            ButtonSection.AppendChildrenTabIndex(_buttonCollection.ToArray());

            this.Body.AppendChild(Panel);

            this.AllowSizeChange = false;
        }
Esempio n. 5
0
 public void InitVariables(EquipmentType t, ButtonSection s, bool isSecondary)
 {
     type         = t;
     section      = s;
     secondaryBar = isSecondary;
 }
Esempio n. 6
0
        /// <summary>
        /// Create a new Message Dialog
        /// </summary>
        /// <param name="prompt">The text to be displayed in the message box</param>
        /// <param name="ui">The UI settings  to be applied to the form</param>
        /// <param name="buttons">The Type of button to be displayed with this message</param>
        /// <param name="title">The title of the message box</param>
        public MessageBoxForm(string prompt, MessageBoxLayout ui, MessageBoxButtons buttons, string title) : base(title)
        {
            var section     = Div();
            var pic         = Div("image32");
            var textContent = Div("messag-box-content");

            _prompt  = prompt;
            _buttons = buttons;

            switch (ui)
            {
            case MessageBoxLayout.Exclamation:
                if (_buttons == MessageBoxButtons.Auto)
                {
                    _buttons = MessageBoxButtons.Ok;
                }
                pic.classList.add("imagewarning");
                break;

            case MessageBoxLayout.Information:
                if (_buttons == MessageBoxButtons.Auto)
                {
                    _buttons = MessageBoxButtons.Ok;
                }
                pic.classList.add("imageinfo");
                break;

            case MessageBoxLayout.Question:
                if (_buttons == MessageBoxButtons.Auto)
                {
                    _buttons = MessageBoxButtons.YesNo;
                }
                pic.classList.add("imageindex");
                break;

            case MessageBoxLayout.Error:
                if (_buttons == MessageBoxButtons.Auto)
                {
                    _buttons = MessageBoxButtons.AbortSendCancel;
                }
                pic.classList.add("imageerror");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(ui), ui, null);
            }
            string heightCalc = Helper.NotDesktop ? "(100% - 60px)" : "(100% - 35px)";

            switch (_buttons)
            {
            case MessageBoxButtons.Ok:
                _buttonCollection = new List <SimpleDialogButton>()
                {
                    new SimpleDialogButton(this, DialogResultEnum.OK)
                    {
                        Text = "Ok", Location = new Vector2("(50% - 37.5px)", heightCalc)
                    }
                };
                break;

            case MessageBoxButtons.YesNo:
                _buttonCollection = new List <SimpleDialogButton>()
                {
                    new SimpleDialogButton(this, DialogResultEnum.No)
                    {
                        Text = "No", Location = new Vector2("(100% - 85px)", heightCalc)
                    },
                    new SimpleDialogButton(this, DialogResultEnum.Yes)
                    {
                        Text = "Yes", Location = new Vector2("(100% - 170px)", heightCalc)
                    }
                };
                break;

            case MessageBoxButtons.YesNoCancel:
                _buttonCollection = new List <SimpleDialogButton>()
                {
                    new SimpleDialogButton(this, DialogResultEnum.Cancel)
                    {
                        Text = "Cancel", Location = new Vector2("(100% - 85px)", heightCalc)
                    },
                    new SimpleDialogButton(this, DialogResultEnum.No)
                    {
                        Text = "No", Location = new Vector2("(100% - 170px)", heightCalc)
                    },
                    new SimpleDialogButton(this, DialogResultEnum.Yes)
                    {
                        Text = "Yes", Location = new Vector2("(100% - 255px)", heightCalc)
                    }
                };
                break;

            case MessageBoxButtons.AbortSendCancel:
                _buttonCollection = new List <SimpleDialogButton>()
                {
                    new SimpleDialogButton(this, DialogResultEnum.Cancel)
                    {
                        Text = "Cancel", Location = new Vector2("(100% - 85px)", heightCalc)
                    },
                    new SimpleDialogButton(this, DialogResultEnum.Send)
                    {
                        Text = "Send", Location = new Vector2("(100% - 170px)", heightCalc), ItemClick = (ev) => {
                            if (Settings.OnSendError != null)
                            {
                                Settings.OnSendError(_prompt);
                            }
                        }
                    },
                    new SimpleDialogButton(this, DialogResultEnum.Abort)
                    {
                        Text = "Abort", Location = new Vector2("(100% - 255px)", heightCalc), ItemClick = (ev) => {
                            bool pre = Settings.AllowCloseWithoutQuestion;

                            Settings.AllowCloseWithoutQuestion = false;
                            Application.Close();
                            Settings.AllowCloseWithoutQuestion = pre;
                        }
                    }
                };
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            TextBlock tb = null;

            int width = 480;

            if (!Helper.NotDesktop)
            {
                tb = new TextBlock(prompt, 480 - 25);
                tb.ComputeString();
                if (_buttonCollection.Count > 2)
                {
                    if (width < 320)
                    {
                        width = 320;
                    }
                }
                if (!tb.ElelemtsOverMax)
                {
                    width = (int)tb.MaxCalculatedWidth + 65 + 37;
                    if (width < Settings.MessageFormMinimumWidthInPx)
                    {
                        width = Settings.MessageFormMinimumWidthInPx;
                    }
                }
            }
            else
            {
                int count = _buttonCollection.Count;
                for (int i = 0; i < count; i++)
                {
                    var but = _buttonCollection[i];
                    but.Height             = 45;
                    but.Style.borderRadius = "4px";
                    but.Style.fontSize     = "14px";
                    if (but.DialogResult == DialogResultEnum.OK || but.DialogResult == DialogResultEnum.Yes)
                    {
                        but.ClassList.add("primary");
                        but.Style.color  = "white";
                        but.Style.border = "0";
                    }
                }
            }

            textContent.innerHTML = prompt;

            section.style.overflowY = "auto";
            section.style.height    = "100%";
            section.style.maxHeight = Settings.MessageFormTextMaximumHeightInPx.ToPx();
            section.appendChild(textContent);
            section.style.top   = "32px";
            section.style.width = "90%";

            base.Body.AppendChildren(pic, section);

            Control[] array = new Control[_buttonCollection.Count];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = _buttonCollection[i];
            }

            ButtonSection.AppendChildrenTabIndex(array);
            if (Helper.NotDesktop)
            {
                section.style.textAlign  = "center";
                section.style.lineHeight = "100%";

                WindowState           = WindowStateType.Maximized;
                Heading.style.display = "none";
                Body.SetLocation(0, 0);
                Body.SetSize("100%", "100%");
                StartPosition   = FormStartPosition.Manual;
                AllowSizeChange = false;
                AllowMoveChange = false;

                ShowMaximize = false;
                ShowMinimize = false;
                ShowClose    = false;

                textContent.style.display       = "inlineBlock";
                textContent.style.fontSize      = "14px";
                textContent.style.verticalAlign = "middle";
                textContent.style.lineHeight    = "normal";
            }
            else
            {
                if (tb.ComputedHeight > Settings.MessageFormTextMaximumHeightInPx)
                {
                    tb.ComputedHeight = Settings.MessageFormTextMaximumHeightInPx;
                }
                if (tb.ComputedHeight < Settings.MessageFormTextMinimumHeightInPx)
                {
                    tb.ComputedHeight = Settings.MessageFormTextMinimumHeightInPx;
                }

                base.Height = tb.ComputedHeight + 77 + 29 + 32 + "px";
                base.Width  = width.ToPx();
            }

            base.AllowSizeChange = false;
        }