示例#1
0
        public void When_DataContext_Changed_Multiple()
        {
            var SUT = new DependencyObjectCollection();

            SUT.DataContext = 41;

            var o1 = new MyDependencyObject();

            o1.SetBinding(MyDependencyObject.MyPropertyProperty, new Binding());

            var o2 = new MyDependencyObject();

            o2.SetBinding(MyDependencyObject.MyPropertyProperty, new Binding());

            Assert.AreEqual(0, o1.MyProperty);
            Assert.AreEqual(0, o1.MyProperty);

            SUT.Add(o1);
            SUT.Add(o2);

            Assert.AreEqual(41, o1.MyProperty);
            Assert.AreEqual(41, o2.MyProperty);

            SUT.DataContext = 42;

            Assert.AreEqual(42, o1.MyProperty);
            Assert.AreEqual(42, o2.MyProperty);

            SUT.Clear();

            Assert.AreEqual(0, o1.MyProperty);
            Assert.AreEqual(0, o2.MyProperty);
        }
示例#2
0
 public void UpdataCollection(DependencyObjectCollection items)
 {
     items.Clear();
     foreach (var item in ocPens)
     {
         items.Add(item);
     }
     foreach (var item in ocToggles)
     {
         items.Add(item);
     }
     foreach (var item in ocTool)
     {
         items.Add(item);
     }
 }
示例#3
0
        public void When_Changed_By_Indexer()
        {
            var SUT = new DependencyObjectCollection();

            SUT.DataContext = 42;

            var o1 = new MyDependencyObject();

            o1.SetBinding(MyDependencyObject.MyPropertyProperty, new Binding());

            var o2 = new MyDependencyObject();

            o2.SetBinding(MyDependencyObject.MyPropertyProperty, new Binding());

            Assert.AreEqual(0, o1.MyProperty);
            Assert.AreEqual(0, o1.MyProperty);

            SUT.Add(o1);
            Assert.AreEqual(42, o1.MyProperty);
            Assert.AreEqual(0, o2.MyProperty);

            SUT[0] = o2;

            Assert.AreEqual(0, o1.MyProperty);
            Assert.AreEqual(42, o2.MyProperty);
        }
示例#4
0
        //20170209 add by liwei1 for P001-170203001 ===end===

        private void InsertMR(DateTime report_datetime, string category, string recommendedOperations, DependencyObjectCollection resultColl, object docId) //20170209 modi by liwei1 for P001-170124001 增加参数:docId
        {
            DataTable dt = QueryForMoReceiptReq(report_datetime, category, recommendedOperations, docId);                                                   //20170209 modi by liwei1 for P001-170124001 增加参数:docId

            ValidateParaFilDoc(dt);                                                                                                                         //20161213 add by shenbao for B001-161213006
            DataTable dt_d = QueryForMoReceipt_D(category, report_datetime, recommendedOperations);

            if (dt.Rows.Count > 0)
            {
                IQueryService    qrySrv      = GetService <IQueryService>();//20170405 add by wangrm for P001-170328001
                ICreateService   createSrv   = GetService <ICreateService>("MO_RECEIPT_REQUISTION");
                DependencyObject entity      = createSrv.Create() as DependencyObject;
                ISaveService     saveService = this.GetService <ISaveService>("MO_RECEIPT_REQUISTION");
                List <IGrouping <object, DataRow> > groupDt          = dt_d.AsEnumerable().GroupBy(a => (a.Field <object>("MO_RECEIPT_REQUISTION_ID"))).ToList();
                IEFNETStatusStatusService           efnetSrv         = this.GetService <IEFNETStatusStatusService>();
                IDocumentNumberGenerateService      docNumberService = this.GetService <IDocumentNumberGenerateService>("MO_RECEIPT_REQUISTION");
                foreach (DataRow dr in dt.Rows)
                {
                    DependencyObject           newEntity      = new DependencyObject(entity.DependencyObjectType);
                    DependencyObjectCollection newEntityDColl = newEntity["MO_RECEIPT_REQUISTION_D"] as DependencyObjectCollection;
                    AddToEntity(newEntity, dr, dt.Columns, false);
                    newEntity["DOC_NO"] = docNumberService.NextNumber(dr["DOC_ID"], dr["DOC_DATE"].ToDate().Date);
                    List <IGrouping <object, DataRow> > entityDColl = groupDt.Where(c => c.Key.Equals(dr["MO_RECEIPT_REQUISTION_ID"])).ToList();
                    foreach (IGrouping <object, DataRow> groupDColl in entityDColl)
                    {
                        foreach (DataRow dr_d in groupDColl)
                        {
                            DependencyObject newEntityD = new DependencyObject(newEntityDColl.ItemDependencyObjectType);
                            AddToEntity(newEntityD, dr_d, dt_d.Columns, true);
                            newEntityDColl.Add(newEntityD);
                        }
                    }
                    //20170428 add by wangyq for P001-170427001  ============begin==========
                    DependencyObject resultObj = resultColl.AddNew();
                    resultObj["doc_no"] = newEntity["DOC_NO"];
                    //20170428 add by wangyq for P001-170427001  ============end==========

                    //20170628 modi by zhangcn for P001-170327001 ===begin===
                    try {
                        SetIgnoreWarningTag();       //忽略警告
                        saveService.Save(newEntity); //希望触发保存校验
                    }
                    finally {
                        ResetIgnoreWarningTag();// 重置警告
                    }
                    //20170628 modi by zhangcn for P001-170327001 ===end===

                    //7.3自动签核
                    efnetSrv.GetFormFlow("MO_RECEIPT_REQUISTION.I01", dr["DOC_ID"], dr["Owner_Org_ROid"],
                                         new List <object>()
                    {
                        dr["MO_RECEIPT_REQUISTION_ID"]
                    });
                }
            }
        }
