public static DependencyPropertyDescriptor FromProperty(PropertyDescriptor property)
        {
            if (property == null)
                throw new ArgumentNullException("property");

            DependencyPropertyDescriptor dpd;
            if (!CachedDpd.TryGetValue(property, out dpd))
            {
                var dp = DependencyObject.FromName(property.Name, property.ComponentType);
                if (dp != null)
                {
                    dpd = new DependencyPropertyDescriptor(property, dp.OwnerType, dp);
                    CachedDpd.TryAdd(property, dpd);
                }
            }

            return dpd; // null if could't get a DependencyProperty
        }
Beispiel #2
0
        public static void AddValueChanged(this DependencyProperty property, object sourceObject, EventHandler handler)
        {
            var propertyDescriptor = DependencyPropertyDescriptor.FromProperty(property, property.OwnerType);

            propertyDescriptor.AddValueChanged(sourceObject, handler);
        }
Beispiel #3
0
        public static bool IsSupportValueChangedEvent(this DependencyProperty property)
        {
            var descriptor = DependencyPropertyDescriptor.FromProperty(property, property.OwnerType);

            return(descriptor.SupportsChangeEvents);
        }
Beispiel #4
0
 static ImageAnimationController()
 {
     _sourceDescriptor = DependencyPropertyDescriptor.FromProperty(Image.SourceProperty, typeof(Image));
 }
Beispiel #5
0
        public void RebuildGrid()
        {
            Monik?.Verbose("Matrix.RebuildGrid started");

            MainGrid.Children.Clear();

            if (Rows == null || Columns == null ||
                Rows.Count == 0 || Columns.Count == 0)
            {
                Monik?.Verbose("Matrix.RebuildGrid skip func");
                return;
            }

            var columns     = Columns.ToList();
            int columnCount = Columns.Count;
            var rows        = Rows.ToList();
            int rowCount    = Rows.Count;

            //////////////////
            // 1. Fill columns
            //////////////////
            MainGrid.ColumnDefinitions.Clear();
            // rows header
            MainGrid.ColumnDefinitions.Add(
                new ColumnDefinition {
                Width = new GridLength(30, GridUnitType.Pixel)
            });

            // columns
            for (int i = 0; i < columnCount; i++)
            {
                var it = columns[i];
                Monik?.Verbose($"Matrix.RebuildGrid add column {it.Id}::{it.Name}::{it.Order}");

                var cd = new ColumnDefinition();
                cd.DataContext = it;
                cd.Width       = new GridLength(it.Size / 10.0, GridUnitType.Star);
                MainGrid.ColumnDefinitions.Add(cd);

                PropertyDescriptor pd = DependencyPropertyDescriptor.FromProperty(ColumnDefinition.WidthProperty, typeof(ColumnDefinition));
                pd.AddValueChanged(cd, new EventHandler(ColumnWidthPropertyChanged));

                ContentControl cc = new ContentControl();
                cc.Content         = it;
                cc.MouseMove      += Head_MouseMove;
                cc.ContextMenu     = HeadContextMenu;
                cc.ContentTemplate = (DataTemplate)this.Resources["DefaultHorizontalHeaderTemplate"];
                MainGrid.Children.Add(cc);

                // Update number of Cards in Column
                CardsObservable
                .Filter(x => x.ColumnDeterminant == it.Id)
                .ToCollection()
                .Subscribe(x => it.CurNumberOfCards = x.Count());

                // dont draw excess splitter
                if (i < columnCount - 1)
                {
                    MainGrid.Children.Add(BuildVerticalSpliter(i, rowCount));
                }

                Grid.SetColumn(cc, i + 1);
                Grid.SetRow(cc, 0);
            }

            ///////////////
            // 2. Fill rows
            ///////////////
            MainGrid.RowDefinitions.Clear();
            // columns header
            MainGrid.RowDefinitions.Add(
                new RowDefinition {
                Height = new GridLength(30, GridUnitType.Pixel)
            });

            // rows
            VerticalHeaders.Clear();
            for (int i = 0; i < rowCount; i++)
            {
                var it = rows[i];
                Monik?.Verbose($"Matrix.RebuildGrid add row {it.Id}::{it.Name}::{it.Order}");

                var rd = new RowDefinition();
                rd.DataContext = it;
                rd.Height      = new GridLength(it.Size / 10.0, GridUnitType.Star);
                MainGrid.RowDefinitions.Add(rd);

                PropertyDescriptor pd = DependencyPropertyDescriptor.FromProperty(RowDefinition.HeightProperty, typeof(RowDefinition));
                pd.AddValueChanged(rd, new EventHandler(RowWidthPropertyChanged));

                ContentControl cc = new ContentControl();
                VerticalHeaders.Add(cc);
                cc.Content         = it;
                cc.MouseMove      += Head_MouseMove;
                cc.ContextMenu     = HeadContextMenu;
                cc.ContentTemplate = (DataTemplate)this.Resources["DefaulVerticalHeaderTemplate"];
                MainGrid.Children.Add(cc);

                // Update number of Cards in Row
                CardsObservable
                .Filter(x => x.RowDeterminant == it.Id)
                .ToCollection()
                .Subscribe(x => it.CurNumberOfCards = x.Count());

                // dont draw excess splitter
                if (i < rowCount - 1)
                {
                    MainGrid.Children.Add(BuildHorizontalSpliter(i, columnCount));
                }
                Grid.SetColumn(cc, 0);
                Grid.SetRow(cc, i + 1);
                Canvas.SetZIndex(cc, System.Int32.MaxValue);
            }

            ////////////////////////
            // 3. Fill Intersections
            ////////////////////////
            for (int i = 0; i < Columns.Count; i++)
            {
                for (int j = 0; j < Rows.Count; j++)
                {
                    int colDet = columns[i].Id;
                    int rowDet = rows[j].Id;

                    CardsObservable
                    .Filter(x => x.ColumnDeterminant == colDet && x.RowDeterminant == rowDet)
                    .Sort(SortExpressionComparer <ICard> .Ascending(c => c.Order))
                    .ObserveOnDispatcher()
                    .Bind(out ReadOnlyObservableCollection <ICard> intersectionCards)
                    .Subscribe();

                    Intersection cell = new Intersection(this)
                    {
                        DataContext       = this,
                        ColumnDeterminant = colDet,
                        RowDeterminant    = rowDet,
                        SelfCards         = intersectionCards
                    };

                    MainGrid.Children.Add(cell);
                    Grid.SetColumn(cell, i + 1);
                    Grid.SetColumnSpan(cell, 1);
                    Grid.SetRow(cell, j + 1);
                    Grid.SetRowSpan(cell, 1);
                }
            }
            SwimLanePropertyChanged(this, null);
            Monik?.Verbose("Matrix.RebuildGrid finished");
        }
        internal void UpdateAdvanceOptionsForItem(MarkupObject markupObject, DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor,
                                                  out string imageName, out object tooltip)
        {
            imageName = "AdvancedProperties11";
            tooltip   = "Advanced Properties";

            bool isResource        = false;
            bool isDynamicResource = false;

            var markupProperty = markupObject.Properties.Where(p => p.Name == GetPropertyName()).FirstOrDefault();

            if (markupProperty != null)
            {
                //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style
                isResource        = (markupProperty.Value is Style);
                isDynamicResource = (markupProperty.Value is DynamicResourceExtension);
            }

            if (isResource || isDynamicResource)
            {
                imageName = "Resource11";
                tooltip   = "Resource";
            }
            else
            {
                if ((dependencyObject != null) && (dpDescriptor != null))
                {
                    if (BindingOperations.GetBindingExpressionBase(dependencyObject, dpDescriptor.DependencyProperty) != null)
                    {
                        imageName = "Database11";
                        tooltip   = "Databinding";
                    }
                    else
                    {
                        BaseValueSource bvs =
                            DependencyPropertyHelper
                            .GetValueSource(dependencyObject, dpDescriptor.DependencyProperty)
                            .BaseValueSource;

                        switch (bvs)
                        {
                        case BaseValueSource.Inherited:
                        case BaseValueSource.DefaultStyle:
                        case BaseValueSource.ImplicitStyleReference:
                            imageName = "Inheritance11";
                            tooltip   = "Inheritance";
                            break;

                        case BaseValueSource.DefaultStyleTrigger:
                            break;

                        case BaseValueSource.Style:
                            imageName = "Style11";
                            tooltip   = "Style Setter";
                            break;

                        case BaseValueSource.Local:
                            imageName = "Local11";
                            tooltip   = "Local";
                            break;
                        }
                    }
                }
            }
        }
