From befffb69eaebf2e607d88cd3ffc956a708d5734e Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Fri, 19 Aug 2016 22:44:48 +0200 Subject: Menu and MenuItem classes, templates, styles and tests modifié : Crow.csproj modifié : Default.style modifié : Style.cs nouveau fichier : Templates/Menu.template nouveau fichier : Templates/MenuItem.template modifié : Tests/Interfaces/TemplatedGroup/0.crow nouveau fichier : Tests/Interfaces/TemplatedGroup/1.crow nouveau fichier : Tests/Interfaces/TemplatedGroup/2.crow modifié : Tests/Tests.csproj nouveau fichier : src/GraphicObjects/Menu.cs nouveau fichier : src/GraphicObjects/MenuItem.cs modifié : src/GraphicObjects/TemplatedGroup.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GraphicObjects/MenuItem.cs | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/GraphicObjects/MenuItem.cs (limited to 'src/GraphicObjects/MenuItem.cs') diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs new file mode 100644 index 00000000..591be2b0 --- /dev/null +++ b/src/GraphicObjects/MenuItem.cs @@ -0,0 +1,71 @@ +// +// MenuItem.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2016 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using System.Xml.Serialization; +using System.ComponentModel; + +namespace Crow +{ + public class MenuItem : TemplatedGroup + { + #region CTOR + public MenuItem () : base() {} + #endregion + +// public event EventHandler Pop; +// public event EventHandler Unpop; + + string caption; + + [XmlAttributeAttribute][DefaultValue("MenuItem")] + public string Caption { + get { return caption; } + set { + if (caption == value) + return; + caption = value; + NotifyValueChanged ("Caption", caption); + } + } +// [XmlIgnore] +// public virtual Alignment Orientation { +// get { return Parent is Menu ? (Parent as Menu).Orientation : (Parent as MenuItem); } +// } + + Menu MenuRoot { + get { + ILayoutable tmp = Parent; + while (tmp != null) { + if (tmp is Menu) + return tmp as Menu; + tmp = tmp.Parent; + } + return null; + } + } + + public override void AddItem (GraphicObject g) + { + base.AddItem (g); + g.NotifyValueChanged ("Orientation", Alignment.Right); + } + } +} -- cgit v1.3.1-4-g156e