示例#5
0
        private DependencyObjectCollection CreateUniformGridDefinitions()
        {
            int count   = Children.Count - 1;
            int rows    = (int)Math.Floor(Math.Sqrt(count));
            int columns = (int)Math.Ceiling(count / (double)rows);
            DependencyObjectCollection definitions = new DependencyObjectCollection();

            for (int i = 0; i < rows; i++)
            {
                definitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }
            for (int i = 0; i < columns; i++)
            {
                definitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }
            return(definitions);
        }
示例#6
0
        public void When_DependencyObjectCollection_And_XBind()
        {
            var SUT = new Border();

            var root = new
            {
                MyElement = new Border()
                {
                    Tag = true
                }
            };

            var group = new VisualStateGroup();
            var state = new VisualState();

            var compositeTrigger = new CompositeTrigger();

            var stateTrigger = new StateTrigger();

            stateTrigger.SetBinding(
                StateTrigger.IsActiveProperty,
                new Binding {
                Path           = "MyElement.Tag",
                CompiledSource = root
            }
                );

            Assert.AreEqual(false, stateTrigger.IsActive);

            var triggers = new DependencyObjectCollection();

            triggers.Add(stateTrigger);
            compositeTrigger.TriggerCollection = triggers;

            state.StateTriggers.Add(compositeTrigger);

            group.States.Add(state);

            VisualStateManager.SetVisualStateGroups(SUT, new List <VisualStateGroup>()
            {
                group
            });

            SUT.ForceLoaded();
            SUT.ApplyCompiledBindings();

            Assert.AreEqual(true, stateTrigger.IsActive);

            compositeTrigger.TriggerCollection = null;

            Assert.IsNull(triggers.GetParent());
        }
        public void When_SimpleInheritance()
        {
            var SUT    = new DependencyObjectCollection();
            var level1 = new DependencyObjectCollection();
            var level2 = new MyObject();

            SUT.Add(level1);
            level1.Add(level2);

            SUT.DataContext = 42;

            Assert.AreEqual(42, level2.DataContext);
        }
示例#8
0
        private DependencyObjectCollection CreateMaximizedDefinitions()
        {
            var defs  = new DependencyObjectCollection();
            int count = Cells.Count;

            defs.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            if (count > 1)
            {
                defs.Add(new ColumnDefinition {
                    Width = new GridLength(_minimizedWidth, GridUnitType.Pixel)
                });
            }
            for (int i = 0; i < count - 1; i++)
            {
                defs.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }
            return(defs);
        }
示例#9
0
        public void When_Add_After_DataContext()
        {
            var SUT = new DependencyObjectCollection();

            SUT.DataContext = 42;

            var o1 = new MyDependencyObject();

            o1.SetBinding(MyDependencyObject.MyPropertyProperty, new Binding());

            Assert.AreEqual(0, o1.MyProperty);

            SUT.Add(o1);

            Assert.AreEqual(42, o1.MyProperty);
        }
示例#10
0
        public void When_ValidBinding_And_Then_InvalidBinding()
        {
            var sub   = new DependencyObjectCollection();
            var other = new MyObjectWithExplicitDefaultValue();

            other.SetBinding(MyObjectWithExplicitDefaultValue.MyPropertyProperty, new Binding()
            {
                Path = new PropertyPath("a")
            });

            sub.Add(other);

            sub.DataContext = new { a = 42 };

            Assert.AreEqual(42, other.MyProperty);

            sub.DataContext = 42;

            Assert.AreEqual(77, other.MyProperty);
        }
示例#11
0
		public void MentorTest_FrameworkElement_CollectionInCustomProperty_AttachOppositeOrder()
		{
			var mentor = new MentorElement();
			var collection = new DependencyObjectCollection<object>();
			var child = new SolidColorBrush();
			BindingOperations.SetBinding(child, SolidColorBrush.ColorProperty, new Binding());

			// Attach the child then the collection
			collection.Add(child);
			mentor.MentoredCollection = collection;

			mentor.DataContext = Colors.Red;
			Assert.AreEqual(Colors.Red, child.Color, "#1");
		}
示例#12
0
 /// <inheritdoc />
 public void Add(Inline item) => _collection.Add(item);
示例#13
0
 public void Add(ColumnDefinition item) => _inner.Add(item);
示例#14
0
 public void Add(RowDefinition item) => _inner.Add(item);