Example #1
0
        private void _btnEdit_Click(object sender, EventArgs e)
        {
            object original = this.GetSelected();
            object toEdit   = original;

            if (original == null)
            {
                return;
            }

            this.HandleBackreferencing();
            this._backups.Backup(toEdit, "Edited");

            Visualisable modified = (Visualisable)this._config.UntypedEdit(this, toEdit, false, false);

            if (modified == original)
            {
                // If they are the same object then only values have changed
                this._listViewHelper.Rebuild(EListInvalids.ValuesChanged);
                this._listViewHelper.Selection = modified;
                return;
            }
            else if (modified != null)
            {
                this.Replace(original, modified);
            }
        }
        public static bool SupportsComment(this Visualisable v)
        {
            if (v == null)
            {
                return(false);
            }

            return(!v.SupportsHide.Has(EPrevent.Comment));
        }
        public static bool SupportsRename(this Visualisable v)
        {
            if (v == null)
            {
                return(false);
            }

            return(!v.SupportsHide.Has(EPrevent.Name));
        }
Example #4
0
        private void _btnAdd_Click(object sender, EventArgs e)
        {
            this.HandleBackreferencing();

            Visualisable o = (Visualisable)(this._config.UntypedEdit(this, null, false, false));

            if (o != null)
            {
                this.Replace(null, o);
            }
        }
Example #5
0
        public static bool Show(Form owner, Visualisable v, bool readOnly)
        {
            string name     = v.OverrideDisplayName;
            string comments = v.Comment;

            if (Show(owner, v.DefaultDisplayName, "Edit name and comments", v.ToString(), v.DefaultDisplayName, ref name, ref comments, readOnly, v))
            {
                v.OverrideDisplayName = name;
                v.Comment             = comments;
                return(true);
            }

            return(false);
        }
Example #6
0
        private void _btnRename_Click(object sender, EventArgs e)
        {
            Visualisable stat = this.GetSelected() as Visualisable;

            if (stat == null)
            {
                return;
            }

            this.Rename(stat);

            this._listViewHelper.Rebuild(EListInvalids.ValuesChanged);
            this._listViewHelper.Selection = stat;
        }
Example #7
0
        private void _btnEnableDisable_Click(object sender, EventArgs e)
        {
            Visualisable first = this.GetSelected() as Visualisable;

            if (first == null)
            {
                return;
            }

            this._backups.Backup(first, "Toggled enabled");
            first.Hidden = !first.Hidden;

            this._listViewHelper.Rebuild(EListInvalids.ValuesChanged);
            this._listViewHelper.Selection = first;
        }
Example #8
0
        private void Rename(Visualisable item)
        {
            string name    = item.OverrideDisplayName;
            string comment = item.Comment;

            if (FrmEditINameable.Show(this, item.DefaultDisplayName, "Rename", item.ToString(), item.DefaultDisplayName, ref name, ref comment, false, item))
            {
                this._backups.Backup(item, "Name changed");

                item.OverrideDisplayName = name;
                item.Comment             = comment;

                this._listViewHelper.Rebuild(EListInvalids.ValuesChanged);
            }
        }
Example #9
0
        private void _btnDuplicate_Click(object sender, EventArgs e)
        {
            object p = this.GetSelected();

            if (p == null)
            {
                return;
            }

            this.HandleBackreferencing();

            Visualisable o = (Visualisable)this._config.UntypedEdit(this, p, false, true);

            if (o != null)
            {
                this.Replace(null, o);
            }
        }
Example #10
0
        protected override void OnActivated(EventArgs e)
        {
            base.OnActivated(e);

            if (!this._activated)
            {
                this._activated = true;

                if (this._automaticAddTemplate != null)
                {
                    Visualisable o = (Visualisable)this._config.UntypedEdit(this, this._automaticAddTemplate, false, true);

                    if (o != null)
                    {
                        this.Replace(null, o);
                    }
                }
            }
        }
Example #11
0
        public static bool Show(Form owner, string windowText, string mainTitle, string subTitle, string defaultName, ref string name, ref string comments, bool readOnly, Visualisable supports)
        {
            bool canRename  = supports == null || IVisualisableExtensions.SupportsRename(supports);
            bool canComment = supports == null || IVisualisableExtensions.SupportsComment(supports);

            if (!canRename && !canComment)
            {
                FrmMsgBox.ShowInfo(owner, defaultName, "This item cannot be renamed.");
                return(false);
            }

            using (FrmEditINameable frm = new FrmEditINameable())
            {
                frm.Text = windowText;

                frm.textBox1.Watermark   = defaultName;
                frm.textBox1.Text        = name;
                frm._txtInput.Text       = comments;
                frm.ctlTitleBar1.Text    = mainTitle;
                frm.ctlTitleBar1.SubText = subTitle;

                frm.AcceptButton = null;
                frm.CancelButton = frm._btnCancel;

                frm.textBox1.Visible  = canRename;
                frm.label6.Visible    = !canRename;
                frm.label6.Text       = defaultName;
                frm._txtInput.Visible = canComment;
                frm.label2.Visible    = canComment;

                if (readOnly)
                {
                    frm._btnOk.Visible     = false;
                    frm._btnCancel.Text    = "  Close";
                    frm.AcceptButton       = frm._btnCancel;
                    frm.textBox1.ReadOnly  = true;
                    frm._txtInput.ReadOnly = true;
                }

                if (UiControls.ShowWithDim(owner, frm) == DialogResult.OK)
                {
                    name     = frm.textBox1.Text;
                    comments = frm._txtInput.Text;
                    return(true);
                }

                return(false);
            }
        }