Example #1
0
        public IntegerField AddIntegerField(string labelText, int integerFieldHeight = -1)
        {
            var label = AddLabel(labelText);

            var integerField = new IntegerField();

            integerField.Initialize();
            container.AddDrawBox(integerField);
            if (integerFieldHeight == -1)
            {
                integerField.Height = integerField.Font.CharHeight + 4;
            }
            else
            {
                integerField.Height = integerFieldHeight;
            }
            Push.ToTheRightSideOf(integerField, label, HorizontalMargin, Push.HorizontalAlign.Top);

            integerField.Width = FieldWidth - integerField.X;

            AddNewFieldList();
            lastField.Add(label);
            lastField.Add(integerField);

            alignments.Add(integerField, new DrawBoxAlignment(AlignTop, AlignBottom, true, true));

            return(integerField);
        }
Example #2
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(4);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(true, true, false, true);
            columnListBox.SetColumnName(0, "ID");
            columnListBox.SetColumnName(1, "Target");
            columnListBox.SetColumnName(2, "IsOutputConnection");
            columnListBox.SetColumnName(3, "Weight");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, TakaGUI.DrawBoxes.ColumnListBox.ListBoxRow item, int index)
            {
                RMP_ConnectionGene connectionGene = null;
                foreach (var gene in connections)
                {
                    if (gene.ID == (uint)item.Values[0])
                    {
                        connectionGene = gene;
                    }
                }

                if (connectionGene != null)
                {
                    EditConnectionGeneForm.ShowDialogue(Parent, connectionGene, delegate(object _sender)
                    {
                        ReloadListBox();
                    });
                }
            };

            ReloadListBox();

            var label = new Label("Connections To Add: ");

            label.Initialize();
            AddDrawBox(label);
            Push.ToTheBottomSideOf(label, columnListBox, 5, Push.VerticalAlign.Left);

            var connectionsToAddIntegerField = new IntegerField();

            connectionsToAddIntegerField.Initialize();
            AddDrawBox(connectionsToAddIntegerField);
            Push.ToTheRightSideOf(connectionsToAddIntegerField, label, 3, Push.HorizontalAlign.Top);
            connectionsToAddIntegerField.Width = 200 - connectionsToAddIntegerField.X;

            var generateConnectionsButton = new ResizableButton();

            generateConnectionsButton.Initialize();
            AddDrawBox(generateConnectionsButton);
            generateConnectionsButton.Title = "Generate Connections";
            generateConnectionsButton.FitToText();
            Push.ToTheBottomSideOf(generateConnectionsButton, label, 5, Push.VerticalAlign.Left);
            generateConnectionsButton.Width  = 200;
            generateConnectionsButton.Click += delegate(object sender)
            {
                GenerateConnections((int)connectionsToAddIntegerField.Value);
                ReloadListBox();
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, generateConnectionsButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment = DrawBoxAlignment.GetFull();
            label.Alignment         = DrawBoxAlignment.GetLeftBottom();
            connectionsToAddIntegerField.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            generateConnectionsButton.Alignment    = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }
