Example #1
0
		public static void AttachEditorComponents(Entity result, ListProperty<Entity.Handle> target)
		{
			Transform transform = result.Get<Transform>();

			Property<bool> selected = result.GetOrMakeProperty<bool>("EditorSelected");

			Command<Entity> toggleEntityConnected = new Command<Entity>
			{
				Action = delegate(Entity entity)
				{
					if (target.Contains(entity))
						target.Remove(entity);
					else if (entity != result)
						target.Add(entity);
				}
			};
			result.Add("ToggleEntityConnected", toggleEntityConnected);

			LineDrawer connectionLines = new LineDrawer { Serialize = false };
			connectionLines.Add(new Binding<bool>(connectionLines.Enabled, selected));

			Color connectionLineColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
			ListBinding<LineDrawer.Line, Entity.Handle> connectionBinding = new ListBinding<LineDrawer.Line, Entity.Handle>(connectionLines.Lines, target, delegate(Entity.Handle entity)
			{
				return new LineDrawer.Line
				{
					A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(transform.Position, connectionLineColor),
					B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(entity.Target.Get<Transform>().Position, connectionLineColor)
				};
			}, x => x.Target != null && x.Target.Active);
			result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, selected));
			result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, () => selected, transform.Position));
			connectionLines.Add(connectionBinding);
			result.Add(connectionLines);
		}
        public ProcessDonationsTaskTab2()
        {
            InitializeComponent();

            this.DonationBinding = new FormBinding("donation");
            this.DonationBinding.AddBinding("donor", this.DonorSelector);
            this.DonationBinding.AddBinding("amount", new MoneyFieldBinding(this.AmountText, allowNull: false));
            this.DonationBinding.AddBinding("comment", new TextBoxBinding(this.CommentText, nullable: false, longText: true));
            this.DonationBinding.AddBinding("modcomment", new TextBoxBinding(this.ModCommentText, nullable: false, longText: true));
            this.DonationBinding.AddBinding("readstate", this.ReadStateBox, typeof(DonationReadState));
            this.DonationBinding.AddBinding("commentstate", this.CommentStateBox, typeof(DonationCommentState));
            this.DonationBinding.AddBinding("bidstate", this.BidStateBox, typeof(DonationBidState));

            this.DonationBinding.AddAssociatedControl(this.OpenDonorButton);
            this.DonationBinding.AddAssociatedControl(this.OpenDonationButton);
            this.DonationBinding.AddAssociatedControl(this.NextButton);

            this.ModeBinding = new ComboBoxBinding(this.ModeBox, typeof(ProcessDonationsMode));

            this.SearchBinding = new ListBinding<JObjectEntityDisplay>(this.TaskList, x => new JObjectFuncDisplay(x, DonationModels.DonationModel.DisplayConverter), "Display");
            this.SearchBinding.AddAssociatedControl(this.RefreshButton);
            this.SearchBinding.AddAssociatedControl(this.NextButton);
            this.SearchBinding.AddAssociatedControl(this.ModeBox);

            this.ModeBinding.LoadField(ProcessDonationsMode.BIDS.ToString());

            this.SearchBinding.OnSelection += this.OnSelection;

            this.CurrentObject = null;
        }
        public ReadTaskTab()
        {
            InitializeComponent();

            this.DonationBinding = new FormBinding("donation");
            this.DonationBinding.AddInstanceBinding(new PublicDonorNameBinding(this.DonorNameText, true));
            this.DonationBinding.AddBinding("amount", new MoneyFieldBinding(this.AmountText, readOnly: true, allowNull: false));
            this.DonationBinding.AddBinding("comment", new TextBoxBinding(this.CommentText, readOnly: true, nullable: false, longText: true));
            this.DonationBinding.AddBinding("modcomment", new TextBoxBinding(this.ModCommentText, readOnly: true, nullable: false, longText: true));
            this.DonationBinding.AddBinding("readstate", this.ReadStateBox, typeof(DonationReadState));
            this.DonationBinding.AddBinding("commentstate", this.CommentStateBox, typeof(DonationCommentState));
            this.DonationBinding.AddBinding("bidstate", this.BidStateBox, typeof(DonationBidState));

            this.DonationBinding.AddAssociatedControl(this.OpenDonorButton);
            this.DonationBinding.AddAssociatedControl(this.OpenDonationButton);
            this.DonationBinding.AddAssociatedControl(this.NextButton);

            this.MinimumAmountBinding = new MoneyFieldBinding(this.MinimumAmountText);
            this.MinimumMinutesBinding = new IntFieldBinding(this.MinimumMinutesText);
            this.ModeBinding = new ComboBoxBinding(this.ModeBox, typeof(ReadTaskVolumeMode));

            this.SearchBinding = new ListBinding<JObjectEntityDisplay>(this.TaskList, x => new JObjectFuncDisplay(x, DonationModels.DonationModel.DisplayConverter), "Display");
            this.SearchBinding.AddAssociatedControl(this.RefreshButton);
            this.SearchBinding.AddAssociatedControl(this.MinimumAmountText);
            this.SearchBinding.AddAssociatedControl(this.MinimumMinutesText);
            this.SearchBinding.AddAssociatedControl(this.ModeBox);

            this.MinimumAmountBinding.LoadField(DefaultMinimumAmount.ToString());
            this.MinimumMinutesBinding.LoadField(DefaultMinimumMinuteOffset.ToString());
            this.ModeBinding.LoadField(DefaultVolumeMode.ToString());

            this.SearchBinding.OnSelection += this.OnSelection;

            this.CurrentObject = null;
        }
        public SearchPanel(EntityModel model, IEnumerable<string> searchFields)
        {
            this.InitializeComponent();

            this.Model = model;
            this.SearchFields = searchFields.ToArray();

            int currentFieldIndex = 2;

            this.FormBinding = new FormBinding(model.ModelName, searchForm: true);
            this.ListBinding = new ListBinding<JObjectEntityDisplay>(this.ResultsList, x => new JObjectFuncDisplay(x, model.DisplayConverter), "Display");

            foreach (string field in this.SearchFields)
            {
                SearchFieldModel searchField = this.Model.GetSearchField(field);
                FieldBinding binding = FieldBindingHelper.CreateBindingField(searchField.FieldType, fieldName: field);
                this.FormBinding.AddBinding(field, binding);
                ++this.SearchParamsTable.RowCount;
                this.SearchParamsTable.Controls.Add(new Label()
                {
                    Text = field.SymbolToNatural(),
                    Dock = DockStyle.Fill
                }, 0, currentFieldIndex);
                this.SearchParamsTable.Controls.Add(binding.BoundControl, 1, currentFieldIndex);
                binding.BoundControl.Dock = DockStyle.Fill;
                ++currentFieldIndex;
            }

            this.SearchButton = new Button()
            {
                Text = "Search",
                Dock = DockStyle.Fill,
            };

            ++this.SearchParamsTable.RowCount;
            this.SearchButton.Click += this.SearchButton_Click;
            this.SearchParamsTable.Controls.Add(this.SearchButton, 1, currentFieldIndex);
            this.BasicSearchButton.Click += this.BasicSearchButton_Click;

            this.FormBinding.AddAssociatedControl(this.SearchButton);
            this.FormBinding.AddAssociatedControl(this.BasicSearchButton);
            this.FormBinding.AddAssociatedControl(this.BasicSearchText);

            this.ListBinding.OnSelection += (selections) =>
            {
                if (this.OnSelect != null)
                    this.OnSelect.Invoke(this.GetSelections());
            };
        }
        public SelectEventDialog(MainForm mainForm, TrackerContext context)
        {
            this.InitializeComponent();

            this.MainForm = mainForm;

            this.ListBinding = new ListBinding<JObjectSimpleDisplay>(this.EventsList, x => new JObjectSimpleDisplay(x as JObject, "name"), "Display");
            this.ListBinding.AddSelectionControl(this.SelectButton);

            this.Context = context;

            this.CurrentSearch = this.Context.DeferredSearch("event", new Dictionary<string, string> { { "q", "" } });

            this.CurrentSearch.OnComplete += results =>
            {
                this.ListBinding.LoadArray(results);
                this.ListBinding.EnableControls();
            };

            this.ListBinding.DisableControls();
            this.CurrentSearch.Begin();
        }
