/// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Clear();
            ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.toMenu")));
        }
        public void TestControlName()
        {
            string json = AssemblyResourceReader.ReadAsString("Test_Data.ValidateRule1.json");
            ValidateTruthCondition condition = JsonConvert.DeserializeObject<ValidateTruthCondition>(json);

            ControlList controlList = new ControlList();
            RepeaterControl repeater = new RepeaterControl
                                       { Id = 3, Name = "Repeater" };
            controlList.Add(repeater);
            repeater.Controls.Add(new TextControl { Id = 1, Name = "Field1", ParentId = 3 });
            repeater.Controls.Add(new TextControl { Id = 2, Name = "Field2", ParentId = 3 });

            ApplicationData appData = new ApplicationData();
            Dictionary<string, object>[] repeaterData = new Dictionary<string, object>[2];
            appData.Add("Repeater", repeaterData);
            repeaterData[0] = new Dictionary<string, object>
                              {
                                  { "Field1", "Is Valid" },
                                  { "Field2", "When Combined With This" }
                              };
            repeaterData[1] = new Dictionary<string, object>
                              {
                                  { "Field1", "Not Valid" },
                                  { "Field2", "When Combined With This" }
                              };

            TruthConditionEvaluatorFactory evaluatorFactory = new TruthConditionEvaluatorFactory();

            ITruthConditionValidator validator = new ITruthConditionValidator(condition, controlList, evaluatorFactory);
            ValidationResults results = validator.Validate(appData);
            Assert.AreEqual("Repeater[1].Field1", results.ToArray()[0].Key);
        }
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            ControlList.Clear();

            if (Mc.TheWorld.GetWorldInfo().IsHardcoreModeEnabled())
            {
                ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 96, StatCollector.TranslateToLocal("deathScreen.deleteWorld")));
            }
            else
            {
                ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 72, StatCollector.TranslateToLocal("deathScreen.respawn")));
                ControlList.Add(new GuiButton(2, Width / 2 - 100, Height / 4 + 96, StatCollector.TranslateToLocal("deathScreen.titleScreen")));

                if (Mc.Session == null)
                {
                    ControlList[1].Enabled = false;
                }
            }

            for (IEnumerator <GuiButton> iterator = ControlList.GetEnumerator(); iterator.MoveNext();)
            {
                GuiButton guibutton = iterator.Current;
                guibutton.Enabled = false;
            }
        }
Exemple #4
0
 /// <summary>
 /// Adds the buttons (and other controls) to the screen in question.
 /// </summary>
 public override void InitGui()
 {
     ControlList.Clear();
     //Keyboard.enableRepeatEvents(true);
     ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 120, "Done"));
     EntitySign.Func_50006_a(false);
 }
        public void RepeaterHideRuleReferenceRootControl()
        {
            ITruthCondition condition = new HideTruthCondition { RuleType = "HIDE" };
            TruthConditionList subRuleList = new TruthConditionList();
            CompareDefinition compareDefinition = new CompareDefinition { CompareTo = ComparisonType.Value, Field = "Checkbox", FieldScope = FieldScope.Unknown, Operator = Operator.Equals, Value = "checked" };
            subRuleList.Add(new CompareTruthCondition { RuleType = "EVAL", Value = compareDefinition });
            condition.Value = subRuleList;

            ControlList controlList = new ControlList { new CheckboxControl { Name = "Checkbox" } };
            RepeaterControl repeater = new RepeaterControl { Name = "Parent" };
            repeater.AddChild(new ComboControl { Name = "Child", VisibilityRule = condition });
            controlList.Add(repeater);

            ApplicationData applicationData = new ApplicationData { { "Checkbox", "checked" } };
            Dictionary<string, object>[] repeaterValue = new Dictionary<string, object>[1];
            repeaterValue[0] = new Dictionary<string, object>();
            repeaterValue[0]["Child"] = string.Empty;
            applicationData.Add("Parent", repeaterValue);

            ITruthConditionEvaluator<ITruthCondition> evaluator = this.EvaluatorRegister.GetEvaluatorFor<HideTruthCondition>();
            bool result = evaluator.Evaluate(condition, controlList, applicationData, null, this.EvaluatorRegister, "Parent[0]");
            Assert.IsTrue(result);

            applicationData["Checkbox"] = string.Empty;
            result = evaluator.Evaluate(condition, controlList, applicationData, null, this.EvaluatorRegister, "Parent[0]");
            Assert.IsFalse(result);
        }
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            base.InitGui();
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Add(new GuiButton(1, Width / 2 - 100, Height - 40, stringtranslate.TranslateKey("multiplayer.stopSleeping")));
        }