Beispiel #7
0
        private bool PropertyIsAttached(PropertyDescriptor descriptor)
        {
            DependencyPropertyDescriptor dependencyPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(PropertyDescriptor);

            return(dependencyPropertyDescriptor != null && dependencyPropertyDescriptor.IsAttached);
        }
Beispiel #8
0
 public static DependencyPropertyDescriptor GetDescriptor(this DependencyProperty property, Type targetType)
 {
     return(DependencyPropertyDescriptor.FromProperty(property, targetType));
 }
Beispiel #9
0
        static List <Expression> Process(Expression expression, ParameterExpression factory)
        {
            if (expression.NodeType == ExpressionType.New)
            {
                if (((NewExpression)expression).Arguments.Any())
                {
                    throw new InvalidOperationException("No arguments in constructo allowed");
                }

                return(new List <Expression>
                {
                    Expression.Assign(factory, Expression.New(ci, Expression.Constant(expression.Type)))
                });
            }

            if (expression.NodeType == ExpressionType.MemberInit)
            {
                MemberInitExpression mie = (MemberInitExpression)expression;
                var list = Process(mie.NewExpression, factory);

                foreach (MemberBinding mb in mie.Bindings)
                {
                    switch (mb.BindingType)
                    {
                    case MemberBindingType.Assignment:
                    {
                        MemberAssignment ma = (MemberAssignment)mb;

                        PropertyInfo pi = ma.Member as PropertyInfo;

                        if (IsDefaultMember(pi))
                        {
                            list.AddRange(ProcessChild(ma.Expression, factory));
                        }
                        else
                        {
                            DependencyPropertyDescriptor desc = DependencyPropertyDescriptor.FromName(pi.Name, pi.DeclaringType, pi.DeclaringType);
                            if (desc == null)
                            {
                                throw new InvalidOperationException("{0} is not a DependencyProperty".FormatWith(pi.PropertyName()));
                            }

                            list.Add(Expression.Call(factory, miSetValue, Expression.Constant(desc.DependencyProperty), Expression.Convert(ma.Expression, typeof(object))));
                        }
                    } break;

                    case MemberBindingType.ListBinding:
                    {
                        MemberListBinding bindings = (MemberListBinding)mb;

                        DefaultMemberAttribute dma = bindings.Member.DeclaringType.GetCustomAttribute <DefaultMemberAttribute>();

                        //if(!IsDefaultMember(bindings.Member))
                        //    throw new InvalidOperationException("Add items only work for the DefaultMember");

                        foreach (var item in bindings.Initializers)
                        {
                            if (item.Arguments.Count != 1)
                            {
                                throw new InvalidOperationException("Add Method {0} not supported".FormatWith(item.AddMethod.MethodName()));
                            }

                            list.AddRange(ProcessChild(item.Arguments.SingleEx(), factory));
                        }
                    } break;

                    case MemberBindingType.MemberBinding:
                        throw new InvalidOperationException("MemberBinding not supported");
                    }
                }

                return(list);
            }

            if (expression.NodeType == ExpressionType.Call)
            {
                MethodCallExpression call = (MethodCallExpression)expression;

                MethodInfo mi = call.Method;

                if (mi.DeclaringType != typeof(Fluent) || mi.ReturnType != mi.GetParameters()[0].ParameterType)
                {
                    throw new InvalidOperationException("Method {0} not supported".FormatWith(mi.MethodName()));
                }

                var list = Process(call.Arguments[0], factory);

                list.Add(ProcessMethod(factory, call));

                return(list);
            }

            if (expression.NodeType == ExpressionType.Convert)
            {
                return(Process(((UnaryExpression)expression).Operand, factory));
            }

            throw new InvalidOperationException("Expression {0} not supported");
        }
