コード例 #1
0
ファイル: FileForm.cs プロジェクト: lukastk/TakaGUI
        public override void AddedToContainer()
        {
            const int buttonMinSize = 50;

            selector = new FileSelector();
            selector.Initialize(null, file);
            AddDrawBox(selector);
            selector.Width  = 200;
            selector.Height = 100;

            cancelButton = new ResizableButton();
            cancelButton.Initialize(null, file);
            AddDrawBox(cancelButton);
            cancelButton.Title = "Cancel";
            cancelButton.FitToText();
            cancelButton.Width = Math.Max(cancelButton.Width, buttonMinSize);
            cancelButton.X     = 0;
            cancelButton.Y     = selector.Height + 3;

            okButton = new ResizableButton();
            okButton.Initialize(null, file);
            AddDrawBox(okButton);
            switch (OperationType)
            {
            case OperationTypes.Open:
                okButton.Title = "Open";
                break;

            case OperationTypes.Save:
                okButton.Title = "Save";
                break;

            case OperationTypes.Select:
                okButton.Title = "Select";
                break;
            }
            okButton.FitToText();
            okButton.Width = Math.Max(okButton.Width, buttonMinSize);
            okButton.X     = selector.Width - cancelButton.Width;
            okButton.Y     = selector.Height + 3;

            Wrap();

            selector.Alignment     = DrawBoxAlignment.GetFull();
            okButton.Alignment     = DrawBoxAlignment.GetRightBottom();
            cancelButton.Alignment = DrawBoxAlignment.GetLeftBottom();

            okButton.Click     += new DefaultEvent(okButton_Click);
            cancelButton.Click += new DefaultEvent(cancelButton_Click);
        }
コード例 #2
0
ファイル: NeuronGeneForms.cs プロジェクト: lukastk/EvoSim
        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);
        }
コード例 #3
0
ファイル: NeuronGeneForms.cs プロジェクト: lukastk/EvoSim
        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);
        }