Exemple #7
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Add(DoneButton = new GuiSmallButton(6, Width / 2 - 75, Height - 38, stringtranslate.TranslateKey("gui.done")));
            LanguageList = new GuiSlotLanguage(this);
            LanguageList.RegisterScrollButtons(ControlList, 7, 8);
        }
 public MainWindowViewModel()
 {
     AppControlManager.AppPages.ForEach(c => ControlList.Add(c));
     if (ControlList != null)
     {
         SelectedControl = ControlList.FirstOrDefault();
     }
 }
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ScreenTitle = stringtranslate.TranslateKey("options.videoTitle");
            int i = 0;

            object[] aobj = VideoOptions;
            int      j    = aobj.Length;

            for (int k = 0; k < j; k++)
            {
                Options enumoptions = (Options)aobj[k];

                if (!enumoptions.Float)
                {
                    ControlList.Add(new GuiSmallButton(enumoptions.Ordinal(), (Width / 2 - 155) + (i % 2) * 160, Height / 6 + 24 * (i >> 1), enumoptions, GuiGameSettings.GetKeyBinding(enumoptions)));
                }
                else
                {
                    ControlList.Add(new GuiSlider(enumoptions.Ordinal(), (Width / 2 - 155) + (i % 2) * 160, Height / 6 + 24 * (i >> 1), enumoptions, GuiGameSettings.GetKeyBinding(enumoptions), GuiGameSettings.GetOptionFloatValue(enumoptions)));
                }

                i++;
            }

            ControlList.Add(new GuiButton(200, Width / 2 - 100, Height / 6 + 168, stringtranslate.TranslateKey("gui.done")));
            Is64bit = false;
            Is64bit = Environment.Is64BitProcess;

            /*
             *          aobj = (new string[] { "sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch" });
             *          string[] @as = ((string [])(aobj));
             *          int l = @as.Length;
             *          int i1 = 0;
             *
             *          do
             *          {
             *                  if (i1 >= l)
             *                  {
             *                          break;
             *                  }
             *
             *                  string s = @as[i1];
             *                  string s1 = System.getProperty(s);
             *
             *                  if (s1 != null && s1.IndexOf("64") >= 0)
             *                  {
             *                          Is64bit = true;
             *                          break;
             *                  }
             *
             *                  i1++;
             *          }
             *          while (true);*/
        }
Exemple #10
0
 private void OnPluginChanged(object sender, PluginChangedEvnetArgs e)
 {
     foreach (var obj in e.NewPlugins)
     {
         if (ControlCreateDictionary.ContainsKey(obj))
         {
             ControlList.Add(ControlCreateDictionary[obj].Create());
         }
     }
 }
Exemple #11
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Add(new GuiSmallButton(5, Width / 2 - 154, Height - 48, stringtranslate.TranslateKey("texturePack.openFolder")));
            ControlList.Add(new GuiSmallButton(6, Width / 2 + 4, Height - 48, stringtranslate.TranslateKey("gui.done")));
            Mc.TexturePackList.UpdateAvaliableTexturePacks();
            FileLocation       = (System.IO.Path.Combine(Minecraft.GetMinecraftDir(), "Texturepacks"));
            GuiTexturePackSlot = new GuiTexturePackSlot(this);
            GuiTexturePackSlot.RegisterScrollButtons(ControlList, 7, 8);
        }
        /// <summary>
        /// intilize the buttons for this GUI
        /// </summary>
        public virtual void InitButtons()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Add(ButtonSelect = new GuiButton(1, Width / 2 - 154, Height - 52, 150, 20, stringtranslate.TranslateKey("selectWorld.select")));
            ControlList.Add(ButtonDelete = new GuiButton(6, Width / 2 - 154, Height - 28, 70, 20, stringtranslate.TranslateKey("selectWorld.rename")));
            ControlList.Add(ButtonRename = new GuiButton(2, Width / 2 - 74, Height - 28, 70, 20, stringtranslate.TranslateKey("selectWorld.delete")));
            ControlList.Add(new GuiButton(3, Width / 2 + 4, Height - 52, 150, 20, stringtranslate.TranslateKey("selectWorld.create")));
            ControlList.Add(new GuiButton(0, Width / 2 + 4, Height - 28, 150, 20, stringtranslate.TranslateKey("gui.cancel")));
            ButtonSelect.Enabled = false;
            ButtonRename.Enabled = false;
            ButtonDelete.Enabled = false;
        }
Exemple #13
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();
            int             i = Func_20080_j();

            for (int j = 0; j < Options.KeyBindings.Length; j++)
            {
                ControlList.Add(new GuiSmallButton(j, i + (j % 2) * 160, Height / 6 + 24 * (j >> 1), 70, 20, Options.GetOptionDisplayString(j)));
            }

            ControlList.Add(new GuiButton(200, Width / 2 - 100, Height / 6 + 168, stringtranslate.TranslateKey("gui.done")));
            ScreenTitle = stringtranslate.TranslateKey("controls.title");
        }
        public MainPage()
        {
            InitializeComponent();
            MyCollectionView.BindingContext = this;
            MyCollectionView.SetBinding(ItemsView.ItemsSourceProperty, nameof(ControlList));

            for (var x = 0; x < 20; x++)
            {
                ControlList.Add(new Label {
                    Text = $"Added at {ControlList.Count}"
                });
            }
        }
Exemple #15
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            //Keyboard.EnableRepeatEvents(true);
            ControlList.Clear();
            ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("selectServer.select")));
            ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel")));
            ServerTextField = new GuiTextField(FontRenderer, Width / 2 - 100, 116, 200, 20);
            ServerTextField.SetMaxStringLength(128);
            ServerTextField.setFocused(true);
            ServerTextField.SetText(Field_52009_d);
            ControlList[0].Enabled = ServerTextField.GetText().Length > 0 && StringHelperClass.StringSplit(ServerTextField.GetText(), ":", true).Length > 0;
        }
