コード例 #1
0
ファイル: EntityConnectable.cs プロジェクト: sparker/Lemma
		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);
		}
コード例 #2
0
        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;
        }
コード例 #3
0
        /// <summary>
        /// Create a value binding.
        /// </summary>
        public IValueBinding CreateValueBinding(object parentObject, object value, Type type)
        {
            IValueBinding valueBinding;

            //
            // Recurse if neccessary and setup bindings for subobjects.
            //
            if (RecurseTypeForBindings(type))
            {
                // Get the sub-object from the property.
                if (type.IsArray)
                {
                    valueBinding = new ArrayBinding((Array)value, this);
                }
                else if (value is IList)
                {
                    valueBinding = new ListBinding((IList)value, this);
                }
                else
                {
                    valueBinding = new ObjectBinding(value, this);
                }
            }
            else
            {
                valueBinding = new PrimitiveBinding(value);
            }
            return(valueBinding);
        }
コード例 #4
0
        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;
        }
コード例 #5
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); }, () => entity.EditorSelected, transform.Position));
                connectionLines.Add(connectionBinding);
                entity.Add(connectionLines);
            }
        }
コード例 #6
0
        public void DoesTrackChangesOnSingleSource()
        {
            ObservableCollection <int> source = new ObservableCollection <int>();

            List <int> projection1 = new List <int>();
            List <int> projection2 = new List <int>();

            ListBinding <int> binding = new ListBinding <int>()
                                        .AddSource(source);

            source.Add(0);
            source.Add(1);
            source.Add(2);
            source.Add(3);
            source.Add(4);

            binding.AddTarget(projection1);

            source.Add(5);
            source.Add(6);

            binding.AddTarget(projection2);

            source.Add(7);
            source.Add(8);

            Assert.Equal(source, projection1);
            Assert.Equal(source, projection2);

            source.Remove(4);
            source.Remove(5);
            source.Remove(6);

            Assert.Equal(source, projection1);
            Assert.Equal(source, projection2);

            source.Insert(4, 4);
            source.Insert(5, 5);
            source.Insert(6, 6);

            Assert.Equal(source, projection1);
            Assert.Equal(source, projection2);

            source[4] = 0;
            source[5] = 0;
            source[5] = 5;
            source[4] = 4;

            Assert.Equal(source, projection1);
            Assert.Equal(source, projection2);

            source.Clear();

            Assert.Equal(source, projection1);
            Assert.Equal(source, projection2);
        }
コード例 #7
0
        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());
            };
        }
コード例 #8
0
        private async void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                jenkinsJobRunner = new JenkinsJobRunner(jenkinsClient)
                {
                    BuildTimeout = 60 * 60
                };

                jenkinsJobRunner.StatusChanged += JenkinsJobRunner_StatusChanged;

                string jobName = JobCombo.SelectedValue.ToString();
                ListBinding.Add(new ListEntry {
                    Message = $"start {jobName}"
                });
                JenkinsBuildBase result = null;
                if (jobData[jobName].Count == 0)
                {
                    result = await jenkinsJobRunner.RunAsync(jobName);
                }
                else
                {
                    Dictionary <string, string> parameters = new Dictionary <string, string>();
                    foreach (var jobProperty in SelectedJob.JobProperties)
                    {
                        parameters[jobProperty.Key] = jobProperty.Value;
                    }
                    result = await jenkinsJobRunner.RunWithParametersAsync(jobName, parameters);
                }

                ListBinding.Add(new ListEntry {
                    Message = $"Duration { result.Duration } ms"
                });
                ListBinding.Add(new ListEntry {
                    Message = $"Result {result.Result}"
                });
            }
            catch (Exception ex)
            {
                var t = ex;
            }
        }
コード例 #9
0
        public IEnumerable <ISettingBinding> ProvideBindings(DependencyObject target)
        {
            var selector = target as Selector;

            if (selector == null || Setting == null)
            {
                return(Enumerable.Empty <ISettingBinding>());
            }

            var targetAdapterBuilder = TargetAdapterBuilder ?? (adapter => adapter);
            var settingAdapter       = new SettingAdapter(Settings.CurrentStoreAccessor, Store, Settings.GetNamespace(selector), Setting);
            var binding =
                new ListBinding(
                    targetAdapterBuilder(
                        new SelectorSortDescriptionsAdapter(
                            new SelectorItemsSourceViewAdapter(selector))),
                    settingAdapter);

            return(new[] { binding });
        }