Beispiel #10
0
        public static DependencyProperty GetDependencyPropertyByName(this DependencyObject obj, string name)
        {
            var descriptor = DependencyPropertyDescriptor.FromName(name, obj.GetType(), obj.GetType());

            return(descriptor.DependencyProperty);
        }
        public static bool IsRelevantProperty(object o, PropertyDescriptor property)
        {
            var element = o as FrameworkElement;

            if (element == null)
            {
                return(true);
            }

            // Filter the 20 stylistic set properties that I've never seen used.
            if (property.Name.Contains("Typography.StylisticSet"))
            {
                return(false);
            }

            var attachedPropertyForChildren  = (AttachedPropertyBrowsableForChildrenAttribute)property.Attributes[typeof(AttachedPropertyBrowsableForChildrenAttribute)];
            var attachedPropertyForType      = (AttachedPropertyBrowsableForTypeAttribute)property.Attributes[typeof(AttachedPropertyBrowsableForTypeAttribute)];
            var attachedPropertyForAttribute = (AttachedPropertyBrowsableWhenAttributePresentAttribute)property.Attributes[typeof(AttachedPropertyBrowsableWhenAttributePresentAttribute)];

            if (attachedPropertyForChildren != null)
            {
                var descriptor = DependencyPropertyDescriptor.FromProperty(property);
                if (descriptor == null)
                {
                    return(false);
                }

                var localElement = element;
                do
                {
                    localElement = localElement.Parent as FrameworkElement;
                    if (localElement != null && descriptor.DependencyProperty.OwnerType.IsInstanceOfType(localElement))
                    {
                        return(true);
                    }
                }while (attachedPropertyForChildren.IncludeDescendants && localElement != null);
                return(false);
            }
            if (attachedPropertyForType != null)
            {
                // when using [AttachedPropertyBrowsableForType(typeof(IMyInterface))] and IMyInterface is not a DependencyObject, Snoop crashes.
                // see http://snoopwpf.codeplex.com/workitem/6712

                if (attachedPropertyForType.TargetType.IsSubclassOf(typeof(DependencyObject)))
                {
                    DependencyObjectType doType = DependencyObjectType.FromSystemType(attachedPropertyForType.TargetType);
                    if (doType.IsInstanceOfType(element))
                    {
                        return(true);
                    }
                }

                return(false);
            }
            if (attachedPropertyForAttribute == null)
            {
                return(true);
            }

            var dependentAttribute = TypeDescriptor.GetAttributes(element)[attachedPropertyForAttribute.AttributeType];

            return(dependentAttribute != null && !dependentAttribute.IsDefaultAttribute());
        }
        private void Loaded_e(object sender, RoutedEventArgs e)
        {
            var dpd = DependencyPropertyDescriptor.FromProperty(ItemsControl.ItemsSourceProperty, typeof(DataGrid));

            dpd.AddValueChanged(DisabledAdaptersDG, ThisIsCalledWhenPropertyIsChanged);
        }
Beispiel #13
0
 static OverlayAdorner()
 {
     _isVisibleDescriptor = DependencyPropertyDescriptor.FromProperty(IsVisibleProperty, typeof(AdornerLayer));
 }
Beispiel #14
0
        static NotificationObject()
        {
            var prop = DesignerProperties.IsInDesignModeProperty;

            IsInDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue;
        }
        private void DetachHandlers(Flyout item)
        {
            var isOpenChanged = DependencyPropertyDescriptor.FromProperty(Flyout.IsOpenProperty, typeof(Flyout));

            isOpenChanged.RemoveValueChanged(item, this.FlyoutIsOpenChanged);
        }
Beispiel #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShowVariable"/> class with the specified
        /// initially selected <see cref="VariableClass"/> and <see cref="VariableDisplay"/> flags.
        /// </summary>
        /// <param name="variable"><para>
        /// The <see cref="VariableClass"/> to select initially.
        /// </para><para>-or-</para><para>
        /// A null reference to select the first <see cref="AttributeClass"/>, <see
        /// cref="ResourceClass"/>, or <see cref="CounterClass"/>, in that order.</para></param>
        /// <param name="flags">
        /// A <see cref="VariableDisplay"/> value indicating which display flags to select
        /// initially.</param>
        /// <exception cref="ArgumentException">
        /// <paramref name="variable"/> is neither a null reference nor an element of the <see
        /// cref="VariableSection"/> collection that matches its <see
        /// cref="VariableClass.Category"/>.</exception>
        /// <exception cref="InvalidEnumArgumentException">
        /// <paramref name="variable"/> specifies an invalid <see cref="VariableClass.Category"/>.
        /// </exception>

        public ShowVariable(VariableClass variable, VariableDisplay flags)
        {
            InitializeComponent();

            if (variable != null)
            {
                VariableSection variables  = MasterSection.Instance.Variables;
                var             dictionary = variables.GetVariables(variable.Category);

                // specified variable must be part of its collection
                if (!dictionary.ContainsKey(variable.Id))
                {
                    ThrowHelper.ThrowArgumentException(
                        "variable", Global.Strings.ArgumentNotNullOrVariable);
                }
            }

            Variable      = variable;
            VariableFlags = flags;

            // read specified display flags into check boxes
            if ((flags & VariableDisplay.Basic) != 0)
            {
                BasicToggle.IsChecked = true;
            }
            if ((flags & VariableDisplay.Modifier) != 0)
            {
                ModifierToggle.IsChecked = true;
            }
            if ((flags & VariableDisplay.Numbers) != 0)
            {
                NumbersToggle.IsChecked = true;
            }
            if ((flags & VariableDisplay.Shades) != 0)
            {
                ShadesToggle.IsChecked = true;
            }

            // adjust column width of Variable list view
            DependencyPropertyDescriptor.FromProperty(
                ListView.ActualWidthProperty, typeof(ListView))
            .AddValueChanged(VariableList, OnVariableWidthChanged);

            if (variable != null)
            {
                // select specified variable, if any
                switch (variable.Category)
                {
                case VariableCategory.Attribute:
                    AttributeToggle.IsChecked = true;
                    break;

                case VariableCategory.Counter:
                    CounterToggle.IsChecked = true;
                    break;

                case VariableCategory.Resource:
                    ResourceToggle.IsChecked = true;
                    break;

                default:
                    ThrowHelper.ThrowInvalidEnumArgumentException("variable.Category",
                                                                  (int)variable.Category, typeof(VariableCategory));
                    break;
                }

                VariableList.SelectAndShow(variable);
            }
            else
            {
                // select category with defined variables
                if (MasterSection.Instance.Variables.Attributes.Count > 0)
                {
                    AttributeToggle.IsChecked = true;
                }
                else if (MasterSection.Instance.Variables.Resources.Count > 0)
                {
                    ResourceToggle.IsChecked = true;
                }
                else if (MasterSection.Instance.Variables.Counters.Count > 0)
                {
                    CounterToggle.IsChecked = true;
                }
                else
                {
                    AttributeToggle.IsChecked = true;
                }
            }
        }
