Пример #1
0
            public InVectorControl(Type type, string[] names, PropertyEditorControlContext context)
                : base(type, names)
            {
                m_context = context;

                RefreshValue();
            }
        /// <summary>
        /// Constructor</summary>
        /// <param name="context">Property editor control context</param>
        public StringArrayEditingControl(PropertyEditorControlContext context)
        {
            m_context = context;
            m_initialSelectedObject = m_context.LastSelectedObject.As <DomNodeAdapter>().DomNode;
            m_initialSelectedObject.AttributeChanged += DomNode_AttributeChanged;
            m_toolStrip = new ToolStrip {
                Dock = DockStyle.Top
            };
            InitToolStrip();
            Controls.Add(m_toolStrip);
            Height = m_toolStrip.Height;
            m_toolStrip.SizeChanged += toolStrip_SizeChanged;

            // Get active contexts and subscribe to ContextChanged event
            IContextRegistry contextRegistry = m_context.ContextRegistry;

            if (contextRegistry != null)
            {
                contextRegistry.ActiveContextChanged += contextRegistry_ActiveContextChanged;
                TransactionContext = contextRegistry.GetActiveContext <ITransactionContext>();
            }
            else if (context.TransactionContext != null)
            {
                TransactionContext = context.TransactionContext;
            }
        }
Пример #3
0
            public MaskControl(PropertyEditorControlContext context)
            {
                m_context = context;

                m_flip       = new Button();
                m_flip.Text  = "Flip";
                m_checkBoxes = new List <CheckBox>();
                int bit = 1;

                for (int i = 0; i < 8; ++i)
                {
                    CheckBox cb = new CheckBox();
                    cb.Size            = cb.PreferredSize;
                    cb.CheckAlign      = ContentAlignment.MiddleLeft;
                    cb.CheckedChanged += checkBox_CheckedChanged;
                    m_checkBoxes.Add(cb);
                    Controls.Add(cb);
                    cb.Tag = bit;
                    bit    = bit << 1;
                    Height = cb.Height + m_topAndLeftMargin;
                }
                m_flip.Click += (sender, args) => {
                    foreach (CheckBox cb in m_checkBoxes)
                    {
                        cb.Checked = !cb.Checked;
                    }
                };
                Controls.Add(m_flip);
                RefreshValue();
            }
Пример #4
0
            public ResourceRefListControl(PropertyEditorControlContext context)
            {
                m_context = context;
                UrhoBackend.ResourceRefList Ref = context.GetValue() as UrhoBackend.ResourceRefList;

                m_textBoxes     = new List <TextBox>();
                m_browseButtons = new List <Button>();
                if (Ref != null)
                {
                    for (int i = 0; i < Ref.Size(); ++i)
                    {
                        TextBox tb = new TextBox();
                        tb.Width        = 160;
                        tb.TextChanged += checkBox_CheckedChanged;
                        tb.Tag          = i;
                        m_textBoxes.Add(tb);

                        Button btn = new Button();
                        btn.Text   = "...";
                        btn.Width  = 32;
                        btn.Height = 32;
                        btn.Tag    = tb;
                        btn.Click += btn_Click;
                        m_browseButtons.Add(btn);

                        Controls.Add(tb);
                        Controls.Add(btn);
                        Height += tb.Height;
                    }
                }

                RefreshValue();
            }
Пример #5
0
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            var combo = new ComboBox();

            Sce.Atf.Applications.SkinService.ApplyActiveSkin(combo);
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.FlatStyle     = FlatStyle.Flat;
            combo.DisplayMember = "Name";
            combo.ValueMember   = "Value";

            var value = context.GetValue();

            for (int i = 0; i < m_names.Length; i++)
            {
                combo.Items.Add(new { Name = m_names[i], Value = m_values[i] });
                if (m_names[i].Equals(value) || m_values[i].Equals(value))
                {
                    combo.SelectedIndex = i;
                }
            }

            bool useIndex = value is int;

            combo.SelectedIndexChanged +=
                (object sender, EventArgs args) =>
            {
                dynamic o = combo.SelectedItem;
                context.SetValue(useIndex ? o.Value : o.Name);
            };

            return(combo);
        }
Пример #6
0
        /// <summary>
        /// Obtains a control to edit a given property. Changes to the selection set
        /// cause this method to be called again (and passed a new 'context'),
        /// unless ICacheablePropertyControl is implemented on the control. For
        /// performance reasons, it is highly recommended that the control implement
        /// the ICacheablePropertyControl interface.</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            if (context.LastSelectedObject == null)
            {
                return(null);
            }
            var control = new StringArrayEditingControl(context);

            Sce.Atf.Applications.SkinService.ApplyActiveSkin(control);
            return(control);
        }
Пример #7
0
        /// <summary>
        /// Gets a control to edit the given property</summary>
        /// <param name="context">Context for property editing control</param>
        /// <returns>Control to edit the given context</returns>
        public Control GetEditingControl(PropertyEditorControlContext context)
        {
            InVectorControl editingControl =
                new InVectorControl(m_numericType, m_names, context);

            editingControl.Height        = editingControl.Font.Height + 2;
            editingControl.ScaleFactor   = m_scaleFactor;
            editingControl.HideAxisLabel = HideAxisLabel;
            editingControl.SetLabelBackColors(m_labelColors);
            SkinService.ApplyActiveSkin(editingControl);
            return(editingControl);
        }
Пример #8
0
 /// <summary>
 /// Obtains a control to edit a given property. Changes to the selection set
 /// cause this method to be called again (and passed a new 'context'),
 /// unless ICacheablePropertyControl is implemented on the control. For
 /// performance reasons, it is highly recommended that the control implement
 /// the ICacheablePropertyControl interface.</summary>
 /// <param name="context">Context for property editing control</param>
 /// <returns>Control to edit the given context</returns>
 public Control GetEditingControl(PropertyEditorControlContext context)
 {
     m_boolControl = new MaskControl(context);
     SkinService.ApplyActiveSkin(m_boolControl);
     return(m_boolControl);
 }