Exemple #16
0
        public MainWindowViewModel()
        {
            RegisterControls();
            Port       = 48360;
            clientCore = new AnywhereClient(1000, Port);
            BindCoreCollections();
            clientCore.PluginChangedHandler += new EventHandler <PluginChangedEvnetArgs>(OnPluginChanged);
            SetUpdateTimer();

            ControlList.Add(new DefaultControlInfo()
            {
                Name     = "Connect",
                Controls = new ConnectPage(),
            });
        }
        internal static ControlList CreateControlList()
        {
            ControlList list = new ControlList();
            int id = 1;

            IEnumerable<JsonKnownTypeAttribute> knownTypeAttrs = typeof(Control).GetCustomAttributes<JsonKnownTypeAttribute>();
            foreach (Control instance in knownTypeAttrs.Select(attr => Activator.CreateInstance(attr.KnownType)).OfType<Control>())
            {
                instance.Id = id++;
                instance.Name = string.Format("Control{0}", instance.Id);
                list.Add(instance);
            }

            return list;
        }
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            ViewportTexture = Mc.RenderEngine.AllocateTexture(Mc.RenderEngine.GenerateNewTexture(256, 256));
            DateTime calendar = new DateTime();

            calendar = DateTime.Now;

            if (calendar.Month + 1 == 11 && calendar.Day == 9)
            {
                SplashText = "Happy birthday, ez!";
            }
            else if (calendar.Month + 1 == 6 && calendar.Day == 1)
            {
                SplashText = "Happy birthday, Notch!";
            }
            else if (calendar.Month + 1 == 12 && calendar.Day == 24)
            {
                SplashText = "Merry X-mas!";
            }
            else if (calendar.Month + 1 == 1 && calendar.Day == 1)
            {
                SplashText = "Happy new year!";
            }

            StringTranslate stringtranslate = StringTranslate.GetInstance();
            int             i = Height / 4 + 48;

            ControlList.Add(new GuiButton(1, Width / 2 - 100, i, stringtranslate.TranslateKey("menu.singleplayer")));
            ControlList.Add(MultiplayerButton = new GuiButton(2, Width / 2 - 100, i + 24, stringtranslate.TranslateKey("menu.multiplayer")));
            ControlList.Add(new GuiButton(3, Width / 2 - 100, i + 48, stringtranslate.TranslateKey("menu.mods")));

            if (Mc.HideQuitButton)
            {
                ControlList.Add(new GuiButton(0, Width / 2 - 100, i + 72, stringtranslate.TranslateKey("menu.options")));
            }
            else
            {
                ControlList.Add(new GuiButton(0, Width / 2 - 100, i + 72 + 12, 98, 20, stringtranslate.TranslateKey("menu.options")));
                ControlList.Add(new GuiButton(4, Width / 2 + 2, i + 72 + 12, 98, 20, stringtranslate.TranslateKey("menu.quit")));
            }

            ControlList.Add(new GuiButtonLanguage(5, Width / 2 - 124, i + 72 + 12));

            if (Mc.Session == null)
            {
                MultiplayerButton.Enabled = false;
            }
        }