Beispiel #17
0
        public static void AddValueChanged <T>(this T obj, DependencyProperty property, EventHandler handler) where T : DependencyObject
        {
            DependencyPropertyDescriptor desc = DependencyPropertyDescriptor.FromProperty(property, typeof(T));

            desc.AddValueChanged(obj, handler);
        }
        public static bool Filter(object target, PropertyDescriptor property)
        {
            var frameworkElement = target as FrameworkElement;

            if (frameworkElement is null)
            {
                return(true);
            }

            var attachedPropertyForChildren = (AttachedPropertyBrowsableForChildrenAttribute)property.Attributes[typeof(AttachedPropertyBrowsableForChildrenAttribute)];

            if (attachedPropertyForChildren is not null)
            {
                var dpd = DependencyPropertyDescriptor.FromProperty(property);
                if (dpd is null)
                {
                    return(false);
                }

                var currentElement = frameworkElement;
                do
                {
                    currentElement = currentElement.Parent as FrameworkElement;
                    if (currentElement is not null &&
                        dpd.DependencyProperty.OwnerType.IsInstanceOfType(currentElement))
                    {
                        return(true);
                    }
                }while (attachedPropertyForChildren.IncludeDescendants && currentElement is not null);

                return(false);
            }

            var attachedPropertyForType = (AttachedPropertyBrowsableForTypeAttribute)property.Attributes[typeof(AttachedPropertyBrowsableForTypeAttribute)];

            if (attachedPropertyForType is not null)
            {
                // when using [AttachedPropertyBrowsableForType(typeof(IMyInterface))] and IMyInterface is not a DependencyObject, Snoop crashes.
                // see http://snoopwpf.codeplex.com/workitem/6712

                if (typeof(DependencyObject).IsAssignableFrom(attachedPropertyForType.TargetType))
                {
                    var doType = DependencyObjectType.FromSystemType(attachedPropertyForType.TargetType);
                    if (doType is not null &&
                        doType.IsInstanceOfType(frameworkElement))
                    {
                        return(true);
                    }
                }

                return(false);
            }

            var attachedPropertyForAttribute = (AttachedPropertyBrowsableWhenAttributePresentAttribute)property.Attributes[typeof(AttachedPropertyBrowsableWhenAttributePresentAttribute)];

            if (attachedPropertyForAttribute is not null)
            {
                var dependentAttribute = TypeDescriptor.GetAttributes(target)[attachedPropertyForAttribute.AttributeType];
                if (dependentAttribute is not null)
                {
                    return(!dependentAttribute.IsDefaultAttribute());
                }

                return(false);
            }

            return(true);
        }
Beispiel #19
0
        private static bool ShouldSerialize(PropertyDescriptor pd, object instance, XamlDesignerSerializationManager manager)
        {
            MethodInfo shouldSerializeMethod;
            object     invokeInstance = instance;

            DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(pd);

            if (dpd != null && dpd.IsAttached)
            {
                Type   ownerType    = dpd.DependencyProperty.OwnerType;
                string propertyName = dpd.DependencyProperty.Name;
                string keyName      = propertyName + "!";
                if (!TryGetShouldSerializeMethod(new ShouldSerializeKey(ownerType, keyName), out shouldSerializeMethod))
                {
                    string methodName = "ShouldSerialize" + propertyName;
                    shouldSerializeMethod = ownerType.GetMethod(methodName, BindingFlags.Static |
                                                                BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsObject, null);
                    if (shouldSerializeMethod == null)
                    {
                        shouldSerializeMethod = ownerType.GetMethod(methodName, BindingFlags.Static |
                                                                    BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsManager, null);
                    }
                    if (shouldSerializeMethod == null)
                    {
                        shouldSerializeMethod = ownerType.GetMethod(methodName, BindingFlags.Static |
                                                                    BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsMode, null);
                    }
                    if (shouldSerializeMethod == null)
                    {
                        shouldSerializeMethod = ownerType.GetMethod(methodName, BindingFlags.Static |
                                                                    BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsObjectManager, null);
                    }
                    if (shouldSerializeMethod != null && shouldSerializeMethod.ReturnType != typeof(bool))
                    {
                        shouldSerializeMethod = null;
                    }
                    CacheShouldSerializeMethod(new ShouldSerializeKey(ownerType, keyName), shouldSerializeMethod);
                }
                invokeInstance = null; // static method
            }
            else
            {
                if (!TryGetShouldSerializeMethod(new ShouldSerializeKey(instance.GetType(), pd.Name), out shouldSerializeMethod))
                {
                    Type   instanceType = instance.GetType();
                    string methodName   = "ShouldSerialize" + pd.Name;
                    shouldSerializeMethod = instanceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static |
                                                                   BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsObject, null);
                    if (shouldSerializeMethod == null)
                    {
                        shouldSerializeMethod = instanceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static |
                                                                       BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsManager, null);
                    }
                    if (shouldSerializeMethod == null)
                    {
                        shouldSerializeMethod = instanceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static |
                                                                       BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsMode, null);
                    }
                    if (shouldSerializeMethod == null)
                    {
                        shouldSerializeMethod = instanceType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static |
                                                                       BindingFlags.NonPublic | BindingFlags.Public, null, _shouldSerializeArgsObjectManager, null);
                    }
                    if (shouldSerializeMethod != null && shouldSerializeMethod.ReturnType != typeof(bool))
                    {
                        shouldSerializeMethod = null;
                    }
                    CacheShouldSerializeMethod(new ShouldSerializeKey(instanceType, pd.Name), shouldSerializeMethod);
                }
            }
            if (shouldSerializeMethod != null)
            {
                ParameterInfo[] parameters = shouldSerializeMethod.GetParameters();
                if (parameters != null)
                {
                    object[] args;
                    if (parameters.Length == 1)
                    {
                        if (parameters[0].ParameterType == typeof(DependencyObject))
                        {
                            args = new object[] { instance as DependencyObject };
                        }
                        else if (parameters[0].ParameterType == typeof(XamlWriterMode))
                        {
                            args = new object[] { manager.XamlWriterMode };
                        }
                        else
                        {
                            args = new object[] { manager };
                        }
                    }
                    else
                    {
                        args = new object[] { instance as DependencyObject, manager }
                    };
                    return((bool)shouldSerializeMethod.Invoke(invokeInstance, args));
                }
            }
            return(pd.ShouldSerializeValue(instance));
        }