コード例 #10
0
        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();
        }
コード例 #11
0
ファイル: EntityConnectable.cs プロジェクト: dsmo7206/Lemma
		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);
			}
		}
コード例 #12
0
 private void OnEnable()
 {
     _binding        = target as ListBinding;
     _listProperties = new MemberCollection <PropertyInfo>(_binding.SourceType, MemberFilters.Lists);
     _listProperty   = serializedObject.FindProperty("_prefabs");
 }
コード例 #13
0
 private void InitTestObject()
 {
     testObject = new ListBinding(testList, mockBindingsFactory.Object);
 }
コード例 #14
0
        public void DoesSupportTransformation()
        {
            ObservableCollection <int> source1 = new ObservableCollection <int>();
            ObservableCollection <int> source2 = new ObservableCollection <int>();
            ObservableCollection <int> source3 = new ObservableCollection <int>();

            List <string> projection1 = new List <string>();
            List <string> projection2 = new List <string>();

            Func <int, string> transformation = i => i.ToString();

            ListBinding <string> binding = new ListBinding <string>()
                                           .AddSource(source1, transformation)
                                           .AddSource(source2, transformation)
                                           .AddSource(source3, transformation);

            source1.Add(0);
            source2.Add(1);
            source3.Add(2);
            source3.Add(3);
            source2.Add(4);

            binding.AddTarget(projection1);

            source1.Add(5);
            source2.Add(6);

            binding.AddTarget(projection2);

            source1.Add(7);
            source3.Add(8);

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source2.Remove(4);
            source1.Remove(5);
            source2.Remove(6);

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source1.Insert(1, 4);
            source3.Insert(0, 5);
            source1.Insert(1, 6);

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source1[1] = 0;
            source1[2] = 0;
            source1[0] = 5;
            source3[1] = 4;

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source1.Clear();

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source3.Clear();
            source2.Clear();

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);
        }
コード例 #15
0
        public void DoesSupportFiltering()
        {
            List <string> expected;

            ObservableCollection <int> source1 = new ObservableCollection <int>();
            ObservableCollection <int> source2 = new ObservableCollection <int>();
            ObservableCollection <int> source3 = new ObservableCollection <int>();

            List <string> projection1 = new List <string>();
            List <string> projection2 = new List <string>();

            Func <int, string> transformation  = i => i.ToString();
            Func <int, bool>   filterPredicate = i => i <= 2;

            ListBinding <string> binding = new ListBinding <string>()
                                           .AddSource(source1, convert: transformation, filter: filterPredicate)
                                           .AddSource(source2, convert: transformation, filter: filterPredicate)
                                           .AddSource(source3, convert: transformation, filter: filterPredicate);

            source1.Add(0);
            source2.Add(1);
            source3.Add(2);
            source3.Add(3);
            source2.Add(4);

            binding.AddTarget(projection1);

            source1.Add(5);
            source2.Add(6);

            binding.AddTarget(projection2);

            source1.Add(7);
            source3.Add(8);

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source2.Remove(4);
            source1.Remove(5);
            source2.Remove(6);

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source1.Insert(1, 4);
            source3.Insert(0, 5);
            source1.Insert(1, 6);

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source1[1] = 0;
            source1[2] = 0;
            source1[0] = 5;
            source3[1] = 4;

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source1.Clear();

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source3.Clear();
            source2.Clear();

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);
        }
コード例 #16
0
        public void DoesSupportObservableHashSet()
        {
            List <string> expected;
            List <int>    expectedForked;

            ObservableHashSet <int> source1 = new ObservableHashSet <int>();
            ObservableHashSet <int> source2 = new ObservableHashSet <int>();
            ObservableHashSet <int> source3 = new ObservableHashSet <int>();

            List <string> projection1 = new List <string>();
            List <string> projection2 = new List <string>();
            List <int>    projection3 = new List <int>();

            Func <int, string> transformation  = i => i.ToString();
            Func <int, bool>   filterPredicate = i => i <= 2;

            ListBinding <string> binding = new ListBinding <string>()
                                           .AddSource(source1, convert: transformation, filter: filterPredicate)
                                           .AddSource(source2, convert: transformation, filter: filterPredicate)
                                           .AddSource(source3, convert: transformation, filter: filterPredicate);

            source1.Add(0);
            source2.Add(1);
            source3.Add(2);
            source3.Add(3);
            source2.Add(4);

            binding.AddTarget(projection1);

            source1.Add(5);
            source2.Add(6);

            binding.AddTarget(projection2);

            source1.Add(7);
            source3.Add(8);

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            var bindingForked = binding.Select <int>(item => int.Parse(item));

            source2.Remove(4);
            source1.Remove(5);
            source2.Remove(6);

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source1.Add(4);
            source3.Add(5);
            source1.Add(6);

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source1.Clear();

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            source3.Clear();
            source2.Clear();

            expected = source1.Concat(source2).Concat(source3).Where(filterPredicate).Select(transformation).ToList();
            expected.Sort();
            Assert.Equal(expected, projection1);
            Assert.Equal(expected, projection2);

            expectedForked = source1.Concat(source2).Concat(source3).Where(filterPredicate).ToList();
            expectedForked.Sort();
            Assert.Equal(expectedForked, projection3);
        }
