Beispiel #1
0
        public static EditNeuronGeneForm ShowDialogue(Window window, RMP_NeuronGene _neuronGene, CloseEvent closeFunction = null, string category = null, ISkinFile file = null)
        {
            var form = new EditNeuronGeneForm();

            form.Initialize(_neuronGene, closeFunction, "Edit Neuron-gene", true, true, category, file);
            form.Show(window);

            return(form);
        }
Beispiel #2
0
        public void Initialize(RMP_NeuronGene _neuronGene, CloseEvent closeFunction = null, string title = null, bool resizable = false, bool isDialog = true, string category = null, ISkinFile file = null)
        {
            neuronGene = _neuronGene;

            base.Initialize(closeFunction, title, resizable, isDialog, category, file);
        }
Beispiel #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);
        }