Exemple #19
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            //Keyboard.EnableRepeatEvents(true);
            ControlList.Clear();
            ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("selectWorld.renameButton")));
            ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel")));
            ISaveFormat isaveformat = Mc.GetSaveLoader();
            WorldInfo   worldinfo   = isaveformat.GetWorldInfo(WorldName);
            string      s           = worldinfo.GetWorldName();

            TheGuiTextField = new GuiTextField(FontRenderer, Width / 2 - 100, 60, 200, 20);
            TheGuiTextField.setFocused(true);
            TheGuiTextField.SetText(s);
        }
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            //Keyboard.EnableRepeatEvents(true);
            ControlList.Clear();
            ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + 12, stringtranslate.TranslateKey("addServer.add")));
            ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + 12, stringtranslate.TranslateKey("gui.cancel")));
            ServerName = new GuiTextField(FontRenderer, Width / 2 - 100, 76, 200, 20);
            ServerName.setFocused(true);
            ServerName.SetText(ServerNBTStorage.Name);
            ServerAddress = new GuiTextField(FontRenderer, Width / 2 - 100, 116, 200, 20);
            ServerAddress.SetMaxStringLength(128);
            ServerAddress.SetText(ServerNBTStorage.Host);
            ControlList[0].Enabled = ServerAddress.GetText().Length > 0 && StringHelperClass.StringSplit(ServerAddress.GetText(), ":", true).Length > 0 && ServerName.GetText().Length > 0;
        }
        /// <summary>
        /// Converts a <see cref="LikertControl"/> to a <see cref="ControlList"/> of
        /// <see cref="RadioControl"/>s, which can then be each question as a radio
        /// in PDFs.
        /// </summary>
        /// <param name="control">The control to convert.</param>
        /// <returns>A <see cref="ControlList"/> of <see cref="RadioControl"/>s.</returns>
        /// <remarks>
        /// Each <see cref="RadioControl"/> in the returned <see cref="ControlList"/>
        /// represents a single <see cref="ControlSubField"/> question from the
        /// <paramref name="control"/>.
        /// </remarks>
        internal static ControlList ToProxyControlList(this LikertControl control)
        {
            ControlValueOptionList optionList = control.Scale != null ? control.Scale.ToOptionList() : new ControlValueOptionList();
            ControlList proxyControlList = new ControlList();
            foreach (ControlSubField item in control.Questions ?? new ControlSubFieldList())
            {
                proxyControlList.Add(new RadioControl
                {
                    Id = control.Id,
                    Name = item.Name,
                    OptionValues = optionList,
                    Label = item.Label
                });
            }

            return proxyControlList;
        }
        /// <summary>
        /// Populate the GuiScreen controlList
        /// </summary>
        public virtual void InitGuiControls()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Add(ButtonEdit   = new GuiButton(7, Width / 2 - 154, Height - 28, 70, 20, stringtranslate.TranslateKey("selectServer.edit")));
            ControlList.Add(ButtonDelete = new GuiButton(2, Width / 2 - 74, Height - 28, 70, 20, stringtranslate.TranslateKey("selectServer.delete")));
            ControlList.Add(ButtonSelect = new GuiButton(1, Width / 2 - 154, Height - 52, 100, 20, stringtranslate.TranslateKey("selectServer.select")));
            ControlList.Add(new GuiButton(4, Width / 2 - 50, Height - 52, 100, 20, stringtranslate.TranslateKey("selectServer.direct")));
            ControlList.Add(new GuiButton(3, Width / 2 + 4 + 50, Height - 52, 100, 20, stringtranslate.TranslateKey("selectServer.add")));
            ControlList.Add(new GuiButton(8, Width / 2 + 4, Height - 28, 70, 20, stringtranslate.TranslateKey("selectServer.refresh")));
            ControlList.Add(new GuiButton(0, Width / 2 + 4 + 76, Height - 28, 75, 20, stringtranslate.TranslateKey("gui.cancel")));
            bool flag = SelectedServer >= 0 && SelectedServer < ServerSlotContainer.GetSize();

            ButtonSelect.Enabled = flag;
            ButtonEdit.Enabled   = flag;
            ButtonDelete.Enabled = flag;
        }
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            UpdateCounter2 = 0;
            ControlList.Clear();
            sbyte byte0 = -16;

            ControlList.Add(new GuiButton(1, Width / 2 - 100, Height / 4 + 120 + byte0, StatCollector.TranslateToLocal("menu.returnToMenu")));

            if (Mc.IsMultiplayerWorld())
            {
                ((GuiButton)ControlList[0]).DisplayString = StatCollector.TranslateToLocal("menu.disconnect");
            }

            ControlList.Add(new GuiButton(4, Width / 2 - 100, Height / 4 + 24 + byte0, StatCollector.TranslateToLocal("menu.returnToGame")));
            ControlList.Add(new GuiButton(0, Width / 2 - 100, Height / 4 + 96 + byte0, StatCollector.TranslateToLocal("menu.options")));
            ControlList.Add(new GuiButton(5, Width / 2 - 100, Height / 4 + 48 + byte0, 98, 20, StatCollector.TranslateToLocal("gui.achievements")));
            ControlList.Add(new GuiButton(6, Width / 2 + 2, Height / 4 + 48 + byte0, 98, 20, StatCollector.TranslateToLocal("gui.stats")));
        }
        public void TestEmptyRepeaterBusinessRule()
        {
            string json = AssemblyResourceReader.ReadAsString("Test_Data.ValidateRule1.json");
            ValidateTruthCondition condition = JsonConvert.DeserializeObject<ValidateTruthCondition>(json);

            ControlList controlList = new ControlList();
            RepeaterControl repeater = new RepeaterControl
                                       { Id = 3, Name = "Repeater" };
            controlList.Add(repeater);
            repeater.Controls.Add(new TextControl { Id = 1, Name = "Field1", ParentId = 3 });
            repeater.Controls.Add(new TextControl { Id = 2, Name = "Field2", ParentId = 3 });

            ApplicationData appData = new ApplicationData();

            TruthConditionEvaluatorFactory evaluatorFactory = new TruthConditionEvaluatorFactory();

            ITruthConditionValidator validator = new ITruthConditionValidator(condition, controlList, evaluatorFactory);
            ValidationResults results = validator.Validate(appData);
            Assert.AreEqual(true, results.IsValid);
        }
Exemple #25
0
 private bool IsPrime(int number)
 {
     Control = 0;
     for (int i = 2; i < number; i++)
     {
         if (number % i == 0)
         {
             ControlList.Add(i);
             Control++;
         }
     }
     if (Control == 2)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #26
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ScreenTitle = stringtranslate.TranslateKey("options.title");
            int i = 0;

            Options[] aenumoptions = RelevantOptions;
            int       j            = aenumoptions.Length;

            for (int k = 0; k < j; k++)
            {
                Options enumoptions = aenumoptions[k];

                if (!enumoptions.Float)
                {
                    GuiSmallButton guismallbutton = new GuiSmallButton(enumoptions.Ordinal(), (Width / 2 - 155) + (i % 2) * 160, Height / 6 + 24 * (i >> 1), enumoptions, Settings.GetKeyBinding(enumoptions));

                    if (enumoptions == Options.DIFFICULTY && Mc.TheWorld != null && Mc.TheWorld.GetWorldInfo().IsHardcoreModeEnabled())
                    {
                        guismallbutton.Enabled       = false;
                        guismallbutton.DisplayString = (new StringBuilder()).Append(StatCollector.TranslateToLocal("options.difficulty")).Append(": ").Append(StatCollector.TranslateToLocal("options.difficulty.hardcore")).ToString();
                    }

                    ControlList.Add(guismallbutton);
                }
                else
                {
                    ControlList.Add(new GuiSlider(enumoptions.Ordinal(), (Width / 2 - 155) + (i % 2) * 160, Height / 6 + 24 * (i >> 1), enumoptions, Settings.GetKeyBinding(enumoptions), Settings.GetOptionFloatValue(enumoptions)));
                }

                i++;
            }

            ControlList.Add(new GuiButton(101, Width / 2 - 100, (Height / 6 + 96) - 6, stringtranslate.TranslateKey("options.video")));
            ControlList.Add(new GuiButton(100, Width / 2 - 100, (Height / 6 + 120) - 6, stringtranslate.TranslateKey("options.controls")));
            ControlList.Add(new GuiButton(102, Width / 2 - 100, (Height / 6 + 144) - 6, stringtranslate.TranslateKey("options.language")));
            ControlList.Add(new GuiButton(200, Width / 2 - 100, Height / 6 + 168, stringtranslate.TranslateKey("gui.done")));
        }