コード例 #17
0
ファイル: ZoneFactory.cs プロジェクト: kernelbitch/Lemma
        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;
        }
コード例 #18
0
 private void JenkinsJobRunner_StatusChanged()
 {
     ListBinding.Add(new ListEntry {
         Message = $"{jenkinsJobRunner.Status}"
     });
 }
コード例 #19
0
        public void DoesTrackChangesOnMultipleSources()
        {
            ObservableCollection <int> source1 = new ObservableCollection <int>();
            ObservableCollection <int> source2 = new ObservableCollection <int>();
            ObservableCollection <int> source3 = new ObservableCollection <int>();

            List <int> projection1 = new List <int>();
            List <int> projection2 = new List <int>();

            ListBinding <int> binding = new ListBinding <int>()
                                        .AddSource(source1)
                                        .AddSource(source2)
                                        .AddSource(source3);

            source1.Add(0);
            source2.Add(1);
            source3.Add(2);
            source3.Add(3);
            source2.Add(4);

            binding.AddTarget(projection1);

            source1.Add(5);
            source2.Add(6);

            binding.AddTarget(projection2);

            source1.Add(7);
            source3.Add(8);

            Assert.Equal(source1.Concat(source2).Concat(source3), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3), projection2);

            source2.Remove(4);
            source1.Remove(5);
            source2.Remove(6);

            Assert.Equal(source1.Concat(source2).Concat(source3), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3), projection2);

            source1.Insert(1, 4);
            source3.Insert(0, 5);
            source1.Insert(1, 6);

            Assert.Equal(source1.Concat(source2).Concat(source3), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3), projection2);

            source1[1] = 0;
            source1[2] = 0;
            source1[0] = 5;
            source3[1] = 4;

            Assert.Equal(source1.Concat(source2).Concat(source3), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3), projection2);

            source1.Clear();

            Assert.Equal(source1.Concat(source2).Concat(source3), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3), projection2);

            source3.Clear();
            source2.Clear();

            Assert.Equal(source1.Concat(source2).Concat(source3), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3), projection2);
        }
コード例 #20
0
        public void DoesSupportNullItems()
        {
            ObservableCollection <string> source1 = new ObservableCollection <string>();
            ObservableCollection <string> source2 = new ObservableCollection <string>();
            ObservableCollection <string> source3 = new ObservableCollection <string>();

            List <string> projection1 = new List <string>();
            List <string> projection2 = new List <string>();

            Func <string, string> transformation = i => i?.ToString();

            ListBinding <string> binding = new ListBinding <string>()
                                           .AddSource(source1, transformation)
                                           .AddSource(source2, transformation)
                                           .AddSource(source3, transformation);

            source1.Add("0");
            source2.Add("1");
            source3.Add("2");
            source3.Add("3");
            source2.Add("4");

            binding.AddTarget(projection1);

            source1.Add(null);
            source2.Add(null);

            binding.AddTarget(projection2);

            source1.Add(null);
            source3.Add(null);

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source2.Remove("4");
            source1.Remove("5");
            source2.Remove("6");

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source1.Insert(1, "4");
            source3.Insert(0, "5");
            source1.Insert(1, "6");

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source1[1] = "0";
            source1[2] = "0";
            source1[0] = "5";
            source3[1] = "4";

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source1.Clear();

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);

            source3.Clear();
            source2.Clear();

            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection1);
            Assert.Equal(source1.Concat(source2).Concat(source3).Select(transformation), projection2);
        }