示例#1
0
        /// <summary>
        /// Создать <see cref="PropertyGridEx"/>.
        /// </summary>
        public PropertyGridEx()
        {
            InitializeComponent();

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            SetDescriptionsProvider(false);

            EditorDefinitions.Add(CreateNullableDateTimeEditor());
            EditorDefinitions.Add(CreateNullableTimeSpanEditor());
            EditorDefinitions.Add(CreateNullableDateTimeOffsetEditor());
            EditorDefinitions.Add(CreateExtensionInfoEditor());
            EditorDefinitions.Add(CreateNullableEnumEditor <SecurityTypes?>());
            EditorDefinitions.Add(CreateNullableEnumEditor <OptionTypes?>());
            EditorDefinitions.Add(CreateNullableEnumEditor <TPlusLimits?>());
            EditorDefinitions.Add(CreateNullableEnumEditor <CurrencyTypes?>(true));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyGridEx"/>.
        /// </summary>
        public PropertyGridEx()
        {
            InitializeComponent();

            if (this.IsDesignMode())
            {
                return;
            }

            SetDescriptionsProvider(false);

            EditorDefinitions.Add(CreateNullableDateTimeEditor());
            EditorDefinitions.Add(CreateNullableTimeSpanEditor());
            EditorDefinitions.Add(CreateNullableDateTimeOffsetEditor());
            EditorDefinitions.Add(CreateExtensionInfoEditor());
            EditorDefinitions.Add(CreateNullableEnumEditor <SecurityTypes?>());
            EditorDefinitions.Add(CreateNullableEnumEditor <OptionTypes?>());
            EditorDefinitions.Add(CreateNullableEnumEditor <TPlusLimits?>());
            EditorDefinitions.Add(CreateNullableEnumEditor <CurrencyTypes?>(true));

            SecurityProvider     = ConfigManager.TryGetService <ISecurityProvider>();
            ExchangeInfoProvider = ConfigManager.TryGetService <IExchangeInfoProvider>();
            Portfolios           = ConfigManager.TryGetService <ThreadSafeObservableCollection <Portfolio> >();

            ConfigManager.ServiceRegistered += (t, s) =>
            {
                var sp = s as ISecurityProvider;

                if (sp != null)
                {
                    this.GuiAsync(() =>
                    {
                        if (SecurityProvider == null)
                        {
                            SecurityProvider = sp;
                        }
                    });
                }

                var ep = s as IExchangeInfoProvider;

                if (ep != null)
                {
                    this.GuiAsync(() =>
                    {
                        if (ExchangeInfoProvider == null)
                        {
                            ExchangeInfoProvider = ep;
                        }
                    });
                }

                var portfolios = s as ThreadSafeObservableCollection <Portfolio>;

                if (portfolios != null)
                {
                    this.GuiAsync(() =>
                    {
                        if (Portfolios == null)
                        {
                            Portfolios = portfolios;
                        }
                    });
                }
            };
        }