Exemple #27
0
        /// <summary>
        /// Adds the buttons (and other controls) to the screen in question.
        /// </summary>
        public override void InitGui()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            //Keyboard.enableRepeatEvents(true);
            ControlList.Clear();
            ControlList.Add(new GuiButton(0, Width / 2 - 155, Height - 28, 150, 20, stringtranslate.TranslateKey("selectWorld.create")));
            ControlList.Add(new GuiButton(1, Width / 2 + 5, Height - 28, 150, 20, stringtranslate.TranslateKey("gui.cancel")));
            ControlList.Add(GameModeButton           = new GuiButton(2, Width / 2 - 75, 100, 150, 20, stringtranslate.TranslateKey("selectWorld.gameMode")));
            ControlList.Add(MoreWorldOptions         = new GuiButton(3, Width / 2 - 75, 172, 150, 20, stringtranslate.TranslateKey("selectWorld.moreWorldOptions")));
            ControlList.Add(GenerateStructuresButton = new GuiButton(4, Width / 2 - 155, 100, 150, 20, stringtranslate.TranslateKey("selectWorld.mapFeatures")));
            GenerateStructuresButton.ShowButton      = false;
            ControlList.Add(WorldTypeButton          = new GuiButton(5, Width / 2 + 5, 100, 150, 20, stringtranslate.TranslateKey("selectWorld.mapType")));
            WorldTypeButton.ShowButton = false;
            TextboxWorldName           = new GuiTextField(FontRenderer, Width / 2 - 100, 60, 200, 20);
            TextboxWorldName.setFocused(true);
            TextboxWorldName.SetText(LocalizedNewWorldText);
            TextboxSeed = new GuiTextField(FontRenderer, Width / 2 - 100, 60, 200, 20);
            TextboxSeed.SetText(Seed);
            MakeUseableName();
            Func_35363_g();
        }
        /// <summary>
        /// Creates the buttons that appear at the top of the Stats GUI.
        /// </summary>
        public virtual void AddHeaderButtons()
        {
            StringTranslate stringtranslate = StringTranslate.GetInstance();

            ControlList.Add(new GuiButton(0, Width / 2 + 4, Height - 28, 150, 20, stringtranslate.TranslateKey("gui.done")));
            ControlList.Add(new GuiButton(1, Width / 2 - 154, Height - 52, 100, 20, stringtranslate.TranslateKey("stat.generalButton")));
            GuiButton guibutton;

            ControlList.Add(guibutton = new GuiButton(2, Width / 2 - 46, Height - 52, 100, 20, stringtranslate.TranslateKey("stat.blocksButton")));
            GuiButton guibutton1;

            ControlList.Add(guibutton1 = new GuiButton(3, Width / 2 + 62, Height - 52, 100, 20, stringtranslate.TranslateKey("stat.itemsButton")));

            if (SlotBlock.GetSize() == 0)
            {
                guibutton.Enabled = false;
            }

            if (SlotItem.GetSize() == 0)
            {
                guibutton1.Enabled = false;
            }
        }
        private void LoadControlListTree()
        {
            colntrolList = new ObservableCollection <OwnControl>();

            //add Root items
            ControlList.Add(new OwnControl {
                ControlName = "Tekst"
            });
            ControlList.Add(new OwnControl {
                ControlName = "Obraz"
            });
            ControlList.Add(new OwnControl {
                ControlName = "Kod kreskowy"
            });
            ControlList.Add(new OwnControl {
                ControlName = "Tekst z bazy"
            });

            ControlList[0].Childrens = new ObservableCollection <OwnControl>();
            ControlList[1].Childrens = new ObservableCollection <OwnControl>();
            ControlList[2].Childrens = new ObservableCollection <OwnControl>();
            ControlList[3].Childrens = new ObservableCollection <OwnControl>();
        }
        private void SelectTemplateQuestion()
        {
            ControlList.Clear();
            if (SelectedTemplateQuestion == null)
            {
                return;
            }

            ITemplateWrapper control;

            switch (SelectedTemplateQuestion.Question.QuestionType.Name)
            {
            case QuestionType.MultipleChoice:   // multiple choice
            case QuestionType.SingleChoice:     // single choice
                control = new TemplateChoiceViewModel(SelectedTemplateQuestion.Question, _answerSetValueRepository);
                break;

            case QuestionType.Text:     // text
            case QuestionType.Number:   // numeric
            case QuestionType.Decimal:  // decimal
            case QuestionType.Date:     // date
            case QuestionType.Time:     // time
            case QuestionType.DateTime: // datetime
            case QuestionType.Photo:    // photo
                control = new TemplateViewModel(SelectedTemplateQuestion.Question);
                break;

            default:
                control = null;
                break;
            }

            if (control != null)
            {
                ControlList.Add(control);
            }
        }
        public void TestNestedRepeaterFailRootCompareBusinessRule()
        {
            string json = AssemblyResourceReader.ReadAsString("Test_Data.ValidateRule2.json");
            ValidateTruthCondition condition = JsonConvert.DeserializeObject<ValidateTruthCondition>(json);

            ControlList controlList = new ControlList();
            RepeaterControl repeater = new RepeaterControl { Id = 3, Name = "Repeater" };
            controlList.Add(repeater);

            RepeaterControl nestedRepeater = new RepeaterControl { Id = 4, Name = "NestedRepeater", ParentId = 3 };
            repeater.Controls.Add(nestedRepeater);

            RepeaterControl nestedNestedRepeater = new RepeaterControl { Id = 5, Name = "NestedNestedRepeater", ParentId = 4 };
            nestedRepeater.Controls.Add(nestedNestedRepeater);

            nestedNestedRepeater.Controls.Add(new TextControl { Id = 1, Name = "Field1", ParentId = 5 });

            // Compare to root level
            controlList.Add(new TextControl { Id = 2, Name = "Field2" });

            var validExample = new Dictionary<string, object>
                        {
                            { "Field1", "Is Valid" }
                        };

            var invalidExample = new Dictionary<string, object>
                        {
                            { "Field1", "Is Not Valid" }
                        };

            ApplicationData appData = new ApplicationData();
            Dictionary<string, object>[] repeaterData = new Dictionary<string, object>[2];
            appData.Add("Field2", "Is Not Valid");
            appData.Add("Repeater", repeaterData);
            repeaterData[0] = new Dictionary<string, object>()
            {
                {
                    "NestedRepeater", new[]
                    {
                        new Dictionary<string, object>()
                        {
                            { "NestedNestedRepeater", new[] { invalidExample, validExample } }
                        },
                        new Dictionary<string, object>()
                        {
                            { "NestedNestedRepeater", new[] { invalidExample, invalidExample } }
                        },
                    }
                }
            };
            repeaterData[1] = new Dictionary<string, object>()
            {
                {
                    "NestedRepeater", new[]
                    {
                        new Dictionary<string, object>()
                        {
                            { "NestedNestedRepeater", new[] { invalidExample } }
                        },
                        new Dictionary<string, object>()
                        {
                            { "NestedNestedRepeater", new[] { validExample } }
                        },
                    }
                }
            };

            TruthConditionEvaluatorFactory evaluatorFactory = new TruthConditionEvaluatorFactory();

            ITruthConditionValidator validator = new ITruthConditionValidator(condition, controlList, evaluatorFactory);
            ValidationResults results = validator.Validate(appData);
            Assert.AreEqual(false, results.IsValid);
            Assert.AreEqual(4, results.Count);
            Assert.AreEqual("Repeater[0].NestedRepeater[0].NestedNestedRepeater[0].Field1", results.ToArray()[0].Key);
            Assert.AreEqual("Repeater[0].NestedRepeater[1].NestedNestedRepeater[0].Field1", results.ToArray()[1].Key);
            Assert.AreEqual("Repeater[0].NestedRepeater[1].NestedNestedRepeater[1].Field1", results.ToArray()[2].Key);
            Assert.AreEqual("Repeater[1].NestedRepeater[0].NestedNestedRepeater[0].Field1", results.ToArray()[3].Key);
        }
        public void EmailUserWithPdf()
        {
            MailQueue queue = new MailQueue();
            EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), new ApplicationPdfWriter(), string.Format("{0}/iapply.pdf", System.IO.Path.GetTempPath()), "*****@*****.**")
                                                      {
                                                          Roles = this.roleList,
                                                          GetUsersFn = this.getUserFn,
                                                          SystemSettings = this.systemSettings
                                                      };

            this.action.AttachPdf = true;
            this.application.ApplicationData.Add("Test", "Test");
            this.recipientList.Users.Add("user-1");

            ControlList controlList = new ControlList();
            TextControl textControl = new TextControl
                                      {
                                          Name = "Test",
                                          Label = "Test"
                                      };
            controlList.Add(textControl);

            PageList pages = new PageList
                             {
                                 new UserPage
                                 {
                                     Controls = controlList
                                 }
                             };
            EventResult result = handler.Handle(null, this.action, this.application, pages, this.getApplicationAccessFn);

            Assert.IsTrue(result.Processed);
            MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable;
            Assert.AreEqual(1, message.To.Count);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.Sender.Address);
            Assert.AreEqual(1, message.Attachments.Count);
            Assert.AreEqual(this.action.Subject, message.Subject);
        }
            public void ValidationMessage()
            {
                ControlList list = new ControlList();
                RepeaterControl control = new RepeaterControl
                {
                    Controls = new ControlList(),
                    Id = 1,
                    Label = "Test Repeater",
                    MinimumCount = 1,
                    MaximumCount = 3,
                    Name = "Test_repeater"
                };
                list.Add(control);

                ApplicationData applicationData = new ApplicationData();
                applicationData["Test_repeater"] = new List<Dictionary<string, object>>().ToArray();

                ApplicationValidator localValidator = new ApplicationValidator(list);
                ValidationResults results = localValidator.Validate(new Application(applicationData));
                Assert.IsFalse(results.IsValid);
                Assert.AreEqual(
                    "Please add between 1 and 3 rows for 'Test Repeater'",
                    results.ToList().First().Message);
            }
