Ejemplo n.º 1
0
        /// <summary>
        /// 设置属性
        /// </summary>
        protected override void SetAttributes()
        {
            Textarea control = this.ControlHost.Content as Textarea;

            this.HtmlWriter.AddAttribute("dojoType", "Controls/SimpleTextarea");
            if (!IsPreview && !string.IsNullOrEmpty(this.ControlHost.Name))
            {
                this.HtmlWriter.AddAttribute("id", this.ControlHost.Name);
                this.HtmlWriter.AddAttribute("name", this.ControlHost.Name);
            }


            StringBuilder sbProps       = new StringBuilder();
            StringBuilder returnContent = new StringBuilder();
            string        props         = control.BuildControlProps(this.ScreenDefinition, this.IsPreview, this.PermissionData, returnContent);

            if (!string.IsNullOrEmpty(props))
            {
                sbProps.AppendFormat("{0},", props);
            }
            if (sbProps.ToString().Length > 0)
            {
                this.HtmlWriter.AddAttribute("data-dojo-props", sbProps.ToString().Substring(0, sbProps.ToString().Length - 1), false);
            }

            base.SetAttributes();
        }
Ejemplo n.º 2
0
        private static void setupObjects(float size, Func <Physical> createPhysical)
        {
            var mesh   = TW.Assets.LoadMesh("SkyMerchant/Tree/Tree_WithLeaves");
            var seeder = new Seeder(0);

            var height    = 200f;
            var density1D = 40f;

            TW.Graphics.SpectaterCamera.FarClip = 10000;

            var min = new Vector3(-size * 0.5f, -height * 0.5f, -size * 0.5f);
            var max = new Vector3(size * 0.5f, height * 0.5f, size * 0.5f);

            var numObjects = size * size * height / density1D / density1D / density1D;

            for (int i = 0; i < numObjects; i++)
            {
                var p = createPhysical();
                p.Mesh        = mesh;
                p.WorldMatrix = Matrix.Translation(seeder.NextVector3(min.xna(), max.xna()).dx());
            }

            var text = new Textarea();

            text.Size = new Vector2(200, 100);
            text.Text = "Total objects: " + numObjects;

            new WireframeBox()
            {
                Color = new Color4(1, 0, 0), WorldMatrix = Matrix.Scaling(size, height, size)
            };
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draw hermite info for given cube and outputs the info to a textarea
        /// </summary>
        private void drawHermiteInfoForCube(Point3 gridPoint, Textarea textarea)
        {
            textarea.Text = "";

            foreach (var edgeID in grid.GetAllEdgeIds())
            {
                var     points         = grid.GetEdgeOffsets(edgeID);
                Vector3 edgeWorldStart = (gridPoint + points[0]).ToVector3() * CellSize;
                TW.Graphics.LineManager3D.AddLine(edgeWorldStart, (gridPoint + points[1]).ToVector3() * CellSize,
                                                  Color.Purple.dx());
                var hasEdge = false;
                if (grid.HasEdgeData(gridPoint, edgeID))
                {
                    textarea.Text += grid.GetEdgeIntersectionCubeLocal(gridPoint, edgeID) + "n: " +
                                     grid.getEdgeData(gridPoint, edgeID).TakeXYZ() + "\n";
                    hasEdge = true;
                    var     normal            = grid.GetEdgeNormal(gridPoint, edgeID);
                    Vector3 worldIntersection = (grid.GetEdgeIntersectionCubeLocal(gridPoint, edgeID) + gridPoint) * CellSize;
                    TW.Graphics.LineManager3D.AddCenteredBox(worldIntersection, 0.04f, Color.LawnGreen.dx());
                    TW.Graphics.LineManager3D.AddLine(worldIntersection, worldIntersection + normal * 0.2f, Color.Blue.dx());
                }

                if (hasEdge)
                {
                    var qef = (Vector3)DualContouringAlgorithm.calculateQefPoint(grid, grid.GetCubeSigns(gridPoint), gridPoint);
                    TW.Graphics.LineManager3D.AddCenteredBox(((Vector3)gridPoint.ToVector3() + qef) * CellSize, 0.05f, Color.Orange.dx());
                }
            }
        }
Ejemplo n.º 4
0
        public DebugSimulator()
        {
            drawcallArea = new Textarea();
            int left = 650;

            drawcallArea.Position = new SlimDX.Vector2(left, 10);
            drawcallArea.Size     = new SlimDX.Vector2(800 - left - 10, 20);
        }
Ejemplo n.º 5
0
        public HotbarTextView(Hotbar bar, Rendering2DComponentsFactory rendering)
        {
            this.bar = bar;

            textarea          = rendering.CreateTextArea();
            textarea.Position = new Vector2(600, 10);
            textarea.Size     = new Vector2(190, 400);
        }
Ejemplo n.º 6
0
        public void ClearTextarea()
        {
            //can't use Clear()
            var textAreaLength = Textarea.GetAttribute("test-value").Length;

            for (var i = 0; i < textAreaLength; i++)
            {
                Textarea.SendKeys(Keys.Backspace);
            }
        }
Ejemplo n.º 7
0
        public PrototypeUserInterface(RobotInventoryTextView inventory, Rendering2DComponentsFactory rendering, LocalPlayer player)
        {
            this.inventory = inventory;
            this.rendering = rendering;
            robot          = player.RobotPlayerPart;

            textarea = rendering.CreateTextArea();

            textarea.Position = new Vector2(5, 5);
            textarea.Size     = new Vector2(300, 300);
        }
        public void Simulate()
        {
            if (data.Textarea == null)
            {
                profilerText          = new Textarea();
                profilerText.Position = new SlimDX.Vector2(20, 20);
                profilerText.Size     = new SlimDX.Vector2(700, 500);
                data.Textarea         = profilerText;
            }
            profilerText = data.Textarea;

            time += TW.Graphics.Elapsed;
            updateProfilerText();
        }
Ejemplo n.º 9
0
        public EngineUISimulator()
        {
            area = data.Area;



            mainMenu = createMainMenu();

            if (!data.ConsoleCreated)
            {
                new EngineUIConsole();
            }
            data.ConsoleCreated = true;
        }
        public void Setup()
        {
            engine            = EngineFactory.CreateEngine();
            textBox           = new DirectInputTextBox();
            textarea          = new Textarea();
            textarea.Position = new Vector2(100, 100);

            engine.AddSimulator(new BasicSimulator(() =>
            {
                textBox.ProcessUserInput(TW.Graphics.Keyboard);
                textarea.Text = textBox.Text;
            }));

            TW.Graphics.SpectaterCamera.EnableUserInput = false;
        }
        public UIRenderingService(Internal.Model.World world, LocalPlayerService localPlayerService, UserInputProcessingService inputSim)
        {
            this.world            = world;
            this.localPlayerState = localPlayerService.Player;
            this.inputSim         = inputSim;

            reticle = new TargetingReticle();

            textarea          = new Textarea();
            textarea.Position = new Vector2(TW.Graphics.Form.Form.ClientSize.Width - 120, 20);
            textarea.Size     = new Vector2(100, 50);

            debugTextarea          = new Textarea();
            debugTextarea.Position = new Vector2(TW.Graphics.Form.Form.ClientSize.Width - 200, 150);
            debugTextarea.Size     = new Vector2(180, 400);
        }
        public void TestIslandBuildArea()
        {
            const int seed        = 1;
            var       generator   = new IslandGenerator();
            var       startShapes = generator.GetIslandBase(seed);
            IMesh     islandMesh;
            List <IBuildingElement> navMesh;
            List <IBuildingElement> buildMesh;
            List <IBuildingElement> borderMesh;

            generator.GetIslandParts(startShapes, seed, false, out islandMesh, out navMesh, out buildMesh, out borderMesh);

            //buildMesh = buildMesh.Where(e => ((Face)e).GetBoundingBox().Maximum.Y < 1f).ToList();

            var spaceManager = new IslandSpaceAllocator {
                BuildAreaMeshes = buildMesh
            };

            var nbBoxes     = 10;
            var rnd         = new Random(0);
            var placedBoxes = generateBuildPlots(rnd, spaceManager, nbBoxes, 1f, 10f);

            DX11Game game        = TW.Graphics;
            var      infoDisplay = new Textarea();

            infoDisplay.Size    = new Vector2(500, 50);
            game.GameLoopEvent += delegate
            {
                if (game.Keyboard.IsKeyPressed(Key.F))
                {
                    spaceManager.ClearBuildingSpotReservations();
                    placedBoxes = generateBuildPlots(rnd, spaceManager, nbBoxes, 1f, 10f);
                }

                foreach (var el in buildMesh)
                {
                    TW.Graphics.LineManager3D.AddBox(el.GetBoundingBox(), new Color4(1, 1, 1));
                }
                foreach (var box in placedBoxes)
                {
                    TW.Graphics.LineManager3D.AddBox(box, new Color4(1, 0, 0));
                }
                infoDisplay.Text = "Press F to regenerate";
            };
        }
Ejemplo n.º 13
0
        public ToolSelectionMenu()
        {
            maxNbItems = 9;
            textAreas  = new Textarea[maxNbItems];
            for (int i = 0; i < maxNbItems; i++)
            {
                var ta = new Textarea();
                ta.Position = new Vector2(10 + i * 125, 25);
                //ta.BackgroundColor = new Color4(0.2f, 0.5f, 0.5f, 1f);
                textAreas[i] = ta;
            }

            currentDisplayedItems = new List <IToolSelectionItem>();

            keyList = new List <Key> {
                Key.D1, Key.D2, Key.D3, Key.D4, Key.D5, Key.D6, Key.D7, Key.D8, Key.D9
            };
            updateTextAreas();
        }
Ejemplo n.º 14
0
        public void Simulate()
        {
            if (data.Area == null)
            {
                area          = new Textarea();
                area.Position = new Vector2(0, 0);
                area.Size     = new Vector2(200, 600);
                data.Area     = area;
            }
            updateErrorArea();

            if (TW.Graphics.Keyboard.IsKeyPressed(Key.Tab))
            {
                TW.Graphics.Mouse.CursorEnabled = !TW.Graphics.Mouse.CursorEnabled;
                TW.Graphics.MouseInputDisabled  = TW.Graphics.Mouse.CursorEnabled;
            }


            updateMenu();
        }
        public void LoadIntoEngine(TWEngine engine)
        {
            TextOutput = new Textarea() { Position = new Vector2(10, 10), Size = new Vector2(300, 200) };
            // Autostops when engine hotloads
            new Thread(generateMeshesJob).Alter(f => f.Name = "GenerateLodMeshes").Alter(f => f.IsBackground = true).Start();
            new Thread(meshBuilderJob).Alter(f => f.Name = "MeshBuildJob1").Alter(f => f.IsBackground = true).Start();
            new Thread(meshBuilderJob).Alter(f => f.Name = "MeshBuildJob2").Alter(f => f.IsBackground = true).Start();
            new Thread(meshBuilderJob).Alter(f => f.Name = "MeshBuildJob3").Alter(f => f.IsBackground = true).Start();

            //TW.Graphics.FixedTimeStepEnabled = true;
            //TW.Graphics.FixedTimeStep = 1 / 10f;
            TW.Graphics.SpectaterCamera.FarClip = 5000;
            engine.AddSimulator(ProcessUserInput, "ProcessUserInput");
            engine.AddSimulator(UpdateQuadtreeClipmaps, "UpdateClipmaps");
            engine.AddSimulator(DrawDebugOutput, "UpdateLines");
            engine.AddSimulator(CreateUpdatedMeshElements, "CreateMeshElements");
            engine.AddSimulator(new WorldRenderingSimulator());
            engine.AddSimulator(new RecordingSimulator());

        }
Ejemplo n.º 16
0
        /// <summary> Validates the textarea. </summary>
        private IEnumerable <ValidationInfo> Validate(Textarea textarea)
        {
            List <ValidationInfo> errors = new List <ValidationInfo>();

            if (textarea.Required && string.IsNullOrEmpty(textarea.Value))
            {
                ValidationInfo validationInfo = Mapper.Map <ValidationInfo>(textarea);
                validationInfo.ErrorType = ValidationErrorType.Required;
                errors.Add(validationInfo);
            }

            if (textarea.MaxLength.HasValue && textarea.Value != null && textarea.Value.Length > textarea.MaxLength)
            {
                ValidationInfo validationInfo = Mapper.Map <ValidationInfo>(textarea);
                validationInfo.ErrorType   = ValidationErrorType.MaxLength;
                validationInfo.ProperValue = textarea.MaxLength.Value.ToString(Global.CultureInfo.InvariantCulture);
                errors.Add(validationInfo);
            }

            return(errors);
        }
        public void TestTextarea()
        {
            var game = EngineFactory.CreateEngine();

            game.Initialize();

            var a = new Textarea
            {
                Position = new Vector2(100, 100)
            };

            game.AddSimulator(new BasicSimulator(delegate()
            {
                a.Text = "hello";
            }));

            game.AddSimulator(new WorldRenderingSimulator());


            game.Run();
        }
Ejemplo n.º 18
0
        public void AddToEngine(TWEngine engine)
        {
            TW.Graphics.SpectaterCamera.MovementSpeed = 0.5f;
            TW.Graphics.AcquireRenderer().Wireframe = false;
            TW.Graphics.AcquireRenderer().CullMode  = CullMode.Front;

            //foreach (var v in vertices) lines.AddCenteredBox(v * cellSize, cellSize * 0.2f, Color.OrangeRed.dx());

            statsArea = new Textarea()
            {
                Position = new Vector2(10, 10),
                Size     = new Vector2(300, 200)
            };
            textarea = new Textarea()
            {
                Position = new Vector2(10, statsArea.Position.Y + statsArea.Size.Y), Size = new Vector2(200, 200)
            };

            engine.AddSimulator(() =>
            {
                updateRaycastInfo();
                tryPlaceObject();
                tryRemoveObject();


                UpdateDirty();


                drawRaycastInfo();
                drawHermiteInfoForCube((RaycastedPoint / cellSize).ToFloored(), textarea);
                updateStatsArea();
            }, "UserInput");

            engine.AddSimulator(new WorldRenderingSimulator());

            addLinesSimulator(engine, this.lines);

            engine.AddSimulator(CameraLightSimulator);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 设置子元素
        /// </summary>
        protected override void SetChildElements()
        {
            FluidLayout control = this.ControlHost.Content as FluidLayout;

            foreach (var child in this.ControlHost.Children)
            {
                this.HtmlWriter.AddAttribute("dojoType", "Controls/ContentPane");
                this.HtmlWriter.AddAttribute("label", child.Title);
                string controlName = child.Content.GetType().Name;
                if (controlName == "Textarea")
                {
                    Textarea ctl = child.Content as Textarea;
                    if (ctl.Height != null && ctl.Height > 0)
                    {
                        this.HtmlWriter.AddAttribute("customHeight", ctl.Height.ToString());
                    }
                }
                else if (controlName == "RichTextBox")
                {
                    RichTextBox ctl = child.Content as RichTextBox;
                    if (ctl.Height != null && ctl.Height > 0)
                    {
                        this.HtmlWriter.AddAttribute("customHeight", ctl.Height.ToString());
                    }
                }
                FluidLayoutAttach formAttach = child.AttachObject as FluidLayoutAttach;
                if (formAttach.ColumnSpan > 1)
                {
                    this.HtmlWriter.AddAttribute("colspan", formAttach.ColumnSpan.ToString().ToLower());
                }
                //if (formAttach.CollapsedTitle) this.HtmlWriter.AddAttribute("spanLabel", "true");
                this.HtmlWriter.RenderBeginTag("div");
                var builder = child.GetBuilder(this.IsPreview, this.ScreenDefinition, this.Compile, this.ProjectDocument, this.PermissionData, this.HtmlWriter);
                builder.Parent = this;
                builder.Build();
                this.HtmlWriter.RenderEndTag();
            }
        }
Ejemplo n.º 20
0
        public HudService(Level level)
        {
            this.level    = level;
            text          = new Textarea();
            text.Position = new Vector2(650, 30);
            text.Size     = new Vector2(140, 200);


            goalText          = new Textarea(); // FOR SOME UNKNOWN REASON THIS DOESNT WORK???
            goalText.Position = new Vector2(right - 20 - 200, 20 + 200 + 20);
            goalText.Size     = new Vector2(120, 150);


            var grayTexture = TW.Assets.LoadTexture("Scattered\\Models\\Maps\\DarkGrey.png");

            throw new NotImplementedException();
            //grayTextureRv = TW.Graphics.AcquireRenderer().TexturePool.LoadTexture(grayTexture);



            DI.Get <UISimulator>().SubSimulators.Add(new BasicSimulator(DrawUI));
            targetingReticle = new TargetingReticle();
        }
Ejemplo n.º 21
0
        public void Setup()
        {
            textarea      = new Textarea();
            textarea.Text = "";

            builder = new Autofac.ContainerBuilder();

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(t => t.Namespace != null && t.Namespace.StartsWith("MHGameWork.TheWizards.GodGame") &&
                                                                                  t.IsPublic))
            {
                builder.Register(delegate(IComponentContext ctx)
                {
                    textarea.Text += type.FullName + "\n";
                    return(new object());
                }).As(type);
            }

            world = TestWorldBuilder.createTestWorld(100, 10);
            builder.RegisterInstance(world);
            builder.RegisterInstance(worldPersister);

            builder.Register(ctx => new PlayerTool[0]).As <IEnumerable <PlayerTool> >();
        }
Ejemplo n.º 22
0
 private void NewBtn_Click(object sender, RoutedEventArgs e)
 {
     Textarea.Clear();
 }
Ejemplo n.º 23
0
 public void SetUp()
 {
     _tag = new Textarea();
 }
Ejemplo n.º 24
0
 public void FillTextarea(string input)
 {
     Textarea.SendKeys(input);
 }
Ejemplo n.º 25
0
        //=== Initialization

        /// <summary> Inits a new field for the specified type. </summary>
        /// <param name="languageId"> This is needed for the calender field. </param>
        public static FormElement InitField(FormElementType Type, int?languageId = null, int?id = null, string label = null, string description = null, bool?required = null, bool applyBasicSettings = false)
        {
            switch (Type)
            {
            case Enums.FormElementType.Calendar:
                Calendar c = Calendar.Init(languageId: languageId, id: id, label: label, description: description, required: required);
                ;

                if (applyBasicSettings)
                {
                    c.AdvancedMode = false;
                    c.DefaultDate  = "*|DATETIME:NOW|*";
                }

                return(c);

            case Enums.FormElementType.Checkbox:
                Checkbox cb = Checkbox.Init(id: id, label: label, description: description);

                if (applyBasicSettings)
                {
                    cb.Min = required.GetValueOrDefault() ? 1 : 0;
                    cb.Max = 1;
                }

                return(cb);

            case Enums.FormElementType.Dropdown:
                Dropdown dd = Dropdown.Init(id: id, label: label, description: description, required: required);

                if (applyBasicSettings)
                {
                    dd.Multiple = false;
                }

                return(dd);

            //case Enums.FormElementType.FileUpload:
            //    return FileUpload.Init(id: id, label: label, description: description, required: required);

            case Enums.FormElementType.Html:
                HtmlElement html = HtmlElement.Init(id: id, label: label, description: description);

                if (applyBasicSettings)
                {
                    html.Editable      = true;
                    html.EditorProfile = HtmlElement.EEditorProfile.Basic;
                    html.Required      = required.GetValueOrDefault();
                }

                return(html);

            case Enums.FormElementType.Input:
                Input input = Input.Init(id: id, label: label, description: description, required: required);

                if (applyBasicSettings)
                {
                    input.MaxLength = 255;
                    input.MinLength = 0;
                }

                return(input);

            case Enums.FormElementType.Radiobutton:
                Radiobutton rb = Radiobutton.Init(id: id, label: label, description: description, required: required);

                //if (applyBasicSettings)
                //{
                //    None available
                //}

                return(rb);

            case Enums.FormElementType.Textarea:
                Textarea ta = Textarea.Init(id: id, label: label, description: description, required: required);

                //if (applyBasicSettings)
                //{
                //    None available
                //}

                return(ta);

            case Enums.FormElementType.Link:
                Link link = Link.Init(id: id, label: label, description: description, required: required);

                //if (applyBasicSettings)
                //{
                //    None available
                //}

                return(link);

            case Enums.FormElementType.Label:
                Label l = Label.Init(id: id, label: label, description: description);

                //if (applyBasicSettings)
                //{
                //    None available
                //}

                return(l);


            case Enums.FormElementType.List:
                ListElement list = ListElement.Init(id: id, label: label, description: description);

                //if (applyBasicSettings)
                //{
                //    None available
                //}

                return(list);

            default:
                throw new Exception("Init: Field type is not supported.");
                // Hidden, Tagging, etc.
            }
        }
Ejemplo n.º 26
0
        void Examples()
        {
            #region Color Picker

            colorPicker = new Form(10, 10, 400, 200, new Color(14, 14, 14))
            {
                IsVisible   = true,
                IsResizable = true,
            };

            colorPicker.AddNewControl(h_val = new Slider(20, 50, 300, 10, Slider.Type.Horizontal)
            {
                Filler = Slider.FillStyle.Slider
            });
            colorPicker.AddNewControl(s_val = new Slider(20, 70, 300, 10, Slider.Type.Horizontal)
            {
                Filler = Slider.FillStyle.Slider
            });
            colorPicker.AddNewControl(v_val = new Slider(20, 90, 300, 10, Slider.Type.Horizontal)
            {
                Filler = Slider.FillStyle.Slider
            });

            h_val.OnSlide += delegate { colorPicker.FormColor = Palette.HSV2RGB(360 * h_val.Value, s_val.Value, v_val.Value); };
            s_val.OnSlide += delegate { colorPicker.FormColor = Palette.HSV2RGB(360 * h_val.Value, s_val.Value, v_val.Value); };
            v_val.OnSlide += delegate { colorPicker.FormColor = Palette.HSV2RGB(360 * h_val.Value, s_val.Value, v_val.Value); };

            colorPicker.CreateLayout(hud_form_headname, hud_form_headseam, hud_form_headend, hud_form_leftborder, hud_form_rightborder, hud_form_bottomleft, hud_form_bottomseam, hud_form_bottomright);

            FormManager.AddForm("colorPicker", colorPicker);
            #endregion

            #region Calc
            var f = new Form(340, 100, 310, 320, new Color(40, 40, 40))
            {
                IsVisible = true
            };
            f.CreateLayout(hud_form_headname,
                           hud_form_headseam,
                           hud_form_headend,
                           hud_form_leftborder,
                           hud_form_rightborder,
                           hud_form_bottomleft,
                           hud_form_bottomseam,
                           hud_form_bottomright);

            Textarea lb;

            Button b1, b2, b3, b4, b5, b6, b7, b8, b9, b0,
                   bex, bdiv, bmul, bsub, bsum,
                   er;

            var buttonx = 50;
            var buttony = 40;
            f.AddNewControl(
                lb = new Textarea(buttonx + 10, buttony + 10, 140, 30)
            {
                Font = font1
            },
                er = new Button(buttonx + 160, buttony + 10, 40, 30)
            {
                Text = "<="
            },
                b1 = new Button(buttonx + 10, buttony + 50, 40, 40)
            {
                Text = "1"
            },
                b2 = new Button(buttonx + 60, buttony + 50, 40, 40)
            {
                Text = "2"
            },
                b3 = new Button(buttonx + 110, buttony + 50, 40, 40)
            {
                Text = "3"
            },
                b4 = new Button(buttonx + 10, buttony + 100, 40, 40)
            {
                Text = "4"
            },
                b5 = new Button(buttonx + 60, buttony + 100, 40, 40)
            {
                Text = "5"
            },
                b6 = new Button(buttonx + 110, buttony + 100, 40, 40)
            {
                Text = "6"
            },
                b7 = new Button(buttonx + 10, buttony + 150, 40, 40)
            {
                Text = "7"
            },
                b8 = new Button(buttonx + 60, buttony + 150, 40, 40)
            {
                Text = "8"
            },
                b9 = new Button(buttonx + 110, buttony + 150, 40, 40)
            {
                Text = "9"
            },
                b0 = new Button(buttonx + 10, buttony + 200, 90, 40)
            {
                Text = "0"
            },
                bex = new Button(buttonx + 110, buttony + 200, 40, 40)
            {
                Text = "="
            },
                bdiv = new Button(buttonx + 160, buttony + 50, 40, 40)
            {
                Text = "/"
            },
                bmul = new Button(buttonx + 160, buttony + 100, 40, 40)
            {
                Text = "*"
            },
                bsub = new Button(buttonx + 160, buttony + 150, 40, 40)
            {
                Text = "-"
            },
                bsum = new Button(buttonx + 160, buttony + 200, 40, 40)
            {
                Text = "+"
            }
                );

            lb.Text = "0";

            List <Button> digs = new List <Button>()
            {
                b1, b2, b3, b4, b5, b6, b7, b8, b9, b0
            };
            List <Button> acts = new List <Button>()
            {
                bdiv, bmul, bsub, bsum
            };
            String v1 = "";

            Func <string> div = delegate { return((int.Parse(v1) / int.Parse(lb.Text)).ToString()); };
            Func <string> mul = delegate { return((int.Parse(v1) * int.Parse(lb.Text)).ToString()); };
            Func <string> sub = delegate { return((int.Parse(v1) - int.Parse(lb.Text)).ToString()); };
            Func <string> sum = delegate { return((int.Parse(v1) + int.Parse(lb.Text)).ToString()); };

            Func <string> sel = null;

            digs.ForEach(n => n.OnLeftClick += delegate
            {
                if (lb.Text == "0")
                {
                    lb.Text = n.Text;
                }
                else
                {
                    lb.Append = n.Text;
                }
            });

            acts.ForEach(n => n.OnLeftClick += delegate
            {
                if (sel == null && lb.Text.Length > 0)
                {
                    sel     = n.Text == "/" ? div : n.Text == "*" ? mul : n.Text == "-" ? sub : sum;
                    v1      = lb.Text;
                    lb.Text = "0";
                }
            });

            bex.OnLeftClick += delegate
            {
                if (sel != null)
                {
                    lb.Text = sel();
                    sel     = null;
                }
            };

            er.OnLeftClick += delegate
            {
                lb.Text = lb.Text.Length == 1 ? "0" : lb.Text.Substring(0, lb.Text.Length - 1);
            };

            FormManager.AddForm("CalcForm", f);
            #endregion
        }
Ejemplo n.º 27
0
 public void Textarea()
 {
     var modal = new Textarea();
     var a     = modal.ToHtml();
 }
Ejemplo n.º 28
0
 public IViewComponentResult Invoke(Textarea textarea)
 {
     return(View(textarea));
 }