private UserControl CreateControlByType(InstanceMember instanceMember, Type type)
        {
            UserControl controlToAdd = null;

            if (instanceMember.PreferredDisplayer != null)
            {
                controlToAdd = (UserControl)Activator.CreateInstance(instanceMember.PreferredDisplayer);
            }

            if (controlToAdd == null)
            {
                foreach (var kvp in mTypeDisplayerAssociation)
                {
                    if (kvp.Key(type))
                    {
                        controlToAdd = (UserControl)Activator.CreateInstance(kvp.Value);
                    }
                }
            }


            if (controlToAdd == null)
            {
                controlToAdd = new TextBoxDisplay();
            }


            IDataUi display = (IDataUi)controlToAdd;

            display.InstanceMember = instanceMember;

            return(controlToAdd);
        }
Example #2
0
        UserControl CreateInternalControl()
        {
            if (InstanceMember == null)
            {
                throw new NullReferenceException(nameof(InstanceMember));
            }


            UserControl controlToAdd = null;

            if (InstanceMember.PreferredDisplayer != null)
            {
                controlToAdd = (UserControl)Activator.CreateInstance(InstanceMember.PreferredDisplayer);
            }

            if (controlToAdd == null)
            {
                var type = InstanceMember.PropertyType;

                foreach (var kvp in mTypeDisplayerAssociation)
                {
                    if (kvp.Key(type))
                    {
                        controlToAdd = (UserControl)Activator.CreateInstance(kvp.Value);
                    }
                }
            }

            if (controlToAdd == null && InstanceMember.CustomOptions != null && InstanceMember.CustomOptions.Count != 0)
            {
                controlToAdd = new ComboBoxDisplay();
            }

            if (controlToAdd == null)
            {
                controlToAdd = new TextBoxDisplay();
            }

            var displayerType = controlToAdd.GetType();

            foreach (var kvp in InstanceMember.PropertiesToSetOnDisplayer)
            {
                var propertyInfo = displayerType.GetProperty(kvp.Key);

                propertyInfo?.SetValue(controlToAdd, kvp.Value, null);
            }

            IDataUi display = (IDataUi)controlToAdd;

            display.InstanceMember = InstanceMember;

            InstanceMember.CallUiCreated(controlToAdd);

            // can we share them like this? Is it safe? OK?
            this.ContextMenu = controlToAdd.ContextMenu;

            return(controlToAdd);
        }
Example #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (iSOperatorClicked)
            {
                TextBoxDisplay.Clear();
            }

            Button btn = (Button)sender;

            if (TextBoxDisplay.Text == Constants.ZeroChar)
            {
                TextBoxDisplay.Clear();
            }
            TextBoxDisplay.Text += btn.Content;
            iSOperatorClicked    = false;
        }