示例#1
0
        protected StackPanel NewTVItemStyle(RepositoryItemBase RI, eImageType imageType, string NameProperty)
        {
            RI.StartDirtyTracking();

            //The new item style with Source control
            StackPanel stack = new StackPanel();

            stack.Orientation = Orientation.Horizontal;

            if (WorkSpace.Instance.SourceControl != null)
            {
                // Source control image
                ImageMakerControl sourceControlImage = new ImageMakerControl();
                sourceControlImage.BindControl(RI, nameof(RepositoryItemBase.SourceControlStatus));
                sourceControlImage.Width  = 10;
                sourceControlImage.Height = 10;
                stack.Children.Add(sourceControlImage);
            }

            // Add Item Image
            ImageMakerControl NodeImageType = new ImageMakerControl();

            NodeImageType.ImageType = imageType;
            NodeImageType.Width     = 16;
            NodeImageType.Height    = 16;
            stack.Children.Add(NodeImageType);

            // Add Item header text
            Label itemHeaderLabel = new Label();

            itemHeaderLabel.BindControl(RI, NameProperty);
            stack.Children.Add(itemHeaderLabel);

            // add icon of dirty status
            ImageMakerControl dirtyStatusImage = new ImageMakerControl();

            dirtyStatusImage.BindControl(RI, nameof(RepositoryItemBase.DirtyStatusImage));
            dirtyStatusImage.Width             = 6;
            dirtyStatusImage.Height            = 6;
            dirtyStatusImage.VerticalAlignment = VerticalAlignment.Top;
            dirtyStatusImage.Margin            = new Thickness(0, 10, 10, 0);
            stack.Children.Add(dirtyStatusImage);

            return(stack);
        }
        public void CheckPropertyChangedTriggered()
        {
            // Scan all RIs for each prop marked with [IsSerializedForLocalRepositoryAttribute] try to change and verify prop changed triggered

            //Arrange

            // Get all Repository items
            IEnumerable <Type> list = GetRepoItems();

            ErrCounter = 0;

            //Act
            foreach (Type type in list)
            {
                Console.WriteLine("CheckPropertyChangedTriggered for type: " + type.FullName);
                if (type.IsAbstract)
                {
                    continue;
                }
                RepositoryItemBase RI = (RepositoryItemBase)Activator.CreateInstance(type);
                RI.PropertyChanged += RIPropertyChanged;
                RI.StartDirtyTracking();

                // Properties
                foreach (PropertyInfo PI in RI.GetType().GetProperties())
                {
                    var token = PI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                    if (token == null)
                    {
                        continue;
                    }
                    Console.WriteLine("CheckPropertyChangedTriggered for property: " + PI.Name);
                    object newValue = GetNewValue(PI.PropertyType, PI.GetValue(RI));
                    if (newValue != null)
                    {
                        RI.DirtyStatus = eDirtyStatus.NoChange;
                        prop           = null;
                        PI.SetValue(RI, newValue);
                        CheckChanges(RI, PI.Name, newValue);
                    }
                }


                // Fields
                foreach (FieldInfo FI in RI.GetType().GetFields())
                {
                    var token = FI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                    if (token == null)
                    {
                        continue;
                    }
                    Console.WriteLine("CheckPropertyChangedTriggered for property: " + FI.Name);
                    object newValue = GetNewValue(FI.FieldType, FI.GetValue(RI));
                    if (newValue != null)
                    {
                        RI.DirtyStatus = eDirtyStatus.NoChange;
                        prop           = null;
                        FI.SetValue(RI, newValue);
                        CheckChanges(RI, FI.Name, newValue);
                    }
                }
            }
            //Assert
            Assert.AreEqual(0, ErrCounter);
        }
示例#3
0
        /// <summary>
        /// The function creates the tree node item header
        /// </summary>
        /// <param name="repoItem">The repository item which the tree nodes represents</param>
        /// <param name="imageType">The image type which associated with the repository item- should be pulled from the repoItem</param>
        /// <param name="NameProperty">The field of the item which holds the item name or static name in case the repository item is null</param>
        /// <returns></returns>
        protected StackPanel NewTVItemHeaderStyle(RepositoryItemBase repoItem, eImageType imageType = eImageType.Null, string NameProperty = "")
        {
            //TODO: Move to biz flow page?
            repoItem.StartDirtyTracking();

            //The new item style with Source control
            StackPanel stack = new StackPanel();

            stack.Orientation = Orientation.Horizontal;

            if (WorkSpace.Instance.SourceControl != null)
            {
                // Source control image
                ImageMakerControl sourceControlImage = new ImageMakerControl();
                sourceControlImage.BindControl(repoItem, nameof(RepositoryItemBase.SourceControlStatus));
                repoItem.RefreshSourceControlStatus();
                sourceControlImage.Width  = 8;
                sourceControlImage.Height = 8;
                stack.Children.Add(sourceControlImage);
            }

            // Add Item Image
            ImageMakerControl NodeImageType = new ImageMakerControl();

            if (imageType == eImageType.Null)
            {
                NodeImageType.ImageType = repoItem.ItemImageType;
            }
            else
            {
                NodeImageType.ImageType = imageType;
            }

            NodeImageType.Width  = 16;
            NodeImageType.Height = 16;
            stack.Children.Add(NodeImageType);

            // Add Item header text
            Label itemHeaderLabel = new Label();

            string nameFieldProperty;

            if (string.IsNullOrEmpty(NameProperty))
            {
                nameFieldProperty = repoItem.ItemNameField;
            }
            else
            {
                nameFieldProperty = NameProperty;
            }
            BindingLib.ControlsBinding.ObjFieldBinding(itemHeaderLabel, Label.ContentProperty, repoItem, nameFieldProperty, BindingMode: System.Windows.Data.BindingMode.OneWay);


            stack.Children.Add(itemHeaderLabel);

            // add icon of dirty status
            ImageMakerControl dirtyStatusImage = new ImageMakerControl();

            dirtyStatusImage.BindControl(repoItem, nameof(RepositoryItemBase.DirtyStatusImage));
            dirtyStatusImage.Width             = 6;
            dirtyStatusImage.Height            = 6;
            dirtyStatusImage.VerticalAlignment = VerticalAlignment.Top;
            dirtyStatusImage.Margin            = new Thickness(0, 10, 10, 0);
            stack.Children.Add(dirtyStatusImage);

            return(stack);
        }