Пример #1
0
        private void CreateColorIndicator(TreeListView tree, RDMPCollection collection)
        {
            if (Tree.Parent == null || collection == RDMPCollection.None)
            {
                return;
            }

            var indicatorHeight = BackColorProvider.IndiciatorBarSuggestedHeight;

            BackColorProvider p = new BackColorProvider();
            var ctrl            = new Control();

            ctrl.BackColor = p.GetColor(collection);
            ctrl.Location  = new Point(Tree.Location.X, tree.Location.Y - indicatorHeight);
            ctrl.Height    = indicatorHeight;
            ctrl.Width     = Tree.Width;

            if (Tree.Dock != DockStyle.None)
            {
                ctrl.Dock = DockStyle.Top;
            }
            else
            {
                ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            }

            Tree.Parent.Controls.Add(ctrl);
        }
        public virtual void SetDatabaseObject(IActivateItems activator, T databaseObject)
        {
            SetItemActivator(activator);
            Activator.RefreshBus.EstablishSelfDestructProtocol(this, activator, databaseObject);
            DatabaseObject = databaseObject;

            CommonFunctionality.ClearToolStrip();

            if (_colorIndicator == null && AssociatedCollection != RDMPCollection.None)
            {
                var colorProvider = new BackColorProvider();
                _colorIndicator           = new Control();
                _colorIndicator.Dock      = DockStyle.Top;
                _colorIndicator.Location  = new Point(0, 0);
                _colorIndicator.Size      = new Size(150, BackColorProvider.IndiciatorBarSuggestedHeight);
                _colorIndicator.TabIndex  = 0;
                _colorIndicator.BackColor = colorProvider.GetColor(AssociatedCollection);
                this.Controls.Add(this._colorIndicator);
            }

            if (_binder == null)
            {
                _binder = new BinderWithErrorProviderFactory(activator);
            }

            SetBindings(_binder, databaseObject);

            if (this is ISaveableUI)
            {
                ObjectSaverButton1.SetupFor(this, databaseObject, activator);
            }
        }
Пример #3
0
        public virtual void SetDatabaseObject(IActivateItems activator, T databaseObject)
        {
            SetItemActivator(activator);
            Activator.RefreshBus.EstablishSelfDestructProtocol(this, activator, databaseObject);
            DatabaseObject = databaseObject;

            CommonFunctionality.ClearToolStrip();

            if (_colorIndicator == null && AssociatedCollection != RDMPCollection.None)
            {
                var colorProvider = new BackColorProvider();
                _colorIndicator           = new Control();
                _colorIndicator.Dock      = DockStyle.Top;
                _colorIndicator.Location  = new Point(0, 0);
                _colorIndicator.Size      = new Size(150, BackColorProvider.IndiciatorBarSuggestedHeight);
                _colorIndicator.TabIndex  = 0;
                _colorIndicator.BackColor = colorProvider.GetColor(AssociatedCollection);
                this.Controls.Add(this._colorIndicator);
            }

            if (_readonlyIndicator == null)
            {
                _readonlyIndicator           = new Label();
                _readonlyIndicator.Dock      = DockStyle.Top;
                _readonlyIndicator.Location  = new Point(0, 0);
                _readonlyIndicator.Size      = new Size(150, 20);
                _readonlyIndicator.TabIndex  = 0;
                _readonlyIndicator.TextAlign = ContentAlignment.MiddleLeft;
                _readonlyIndicator.BackColor = System.Drawing.SystemColors.HotTrack;
                _readonlyIndicator.Font      = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                _readonlyIndicator.ForeColor = System.Drawing.Color.Moccasin;
            }

            if (databaseObject is IMightBeReadOnly ro)
            {
                if (ro.ShouldBeReadOnly(out string reason))
                {
                    _readonlyIndicator.Text = reason;
                    this.Controls.Add(this._readonlyIndicator);
                    ReadOnly = true;
                }
                else
                {
                    //removing it allows us to handle refreshes (where something becomes unfrozen for example)
                    this.Controls.Remove(this._readonlyIndicator);
                    ReadOnly = false;
                }
            }


            if (_binder == null)
            {
                _binder = new BinderWithErrorProviderFactory(activator);
            }

            SetBindings(_binder, databaseObject);

            if (this is ISaveableUI)
            {
                ObjectSaverButton1.SetupFor(this, databaseObject, activator);
            }
        }