Beispiel #20
0
        public MetadataContainerLoadWindow(object owner, MetadataContainer metadataContainer, BaseConnectionDescriptor connection = null)
        {
            Debug.Assert(metadataContainer != null);

            _owner = owner;

            _pages = new List <WizardPageInfo>();

            // store reference to edited object
            EditedMetadataContainer = metadataContainer;

            _initialConnection = connection;
            Connection         = connection;

            // create new SQLContext for loading
            _temporarySqlContext = new SQLContext();
            _temporarySqlContext.Assign(EditedMetadataContainer.SQLContext);

            // create temporary MetadataContainer
            TemporaryMetadataContainer             = new MetadataContainer(_temporarySqlContext);
            _temporarySqlContext.MetadataContainer = TemporaryMetadataContainer;

            TemporaryMetadataContainer.Assign(EditedMetadataContainer);
            TemporaryMetadataContainer.LoadingOptions = new MetadataLoadingOptions();
            TemporaryMetadataContainer.LoadingOptions.Assign(EditedMetadataContainer.LoadingOptions);

            InitializeComponent();

            // set up pages

            _wizardPageWelcome = new WelcomeWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageWelcome);

            _wizardPageConnectionType = new ConnectionTypeWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageConnectionType);

            _wizardPageMetadataOpts = new MetadataOptsWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageMetadataOpts);

            _wizardPageLoadOpts = new LoadOptsWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageLoadOpts);

            _wizardPageFilter = new FilterWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageFilter);

            _wizardPageLoading = new LoadingWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageLoading);

            _pages.Add(new WizardPageInfo(ShowWelcome));
            _pages.Add(new WizardPageInfo(ShowConnection, CheckConnectionSelected));
            _pages.Add(new WizardPageInfo(ShowMetadataOpts, CheckShowMetadataOpts, true, BeforeMetadataOpts));
            _pages.Add(new WizardPageInfo(ShowLoadOpts, CheckLoadOpts, (_temporarySqlContext.SyntaxProvider != null && _temporarySqlContext.SyntaxProvider.IsSupportDatabases()), BeforeLoadOpts));
            _pages.Add(new WizardPageInfo(ShowFilter, CheckFilter));
            _pages.Add(new WizardPageInfo(ShowLoading));

            _currentPage = 0;

            _pages[_currentPage].ShowProc();

            _wizardPageMetadataOpts.bConnectionTest.Click += buttonConnectionTest_Click;
            _wizardPageConnectionType.ComboBoxConnectionType.SelectionChanged += cbConnectionType_SelectedIndexChanged;
            _wizardPageConnectionType.ComboBoxSyntaxProvider.SelectionChanged += ComboBoxSyntaxProvider_SelectedIndexChanged;

            bBack.Click += buttonBack_Click;
            bNext.Click += buttonNext_Click;

            Loaded += MetadataContainerLoadForm_Load;

            Localize();

            Loaded += MetadataContainerLoadForm_Loaded;

            var propertyLanguage =
                DependencyPropertyDescriptor.FromProperty(LanguageProperty, typeof(MetadataContainerLoadWindow));

            propertyLanguage.AddValueChanged(this, LanguagePropertyChanged);
        }
 public static bool IsInDesignMode(this object element)
 {
     return((bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty,
                                                            typeof(DependencyObject)).Metadata.DefaultValue);
 }
Beispiel #22
0
        public Shell(IApplicationState applicationState, IMethodQueue methodQueue)
        {
            _applicationState = applicationState;
            _methodQueue      = methodQueue;
            InitializeComponent();
            LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            Application.Current.MainWindow.SizeChanged += MainWindow_SizeChanged;

            var selectedIndexChange = DependencyPropertyDescriptor.FromProperty(Selector.SelectedIndexProperty, typeof(TabControl));

            selectedIndexChange.AddValueChanged(MainTabControl, MainTabControlSelectedIndexChanged);

            EventServiceFactory.EventService.GetEvent <GenericEvent <User> >().Subscribe(x =>
            {
                if (x.Topic == EventTopicNames.UserLoggedIn)
                {
                    UserLoggedIn(x.Value);
                }
                if (x.Topic == EventTopicNames.UserLoggedOut)
                {
                    UserLoggedOut(x.Value);
                }
            });

            EventServiceFactory.EventService.GetEvent <GenericEvent <UserControl> >().Subscribe(
                x =>
            {
                if (x.Topic == EventTopicNames.DashboardClosed)
                {
                    SerialPortService.ResetCache();
                    EventServiceFactory.EventService.PublishEvent(EventTopicNames.ResetCache, true);
                }
            });

            EventServiceFactory.EventService.GetEvent <GenericEvent <EventAggregator> >().Subscribe(
                x =>
            {
                if (x.Topic == EventTopicNames.LocalSettingsChanged)
                {
                    InteractionService.Scale(MainGrid);
                }
            });



            UserRegion.Visibility      = Visibility.Collapsed;
            RightUserRegion.Visibility = Visibility.Collapsed;
            Height = Properties.Settings.Default.ShellHeight;
            Width  = Properties.Settings.Default.ShellWidth;



            _timer         = new DispatcherTimer();
            _timer.Tick   += TimerTick;
            TimeLabel.Text = "...";

#if !DEBUG
            WindowStyle = WindowStyle.None;
            WindowState = WindowState.Maximized;
#endif
        }