Example #6
0
		public static void AttachEditorComponents(Entity entity, string name, ListProperty<Entity.Handle> target)
		{
			entity.Add(name, target);
			if (entity.EditorSelected != null)
			{
				Transform transform = entity.Get<Transform>("Transform");

				LineDrawer connectionLines = new LineDrawer { Serialize = false };
				connectionLines.Add(new Binding<bool>(connectionLines.Enabled, entity.EditorSelected));

				ListBinding<LineDrawer.Line, Entity.Handle> connectionBinding = new ListBinding<LineDrawer.Line, Entity.Handle>(connectionLines.Lines, target, delegate(Entity.Handle other)
				{
					return new LineDrawer.Line
					{
						A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(transform.Position, connectionLineColor),
						B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(other.Target.Get<Transform>("Transform").Position, connectionLineColor)
					};
				}, x => x.Target != null && x.Target.Active);
				entity.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, entity.EditorSelected));
				entity.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, transform.Position));
				connectionLines.Add(connectionBinding);
				entity.Add(connectionLines);
			}
		}
Example #7
0
        public override void AttachEditorComponents(Entity result, Main main)
        {
            Transform transform = result.Get<Transform>();

            Zone zone = result.Get<Zone>();

            Property<bool> selected = new Property<bool> { Value = false, Editable = false, Serialize = false };
            result.Add("EditorSelected", selected);

            Command<Entity> toggleEntityConnected = new Command<Entity>
            {
                Action = delegate(Entity entity)
                {
                    if (zone.ConnectedEntities.Contains(entity))
                    {
                        zone.ConnectedEntities.Remove(entity);
                        Zone z = entity.Get<Zone>();
                        if (z != null)
                            z.Parent.Value = null;
                    }
                    else
                    {
                        zone.ConnectedEntities.Add(entity);
                        Zone z = entity.Get<Zone>();
                        if (z != null)
                            z.Parent.Value = result;
                    }
                }
            };
            result.Add("ToggleEntityConnected", toggleEntityConnected);

            LineDrawer connectionLines = new LineDrawer { Serialize = false };
            connectionLines.Add(new Binding<bool>(connectionLines.Enabled, selected));

            Color connectionLineColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
            ListBinding<LineDrawer.Line, Entity.Handle> connectionBinding = new ListBinding<LineDrawer.Line, Entity.Handle>(connectionLines.Lines, zone.ConnectedEntities, delegate(Entity.Handle entity)
            {
                if (entity.Target == null)
                    return new LineDrawer.Line[] { };
                else
                {
                    return new[]
                    {
                        new LineDrawer.Line
                        {
                            A = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(transform.Position, connectionLineColor),
                            B = new Microsoft.Xna.Framework.Graphics.VertexPositionColor(entity.Target.Get<Transform>().Position, connectionLineColor)
                        }
                    };
                }
            });
            result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, selected));
            result.Add(new NotifyBinding(delegate() { connectionBinding.OnChanged(null); }, () => selected, transform.Position));
            connectionLines.Add(connectionBinding);
            result.Add(connectionLines);

            Model model = new Model();
            model.Filename.Value = "Models\\sphere";
            model.Color.Value = this.Color;
            model.IsInstanced.Value = false;
            model.Scale.Value = new Vector3(0.5f);
            model.Editable = false;
            model.Serialize = false;
            result.Add("EditorModel", model);
            model.Add(new Binding<Matrix, Vector3>(model.Transform, x => Matrix.CreateTranslation(x), transform.Position));

            Property<Vector3> corner1 = new Property<Vector3> { Editable = false, Serialize = false, Value = zone.BoundingBox.Value.Min };
            Property<Vector3> corner2 = new Property<Vector3> { Editable = false, Serialize = false, Value = zone.BoundingBox.Value.Max };

            result.Add(new Binding<BoundingBox>(zone.BoundingBox, delegate()
            {
                Vector3 a = corner1, b = corner2;
                return new BoundingBox(new Vector3(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z)), new Vector3(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z)));
            }, corner1, corner2));

            Transform cornerTransform1 = this.addCornerModel(result, selected);
            cornerTransform1.Add(new TwoWayBinding<Vector3, Vector3>
            (
                corner1,
                x => Vector3.Transform(x, Matrix.Invert(transform.Matrix)),
                new[] { transform.Matrix },
                cornerTransform1.Position,
                x => Vector3.Transform(x, transform.Matrix),
                new[] { transform.Matrix }
            ));

            Transform cornerTransform2 = this.addCornerModel(result, selected);
            cornerTransform2.Add(new TwoWayBinding<Vector3, Vector3>
            (
                corner2,
                x => Vector3.Transform(x, Matrix.Invert(transform.Matrix)),
                new[] { transform.Matrix },
                cornerTransform2.Position,
                x => Vector3.Transform(x, transform.Matrix),
                new[] { transform.Matrix }
            ));

            ModelAlpha box = new ModelAlpha();
            box.Filename.Value = "Models\\alpha-box";
            box.Color.Value = new Vector3(this.Color.X, this.Color.Y, this.Color.Z);
            box.Alpha.Value = 0.125f;
            box.IsInstanced.Value = false;
            box.Editable = false;
            box.Serialize = false;
            box.DrawOrder.Value = 11; // In front of water
            box.DisableCulling.Value = true;
            result.Add(box);
            box.Add(new Binding<Matrix>(box.Transform, delegate()
            {
                BoundingBox b = zone.BoundingBox;
                return Matrix.CreateScale(b.Max - b.Min) * Matrix.CreateTranslation((b.Min + b.Max) * 0.5f) * transform.Matrix;
            }, zone.BoundingBox, transform.Matrix));
            box.Add(new Binding<bool>(box.Enabled, selected));
            box.Add(new Binding<BoundingBox>(box.BoundingBox, zone.BoundingBox));
            box.CullBoundingBox.Value = false;
        }