Exemple #34
0
 ///<summary>
 /// Adds the buttons (and other controls) to the screen in question.
 ///</summary>
 public new void InitGui()
 {
     ControlList.Clear();
     ControlList.Add(new GuiSmallButton(1, Width / 2 + 24, Height / 2 + 74, 80, 20, StatCollector.TranslateToLocal("gui.done")));
 }
            public void MaximumOnlyValidationMessage()
            {
                ControlList list = new ControlList();
                RepeaterControl control = new RepeaterControl
                {
                    Controls = new ControlList(),
                    Id = 1,
                    Label = "Test Repeater",
                    MinimumCount = null,
                    MaximumCount = 2,
                    Name = "Test_repeater"
                };
                list.Add(control);

                ApplicationData applicationData = new ApplicationData();
                List<Dictionary<string, object>> repeaterArr = new List<Dictionary<string, object>>();
                for (int i = 0; i <= 2; i++)
                {
                    repeaterArr.Add(new Dictionary<string, object>());
                }

                applicationData["Test_repeater"] = repeaterArr.ToArray();

                ApplicationValidator localValidator = new ApplicationValidator(list, validatorList: this.validatorList);
                ValidationResults results = localValidator.Validate(new Application(applicationData));
                Assert.IsFalse(results.IsValid);
                Assert.AreEqual(
                    "Please add no more than 2 rows for 'Test Repeater'",
                    results.ToList().First().Message);
            }
        public StrategyContent()
        {
            InitializeComponent();

            _controls         = new ControlList();
            _controls.Loaded += () =>
            {
                //чтобы команда привязки стратегии отработала корректно,
                //ее необходимо вызвать когда проинициализированы все Scope
                //для контролов, что будет только после их загрузки.
                if (Strategy != null)
                {
                    RaiseBindStrategy();
                    //RaiseSelectStrategy();
                }

                ChildsLoaded.SafeInvoke();

                if (!_needRaiseChangedOnLoaded)
                {
                    return;
                }

                //первая загрузка шаблона происходит до открытия вкладки
                //поэтому после того как она будет открыта необходимо сохранить настройки
                _needRaiseChangedOnLoaded = false;
                RaiseChangedCommand();
            };
            _controls.SizeChanged += RaiseChangedCommand;

            DockSite.WindowClosing += (sender, args) =>
            {
                //окна могут открываться и закрываться в момент загрузки разметки
                if (!_suspendChangedEvent)
                {
                    ((IStudioControl)args.Window.Content).Dispose();
                }

                var contentWindow = args.Window as IContentWindow;
                if (contentWindow != null)
                {
                    _controls.Remove(contentWindow);
                }

                RaiseChangedCommand();
            };
            DockSite.WindowOpened += (sender, args) =>
            {
                var contentWindow = args.Window as IContentWindow;
                if (contentWindow != null)
                {
                    _controls.Add(contentWindow);
                }

                RaiseChangedCommand();
            };
            DockSite.WindowStateChanged += (sender, args) => RaiseChangedCommand();
            DockSite.WindowDragged      += (sender, args) => RaiseChangedCommand();

            var cmdSvc = ConfigManager.GetService <IStudioCommandService>();

            cmdSvc.Register <ControlChangedCommand>(this, false, cmd => RaiseChangedCommand());
            cmdSvc.Register <OpenWindowCommand>(this, true, cmd => OpenControl(cmd.Id, cmd.CtrlType, null, ctrl => { }));
            cmdSvc.Register <OpenMarketDepthCommand>(this, true, cmd => OpenControl(cmd.Security.Id, typeof(ScalpingMarketDepthControl), cmd.Security, ctrl =>
            {
                ((ScalpingMarketDepthControl)ctrl).Settings.Security = cmd.Security;
            }));
            cmdSvc.Register <AddLogListenerCommand>(this, false, cmd => _logManager.Listeners.Add(cmd.Listener));
            cmdSvc.Register <RemoveLogListenerCommand>(this, false, cmd => _logManager.Listeners.Remove(cmd.Listener));
            cmdSvc.Register <RequestBindSource>(this, true, cmd => RaiseBindStrategy(cmd.Control));
            cmdSvc.Register <LoadLayoutCommand>(this, true, cmd => LoadTemplate(cmd.Layout, true));
            cmdSvc.Register <SaveLayoutCommand>(this, true, cmd => cmd.Layout = this.Save().SaveSettingsStorage());

            cmdSvc.Register <StartStrategyCommand>(this, true, cmd =>
            {
                if (EmulationService != null)
                {
                    var error = Strategy.CheckCanStart(false);
                    if (error != null)
                    {
                        new MessageBoxBuilder()
                        .Owner(this)
                        .Caption(LocalizedStrings.Str3598)
                        .Text(error)
                        .Warning()
                        .Show();

                        return;
                    }

                    EmulationService.StartEmulation();
                }
                else
                {
                    new StartStrategyCommand(cmd.Strategy).Process(this);
                }
            });
            cmdSvc.Register <StopStrategyCommand>(this, true, cmd =>
            {
                if (EmulationService != null)
                {
                    EmulationService.StopEmulation();
                }
                else
                {
                    new StopStrategyCommand(cmd.Strategy).Process(this);
                }
            });
        }
            public void RepeaterInsideGroupCalc()
            {
                ControlList controls = new ControlList();
                int i = 0;

                GroupControl group = new GroupControl { Id = i++, Name = "group1" };
                controls.Add(group);
                RepeaterControl control = new RepeaterControl
                                          { Id = i++, Name = "repeater1" };
                group.Controls.Add(control);
                control.AddChild(new TextControl { Id = i++, Name = "field1" });
                control.AddChild(new TextControl { Id = i++, Name = "field2" });
                control.AddChild(new CalculationControl { Id = i + 1, Name = "field3", CalculationExpression = "{%field1%}+{%field2%}" });

                Application app = new Application();
                List<Dictionary<string, object>> repeaterValue = new List<Dictionary<string, object>>
                                                                 {
                                                                     new Dictionary<string, object>()
                                                                 };
                repeaterValue[0]["field1"] = "1";
                repeaterValue[0]["field2"] = "1";
                repeaterValue[0]["field3"] = null;
                repeaterValue.Add(new Dictionary<string, object>());
                repeaterValue[1]["field1"] = "2";
                repeaterValue[1]["field2"] = "2";
                repeaterValue[1]["field3"] = null;
                app.ApplicationData["repeater1"] = repeaterValue.ToArray();

                MultiExpressionEvaluator evaluator = new MultiExpressionEvaluator(app, controls);
                ApplicationData result = evaluator.EvaluateAll();

                var repeater = (Dictionary<string, object>[])result["repeater1"];
                Assert.AreEqual(repeater[0]["field3"], "2");
                Assert.AreEqual(repeater[1]["field3"], "4");
            }