Beispiel #23
0
        public void setup()
        {
            settingUp = true;

            DataTable dt = new DataTable(sampleInstance.GetType().Name);

            FieldInfo[]    fields     = getFieldInfos();
            PropertyInfo[] properties = getPropertyInfos();

            MemberInfo[] items = new MemberInfo[fields.Length + properties.Length];
            items = items.Union(fields).Union(properties).OrderBy(x => x == null ? "" : x.Name, new ItemOrderComparer(GetRawItemOrder())).ToArray();

            foreach (MemberInfo i in items)
            {
                if (i == null)
                {
                    continue;
                }

                String name = i.Name;
                Type   type;
                if (i is FieldInfo)
                {
                    type = ((FieldInfo)i).FieldType;
                }
                else
                {
                    type = ((PropertyInfo)i).PropertyType;
                }

                /*
                 * if (type.Name == "Nullable`1")
                 * {
                 *  type = type.GenericTypeArguments[0];
                 * }*/
                String defaultValue;
                if (!GetDefaultValues().TryGetValue(name, out defaultValue))
                {
                    if (type == typeof(string))
                    {
                        defaultValue = "";
                    }
                    else
                    {
                        defaultValue = "0";
                    }
                }

                string helpText = getColumnName(name);
                if (type.IsEnum)
                {
                    DataColumn col = new DataColumn(name, 1.GetType());
                    col.DefaultValue = 0;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else if (type == typeof(InfluenceKind))
                {
                    DataColumn col = new DataColumn(name, 1.GetType());
                    col.DefaultValue = 0;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else if (type == typeof(ConditionKind))
                {
                    DataColumn col = new DataColumn(name, 1.GetType());
                    col.DefaultValue = 0;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else if (type == typeof(TitleKind))
                {
                    DataColumn col = new DataColumn(name, 1.GetType());
                    col.DefaultValue = 1;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else if (type == typeof(GameObjects.ArchitectureDetail.EventEffect.EventEffectKind))
                {
                    DataColumn col = new DataColumn(name, 1.GetType());
                    col.DefaultValue = 0;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else if (type == typeof(GameObjects.TroopDetail.EventEffect.EventEffectKind))
                {
                    DataColumn col = new DataColumn(name, 1.GetType());
                    col.DefaultValue = 0;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else if (type == typeof(List <int>))
                {
                    DataColumn col = new DataColumn(name, "".GetType());
                    col.DefaultValue = "";
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
                else
                {
                    DataColumn col = new DataColumn(name, type);
                    col.DefaultValue = defaultValue;
                    col.ColumnName   = helpText;
                    dt.Columns.Add(col);
                }
            }

            foreach (T p in GetDataList(scen).GetList())
            {
                DataRow row = dt.NewRow();

                foreach (FieldInfo i in fields)
                {
                    string helpText = getColumnName(i.Name);

                    if (i.FieldType.IsEnum)
                    {
                        row[helpText] = (int)i.GetValue(p);
                    }
                    else if (i.FieldType == typeof(InfluenceKind))
                    {
                        row[helpText] = ((InfluenceKind)i.GetValue(p)).ID;
                    }
                    else if (i.FieldType == typeof(ConditionKind))
                    {
                        row[helpText] = ((ConditionKind)i.GetValue(p)).ID;
                    }
                    else if (i.FieldType == typeof(TitleKind))
                    {
                        row[helpText] = ((TitleKind)i.GetValue(p)).ID;
                    }
                    else if (i.FieldType == typeof(GameObjects.ArchitectureDetail.EventEffect.EventEffectKind))
                    {
                        row[helpText] = ((GameObjects.ArchitectureDetail.EventEffect.EventEffectKind)i.GetValue(p)).ID;
                    }
                    else if (i.FieldType == typeof(GameObjects.TroopDetail.EventEffect.EventEffectKind))
                    {
                        row[helpText] = ((GameObjects.TroopDetail.EventEffect.EventEffectKind)i.GetValue(p)).ID;
                    }
                    else if (i.FieldType == typeof(List <int>))
                    {
                        row[helpText] = ((List <int>)i.GetValue(p)).Aggregate <int, string>("", (s, x) => s += x.ToString() + " ");
                    }
                    else
                    {
                        row[helpText] = i.GetValue(p);
                    }
                }
                foreach (PropertyInfo i in properties)
                {
                    string helpText = getColumnName(i.Name);

                    if (i.PropertyType.IsEnum)
                    {
                        row[helpText] = (int)i.GetValue(p);
                    }
                    else if (i.PropertyType == typeof(InfluenceKind))
                    {
                        row[helpText] = ((InfluenceKind)i.GetValue(p)).ID;
                    }
                    else if (i.PropertyType == typeof(ConditionKind))
                    {
                        row[helpText] = ((ConditionKind)i.GetValue(p)).ID;
                    }
                    else if (i.PropertyType == typeof(TitleKind))
                    {
                        row[helpText] = ((TitleKind)i.GetValue(p)).ID;
                    }
                    else if (i.PropertyType == typeof(GameObjects.ArchitectureDetail.EventEffect.EventEffectKind))
                    {
                        row[helpText] = ((GameObjects.ArchitectureDetail.EventEffect.EventEffectKind)i.GetValue(p)).ID;
                    }
                    else if (i.PropertyType == typeof(GameObjects.TroopDetail.EventEffect.EventEffectKind))
                    {
                        row[helpText] = ((GameObjects.TroopDetail.EventEffect.EventEffectKind)i.GetValue(p)).ID;
                    }
                    else if (i.PropertyType == typeof(List <int>))
                    {
                        row[helpText] = ((List <int>)i.GetValue(p)).Aggregate <int, string>("", (s, x) => s += x.ToString() + " ");
                    }
                    else
                    {
                        row[helpText] = i.GetValue(p) ?? DBNull.Value;
                    }
                }

                dt.Rows.Add(row);
            }

            DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(ItemsControl.ItemsSourceProperty, typeof(DataGrid));

            dg.ItemsSource = dt.AsDataView();

            dt.TableNewRow    += Dt_TableNewRow;
            dt.ColumnChanging += Dt_ColumnChanging;
            dt.RowChanged     += Dt_RowChanged;
            dt.RowDeleting    += Dt_RowDeleting;

            dg.CurrentCellChanged += Dg_CurrentCellChanged;

            dpd.AddValueChanged(dg, dg_ItemsSourceChanged);
            settingUp = false;
        }
Beispiel #24
0
 public DrawCanvas()
 {
     MouseDown += Canvas_MouseDown;
     MouseMove += Canvas_MouseMove;
     DependencyPropertyDescriptor.FromProperty(DrawColourProperty, typeof(DrawCanvas)).AddValueChanged(this, OnDrawColourChanged);
 }
Beispiel #25
0
 private void RegisterEventHandlerForWhenIsHighlightedChanges(ComboBoxItemEx comboBoxItem)
 {
     DependencyPropertyDescriptor.FromProperty(ComboBoxItem.IsHighlightedProperty, typeof(ComboBoxItemEx)).
     AddValueChanged(comboBoxItem, (o, e) => OnComboBoxItemHighlighted(o as ComboBoxItemEx));
 }
 public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
 {
     return(new PropertyDescriptorCollection(new DependencyPropertyDescriptor[] { DependencyPropertyDescriptor.FromProperty(Usage.ExamplesProperty, value.GetType()) }));
 }
Beispiel #27
0
        public static void RemoveValueChanged(this DependencyProperty property, DependencyObject element, EventHandler handler)
        {
            var descriptor = DependencyPropertyDescriptor.FromProperty(property, property.OwnerType);

            descriptor.RemoveValueChanged(element, handler);
        }
Beispiel #28
0
        /// <summary>
        /// See <see cref="AnalyzerBase.Analyze" />
        /// </summary>
        public override void Analyze(TreeItem treeItem, AnalyzerContext analyzerContext)
        {
            PresentationTraceSources.SetTraceLevel(treeItem.Instance, PresentationTraceLevel.High);
            var dependencyObject = treeItem.Instance as DependencyObject;

            if (dependencyObject == null)
            {
                return;
            }

            if (_pendingTreeItems.ContainsKey(treeItem))
            {
                return;
            }

            var backgroundHelper = new DataBindingBackgroundHelper(this, treeItem, analyzerContext, () => _pendingTreeItems.Remove(treeItem));

            _pendingTreeItems.Add(treeItem, backgroundHelper);

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(dependencyObject.GetType()))
            {
                var dpd = DependencyPropertyDescriptor.FromProperty(property);
                if (dpd != null)
                {
                    BindingExpressionBase binding = BindingOperations.GetBindingExpressionBase(dependencyObject, dpd.DependencyProperty);
                    if (binding != null)
                    {
                        if (binding.HasError || binding.Status != BindingStatus.Active)
                        {
                            var callback = backgroundHelper.CreateCallback();

                            // Ensure that no pending calls are in the dispatcher queue
                            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action) delegate
                            {
                                var stringBuilder = new StringBuilder();
                                var stringWriter  = new StringWriter(stringBuilder);
                                var listener      = new TextWriterTraceListener(stringWriter);
                                PresentationTraceSources.DataBindingSource.Listeners.Add(listener);
                                PresentationTraceSources.SetTraceLevel(treeItem.Instance, PresentationTraceLevel.High);

                                // Remove and add the binding to re-trigger the binding error
                                dependencyObject.ClearValue(dpd.DependencyProperty);
                                BindingOperations.SetBinding(dependencyObject, dpd.DependencyProperty, binding.ParentBindingBase);

                                listener.Flush();
                                stringWriter.Flush();

                                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (Action) delegate
                                {
                                    string bindingError = stringBuilder.ToString();
                                    if (bindingError.Length > 0)
                                    {
                                        int prefix   = bindingError.IndexOf(':');
                                        bindingError = bindingError.Substring(prefix + 6).Replace("\r", "").Replace("\n", "");

                                        callback.Issue = new Issue("BindingError", string.Format("{0}: {1}", dpd.DisplayName, bindingError),
                                                                   IssueSeverity.Error, IssueCategory.Functionality,
                                                                   treeItem, dpd);
                                    }
                                    PresentationTraceSources.DataBindingSource.Listeners.Remove(listener);
                                    listener.Close();

                                    callback.SetDone();
                                });
                            });
                        }
                    }
                }
            }

            backgroundHelper.ReportIssues();
        }
Beispiel #29
0
        internal void UpdateAdvanceOptionsForItem(MarkupObject markupObject, DependencyObject dependencyObject, DependencyPropertyDescriptor dpDescriptor,
                                                  out object tooltip)
        {
            tooltip = StringConstants.Default;

            bool isResource        = false;
            bool isDynamicResource = false;

            var markupProperty = markupObject.Properties.FirstOrDefault(p => p.Name == PropertyName);

            if (markupProperty != null)
            {
                //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style(maybe with StaticResourceExtension)
                isResource        = typeof(Style).IsAssignableFrom(markupProperty.PropertyType);
                isDynamicResource = typeof(DynamicResourceExtension).IsAssignableFrom(markupProperty.PropertyType);
            }

            if (isResource || isDynamicResource)
            {
                tooltip = StringConstants.Resource;
            }
            else
            {
                if ((dependencyObject != null) && (dpDescriptor != null))
                {
                    if (BindingOperations.GetBindingExpressionBase(dependencyObject, dpDescriptor.DependencyProperty) != null)
                    {
                        tooltip = StringConstants.Databinding;
                    }
                    else
                    {
                        BaseValueSource bvs =
                            DependencyPropertyHelper
                            .GetValueSource(dependencyObject, dpDescriptor.DependencyProperty)
                            .BaseValueSource;

                        switch (bvs)
                        {
                        case BaseValueSource.Inherited:
                        case BaseValueSource.DefaultStyle:
                        case BaseValueSource.ImplicitStyleReference:
                            tooltip = StringConstants.Inheritance;
                            break;

                        case BaseValueSource.DefaultStyleTrigger:
                            break;

                        case BaseValueSource.Style:
                            tooltip = StringConstants.StyleSetter;
                            break;

                        case BaseValueSource.Local:
                            tooltip = StringConstants.Local;
                            break;
                        }
                    }
                }
                else
                {
                    // When the Value is diferent from the DefaultValue, use the local icon.
                    if (markupProperty != null && !markupProperty.Value.Equals(this.DefaultValue))
                    {
                        if (this.DefaultValue != null)
                        {
                            if (!markupProperty.Value.Equals(this.DefaultValue))
                            {
                                tooltip = StringConstants.Local;
                            }
                        }
                        else
                        {
                            if (markupProperty.PropertyType.IsValueType)
                            {
                                var defaultValue = Activator.CreateInstance(markupProperty.PropertyType);
                                // When the Value is diferent from the DefaultValue, use the local icon.
                                if (!markupProperty.Value.Equals(defaultValue))
                                {
                                    tooltip = StringConstants.Local;
                                }
                            }
                            else
                            {
                                // When the Value is diferent from the DefaultValue, use the local icon.
                                if (!(markupProperty.Value is System.Windows.Markup.NullExtension))
                                {
                                    tooltip = StringConstants.Local;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #30
0
 public void Dispose()
 {
     DependencyPropertyDescriptor.FromProperty(Property, Source.GetType()).RemoveValueChanged(Source, Handler);
 }
        internal static DependencyPropertyDescriptor FromProperty(DependencyProperty dependencyProperty)
        {
            if (dependencyProperty == null)
                throw new ArgumentNullException("dependencyProperty");

            #region find PropertyDescriptor

            PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(dependencyProperty.OwnerType);
            /*foreach (PropertyDescriptor pd in pdc)
            {
                if (pd.Name == dependencyProperty.Name)
                {
                    property = pd;
                    break;
                }
            }*/
            var property = pdc.Cast<PropertyDescriptor>().FirstOrDefault(pd => pd.Name == dependencyProperty.Name);

            #endregion

            DependencyPropertyDescriptor dpd = null;
            if (property != null)
            {
                if (!CachedDpd.TryGetValue(property, out dpd))
                {
                    dpd = new DependencyPropertyDescriptor(property, dependencyProperty.OwnerType, dependencyProperty);
                    CachedDpd.TryAdd(property, dpd);
                }
            }

            return dpd;
        }
        // Optimize tasks between task events, by removing generic links and replacing them by multiple dependencies between the same two task events as appropriate.
        private static void OptimizeTasks(ObservableCollection <DlhSoft.Windows.Controls.Pert.PertChartItem> taskEvents)
        {
            foreach (var taskEvent in taskEvents.Where(te => te.Predecessors != null).ToArray())
            {
                var tasks = taskEvent.Predecessors;

                // When a task event has only virtual effort links to other events, link the previous events directly to the current event.
                if (tasks.Any() && tasks.All(t => t.IsEffortVirtual))
                {
                    var previousTaskEvents = tasks.Select(t => t.Item).ToArray();
                    var previousTasks      = previousTaskEvents.SelectMany(pte => pte.Predecessors).ToArray();
                    foreach (var pte in previousTaskEvents)
                    {
                        taskEvents.Remove(pte);
                    }
                    taskEvent.Predecessors.Clear();

                    for (var i = 0; i < previousTasks.Length; i++)
                    {
                        var pt = previousTasks[i];
                        taskEvent.Predecessors.Add(pt);

                        // Set line index values to dependency lines sharing the same start and end events to be able to compute points to be used when displaying polygonal dependency lines accordingly.
                        TaskEventExtensions.SetLineIndex(pt, i);

                        // Whenever dependency line points are computed being required in the UI, we'll update them accordingly, inserting intermediary points to respect line indexes using vertical positioning.
                        DependencyPropertyDescriptor computedDependencyLinePointsPropertyDescriptor = DependencyPropertyDescriptor.FromProperty(DlhSoft.Windows.Controls.Pert.PredecessorItem.ComputedDependencyLinePointsProperty, typeof(DlhSoft.Windows.Controls.Pert.PredecessorItem));
                        computedDependencyLinePointsPropertyDescriptor.AddValueChanged(pt, (sender, e) =>
                        {
                            var task   = sender as DlhSoft.Windows.Controls.Pert.PredecessorItem;
                            var points = task.ComputedDependencyLinePoints;
                            if (points.Count < 2)
                            {
                                return;
                            }
                            Point fp     = points.First(), lp = points.Last();
                            double width = lp.X - fp.X;
                            points.Insert(1, new Point(fp.X + width * DistanceRateToIntermediaryPoints, fp.Y + TaskEventExtensions.GetLineIndex(pt) * DistanceBetweenLines));
                            points.Insert(points.Count - 1, new Point(lp.X - width * DistanceRateToIntermediaryPoints, fp.Y + TaskEventExtensions.GetLineIndex(pt) * DistanceBetweenLines));
                        });
                    }
                }
            }
        }