Example #3
0
        public override void AddedToContainer()
        {
            base.AddedToContainer();

            columnListBox = new ColumnListBox();
            columnListBox.Initialize(5);
            AddDrawBox(columnListBox);
            columnListBox.SetIntOrStringSort(true, false, true, true, true);
            columnListBox.SetColumnName(0, "Order");
            columnListBox.SetColumnName(1, "Name");
            columnListBox.SetColumnName(2, "ID");
            columnListBox.SetColumnName(3, "Bias");
            columnListBox.SetColumnName(4, "Connections");
            columnListBox.Width  = 200;
            columnListBox.Height = 200;

            columnListBox.ItemDoubleClicked += delegate(object sender, TakaGUI.DrawBoxes.ColumnListBox.ListBoxRow item, int index)
            {
                RMP_NeuronGene neuronGene = null;
                foreach (var gene in neuronList)
                {
                    if (gene.ID == (uint)item.Values[2])
                    {
                        neuronGene = gene;
                    }
                }

                if (neuronGene != null)
                {
                    EditNeuronGeneForm.ShowDialogue(Parent, neuronGene, delegate(object _sender)
                    {
                        ReloadListBox();
                    });
                }
            };

            ReloadListBox();

            var label = new Label("Neurons To Add: ");

            label.Initialize();
            AddDrawBox(label);
            Push.ToTheBottomSideOf(label, columnListBox, 5, Push.VerticalAlign.Left);

            var neuronsToAddIntegerField = new IntegerField();

            neuronsToAddIntegerField.Initialize();
            AddDrawBox(neuronsToAddIntegerField);
            Push.ToTheRightSideOf(neuronsToAddIntegerField, label, 3, Push.HorizontalAlign.Top);
            neuronsToAddIntegerField.Width = 200 - neuronsToAddIntegerField.X;

            var generateNeuronsButton = new ResizableButton();

            generateNeuronsButton.Initialize();
            AddDrawBox(generateNeuronsButton);
            generateNeuronsButton.Title = "Generate Neurons";
            generateNeuronsButton.FitToText();
            Push.ToTheBottomSideOf(generateNeuronsButton, label, 5, Push.VerticalAlign.Left);
            generateNeuronsButton.Width  = 200;
            generateNeuronsButton.Click += delegate(object sender)
            {
                GenerateNeurons((int)neuronsToAddIntegerField.Value, neuronList);
                ReloadListBox();
            };

            var deleteNeuronsButton = new ResizableButton();

            deleteNeuronsButton.Initialize();
            AddDrawBox(deleteNeuronsButton);
            deleteNeuronsButton.Title = "Delete Neurons";
            deleteNeuronsButton.FitToText();
            Push.ToTheBottomSideOf(deleteNeuronsButton, generateNeuronsButton, 5, Push.VerticalAlign.Left);
            deleteNeuronsButton.Width  = 200;
            deleteNeuronsButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex == -1)
                {
                    return;
                }

                uint searchId = (uint)columnListBox.Values[columnListBox.SelectedRowIndex].Values[2];

                foreach (var gene in neuronList)
                {
                    if (gene.ID == searchId)
                    {
                        neuronList.Remove(gene);
                        break;
                    }
                }

                ReloadListBox();
            };

            var moveUpButton = new ResizableButton();

            moveUpButton.Initialize();
            AddDrawBox(moveUpButton);
            moveUpButton.Title = "Move Up";
            moveUpButton.FitToText();
            Push.ToTheBottomSideOf(moveUpButton, deleteNeuronsButton, 3, Push.VerticalAlign.Left);
            moveUpButton.Width  = 200;
            moveUpButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex < 1)
                {
                    return;
                }

                int index = columnListBox.SelectedRowIndex;

                var selected = neuronList[index];
                var upper    = neuronList[index - 1];
                neuronList[index - 1] = selected;
                neuronList[index]     = upper;

                ReloadListBox();

                columnListBox.SelectedRowIndex = index - 1;
            };

            var moveDownButton = new ResizableButton();

            moveDownButton.Initialize();
            AddDrawBox(moveDownButton);
            moveDownButton.Title = "Move Down";
            moveDownButton.FitToText();
            Push.ToTheBottomSideOf(moveDownButton, moveUpButton, 3, Push.VerticalAlign.Left);
            moveDownButton.Width  = 200;
            moveDownButton.Click += delegate(object sender)
            {
                if (columnListBox.SelectedRowIndex == -1 ||
                    columnListBox.SelectedRowIndex == columnListBox.Values.Count - 1)
                {
                    return;
                }

                int index = columnListBox.SelectedRowIndex;

                var selected = neuronList[index];
                var lower    = neuronList[index + 1];
                neuronList[index + 1] = selected;
                neuronList[index]     = lower;

                ReloadListBox();

                columnListBox.SelectedRowIndex = index + 1;
            };

            var okButton = new ResizableButton();

            okButton.Initialize();
            AddDrawBox(okButton);
            okButton.Title = "OK";
            okButton.FitToText();
            Push.ToTheBottomSideOf(okButton, moveDownButton, 3, Push.VerticalAlign.Left);
            okButton.Width  = 200;
            okButton.Click += delegate(object sender)
            {
                Close();
            };

            Wrap();

            columnListBox.Alignment            = DrawBoxAlignment.GetFull();
            label.Alignment                    = DrawBoxAlignment.GetLeftBottom();
            neuronsToAddIntegerField.Alignment = DrawBoxAlignment.GetLeftRightBottom();
            generateNeuronsButton.Alignment    = DrawBoxAlignment.GetLeftRightBottom();
            deleteNeuronsButton.Alignment      = DrawBoxAlignment.GetLeftRightBottom();
            moveUpButton.Alignment             = DrawBoxAlignment.GetLeftRightBottom();
            moveDownButton.Alignment           = DrawBoxAlignment.GetLeftRightBottom();
            okButton.Alignment                 = DrawBoxAlignment.GetLeftRightBottom();

            X = (Parent.Width / 2) - (Width / 2);
            Y = (Parent.Height / 2) - (Height / 2);
        }