Exemple #38
0
 /// <summary>
 /// Adds the buttons (and other controls) to the screen in question.
 /// </summary>
 public override void InitGui()
 {
     ControlList.Add(new GuiButton(0, (Width / 3 - 83) + 0, Height / 6 + 96, 100, 20, ButtonText1));
     ControlList.Add(new GuiButton(2, (Width / 3 - 83) + 105, Height / 6 + 96, 100, 20, Field_50053_b));
     ControlList.Add(new GuiButton(1, (Width / 3 - 83) + 210, Height / 6 + 96, 100, 20, ButtonText2));
 }
Exemple #39
0
 public void Add(BaseButton control)
 {
     ControlList.Add(control);
 }
            public void RootCalc()
            {
                ControlList controls = new ControlList();
                int i = 0;
                controls.Add(new TextControl { Id = i++, Name = "field1" });
                controls.Add(new TextControl { Id = i++, Name = "field2" });
                controls.Add(new CalculationControl { Id = i + 1, Name = "field3", CalculationExpression = "{%field1%}+{%field2%}" });

                Application app = new Application();
                app.ApplicationData["field1"] = "1";
                app.ApplicationData["field2"] = "1";
                app.ApplicationData["field3"] = null;

                MultiExpressionEvaluator evaluator = new MultiExpressionEvaluator(app, controls);
                ApplicationData result = evaluator.EvaluateAll();
                Assert.AreEqual("2", result["field3"]);
            }
 public void Add(BaseWidget control)
 {
     m_widgets.Add(control);
     control.Row = m_row;
 }
        /// <summary>
        /// The remove inaccessible controls.
        /// </summary>
        /// <param name="controls">
        /// The controls.
        /// </param>
        /// <param name="controlsAccess">
        /// The control access list.
        /// </param>
        /// <param name="parentAccessLevel">The parent control access level.</param>
        /// <returns>
        /// The <see cref="ControlList"/>.
        /// </returns>
        private ControlList RemoveInaccessibleControls(ControlList controls, List<ControlAccess> controlsAccess, AccessLevel? parentAccessLevel = null)
        {
            var result = new ControlList();
            foreach (var control in controls)
            {
                if (parentAccessLevel.HasValue && parentAccessLevel == AccessLevel.NoAccess)
                {
                    continue;
                }

                var controlAccess = controlsAccess.FirstOrDefault(a => a.Id == control.Id);
                if (controlAccess == null || controlAccess.AccessLevel == AccessLevel.NoAccess)
                {
                    continue;
                }

                result.Add(control);

                var groupControl = control as GroupControl;
                if (groupControl != null && groupControl.Controls.Any())
                {
                    groupControl.Controls = this.RemoveInaccessibleControls(groupControl.Controls, controlsAccess, controlAccess.AccessLevel);
                }
            }

            return result;
        }
        public void TestNestedRepeaterPassValueBusinessRule()
        {
            string json = AssemblyResourceReader.ReadAsString("Test_Data.ValidateRule1.json");
            ValidateTruthCondition condition = JsonConvert.DeserializeObject<ValidateTruthCondition>(json);

            ControlList controlList = new ControlList();
            RepeaterControl repeater = new RepeaterControl { Id = 3, Name = "Repeater" };
            controlList.Add(repeater);

            RepeaterControl nestedRepeater = new RepeaterControl { Id = 4, Name = "NestedRepeater", ParentId = 3 };
            repeater.Controls.Add(nestedRepeater);

            nestedRepeater.Controls.Add(new TextControl { Id = 1, Name = "Field1", ParentId = 4 });
            nestedRepeater.Controls.Add(new TextControl { Id = 2, Name = "Field2", ParentId = 4 });

            ApplicationData appData = new ApplicationData();

            var validExample = new Dictionary<string, object>
                              {
                                  { "Field1", "Is Valid" },
                                  { "Field2", "When Combined With This" }
                              };

            var anotherValidExample = new Dictionary<string, object>
                              {
                                  { "Field1", "And So Is This" },
                                  { "Field2", "When Combined With This" }
                              };

            Dictionary<string, object>[] repeaterData = new Dictionary<string, object>[2];
            appData.Add("Repeater", repeaterData);
            repeaterData[0] = new Dictionary<string, object>()
            {
                { "NestedRepeater", new[] { validExample, anotherValidExample } }
            };
            repeaterData[1] = new Dictionary<string, object>()
            {
                { "NestedRepeater", new[] { anotherValidExample, validExample } }
            };

            TruthConditionEvaluatorFactory evaluatorFactory = new TruthConditionEvaluatorFactory();

            ITruthConditionValidator validator = new ITruthConditionValidator(condition, controlList, evaluatorFactory);
            ValidationResults results = validator.Validate(appData);
            Assert.AreEqual(true, results.IsValid);
        }