From 1092a4033b912e9b5e06e2e6691c6db541211e46 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 23 Dec 2006 16:58:18 +0000 Subject: [PATCH] Add ClassDiagram AddIn by Itai Bar-Haim. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2204 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../ClassDiagram/ClassCanvas/AssemblyInfo.cs | 22 + .../ClassDiagram/ClassCanvas/CanvasItem.cs | 490 ++++++++++++++ .../ClassCanvas/ClassCanvas.Designer.cs | 91 +++ .../ClassDiagram/ClassCanvas/ClassCanvas.cd | 171 +++++ .../ClassDiagram/ClassCanvas/ClassCanvas.cs | 598 ++++++++++++++++++ .../ClassCanvas/ClassCanvas.csproj | 108 ++++ .../ClassDiagram/ClassCanvas/ClassCanvas.resx | 120 ++++ .../ClassCanvas/ClassCanvasItem.cs | 573 +++++++++++++++++ .../ClassCanvas/Decorators/FocusDecorator.cs | 55 ++ .../Decorators/SizeGripDecorator.cs | 249 ++++++++ .../ClassCanvas/DelegateCanvasItem.cs | 64 ++ .../ClassCanvas/EnumCanvasItem.cs | 47 ++ .../ClassDiagram/ClassCanvas/IHitTestable.cs | 29 + .../ClassCanvas/IInteractiveDrawable.cs | 19 + .../ClassCanvas/IMouseInteractable.cs | 81 +++ .../ClassCanvas/InteractiveHeaderedItem.cs | 111 ++++ .../ClassCanvas/InterfaceCanvasItem.cs | 38 ++ .../ClassCanvas/NoteCanvasItem.cs | 92 +++ .../ClassCanvas/RectangleDecorator.cs | 73 +++ .../ClassCanvas/Shapes/CollapseExpandShape.cs | 95 +++ .../ClassCanvas/Shapes/CollapseShape.cs | 78 +++ .../ClassCanvas/Shapes/EventShape.cs | 68 ++ .../ClassCanvas/Shapes/ExpandShape.cs | 30 + .../ClassCanvas/Shapes/FieldShape.cs | 35 + .../ClassCanvas/Shapes/InheritanceShape.cs | 61 ++ .../ClassCanvas/Shapes/MethodShape.cs | 69 ++ .../ClassCanvas/Shapes/MinusShape.cs | 31 + .../ClassCanvas/Shapes/PlusShape.cs | 44 ++ .../ClassCanvas/Shapes/PropertyShape.cs | 80 +++ .../Shapes/RouteInheritanceShape.cs | 47 ++ .../ClassCanvas/Shapes/RouteShape.cs | 69 ++ .../ClassDiagram/ClassCanvas/Shapes/Shapes.cs | 34 + .../ClassCanvas/Shapes/SmallButtonShape.cs | 31 + .../ClassCanvas/Shapes/SmallIconShape.cs | 29 + .../ClassCanvas/Shapes/VectorShape.cs | 78 +++ .../ClassCanvas/StructCanvasItem.cs | 34 + .../ClassDiagram/ClassDiagramAddin.sln | 120 ++++ .../ClassDiagramAddin/ClassDiagramAddin.addin | 151 +++++ .../ClassDiagramAddin/ClassDiagramAddin.cd | 63 ++ .../ClassDiagramAddin.csproj | 104 +++ .../Configuration/AssemblyInfo.cs | 22 + .../Resources/Bitmaps.resources | Bin 0 -> 4627 bytes .../Src/ClassDiagramAddItemCommands.cs | 73 +++ .../Src/ClassDiagramCommand.cs | 121 ++++ .../Src/ClassDiagramDisplayBinding.cs | 46 ++ .../Src/ClassDiagramViewContent.cs | 182 ++++++ .../ClassDiagramAddin/Src/ClassEditorPad.cs | 82 +++ .../Src/SaveToBitmapCommand.cs | 36 ++ .../Src/ShowClassDiagramCommand.cs | 64 ++ .../ClassDiagramApp/AssemblyInfo.cs | 38 ++ .../ClassDiagramApp/ClassDiagramApp.csproj | 70 ++ .../ClassDiagramApp/MainForm.Designer.cs | 310 +++++++++ .../ClassDiagram/ClassDiagramApp/MainForm.cs | 185 ++++++ .../ClassDiagramApp/MainForm.resx | 126 ++++ .../ClassDiagram/ClassEditor/AssemblyInfo.cs | 22 + .../ClassEditor/ClassEditor.Designer.cs | 50 ++ .../ClassDiagram/ClassEditor/ClassEditor.cs | 302 +++++++++ .../ClassEditor/ClassEditor.csproj | 74 +++ .../ClassDiagram/ClassEditor/ClassEditor.resx | 157 +++++ .../ClassDiagram/ClassEditor/MembersList.cs | 55 ++ .../ClassDiagram/ClassEditor/closebrace.bmp | Bin 0 -> 246 bytes .../ClassDiagram/ClassEditor/comma.bmp | Bin 0 -> 246 bytes .../ClassDiagram/ClassEditor/emptybraces.bmp | Bin 0 -> 246 bytes .../ClassDiagram/ClassEditor/openbrace.bmp | Bin 0 -> 246 bytes .../DiagramRouter/AssemblyInfo.cs | 22 + .../DiagramRouter/BaseRectangle.cs | 185 ++++++ .../DiagramRouter/DependencyTree.cs | 126 ++++ .../DiagramRouter/DependencyTreeNode.cs | 81 +++ .../DiagramRouter/DiagramRouter.cs | 269 ++++++++ .../DiagramRouter/Diagrams.csproj | 56 ++ .../ClassDiagram/DiagramRouter/Direction.cs | 15 + .../Drawables/DrawableItemsStack.cs | 35 + .../Drawables/DrawableRectangle.cs | 83 +++ .../DiagramRouter/Drawables/HeaderedItem.cs | 166 +++++ .../DiagramRouter/Drawables/IDrawable.cs | 17 + .../Drawables/IDrawableRectangle.cs | 17 + .../DiagramRouter/Drawables/TextSegment.cs | 126 ++++ .../ClassDiagram/DiagramRouter/IRectangle.cs | 118 ++++ .../ClassDiagram/DiagramRouter/ItemsStack.cs | 410 ++++++++++++ .../ClassDiagram/DiagramRouter/Route.cs | 294 +++++++++ .../DiagramRouter/RouteSegment.cs | 99 +++ src/Setup/Files.wxs | 17 +- src/Setup/Setup.wxs | 2 + src/SharpDevelop.sln | 35 +- 84 files changed, 8568 insertions(+), 2 deletions(-) create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/AssemblyInfo.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/CanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.Designer.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cd create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.csproj create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.resx create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/FocusDecorator.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/SizeGripDecorator.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/DelegateCanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/EnumCanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IHitTestable.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IInteractiveDrawable.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IMouseInteractable.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InteractiveHeaderedItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InterfaceCanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/NoteCanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/RectangleDecorator.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseExpandShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/EventShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/ExpandShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/FieldShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/InheritanceShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MethodShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MinusShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PlusShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PropertyShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteInheritanceShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/Shapes.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallButtonShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallIconShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/VectorShape.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/StructCanvasItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin.sln create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.addin create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.cd create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.csproj create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Configuration/AssemblyInfo.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Resources/Bitmaps.resources create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramAddItemCommands.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramCommand.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramDisplayBinding.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramViewContent.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassEditorPad.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/SaveToBitmapCommand.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ShowClassDiagramCommand.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/AssemblyInfo.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/ClassDiagramApp.csproj create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.Designer.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.resx create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/AssemblyInfo.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.Designer.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.csproj create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.resx create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/MembersList.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/closebrace.bmp create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/comma.bmp create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/emptybraces.bmp create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/openbrace.bmp create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/AssemblyInfo.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/BaseRectangle.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTree.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTreeNode.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DiagramRouter.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Diagrams.csproj create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Direction.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableItemsStack.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableRectangle.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/HeaderedItem.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawable.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawableRectangle.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/TextSegment.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/IRectangle.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/ItemsStack.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Route.cs create mode 100644 src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/RouteSegment.cs diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/AssemblyInfo.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/AssemblyInfo.cs new file mode 100644 index 0000000000..85cb7530e3 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/AssemblyInfo.cs @@ -0,0 +1,22 @@ +// +// +// +// +// $Revision$ +// + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ClassCanvas")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/CanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/CanvasItem.cs new file mode 100644 index 0000000000..56114d7981 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/CanvasItem.cs @@ -0,0 +1,490 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using System.Globalization; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + public class ValueChangedEventArgs : EventArgs + { + private T val; + + public ValueChangedEventArgs (T value) + { + this.val = value; + } + + public virtual T Value + { + get { return val; } + set { throw new InvalidOperationException("Cannot set the value of an event that type of event."); } + } + + protected void SetValue (T value) + { + val = value; + } + } + + public class ValueChangingEventArgs : ValueChangedEventArgs + { + bool cancel; + + public ValueChangingEventArgs (T value) : base (value) {} + + public override T Value + { + set { base.SetValue(value); } + } + + public bool Cancel + { + get { return cancel; } + set { cancel = value; } + } + } + + public abstract class CanvasItem : IInteractiveDrawable, IRectangle + { + #region Constructors + + protected CanvasItem () + { + Bitmap bitmap = new Bitmap(1, 1); + this.g = Graphics.FromImage(bitmap); + } + + #endregion + + public virtual bool IsHResizable + { + get { return true; } + } + + public virtual bool IsVResizable + { + get { return true; } + } + + #region Layout Events + + bool dontHandleLayoutChanges; + bool layoutChangesOccured; + + public event EventHandler LayoutChanged = delegate {}; + public event EventHandler RedrawNeeded = delegate {}; + + protected bool HoldLayoutChanges + { + get { return dontHandleLayoutChanges; } + set + { + dontHandleLayoutChanges = value; + if (layoutChangesOccured && !value) + EmitLayoutUpdate(); + } + } + + protected void EmitLayoutUpdate() + { + if (HoldLayoutChanges) + { + layoutChangesOccured = true; + return; + } + + LayoutChanged(this, EventArgs.Empty); + } + + protected void EmitRedrawNeeded() + { + RedrawNeeded(this, EventArgs.Empty); + } + + #endregion + + #region Geometry + + private float x, y, w, h; + + #region Geometry related events + + public event EventHandler> PositionChanging = delegate { }; + public event EventHandler> PositionChanged = delegate { }; + + public event EventHandler> SizeChanging = delegate { }; + public event EventHandler> SizeChanged = delegate { }; + + #endregion + + #region Geometry related methods + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] + public void Move (float x, float y) + { + ValueChangingEventArgs e = new ValueChangingEventArgs(new PointF(x, y)); + PositionChanging (this, e); + if (e.Cancel) return; + + if (AllowXModifications()) + this.x = e.Value.X; + else + this.x = x; + + if (AllowYModifications()) + this.y = e.Value.Y; + else + this.y = y; + + PositionChanged (this, new ValueChangedEventArgs (new PointF(this.x, this.y))); + EmitLayoutUpdate(); + } + + public void Resize (float width, float height) + { + ValueChangingEventArgs e = new ValueChangingEventArgs(new SizeF(width, height)); + SizeChanging (this, e); + if (e.Cancel) return; + + if (AllowWidthModifications()) + this.w = e.Value.Width; + else + this.w = width; + + if (AllowHeightModifications()) + this.h = e.Value.Height; + else + this.h = height; + + SizeChanged (this, new ValueChangedEventArgs (new SizeF(this.w, this.h))); + EmitLayoutUpdate(); + } + + #endregion + + #region Geometry related properties + + #region IRectangle implementation + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "X")] + public virtual float X + { + get { return x; } + set { Move(value, y); } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Y")] + public virtual float Y + { + get { return y; } + set { Move(x, value); } + } + + public virtual float AbsoluteX + { + get { return x; } + } + + public virtual float AbsoluteY + { + get { return y; } + } + + public virtual float Width + { + get { return w; } + set { Resize (value, h); WidthChanged(this, EventArgs.Empty); } + } + + public virtual float Height + { + get { return h; } + set { Resize (w, value); HeightChanged(this, EventArgs.Empty); } + } + + public virtual float ActualWidth + { + get { return Width; } + set { Width = value; ActualWidthChanged(this, EventArgs.Empty); } + } + + public virtual float ActualHeight + { + get { return Height; } + set { Height = value; ActualHeightChanged(this, EventArgs.Empty); } + } + + public virtual float Border + { + get { return 0; } + set { } + } + + public virtual float Padding + { + get { return 0; } + set { } + } + + public virtual IRectangle Container + { + get { return null; } + set {} + } + + #endregion + + #region Geometry Controllers + protected virtual bool AllowXModifications () + { + return true; + } + + protected virtual bool AllowYModifications () + { + return true; + } + + protected virtual bool AllowWidthModifications () + { + return true; + } + + protected virtual bool AllowHeightModifications () + { + return true; + } + #endregion + + #endregion + + #endregion + + #region Graphics + + Graphics g; + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly Brush ShadowBrush = new SolidBrush(Color.FromArgb(64,0,0,0)); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly Font MemberFont = new Font (FontFamily.GenericSansSerif, 11, FontStyle.Regular, GraphicsUnit.Pixel); + + /// + /// Draws the item decorators to the given graphics object. + /// Inheriters of this class should override this method and call the base implementation + /// at the end of their implementation, or call DrawDecorators instead. + /// + /// + public virtual void DrawToGraphics (Graphics graphics) + { + DrawDecorators(graphics); + } + + /// + /// Returns an initialized System.Drawing.Graphics + /// object, that should ONLY be used where a Graphics object is needed for initialization + /// of other objects, like to create a font for text measurment. + /// + protected Graphics Graphics // TODO - try to abandon this + { + get { return g; } + } + + #endregion + + #region Decorators + + List decorators = new List(); + + public void AddDecorator (RectangleDecorator decorator) + { + decorators.Add(decorator); + decorator.RedrawNeeded += HandleDecoratorRedrawRequest; + } + + public void RemoveDecorator (RectangleDecorator decorator) + { + decorator.RedrawNeeded -= HandleDecoratorRedrawRequest; + decorators.Remove(decorator); + } + + protected void DrawDecorators (Graphics graphics) + { + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + decorator.DrawToGraphics(graphics); + } + } + + #endregion + + #region Mouse Events + + #region Dragging Variables + + private PointF dragPos = new Point(0, 0); + private PointF dragOfst = new Point(0, 0); + private bool dragged; + + #endregion + + public virtual void HandleMouseClick (PointF pos) + { + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + decorator.HandleMouseClick(pos); + } + } + + public virtual void HandleMouseDown (PointF pos) + { + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + decorator.HandleMouseDown(pos); + } + + bool hit = HitTest(pos); + + if (DragAreaHitTest(pos)) + { + dragPos = pos; + dragOfst.X = X - dragPos.X; + dragOfst.Y = Y - dragPos.Y; + dragged = true; + } + } + + public virtual void HandleMouseMove (PointF pos) + { + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + decorator.HandleMouseMove(pos); + } + + if (dragged) + { + Move (dragOfst.X + pos.X, dragOfst.Y + pos.Y); + } + } + + public virtual void HandleMouseUp (PointF pos) + { + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + decorator.HandleMouseUp(pos); + } + + dragged = false; + } + + public virtual void HandleMouseLeave () + { + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + decorator.HandleMouseLeave(); + } + } + + #endregion + + private void HandleDecoratorRedrawRequest (object sender, EventArgs args) + { + EmitRedrawNeeded(); + } + + #region User Interaction + + public virtual bool HitTest(PointF pos) + { + bool ret = (pos.X > X && pos.Y > Y && pos.X < X + ActualWidth && pos.Y < Y + ActualHeight); + foreach (RectangleDecorator decorator in decorators) + { + if (decorator.Active) + ret |= decorator.HitTest(pos); + } + return ret; + } + + protected virtual bool DragAreaHitTest(PointF pos) + { + return (pos.X > X && pos.Y > Y && pos.X < X + ActualWidth && pos.Y < Y + ActualHeight); + } + + #endregion + + public virtual float GetAbsoluteContentWidth() + { + throw new NotImplementedException(); + } + + public virtual float GetAbsoluteContentHeight() + { + throw new NotImplementedException(); + } + + #region Storage + + protected virtual XmlElement CreateXmlElement(XmlDocument doc) + { + return doc.CreateElement("CanvasItem"); + } + + protected virtual void FillXmlElement (XmlElement element, XmlDocument document) + { + element.SetAttribute("X", X.ToString(CultureInfo.InvariantCulture)); + element.SetAttribute("Y", Y.ToString(CultureInfo.InvariantCulture)); + element.SetAttribute("Width", Width.ToString(CultureInfo.InvariantCulture)); + } + + public virtual void WriteToXml(XmlDocument document) + { + XmlElement elem = CreateXmlElement(document); + FillXmlElement (elem, document); + document.DocumentElement.AppendChild(elem); + } + + public virtual void LoadFromXml (XPathNavigator navigator) + { + X = float.Parse(navigator.GetAttribute("X", ""), CultureInfo.InvariantCulture); + Y = float.Parse(navigator.GetAttribute("Y", ""), CultureInfo.InvariantCulture); + Width = float.Parse(navigator.GetAttribute("Width", ""), CultureInfo.InvariantCulture); + } + + #endregion + + public bool KeepAspectRatio + { + get { return false; } + set {} + } + + public event EventHandler WidthChanged = delegate {}; + public event EventHandler HeightChanged = delegate {}; + public event EventHandler ActualWidthChanged = delegate {}; + public event EventHandler ActualHeightChanged = delegate {}; + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.Designer.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.Designer.cs new file mode 100644 index 0000000000..f19faecf21 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.Designer.cs @@ -0,0 +1,91 @@ +// +// +// +// +// $Revision$ +// + +namespace ClassDiagram +{ + partial class ClassCanvas : System.Windows.Forms.UserControl + { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the control. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.panel1 = new System.Windows.Forms.Panel(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBox1 + // + this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Default; + this.pictureBox1.Location = new System.Drawing.Point(0, 0); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(155, 167); + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PictureBox1MouseDown); + this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.PictureBox1MouseMove); + this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBox1Paint); + this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PictureBox1MouseClick); + this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.PictureBox1MouseUp); + // + // panel1 + // + this.panel1.AllowDrop = true; + this.panel1.AutoScroll = true; + this.panel1.Controls.Add(this.pictureBox1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(253, 259); + this.panel1.TabIndex = 1; + // + // ClassCanvas + // + this.AllowDrop = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScroll = true; + this.BackColor = System.Drawing.Color.White; + this.Controls.Add(this.panel1); + this.Cursor = System.Windows.Forms.Cursors.Default; + this.Name = "ClassCanvas"; + this.Size = new System.Drawing.Size(253, 259); + this.DragOver += new System.Windows.Forms.DragEventHandler(this.ClassCanvasDragOver); + this.DragDrop += new System.Windows.Forms.DragEventHandler(this.ClassCanvasDragDrop); + this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.ClassCanvasKeyUp); + this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ClassCanvasKeyDown); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + } + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.PictureBox pictureBox1; + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cd b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cd new file mode 100644 index 0000000000..26789f318c --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cd @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cs new file mode 100644 index 0000000000..2e2f7e5c3b --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.cs @@ -0,0 +1,598 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.ComponentModel; + +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + public partial class ClassCanvas + { + private class CanvasItemData : IDisposable + { + public CanvasItemData (CanvasItem item, + EventHandler SizeGripMouseEntered, + EventHandler SizeGripMouseLeft) + { + this.item = item; + + focusDecorator = new FocusDecorator(item); + sizeGripDecorator = new SizeGripDecorator(item); + + sizeGripDecorator.SizeGripMouseEnter += SizeGripMouseEntered; + sizeGripDecorator.SizeGripMouseLeave += SizeGripMouseLeft; + + item.AddDecorator(focusDecorator); + item.AddDecorator(sizeGripDecorator); + } + + CanvasItem item; + + public CanvasItem Item + { + get { return item; } + } + + public bool Focused + { + get { return focusDecorator.Active; } + set + { + focusDecorator.Active = value; + sizeGripDecorator.Active = value; + } + } + + FocusDecorator focusDecorator; + SizeGripDecorator sizeGripDecorator; + + public void Dispose() + { + item.RemoveDecorator(focusDecorator); + item.RemoveDecorator(sizeGripDecorator); + } + } + + LinkedListNode dragItemNode; + LinkedListNode hoverItemNode; + LinkedList itemsList = new LinkedList(); + Dictionary itemsData = new Dictionary(); + DiagramRouter diagramRouter = new DiagramRouter(); + + float zoom = 1.0f; + bool ctrlDown; + bool holdRedraw; + bool redrawNeeded; + + PointF lastMouseClickPosition; + + public ClassCanvas() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + } + + #region Diagram Activities + + public float Zoom + { + get { return zoom; } + set + { + zoom = value; + pictureBox1.Invalidate(); + LayoutChanged (this, EventArgs.Empty); + } + } + + public void CollapseAll () + { + foreach (CanvasItemData item in itemsList) + { + ClassCanvasItem classitem = item.Item as ClassCanvasItem; + if (classitem != null) + classitem.Collapsed = true; + } + LayoutChanged (this, EventArgs.Empty); + } + + public void ExpandAll () + { + foreach (CanvasItemData item in itemsList) + { + ClassCanvasItem classitem = item.Item as ClassCanvasItem; + if (classitem != null) + classitem.Collapsed = false; + } + LayoutChanged (this, EventArgs.Empty); + } + + public void MatchAllWidths () + { + foreach (CanvasItemData item in itemsList) + { + ClassCanvasItem classitem = item.Item as ClassCanvasItem; + if (classitem != null) + classitem.Width = classitem.GetAbsoluteContentWidth(); + } + LayoutChanged (this, EventArgs.Empty); + } + + public void ShrinkAllWidths () + { + foreach (CanvasItemData item in itemsList) + { + ClassCanvasItem classitem = item.Item as ClassCanvasItem; + if (classitem != null) + classitem.Width = 0; + } + LayoutChanged (this, EventArgs.Empty); + } + + #endregion + + public SizeF GetDiagramLogicalSize () + { + float w=1, h=1; + foreach (CanvasItemData item in itemsList) + { + w = Math.Max(w, item.Item.X + item.Item.ActualWidth + item.Item.Border); + h = Math.Max(h, item.Item.Y + item.Item.ActualHeight + item.Item.Border); + } + return new SizeF(w + 40, h + 40); + } + + public Size GetDiagramPixelSize () + { + float zoom = Math.Max(this.zoom, 0.1f); + SizeF size = GetDiagramLogicalSize(); + return new Size((int)(size.Width * zoom), (int)(size.Height * zoom)); + } + + public void SetRecommendedGraphicsAttributes (Graphics graphics) + { + graphics.CompositingQuality = CompositingQuality.HighSpeed; + graphics.SmoothingMode = SmoothingMode.AntiAlias; + graphics.PageUnit = GraphicsUnit.Pixel; + graphics.PixelOffsetMode = PixelOffsetMode.Half; + graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; + } + + public void DrawToGraphics(Graphics graphics) + { + foreach (CanvasItemData item in itemsList) + item.Item.DrawToGraphics(graphics); + + DrawRoutes(graphics); + } + + private void PictureBox1Paint (object sender, PaintEventArgs e) + { + Size bbox = GetDiagramPixelSize(); + + pictureBox1.Width = bbox.Width + 100; + pictureBox1.Height = bbox.Height + 100; + + e.Graphics.PageScale = zoom; + SetRecommendedGraphicsAttributes(e.Graphics); + DrawToGraphics(e.Graphics); + } + + private void DrawRoutes (Graphics g) + { + foreach (Route route in diagramRouter.Routes) + { + route.Recalc(itemsList as IEnumerable); + PointF origin = route.GetStartPoint(); + RouteSegment[] segments = route.RouteSegments; + foreach (RouteSegment rs in segments) + { + PointF dest = rs.CreateDestinationPoint(origin); + g.DrawLine(Pens.Black, origin, dest); + origin = dest; + } + + if (route.EndShape != null) + ((RouteShape)route.EndShape).Draw(g, route, true); + + if (route.StartShape != null) + ((RouteShape)route.StartShape).Draw(g, route, false); + } + } + + private LinkedListNode FindCanvasItemNode (PointF pos) + { + LinkedListNode itemNode = itemsList.Last; + while (itemNode != null) + { + if (itemNode.Value.Item.HitTest(pos)) + { + return itemNode; + } + itemNode = itemNode.Previous; + } + return null; + } + + #region Diagram Items Drag and Selection + + private void PictureBox1MouseClick (object sender, MouseEventArgs e) + { + PointF pos = new PointF(e.X / zoom, e.Y / zoom); + lastMouseClickPosition = pos; + LinkedListNode itemNode = FindCanvasItemNode(pos); + if (itemNode != null) + itemNode.Value.Item.HandleMouseClick(pos); + } + + private void PictureBox1MouseDown (object sender, MouseEventArgs e) + { + HoldRedraw = true; + PointF pos = new PointF(e.X / zoom, e.Y / zoom); + LinkedListNode itemNode = FindCanvasItemNode(pos); + dragItemNode = itemNode; + + if (!ctrlDown) + { + foreach (CanvasItemData item in itemsList) + item.Focused = false; + } + + if (itemNode != null) + { + itemNode.Value.Focused = true; + itemNode.Value.Item.HandleMouseDown(pos); + itemsList.Remove(itemNode); + itemsList.AddLast(itemNode); + CanvasItemSelected (this, new CanvasItemEventArgs (itemNode.Value.Item)); + } + HoldRedraw = false; + } + + private void PictureBox1MouseMove (object sender, MouseEventArgs e) + { + HoldRedraw = true; + PointF pos = new PointF(e.X / zoom, e.Y / zoom); + if (dragItemNode != null) + dragItemNode.Value.Item.HandleMouseMove(pos); + else + { + LinkedListNode itemNode = FindCanvasItemNode(pos); + if (hoverItemNode != itemNode) + { + if (hoverItemNode != null && hoverItemNode.Value != null) + hoverItemNode.Value.Item.HandleMouseLeave(); + hoverItemNode = itemNode; + } + + if (itemNode != null) + itemNode.Value.Item.HandleMouseMove(pos); + } + HoldRedraw = false; + } + + private void PictureBox1MouseUp (object sender, MouseEventArgs e) + { + PointF pos = new PointF(e.X / zoom, e.Y / zoom); + + if (dragItemNode != null) + dragItemNode.Value.Item.HandleMouseUp(pos); + dragItemNode = null; + + LinkedListNode itemNode = FindCanvasItemNode(pos); + if (itemNode != null) + itemNode.Value.Item.HandleMouseUp(pos); + } + + #endregion + + private bool HoldRedraw + { + get { return holdRedraw; } + set + { + holdRedraw = value; + if (!value && redrawNeeded) + { + redrawNeeded = false; + this.Invalidate(true); + HandleRedraw (this, EventArgs.Empty); + } + } + } + + private void HandleItemLayoutChange (object sender, EventArgs args) + { + LayoutChanged (this, args); + if (HoldRedraw) + redrawNeeded = true; + else + HandleRedraw (sender, args); + } + + private void HandleRedraw (object sender, EventArgs args) + { + if (HoldRedraw) + { + redrawNeeded = true; + return; + } + this.Invalidate(true); + } + + private void HandleItemPositionChange (object sender, ValueChangingEventArgs args) + { + PointF pos = new PointF(args.Value.X, args.Value.Y); + + pos.X = Math.Max ((float) Math.Round(pos.X / 10.0f) * 10.0f, 40.0f); + pos.Y = Math.Max ((float) Math.Round(pos.Y / 10.0f) * 10.0f, 40.0f); + + args.Cancel = (pos.X == args.Value.X) && (pos.Y == args.Value.Y); + args.Value = pos; + } + + private void HandleItemSizeChange (object sender, ValueChangingEventArgs args) + { + SizeF size = new SizeF(args.Value); + + size.Width = (float) Math.Round(size.Width / 10.0f) * 10.0f; + size.Height = (float) Math.Round(size.Height / 10.0f) * 10.0f; + + args.Cancel = (size.Width == args.Value.Width) && (size.Height == args.Value.Height); + args.Value = size; + } + + private void SizeGripMouseEntered (object sender, SizeGripEventArgs e) + { + if ((e.GripPosition & SizeGripPositions.EastWest) != SizeGripPositions.None) + { + pictureBox1.Cursor = Cursors.SizeWE; + } + else if ((e.GripPosition & SizeGripPositions.NorthSouth) != SizeGripPositions.None) + { + pictureBox1.Cursor = Cursors.SizeNS; + } + } + + private void SizeGripMouseLeft (object sender, SizeGripEventArgs e) + { + pictureBox1.Cursor = Cursors.Default; + } + + public void AddCanvasItem (CanvasItem item) + { + ClassCanvasItem classItem = item as ClassCanvasItem; + if (classItem != null) + { + foreach (CanvasItemData ci in itemsList) + { + ClassCanvasItem cci = ci.Item as ClassCanvasItem; + if (cci != null) + { + Route r = null; + if (cci.RepresentedClassType == classItem.RepresentedClassType.BaseClass) + r = diagramRouter.AddRoute(item, cci); + else if (classItem.RepresentedClassType == cci.RepresentedClassType.BaseClass) + r = diagramRouter.AddRoute(cci, classItem); + + if (r != null) + r.EndShape = new RouteInheritanceShape(); + } + } + } + + diagramRouter.AddItem(item); + CanvasItemData itemData = new CanvasItemData(item, SizeGripMouseEntered, SizeGripMouseLeft); + itemsData[item] = itemData; + + itemsList.AddLast(itemData); + item.RedrawNeeded += HandleRedraw; + item.LayoutChanged += HandleItemLayoutChange; + item.PositionChanging += HandleItemPositionChange; + item.SizeChanging += HandleItemSizeChange; + } + + public void RemoveCanvasItem (CanvasItem item) + { + itemsList.Remove(itemsData[item]); + Stack routesToRemove = new Stack(); + foreach (Route r in diagramRouter.Routes) + { + if (r.From == item || r.To == item) + routesToRemove.Push(r); + } + + foreach (Route r in routesToRemove) + diagramRouter.RemoveRoute(r); + + diagramRouter.RemoveItem (item); + + LayoutChanged(this, EventArgs.Empty); + } + + /// + /// Retruns a copy of the the canvas items list as an array. + /// + public CanvasItem[] GetCanvasItems() + { + CanvasItem[] items = new CanvasItem[itemsList.Count]; + int i = 0; + foreach (CanvasItemData item in itemsList) + items[i++] = item.Item; + return items; + } + + public bool Contains (IClass ct) + { + foreach (CanvasItemData ci in itemsList) + { + ClassCanvasItem cci = ci.Item as ClassCanvasItem; + if (cci != null) + if (cci.RepresentedClassType.Equals(ct)) return true; + } + + return false; + } + + public void AutoArrange () + { + diagramRouter.RecalcPositions(); + } + + public static ClassCanvasItem CreateItemFromType (IClass ct) + { + if (ct == null) return null; + ClassCanvasItem item = null; + if (ct.ClassType == ClassType.Interface) + item = new InterfaceCanvasItem(ct); + else if (ct.ClassType == ClassType.Enum) + item = new EnumCanvasItem(ct); + else if (ct.ClassType == ClassType.Struct) + item = new StructCanvasItem(ct); + else if (ct.ClassType == ClassType.Delegate) + item = new DelegateCanvasItem(ct); + else + item = new ClassCanvasItem(ct); + item.Initialize(); + return item; + } + + #region File Save/Load + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", MessageId = "System.Xml.XmlNode")] + public XmlDocument WriteToXml () + { + XmlDocument doc = new XmlDocument(); + doc.LoadXml(""); + + XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-8", "yes"); + doc.InsertBefore(decl, doc.FirstChild); + + XmlAttribute zoom = doc.CreateAttribute("Zoom"); + zoom.Value = Zoom.ToString(System.Globalization.CultureInfo.InvariantCulture); + doc.DocumentElement.Attributes.Append(zoom); + + foreach (CanvasItemData item in itemsList) + { + item.Item.WriteToXml(doc); + } + return doc; + } + + public void LoadFromXml (IXPathNavigable doc, IProjectContent pc) + { + if (pc == null) return; + if (doc == null) return; + XPathNavigator nav = doc.CreateNavigator(); + XPathNodeIterator ni = nav.Select(@"/ClassDiagram/ClassItem"); + while (ni.MoveNext()) + { + string typeName = ni.Current.GetAttribute("Type", ""); + IClass ct = pc.GetClass(typeName, 0); + ClassCanvasItem canvasitem = ClassCanvas.CreateItemFromType(ct); + if (canvasitem != null) + { + canvasitem.LoadFromXml (ni.Current); + AddCanvasItem(canvasitem); + } + } + ni = nav.Select(@"/ClassDiagram/Note"); + while (ni.MoveNext()) + { + NoteCanvasItem note = new NoteCanvasItem(); + note.LoadFromXml(ni.Current); + AddCanvasItem(note); + } + } + + #endregion + + public event EventHandler LayoutChanged = delegate {}; + public event EventHandler CanvasItemSelected = delegate {}; + + public Bitmap GetAsBitmap () + { + Size bbox = GetDiagramPixelSize(); + Bitmap bitmap = new Bitmap(bbox.Width, bbox.Height); + Graphics g = Graphics.FromImage(bitmap); + g.PageScale = zoom; + SetRecommendedGraphicsAttributes(g); + DrawToGraphics(g); + return bitmap; + } + + public void SaveToImage (string filename) + { + GetAsBitmap().Save(filename); + } + + public PointF LastMouseClickPosition + { + get { return lastMouseClickPosition; } + } + + #region Drag/Drop from Class Browser Handling + + private void ClassCanvasDragOver(object sender, DragEventArgs e) + { + e.Effect = DragDropEffects.Link; + } + + private void ClassCanvasDragDrop(object sender, DragEventArgs e) + { + + } + + #endregion + + void ClassCanvasKeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Control) + ctrlDown = true; + } + + void ClassCanvasKeyUp(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Control) + ctrlDown = false; + } + } + + public class CanvasItemEventArgs : EventArgs + { + public CanvasItemEventArgs (CanvasItem canvasItem) + { + this.canvasItem = canvasItem; + } + + private CanvasItem canvasItem; + + public CanvasItem CanvasItem + { + get { return canvasItem; } + } + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] + public enum TestEnum {Dog, Cat, Fish}; +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.csproj b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.csproj new file mode 100644 index 0000000000..db8a910da8 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.csproj @@ -0,0 +1,108 @@ + + + Library + ClassCanvas + ClassCanvas + Debug + AnyCPU + {08F772A1-F0BE-433E-8B37-F6522953DB05} + False + -Microsoft.Design#CA1063 + + + obj\ + obj\Debug\ + bin\Debug\ + False + DEBUG;TRACE + True + Full + True + + + obj\ + obj\Release\ + bin\Release\ + True + TRACE + False + None + False + + + + + + + + + + + GlobalAssemblyInfo.cs + + + + + ClassCanvas.cs + + + + + + + + + + + + + + + + + + + + + + + + + + ClassCanvas.Designer.cs + + + + + + + + + + + + + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + False + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + False + + + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} + ICSharpCode.SharpDevelop.Dom + False + + + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} + Diagrams + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.resx b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.resx new file mode 100644 index 0000000000..7080a7d118 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvas.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvasItem.cs new file mode 100644 index 0000000000..0edfeb41e2 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/ClassCanvasItem.cs @@ -0,0 +1,573 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using System.Globalization; + +using Tools.Diagrams; +using Tools.Diagrams.Drawables; + +namespace ClassDiagram +{ + public class ClassCanvasItem : CanvasItem, IDisposable + { + IClass classtype; + string typeclass; + InteractiveHeaderedItem classItemHeaderedContent; + DrawableItemsStack classItemContainer = new DrawableItemsStack(); + + const int radius = 20; + + #region Graphics related variables + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly Font TitleFont = new Font (FontFamily.GenericSansSerif, 11, FontStyle.Bold, GraphicsUnit.Pixel); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly Font SubtextFont = new Font (FontFamily.GenericSansSerif, 11, FontStyle.Regular, GraphicsUnit.Pixel); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly Font GroupTitleFont = new Font (FontFamily.GenericSansSerif, 11, FontStyle.Regular, GraphicsUnit.Pixel); + + LinearGradientBrush grad; + + GraphicsPath shadowpath; + + #endregion + + CollapseExpandShape collapseExpandShape = new CollapseExpandShape(); + + DrawableItemsStack titles = new DrawableItemsStack(); + + DrawableItemsStack titlesCollapsed = new DrawableItemsStack(); + DrawableItemsStack titlesExpanded = new DrawableItemsStack(); + + DrawableItemsStack groups = new DrawableItemsStack(); + Dictionary groupNames = new Dictionary(); // TODO - this is really an ugly patch + + DrawableItemsStack interfaces = new DrawableItemsStack(); + + DrawableRectangle titlesBackgroundCollapsed; + DrawableRectangle titlesBackgroundExpanded; + + protected override bool AllowHeightModifications() + { + return false; + } + + public override float Width + { + set + { + base.Width = Math.Max (value, 100.0f); + PrepareFrame(); + } + } + + public override float GetAbsoluteContentWidth() + { + return classItemHeaderedContent.GetAbsoluteContentWidth(); + } + + public override float GetAbsoluteContentHeight() + { + return classItemHeaderedContent.GetAbsoluteContentHeight(); + } + + public IClass RepresentedClassType + { + get { return classtype; } + } + + #region Constructors + + public ClassCanvasItem (IClass ct) + { + classtype = ct; + + classItemHeaderedContent = new InteractiveHeaderedItem(titlesCollapsed, titlesExpanded, InitContentContainer(InitContent())); + + classItemContainer.Container = this; + classItemContainer.Add(classItemHeaderedContent); + classItemContainer.Add(new DrawableRectangle(null, Pens.Gray, radius, radius, radius, radius)); + classItemContainer.OrientationAxis = Axis.Z; + + grad = new LinearGradientBrush( + new PointF(0, 0), new PointF(1, 0), + TitleBackground, Color.White); + + titlesBackgroundCollapsed = new DrawableRectangle(grad, null, radius, radius, radius, radius); + titlesBackgroundExpanded = new DrawableRectangle(grad, null, radius, radius, 1, 1); + + titles.Border = 5; + + titlesCollapsed.Add(titlesBackgroundCollapsed); + titlesCollapsed.Add(titles); + titlesCollapsed.OrientationAxis = Axis.Z; + + titlesExpanded.Add(titlesBackgroundExpanded); + titlesExpanded.Add(titles); + titlesExpanded.OrientationAxis = Axis.Z; + + if (classtype != null) + { + typeclass = classtype.Modifiers.ToString(); + typeclass += " " + classtype.ClassType.ToString(); + } + } + + #endregion + + public override bool IsVResizable + { + get { return false; } + } + + protected virtual DrawableItemsStack InitContentContainer(params IDrawableRectangle[] items) + { + DrawableItemsStack content = new DrawableItemsStack(); + content.OrientationAxis = Axis.Z; + content.Add(new DrawableRectangle(Brushes.White, null, 1, 1, radius, radius)); + foreach (IDrawableRectangle item in items) + content.Add(item); + + return content; + } + + protected virtual IDrawableRectangle InitContent () + { + groups.MinWidth = 80; + groups.Spacing = 5; + groups.Border = 5; + + return groups; + } + + public void Initialize () + { + PrepareMembersContent(); + PrepareTitles(); + Width = GetAbsoluteContentWidth(); + } + + #region Graphics related members + + protected virtual Color TitleBackground + { + get { return Color.LightSteelBlue;} + } + + protected virtual Brush InnerTitlesBackground + { + get { return Brushes.AliceBlue;} + } + + #endregion + + #region Preparations + + protected IAmbience GetAmbience() + { + IAmbience ambience = null; + + try + { + ambience = AmbienceService.CurrentAmbience; + } + catch (NullReferenceException) + { + ambience = ICSharpCode.SharpDevelop.Dom.CSharp.CSharpAmbience.Instance; + } + + ambience.ConversionFlags = ConversionFlags.None; + return ambience; + } + + protected virtual void PrepareTitles () + { + if (classtype == null) return; + + IAmbience ambience = GetAmbience(); + + DrawableItemsStack title = new DrawableItemsStack(); + title.OrientationAxis = Axis.X; + + TextSegment titleString = new TextSegment(base.Graphics, classtype.Name, TitleFont, true); + title.Add(titleString); + title.Add(collapseExpandShape); + + collapseExpandShape.Collapsed = Collapsed; + + titles.OrientationAxis = Axis.Y; + + titles.Add(title); + + titles.Add(new TextSegment(base.Graphics, typeclass, SubtextFont, true)); + + if (classtype.BaseClass != null) + { + DrawableItemsStack inherits = new DrawableItemsStack(); + inherits.OrientationAxis = Axis.X; + inherits.Add(new InheritanceShape()); + inherits.Add(new TextSegment(base.Graphics, classtype.BaseClass.Name, SubtextFont, true)); + titles.Add(inherits); + } + + foreach (IReturnType rt in classtype.BaseTypes) + { + IClass ct = rt.GetUnderlyingClass(); + if (ct != null && ct.ClassType == ClassType.Interface) + interfaces.Add(new TextSegment(base.Graphics, ambience.Convert(rt), SubtextFont, true)); + } + } + + protected class MemberData : IComparable + { + public MemberData (IMember member, IAmbience ambience, Graphics graphics, Font font) + { + IMethod methodMember = member as IMethod; + IEvent eventMember = member as IEvent; + IProperty propertyMember = member as IProperty; + IField fieldMember = member as IField; + + DrawableItemsStack image = new DrawableItemsStack(); + image.OrientationAxis = Axis.Z; // stack image components one on top of the other + image.KeepAspectRatio = true; + + if (methodMember != null) + { + memberString = ambience.Convert(methodMember) + " : " + ambience.Convert(member.ReturnType); + image.Add(new MethodShape()); + } + else if (eventMember != null) + { + memberString = ambience.Convert(eventMember) + " : " + ambience.Convert(member.ReturnType); + image.Add(new EventShape()); + } + else if (fieldMember != null) + { + memberString = ambience.Convert(fieldMember) + " : " + ambience.Convert(member.ReturnType); + image.Add(new FieldShape()); + } + else if (propertyMember != null) + { + memberString = ambience.Convert(propertyMember) + " : " + ambience.Convert(member.ReturnType); + image.Add(new PropertyShape()); + } + + memberItem.OrientationAxis = Axis.X; + memberItem.Add(image); + memberItem.Add(new TextSegment(graphics, memberString, font, true)); + + image.Border = 1; + } + + DrawableItemsStack memberItem = new DrawableItemsStack(); + + string memberString; + + public string MemberString + { + get { return memberString; } + } + + public int CompareTo(MemberData other) + { + return memberString.CompareTo(other.MemberString); + } + + public DrawableItemsStack Item + { + get { return memberItem; } + } + } + + protected InteractiveHeaderedItem PrepareGroup (string title, IDrawableRectangle content) + { + #region Prepare Group Container + DrawableItemsStack headerPlus = new DrawableItemsStack(); + DrawableItemsStack headerMinus = new DrawableItemsStack(); + + headerPlus.OrientationAxis = Axis.X; + headerMinus.OrientationAxis = Axis.X; + #endregion + + #region Create Header + TextSegment titleSegment = new TextSegment(Graphics, title, GroupTitleFont, true); + + headerPlus.Add(new PlusShape()); + headerPlus.Add(titleSegment); + + headerMinus.Add(new MinusShape()); + headerMinus.Add(titleSegment); + + DrawableItemsStack headerCollapsed = new DrawableItemsStack(); + DrawableItemsStack headerExpanded = new DrawableItemsStack(); + + headerCollapsed.OrientationAxis = Axis.Z; + headerExpanded.OrientationAxis = Axis.Z; + + headerCollapsed.Add (new DrawableRectangle(InnerTitlesBackground, null)); + headerCollapsed.Add (headerPlus); + + headerExpanded.Add (new DrawableRectangle(InnerTitlesBackground, null)); + headerExpanded.Add (headerMinus); + #endregion + + InteractiveHeaderedItem tg = new InteractiveHeaderedItem(headerCollapsed, headerExpanded, content); + tg.HeaderClicked += delegate { tg.Collapsed = !tg.Collapsed; }; + tg.RedrawNeeded += HandleRedraw; + + return tg; + } + + protected virtual DrawableItemsStack PrepareMembersContent (ICollection members) where MT : IMember + { + if (members == null) return null; + if (members.Count == 0) return null; + DrawableItemsStack content = new DrawableItemsStack(); + content.OrientationAxis = Axis.Y; + PrepareMembersContent (members, content); + return content; + } + + protected virtual void PrepareMembersContent (ICollection members, DrawableItemsStack content) where MT : IMember + { + if (members == null) return; + if (members.Count == 0) return; + + IAmbience ambience = GetAmbience(); + + #region Prepare Group Members + List membersData = new List(); + foreach (MT member in members) + { + membersData.Add(new MemberData(member, ambience, Graphics, MemberFont)); + } + membersData.Sort(); + #endregion + + #region Add Members To Group + foreach (MemberData memberData in membersData) + { + content.Add(memberData.Item); + } + #endregion + } + + private void AddGroupToContent(string title, DrawableItemsStack groupContent) + { + if (groupContent != null) + { + InteractiveHeaderedItem tg = PrepareGroup (title, groupContent); + groupNames.Add(tg, title); + groups.Add(tg); + } + } + + protected virtual void PrepareMembersContent () + { + if (classtype == null) return; + + groups.Clear(); + + DrawableItemsStack propertiesContent = PrepareMembersContent (classtype.Properties); + DrawableItemsStack methodsContent = PrepareMembersContent (classtype.Methods); + DrawableItemsStack fieldsContent = PrepareMembersContent (classtype.Fields); + DrawableItemsStack eventsContent = PrepareMembersContent (classtype.Events); + + AddGroupToContent("Properties", propertiesContent); + AddGroupToContent("Methods", methodsContent); + AddGroupToContent("Fields", fieldsContent); + AddGroupToContent("Events", eventsContent); + } + + protected virtual void PrepareFrame () + { + ActualHeight = classItemContainer.GetAbsoluteContentHeight(); + + shadowpath = new GraphicsPath(); + shadowpath.AddArc(ActualWidth-radius + 4, 3, radius, radius, 300, 60); + shadowpath.AddArc(ActualWidth-radius + 4, ActualHeight-radius + 3, radius, radius, 0, 90); + shadowpath.AddArc(4, ActualHeight-radius + 3, radius, radius, 90, 45); + shadowpath.AddArc(ActualWidth-radius, ActualHeight-radius, radius, radius, 90, -90); + shadowpath.CloseFigure(); + } + + #endregion + + public override void DrawToGraphics (Graphics graphics) + { + grad.ResetTransform(); + grad.TranslateTransform(X, Y); + grad.ScaleTransform(ActualWidth, 1); + + GraphicsState state = graphics.Save(); + graphics.TranslateTransform (X, Y); + + //Draw Shadow + graphics.FillPath(CanvasItem.ShadowBrush, shadowpath); + + classItemContainer.Width = Width; + classItemContainer.Height = Height; + + graphics.Restore(state); + + classItemContainer.DrawToGraphics(graphics); + + //Draw interfaces lollipops + //TODO - should be converted to an headered item. + if (interfaces.Count > 0) + { + interfaces.X = X + 15; + interfaces.Y = Y - interfaces.ActualHeight - 1; + interfaces.DrawToGraphics(graphics); + + graphics.DrawEllipse(Pens.Black, X + 9, Y - interfaces.ActualHeight - 11, 10, 10); + graphics.DrawLine(Pens.Black, X + 14, Y - interfaces.ActualHeight - 1, X + 14, Y); + } + + base.DrawToGraphics(graphics); + } + + public bool Collapsed + { + get { return classItemHeaderedContent.Collapsed; } + set + { + classItemHeaderedContent.Collapsed = value; + collapseExpandShape.Collapsed = value; + PrepareFrame(); + EmitLayoutUpdate(); + } + } + + private void HandleRedraw (object sender, EventArgs args) + { + PrepareFrame(); + EmitLayoutUpdate(); + } + + #region Behaviour + + public override void HandleMouseClick (PointF pos) + { + base.HandleMouseClick(pos); + + if (collapseExpandShape.IsInside(pos.X, pos.Y)) + { + Collapsed = !Collapsed; + } + else + { + foreach (InteractiveHeaderedItem tg in groups) + { + if (tg.HitTest(pos)) + { + tg.HandleMouseClick(pos); + } + } + } + } + + #endregion + + #region Storage + + protected override XmlElement CreateXmlElement(XmlDocument doc) + { + return doc.CreateElement("ClassItem"); + } + + protected override void FillXmlElement(XmlElement element, XmlDocument document) + { + base.FillXmlElement(element, document); + element.SetAttribute("Type", RepresentedClassType.FullyQualifiedName); + element.SetAttribute("Collapsed", Collapsed.ToString()); + + foreach (InteractiveHeaderedItem tg in groups) + { + XmlElement grp = document.CreateElement(groupNames[tg]); + grp.SetAttribute("Collapsed", tg.Collapsed.ToString()); + element.AppendChild(grp); + } + + } + + public override void LoadFromXml (XPathNavigator navigator) + { + base.LoadFromXml(navigator); + + Collapsed = bool.Parse(navigator.GetAttribute("Collapsed", "")); + + foreach (InteractiveHeaderedItem tg in groups) + { + XPathNodeIterator ni = navigator.SelectChildren(groupNames[tg], ""); + ni.MoveNext(); + tg.Collapsed = bool.Parse(ni.Current.GetAttribute("Collapsed", "")); + } + } + + #endregion + + public void Dispose() + { + grad.Dispose(); + shadowpath.Dispose(); + } + + public override string ToString() + { + return "ClasCanvasItem: " + classtype.Name; + } + } + + /// + /// Test interface + /// + public interface TestInterface + { + + } + + /// + /// Test class. + /// + public class TestClass_Long_Title : TestInterface + { + /// + /// A method with a common test name and one parameter. + /// + public void foo(string str) {} + + /// + /// Some test field. + /// + public int bar; + + /// + /// The getter for the 'bar' field. + /// + public int Bar { get { return bar; } } + + /// + /// A simple test event. + /// + public event EventHandler stupid = delegate {}; + } + +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/FocusDecorator.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/FocusDecorator.cs new file mode 100644 index 0000000000..98a89cf80e --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/FocusDecorator.cs @@ -0,0 +1,55 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:03 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + public class FocusDecorator : RectangleDecorator + { + public FocusDecorator (IRectangle rectangle) : base (rectangle) {} + + static Pen InitPen () + { + Pen pen = new Pen(Color.Black); + pen.DashStyle = DashStyle.Dot; + return pen; + } + + static Pen pen = InitPen(); + + public override void DrawToGraphics(Graphics graphics) + { + if (graphics == null) return; + + graphics.DrawRectangle(pen, + Rectangle.AbsoluteX - 4, Rectangle.AbsoluteY - 4, + Rectangle.ActualWidth + 8, Rectangle.ActualHeight + 8); + } + + public override void HandleMouseClick(PointF pos) { } + public override void HandleMouseDown(PointF pos) { } + public override void HandleMouseMove(PointF pos) { } + public override void HandleMouseUp(PointF pos) { } + public override void HandleMouseLeave() { } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/SizeGripDecorator.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/SizeGripDecorator.cs new file mode 100644 index 0000000000..9e7367d89c --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Decorators/SizeGripDecorator.cs @@ -0,0 +1,249 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:03 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + [Flags] + public enum SizeGripPositions { + None = 0, + North = 1, + East = 2, + South = 4, + West = 8, + NorthSouth = 5, + EastWest = 10, + All = 15 + }; + + public class SizeGripEventArgs : EventArgs + { + SizeGripPositions gripPosition; + + public SizeGripEventArgs (SizeGripPositions gripPosition) + { + this.gripPosition = gripPosition; + } + + public SizeGripPositions GripPosition + { + get { return gripPosition; } + } + } + + public class SizeGripDecorator : RectangleDecorator + { + public SizeGripDecorator (IRectangle rectangle) + : base (rectangle) + { + if (rectangle.IsHResizable) + this.gripPositions |= SizeGripPositions.EastWest; + + if (rectangle.IsVResizable) + this.gripPositions |= SizeGripPositions.NorthSouth; + } + + private SizeGripPositions gripPositions; + private SizeGripPositions grabbedGrip; + private SizeGripPositions highlightedGrip; + + private PointF dragPos = new Point(0, 0); + private PointF dragOfst = new Point(0, 0); + private float dragOrigWidth; + private float dragOrigHeight; + + private PointF GetGripPosition (SizeGripPositions grip) + { + PointF pos = new PointF(0, 0); + if (grip == SizeGripPositions.North) + { + pos.X = Rectangle.ActualWidth / 2; + pos.Y = -4; + } + else if (grip == SizeGripPositions.East) + { + pos.X = Rectangle.ActualWidth + 4; + pos.Y = Rectangle.ActualHeight / 2; + } + else if (grip == SizeGripPositions.South) + { + pos.X = Rectangle.ActualWidth / 2; + pos.Y = Rectangle.ActualHeight + 4; + } + else if (grip == SizeGripPositions.West) + { + pos.X = - 4; + pos.Y = Rectangle.ActualHeight / 2; + } + + pos.X += Rectangle.AbsoluteX; + pos.Y += Rectangle.AbsoluteY; + + return pos; + } + + private void DrawGripRect (Graphics graphics, SizeGripPositions grip) + { + Pen pen = Pens.Gray; + if (grip == highlightedGrip) + pen = Pens.Black; + + PointF pos = GetGripPosition (grip); + graphics.FillRectangle(Brushes.White, pos.X - 3, pos.Y - 3, 6, 6); + graphics.DrawRectangle(pen, pos.X - 3, pos.Y - 3, 6, 6); + } + + private static bool IsInGrip (PointF pos, PointF gripPos) + { + return (pos.X >= gripPos.X - 3 && pos.Y >= gripPos.Y - 3 && + pos.X <= gripPos.X + 3 && pos.Y <= gripPos.Y + 3); + } + + public override void DrawToGraphics(Graphics graphics) + { + if (graphics == null) return; + if ((gripPositions & SizeGripPositions.North) == SizeGripPositions.North) + DrawGripRect (graphics, SizeGripPositions.North); + + if ((gripPositions & SizeGripPositions.East) == SizeGripPositions.East) + DrawGripRect (graphics, SizeGripPositions.East); + + if ((gripPositions & SizeGripPositions.South) == SizeGripPositions.South) + DrawGripRect (graphics, SizeGripPositions.South); + + if ((gripPositions & SizeGripPositions.West) == SizeGripPositions.West) + DrawGripRect (graphics, SizeGripPositions.West); + } + + public SizeGripPositions GripPositions + { + get { return gripPositions; } + set { gripPositions = value; } + } + + private bool InternalHitTest(PointF pos, SizeGripPositions grip) + { + if ((gripPositions & grip) == grip) + if (IsInGrip (pos, GetGripPosition(grip))) + return true; + return false; + } + + private SizeGripPositions InternalHitTest(PointF pos) + { + if (InternalHitTest (pos, SizeGripPositions.North)) + return SizeGripPositions.North; + + if (InternalHitTest (pos, SizeGripPositions.East)) + return SizeGripPositions.East; + + if (InternalHitTest (pos, SizeGripPositions.South)) + return SizeGripPositions.South; + + if (InternalHitTest (pos, SizeGripPositions.West)) + return SizeGripPositions.West; + + return SizeGripPositions.None; + } + + public override bool HitTest(PointF pos) + { + return InternalHitTest(pos) != SizeGripPositions.None; + } + + public override void HandleMouseClick(PointF pos) { } + + public override void HandleMouseDown(PointF pos) + { + grabbedGrip = InternalHitTest(pos); + dragPos = pos; + dragOfst.X = Rectangle.X - dragPos.X; + dragOfst.Y = Rectangle.Y - dragPos.Y; + + dragOrigWidth = Rectangle.ActualWidth; + dragOrigHeight = Rectangle.ActualHeight; + } + + public override void HandleMouseMove(PointF pos) + { + SizeGripPositions newGrip = InternalHitTest(pos); + + if (grabbedGrip == SizeGripPositions.None) + { + if (highlightedGrip != newGrip) + { + SizeGripMouseLeave (this, new SizeGripEventArgs(highlightedGrip)); + highlightedGrip = newGrip; + SizeGripMouseEnter (this, new SizeGripEventArgs(highlightedGrip)); + EmitRedraw(); + } + } + + if (grabbedGrip != SizeGripPositions.None) + { + if (grabbedGrip == SizeGripPositions.North) + { + if (pos.Y >= 40) + { + Rectangle.Y = dragOfst.Y + pos.Y; + Rectangle.Height = dragOrigHeight - pos.Y + dragPos.Y; + } + } + else if (grabbedGrip == SizeGripPositions.East) + { + Rectangle.Width = dragOrigWidth + pos.X - dragPos.X; + } + else if (grabbedGrip == SizeGripPositions.South) + { + Rectangle.Height = dragOrigHeight + pos.Y - dragPos.Y; + } + else if (grabbedGrip == SizeGripPositions.West) + { + if (pos.X >= 40) + { + Rectangle.X = dragOfst.X + pos.X; + Rectangle.Width = dragOrigWidth - pos.X + dragPos.X; + } + } + } + } + + public override void HandleMouseUp(PointF pos) + { + grabbedGrip = SizeGripPositions.None; + } + + public override void HandleMouseLeave() + { + if (grabbedGrip == SizeGripPositions.None) + { + SizeGripMouseLeave (this, new SizeGripEventArgs(highlightedGrip)); + highlightedGrip = SizeGripPositions.None; + EmitRedraw(); + } + } + + public event EventHandler SizeGripMouseEnter = delegate { }; + public event EventHandler SizeGripMouseLeave = delegate { }; + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/DelegateCanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/DelegateCanvasItem.cs new file mode 100644 index 0000000000..5bd7420240 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/DelegateCanvasItem.cs @@ -0,0 +1,64 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using System.Globalization; + +using Tools.Diagrams; +using Tools.Diagrams.Drawables; + +namespace ClassDiagram +{ + // TODO - should look at the Invoke method and extract the parameters and return type. + // this is the only information that need to be shown. The parameters should + // be listed in the form of paramName : paramType, as for the return type, still + // need to figure that out ;) + public class DelegateCanvasItem : ClassCanvasItem + { + public DelegateCanvasItem (IClass ct) : base (ct) {} + + private DrawableItemsStack parameters = new DrawableItemsStack(); + + protected override Color TitleBackground + { + get { return Color.LightPink;} + } + + protected override IDrawableRectangle InitContent() + { + parameters.Border = 5; + parameters.OrientationAxis = Axis.Y; + return parameters; + } + + protected override void PrepareMembersContent() + { + parameters.Clear(); + IMethod invokeMethod = RepresentedClassType.SearchMember("Invoke", RepresentedClassType.ProjectContent.Language) as IMethod; + IAmbience ambience = GetAmbience(); + foreach (IParameter par in invokeMethod.Parameters) + { + TextSegment ts = new TextSegment(Graphics, par.Name + " : " + ambience.Convert(par.ReturnType), MemberFont, true); + parameters.Add(ts); + } + } + } + + public delegate TestEnum TestDelegate (int num, string str); +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/EnumCanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/EnumCanvasItem.cs new file mode 100644 index 0000000000..0dc8879648 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/EnumCanvasItem.cs @@ -0,0 +1,47 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; +using Tools.Diagrams.Drawables; + +namespace ClassDiagram +{ + //TODO - an enum looks differently. + public class EnumCanvasItem : ClassCanvasItem + { + public EnumCanvasItem (IClass ct) : base (ct) {} + + private DrawableItemsStack fields = new DrawableItemsStack(); + + protected override Color TitleBackground + { + get { return Color.Plum; } + } + + protected override IDrawableRectangle InitContent() + { + fields.Border = 5; + fields.OrientationAxis = Axis.Y; + return fields; + } + + protected override void PrepareMembersContent () + { + fields.Clear(); + PrepareMembersContent (RepresentedClassType.Fields, fields); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IHitTestable.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IHitTestable.cs new file mode 100644 index 0000000000..dc0227c413 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IHitTestable.cs @@ -0,0 +1,29 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + public interface IHitTestable + { + bool HitTest (PointF pos); + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IInteractiveDrawable.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IInteractiveDrawable.cs new file mode 100644 index 0000000000..b4fdc9edd1 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IInteractiveDrawable.cs @@ -0,0 +1,19 @@ +// +// +// +// +// $Revision$ +// + +using System; + +using Tools.Diagrams; +using Tools.Diagrams.Drawables; + +namespace ClassDiagram +{ + public interface IInteractiveDrawable : IDrawable, IHitTestable, IMouseInteractable + { + } + +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IMouseInteractable.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IMouseInteractable.cs new file mode 100644 index 0000000000..62df3ea4e7 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/IMouseInteractable.cs @@ -0,0 +1,81 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + public interface IMouseInteractable + { + /// + /// Called by the canvas when the user clicks inside the item. + /// + /// + /// The given point is relative to the canvas origin. + /// Subtruct the item's X and Y values to get a position relative to the item's origin. + /// + /// + /// The click position relative to the canvas origin. + /// + void HandleMouseClick (PointF pos); + + /// + /// Called by the canvas when the user presses a mouse button inside the item. + /// + /// + /// The given point is relative to the canvas origin. + /// Subtruct the item's X and Y values to get a position relative to the item's origin. + /// + /// + /// The mouse button press position relative to the canvas origin. + /// + void HandleMouseDown (PointF pos); + + /// + /// Called by the canvas when the user moves the mouse cursor inside the item. + /// + /// + /// The given point is relative to the canvas origin. + /// Subtruct the item's X and Y values to get a position relative to the item's origin. + /// + /// + /// The mouse cursor position relative to the canvas origin. + /// + void HandleMouseMove (PointF pos); + + /// + /// Called by the canvas when the user releases a mouse button inside the item. + /// + /// + /// The given point is relative to the canvas origin. + /// Subtruct the item's X and Y values to get a position relative to the item's origin. + /// + /// + /// The mouse button release position relative to the canvas origin. + /// + void HandleMouseUp (PointF pos); + + /// + /// Called by the canvas whenever the mouse cursor leaves the item (i.e. the HitTest + /// method returns false after it returned true). + /// + void HandleMouseLeave (); + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InteractiveHeaderedItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InteractiveHeaderedItem.cs new file mode 100644 index 0000000000..2a70f2310c --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InteractiveHeaderedItem.cs @@ -0,0 +1,111 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using Tools.Diagrams; +using Tools.Diagrams.Drawables; + +namespace ClassDiagram +{ + public class InteractiveHeaderedItem : HeaderedItem, IMouseInteractable, IHitTestable + { + public InteractiveHeaderedItem(IDrawableRectangle headerCollapsed, + IDrawableRectangle headerExpanded, + IDrawableRectangle content) + : base (headerCollapsed, headerExpanded, content) {} + + public event EventHandler HeaderClicked = delegate {}; + public event EventHandler ContentClicked = delegate {}; + public event EventHandler HeaderMouseDown = delegate {}; + public event EventHandler ContentMouseDown = delegate {}; + public event EventHandler HeaderMouseMove = delegate {}; + public event EventHandler ContentMouseMove = delegate {}; + public event EventHandler HeaderMouseUp = delegate {}; + public event EventHandler ContentMouseUp = delegate {}; + + private void HandleMouseEvent(PointF pos, EventHandler headerEvent, EventHandler contentEvent) + { + if (Collapsed) + { + if (pos.X >= HeaderCollapsed.AbsoluteX && + pos.X <= HeaderCollapsed.AbsoluteX + HeaderCollapsed.ActualWidth && + pos.Y >= HeaderCollapsed.AbsoluteY && + pos.Y <= HeaderCollapsed.AbsoluteY + HeaderCollapsed.ActualHeight) + { + headerEvent(this, EventArgs.Empty); + } + } + else + { + if (pos.X >= HeaderExpanded.AbsoluteX && + pos.X <= HeaderExpanded.AbsoluteX + HeaderExpanded.ActualWidth && + pos.Y >= HeaderExpanded.AbsoluteY && + pos.Y <= HeaderExpanded.AbsoluteY + HeaderExpanded.ActualHeight) + { + headerEvent(this, EventArgs.Empty); + } + else if (pos.X >= Content.AbsoluteX && + pos.X <= Content.AbsoluteX + Content.ActualWidth && + pos.Y >= Content.AbsoluteY && + pos.Y <= Content.AbsoluteY + Content.ActualHeight) + { + contentEvent(this, EventArgs.Empty); + } + } + } + + public void HandleMouseClick(PointF pos) + { + HandleMouseEvent (pos, HeaderClicked, ContentClicked); + } + + public void HandleMouseDown(PointF pos) + { + HandleMouseEvent (pos, HeaderMouseDown, ContentMouseDown); + } + + public void HandleMouseMove(PointF pos) + { + HandleMouseEvent (pos, HeaderMouseMove, ContentMouseMove); + } + + public void HandleMouseUp(PointF pos) + { + HandleMouseEvent (pos, HeaderMouseUp, ContentMouseUp); + } + + public void HandleMouseLeave() + { + // TODO implement HandleMouseLeave + } + + public bool HitTest(PointF pos) + { + return (pos.X >= AbsoluteX && pos.X <= AbsoluteX + ActualWidth && + pos.Y >= AbsoluteY && pos.Y <= AbsoluteY + ActualHeight); + } + + public bool HeaderHitTest(PointF pos) + { + if (Collapsed) + { + return (pos.X >= HeaderCollapsed.AbsoluteX && pos.X <= HeaderCollapsed.AbsoluteX + HeaderCollapsed.ActualWidth && + pos.Y >= HeaderCollapsed.AbsoluteY && pos.Y <= HeaderCollapsed.AbsoluteY + HeaderCollapsed.ActualHeight); + } + else + { + return (pos.X >= HeaderExpanded.AbsoluteX && pos.X <= HeaderExpanded.AbsoluteX + HeaderExpanded.ActualWidth && + pos.Y >= HeaderExpanded.AbsoluteY && pos.Y <= HeaderExpanded.AbsoluteY + HeaderExpanded.ActualHeight); + } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InterfaceCanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InterfaceCanvasItem.cs new file mode 100644 index 0000000000..66dc7dc3f8 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/InterfaceCanvasItem.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +//using System.Reflection; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ClassDiagram +{ + public class InterfaceCanvasItem : ClassCanvasItem + { + static Brush innerTitlesBG = new SolidBrush(Color.FromArgb(255, 224, 255, 224)); + static Color titlesBG = Color.FromArgb(255, 192, 224, 192); + + public InterfaceCanvasItem (IClass ct) : base (ct) {} + + protected override Color TitleBackground + { + get { return titlesBG;} + } + + protected override Brush InnerTitlesBackground + { + get { return innerTitlesBG; } + } + } + +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/NoteCanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/NoteCanvasItem.cs new file mode 100644 index 0000000000..186d8949b6 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/NoteCanvasItem.cs @@ -0,0 +1,92 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using System.Globalization; + +namespace ClassDiagram +{ + //TODO - complete note item + public class NoteCanvasItem : CanvasItem + { + private string note = ""; + + public NoteCanvasItem() + { + } + + public string Note + { + get { return note; } + set { note = value; } + } + + public override void DrawToGraphics (Graphics graphics) + { + if (graphics == null) return; + + // Draw Shadow + graphics.FillRectangle(CanvasItem.ShadowBrush, X + ActualWidth, Y + 3, 4, ActualHeight); + graphics.FillRectangle(CanvasItem.ShadowBrush, X + 4, Y + ActualHeight, ActualWidth - 4, 3); + + // Draw Note Area + graphics.FillRectangle(Brushes.LightYellow, X, Y, ActualWidth, ActualHeight); + graphics.DrawRectangle(Pens.Olive, X, Y, ActualWidth, ActualHeight); + + // Draw Note Text + RectangleF rect = new RectangleF (X + 5, Y + 5, ActualWidth - 10, ActualHeight - 10); + graphics.DrawString(note, MemberFont, Brushes.Black, rect); + + base.DrawToGraphics(graphics); + } + + protected override bool DragAreaHitTest(PointF pos) + { + return (pos.X > X && pos.Y > Y && pos.X < X + ActualWidth && pos.Y < Y + ActualHeight); + } + + protected override XmlElement CreateXmlElement(XmlDocument doc) + { + return doc.CreateElement("Note"); + } + + protected override void FillXmlElement(XmlElement element, XmlDocument document) + { + base.FillXmlElement(element, document); + element.SetAttribute("Height", Height.ToString(CultureInfo.InvariantCulture)); + element.SetAttribute("Note", Note); + } + + public override void LoadFromXml (XPathNavigator navigator) + { + base.LoadFromXml(navigator); + Height = float.Parse(navigator.GetAttribute("Height", ""), CultureInfo.InvariantCulture); + Note = navigator.GetAttribute("Note", ""); + } + + public override float Width + { + set { base.Width = Math.Max (value, 40.0f); } + } + + public override float Height + { + set { base.Height = Math.Max (value, 40.0f); } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/RectangleDecorator.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/RectangleDecorator.cs new file mode 100644 index 0000000000..d040c885a9 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/RectangleDecorator.cs @@ -0,0 +1,73 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + public abstract class RectangleDecorator : IInteractiveDrawable + { + private IRectangle rect; + private bool active; + + protected RectangleDecorator (IRectangle rectangle) + { + this.rect = rectangle; + } + + public IRectangle Rectangle + { + get { return rect; } + } + + public bool Active + + { + get { return active; } + set + { + active = value; + EmitRedraw(); + } + } + + public event EventHandler RedrawNeeded = delegate { }; + + public abstract void DrawToGraphics(Graphics graphics); + + public virtual bool HitTest(PointF pos) + { + return (pos.X >= rect.AbsoluteX && pos.X <= rect.AbsoluteX + rect.ActualWidth && + pos.Y >= rect.AbsoluteY && pos.Y <= rect.AbsoluteY + rect.ActualHeight); + } + + public abstract void HandleMouseClick(PointF pos); + public abstract void HandleMouseDown(PointF pos); + public abstract void HandleMouseMove(PointF pos); + public abstract void HandleMouseUp(PointF pos); + public abstract void HandleMouseLeave(); + + protected void EmitRedraw () + { + RedrawNeeded (this, EventArgs.Empty); + } + } +} + diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseExpandShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseExpandShape.cs new file mode 100644 index 0000000000..7f6aa11680 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseExpandShape.cs @@ -0,0 +1,95 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class CollapseExpandShape : VectorShape + { + private bool collapsed; + static LinearGradientBrush shade = new LinearGradientBrush( + new PointF(0, 0), new PointF(0, 22), + Color.White, Color.LightSteelBlue); + + static PointF[] arrowPoints = new PointF[]{ + new PointF(4.0f, 9.0f), + new PointF(10.0f, 3.0f), + new PointF(16.0f, 9.0f), + new PointF(15.0f, 11.0f), + new PointF(10.0f, 6.0f), + new PointF(5.0f, 11.0f) + }; + + static GraphicsPath roundedButton = InitializeButtonShape(); + + static Pen buttonPen = Pens.SteelBlue; + static Brush arrowBrush = Brushes.DarkBlue; + + static GraphicsPath InitializeButtonShape() + { + GraphicsPath path = new GraphicsPath(); + path.AddArc(0, 0, 3, 3, 180, 90); + path.AddArc(17, 0, 3, 3, 270, 90); + path.AddArc(17, 17, 3, 3, 0, 90); + path.AddArc(0, 17, 3, 3, 90, 90); + path.CloseFigure(); + return path; + } + + static protected void DrawButton (Graphics graphics) + { + if (graphics == null) return; + graphics.FillPath(shade, roundedButton); + graphics.DrawPath(buttonPen, roundedButton); + } + + static protected void DrawArrow (Graphics graphics) + { + if (graphics == null) return; + graphics.FillPolygon (arrowBrush, arrowPoints); + } + + public bool Collapsed + { + get { return collapsed; } + set { collapsed = value; } + } + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + GraphicsState state = graphics.Save(); + CollapseExpandShape.DrawButton(graphics); + + if (collapsed) + { + graphics.TranslateTransform(0, 21); + graphics.ScaleTransform(1, -1); + } + + CollapseExpandShape.DrawArrow(graphics); + graphics.TranslateTransform(0, 6); + CollapseExpandShape.DrawArrow(graphics); + graphics.Restore(state); + } + + public override float ShapeWidth + { + get { return 20; } + } + + public override float ShapeHeight + { + get { return 20; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseShape.cs new file mode 100644 index 0000000000..c4f48743e9 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseShape.cs @@ -0,0 +1,78 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class CollapseShape : VectorShape + { + static LinearGradientBrush shade = new LinearGradientBrush( + new PointF(0, 0), new PointF(0, 22), + Color.White, Color.LightSteelBlue); + + static PointF[] arrowPoints = new PointF[]{ + new PointF(5.0f, 10.0f), + new PointF(11.0f, 4.0f), + new PointF(17.0f, 10.0f), + new PointF(16.0f, 12.0f), + new PointF(11.0f, 7.0f), + new PointF(6.0f, 12.0f) + }; + + static GraphicsPath roundedButton = InitializeButtonShape(); + + static GraphicsPath InitializeButtonShape() + { + GraphicsPath path = new GraphicsPath(); + path.AddArc(3, 3, 3, 3, 180, 90); + path.AddArc(18, 3, 3, 3, 270, 90); + path.AddArc(18, 18, 3, 3, 0, 90); + path.AddArc(3, 18, 3, 3, 90, 90); + path.CloseFigure(); + return path; + } + + static protected void DrawButton (Graphics graphics) + { + if (graphics == null) return; + graphics.FillPath(shade, roundedButton); + graphics.DrawPath(Pens.SteelBlue, roundedButton); + } + + static protected void DrawArrow (Graphics graphics) + { + if (graphics == null) return; + graphics.FillPolygon (Brushes.DarkBlue, arrowPoints); + } + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + CollapseShape.DrawButton(graphics); + + graphics.TranslateTransform(1, 1); + CollapseShape.DrawArrow(graphics); + graphics.TranslateTransform(0, 6); + CollapseShape.DrawArrow(graphics); + } + + public override float ShapeWidth + { + get { return 23; } + } + + public override float ShapeHeight + { + get { return 23; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/EventShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/EventShape.cs new file mode 100644 index 0000000000..2932dfeceb --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/EventShape.cs @@ -0,0 +1,68 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class EventShape : VectorShape + { + static PointF[] lightningPoints1 = new PointF[]{ + new PointF( 5.0f, 1.0f), + new PointF( 9.0f, 1.0f), + new PointF( 6.0f, 5.0f), + new PointF( 8.0f, 5.0f), + new PointF( 4.0f, 12.0f), + new PointF( 6.0f, 6.0f), + new PointF( 4.0f, 6.0f) + }; + + static PointF[] lightningPoints2 = new PointF[]{ + new PointF( 9.0f, 1.0f), + new PointF(10.0f, 2.0f), + new PointF( 8.0f, 5.0f), + new PointF( 6.0f, 5.0f) + }; + + static PointF[] lightningPoints3 = new PointF[]{ + new PointF( 8.0f, 5.0f), + new PointF( 9.0f, 6.0f), + new PointF( 5.0f, 13.0f), + new PointF( 4.0f, 12.0f) + }; + + static PointF[] lightningPoints4 = new PointF[]{ + new PointF( 4.0f, 6.0f), + new PointF( 6.0f, 6.0f), + new PointF( 6.0f, 7.0f), + new PointF( 5.0f, 7.0f) + }; + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + graphics.FillPolygon (Brushes.DarkGoldenrod, lightningPoints2); + graphics.FillPolygon (Brushes.DarkGoldenrod, lightningPoints3); + graphics.FillPolygon (Brushes.DarkGoldenrod, lightningPoints4); + graphics.FillPolygon (Brushes.Gold, lightningPoints1); + } + + public override float ShapeWidth + { + get { return 14.0f; } + } + + public override float ShapeHeight + { + get { return 14.0f; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/ExpandShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/ExpandShape.cs new file mode 100644 index 0000000000..34312acfbc --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/ExpandShape.cs @@ -0,0 +1,30 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class ExpandShape : CollapseShape + { + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + CollapseShape.DrawButton(graphics); + + graphics.TranslateTransform(1, 23); + graphics.ScaleTransform(1, -1); + CollapseShape.DrawArrow(graphics); + graphics.TranslateTransform(0, 6); + CollapseShape.DrawArrow(graphics); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/FieldShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/FieldShape.cs new file mode 100644 index 0000000000..0fdf3668fe --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/FieldShape.cs @@ -0,0 +1,35 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class FieldShape : MethodShape + { + static Brush brickBrush1 = new SolidBrush(Color.FromArgb(255, 0, 192, 192)); + static Brush brickBrush2 = new SolidBrush(Color.FromArgb(255, 0, 064, 064)); + static Brush brickBrush3 = new SolidBrush(Color.FromArgb(255, 0, 128, 128)); + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + GraphicsState state = graphics.Save(); + graphics.TranslateTransform(17.0f, 0.0f); + graphics.ScaleTransform(-1.0f, 1.0f); + MethodShape.DrawBrick(graphics, brickBrush1, brickBrush2, brickBrush3); + graphics.Restore(state); + graphics.FillRectangle(Brushes.Gray, 1.0f, 4.5f, 3.5f, 0.5f); + graphics.FillRectangle(Brushes.Gray, 0.0f, 6.5f, 3.5f, 0.5f); + graphics.FillRectangle(Brushes.Gray, 2.0f, 8.5f, 3.5f, 0.5f); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/InheritanceShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/InheritanceShape.cs new file mode 100644 index 0000000000..5bf301c470 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/InheritanceShape.cs @@ -0,0 +1,61 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class InheritanceShape : VectorShape + { + static GraphicsPath path = InitializePath(); + + static GraphicsPath InitializePath () + { + GraphicsPath path = new GraphicsPath(); + path.StartFigure(); + path.AddPolygon(new PointF[]{ + new PointF(0.0f, 1.9f), + new PointF(2.0f, 1.9f), + new PointF(2.0f, 1.0f), + new PointF(3.0f, 2.0f), + new PointF(2.0f, 3.0f), + new PointF(2.0f, 2.1f), + new PointF(0.0f, 2.1f) + }); + path.CloseFigure(); + path.StartFigure(); + path.AddPolygon(new PointF[]{ + new PointF(2.2f, 1.4f), + new PointF(2.7f, 2.0f), + new PointF(2.2f, 2.6f) + }); + path.FillMode = FillMode.Alternate; + path.CloseFigure(); + return path; + } + + public override float ShapeWidth + { + get { return 3.0f; } + } + + public override float ShapeHeight + { + get { return 4.0f; } + } + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + graphics.FillPath(Brushes.Black, path); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MethodShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MethodShape.cs new file mode 100644 index 0000000000..1ecb0968fa --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MethodShape.cs @@ -0,0 +1,69 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class MethodShape : VectorShape + { + static Brush brickBrush1 = new SolidBrush(Color.FromArgb(255, 192, 0, 192)); + static PointF[] brickPoints1 = new PointF[]{ + new PointF( 8.0f, 2.0f), + new PointF(12.0f, 5.0f), + new PointF( 9.0f, 8.0f), + new PointF( 5.0f, 4.0f) + }; + + static Brush brickBrush2 = new SolidBrush(Color.FromArgb(255, 064, 0, 064)); + static PointF[] brickPoints2 = new PointF[]{ + new PointF( 9.0f, 8.0f), + new PointF(12.0f, 5.0f), + new PointF(12.0f, 7.0f), + new PointF( 9.0f, 10.0f), + }; + + static Brush brickBrush3 = new SolidBrush(Color.FromArgb(255, 128, 0, 128)); + static PointF[] brickPoints3 = new PointF[]{ + new PointF( 5.0f, 4.0f), + new PointF( 9.0f, 8.0f), + new PointF( 9.0f, 10.0f), + new PointF( 5.0f, 6.0f) + }; + + static protected void DrawBrick (Graphics graphics, Brush b1, Brush b2, Brush b3) + { + if (graphics == null) return; + graphics.FillPolygon (b1, brickPoints1); + graphics.FillPolygon (b2, brickPoints2); + graphics.FillPolygon (b3, brickPoints3); + } + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + MethodShape.DrawBrick(graphics, brickBrush1, brickBrush2, brickBrush3); + graphics.FillRectangle(Brushes.Gray, 1.0f, 4.5f, 3.5f, 0.5f); + graphics.FillRectangle(Brushes.Gray, 0.0f, 6.5f, 3.5f, 0.5f); + graphics.FillRectangle(Brushes.Gray, 2.0f, 8.5f, 3.5f, 0.5f); + } + + public override float ShapeWidth + { + get { return 13.0f; } + } + + public override float ShapeHeight + { + get { return 13.0f; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MinusShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MinusShape.cs new file mode 100644 index 0000000000..32f555f4f7 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/MinusShape.cs @@ -0,0 +1,31 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class MinusShape : SmallButtonShape + { + static Rectangle minus = new Rectangle(2, 4, 6, 2); + + static Pen stroke = Pens.Black; + static Brush fill = Brushes.White; + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + base.Draw(graphics); + graphics.FillRectangle (fill, minus); + graphics.DrawRectangle (stroke, minus); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PlusShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PlusShape.cs new file mode 100644 index 0000000000..578aa8c0d2 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PlusShape.cs @@ -0,0 +1,44 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class PlusShape : SmallButtonShape + { + static PointF[] plusPoints = new PointF[]{ + new PointF(4.0f, 2.0f), + new PointF(6.0f, 2.0f), + new PointF(6.0f, 4.0f), + new PointF(8.0f, 4.0f), + new PointF(8.0f, 6.0f), + new PointF(6.0f, 6.0f), + new PointF(6.0f, 8.0f), + new PointF(4.0f, 8.0f), + new PointF(4.0f, 6.0f), + new PointF(2.0f, 6.0f), + new PointF(2.0f, 4.0f), + new PointF(4.0f, 4.0f) + }; + + static Pen stroke = Pens.Black; + static Brush fill = Brushes.White; + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + base.Draw(graphics); + graphics.FillPolygon (fill , plusPoints); + graphics.DrawPolygon (stroke, plusPoints); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PropertyShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PropertyShape.cs new file mode 100644 index 0000000000..353344c2dc --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/PropertyShape.cs @@ -0,0 +1,80 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class PropertyShape : VectorShape + { + static PointF[] handPoints = new PointF[]{ + new PointF( 3.0f, 7.0f), + new PointF( 4.0f, 8.0f), + new PointF( 6.0f, 6.0f), + new PointF( 8.0f, 8.0f), + new PointF( 9.0f, 7.0f), + new PointF(10.0f, 8.0f), + new PointF(12.0f, 6.0f), + new PointF(13.0f, 6.0f), + new PointF(13.0f, 2.0f), + new PointF( 8.0f, 2.0f) + }; + + static Pen handPen = new Pen(Color.Brown, 0.5f); + static Brush handBrush = Brushes.Yellow; + static Pen sleevePen = Pens.DarkBlue; + static Brush sleeveBrush = Brushes.Blue; + static Brush shadowBrush = Brushes.Gray; + static Brush linesBrush = Brushes.Black; + static Brush panelBrush = Brushes.White; + static Pen panelPen = Pens.SteelBlue; + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + + #region Panel + graphics.FillRectangle(shadowBrush, 1, 14, 10.5f, 1.5f); + graphics.FillRectangle(shadowBrush, 10, 6, 1.5f, 9); + + graphics.FillRectangle(panelBrush, 0, 5, 10, 9); + graphics.DrawRectangle(panelPen, 0, 5, 10, 9); + + graphics.FillRectangle(linesBrush, 1.5f, 9, 2, 1); + graphics.FillRectangle(linesBrush, 5, 9, 3, 1); + + graphics.FillRectangle(linesBrush, 1.5f, 11, 2, 1); + graphics.FillRectangle(linesBrush, 5, 11, 3, 1); + #endregion + + #region Hand + //TODO - improve the hand, choose better colors + graphics.FillPolygon(handBrush, handPoints); + graphics.DrawPolygon(handPen, handPoints); + graphics.DrawLine(handPen, 6, 6, 8, 4); + graphics.DrawLine(handPen, 7, 7, 9.5f, 4.5f); + graphics.DrawLine(handPen, 8, 8, 11, 5); + graphics.FillRectangle(sleeveBrush, 13, 2, 2, 4); + graphics.DrawRectangle(sleevePen, 13, 2, 2, 4); + #endregion + } + + public override float ShapeWidth + { + get { return 16.0f; } + } + + public override float ShapeHeight + { + get { return 16.0f; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteInheritanceShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteInheritanceShape.cs new file mode 100644 index 0000000000..53dc2c7503 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteInheritanceShape.cs @@ -0,0 +1,47 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 11/9/2006 + * Time: 4:57 PM + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using Tools.Diagrams; + +namespace ClassDiagram +{ + /// + /// Description of RouteInheritanceShape. + /// + public class RouteInheritanceShape : RouteShape + { + static GraphicsPath path = InitizlizePath(); + + static GraphicsPath InitizlizePath() + { + GraphicsPath path = new GraphicsPath(); + path.AddLines( new PointF[] + { + new PointF(0.0f, 0.0f), + new PointF(5.0f, 9.0f), + new PointF(-5.0f, 9.0f) + }); + path.CloseFigure(); + return path; + } + + static Pen stroke = Pens.Black; + static Brush fill = Brushes.White; + + protected override void Paint (Graphics graphics) + { + graphics.FillPath(fill, path); + graphics.DrawPath(stroke, path); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteShape.cs new file mode 100644 index 0000000000..06ef6ae5e3 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/RouteShape.cs @@ -0,0 +1,69 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 03/11/2006 + * Time: 19:42 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using Tools.Diagrams; + +namespace ClassDiagram +{ + public abstract class RouteShape : IRouteShape + { + private static SizeF baseSize = new SizeF(10, 10); + + private static float ConvertDirection (Direction dir) + { + switch (dir) + { + case Direction.Up: return 0; + case Direction.Down: return 180; + case Direction.Right: return 90; + case Direction.Left: return 270; + } + return 0; + } + + public void Draw (Graphics graphics, Route route, bool atEnd) + { + if (graphics == null) return; + if (route == null) return; + GraphicsState state = graphics.Save(); + float direction = 0; + PointF pos = default(PointF); + if (atEnd) + { + pos = route.GetEndPoint(); + direction = ConvertDirection(route.GetEndDirection()); + } + else + { + pos = route.GetStartPoint(); + direction = ConvertDirection(route.GetStartDirection()); + } + + // In matrix math, the correct way is to put rotation BEFORE + // translation. However, the simple transformation maethods of + // GDI+ works in "Prepend" mode, which reverses the order of + // operations. + graphics.TranslateTransform(pos.X, pos.Y); + graphics.RotateTransform(direction); + + Paint(graphics); + graphics.Restore(state); + } + + protected abstract void Paint (Graphics graphics); + + protected virtual SizeF Size + { + get { return RouteShape.baseSize; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/Shapes.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/Shapes.cs new file mode 100644 index 0000000000..a71080c3fd --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/Shapes.cs @@ -0,0 +1,34 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public static class Shapes + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly PlusShape Plus = new PlusShape(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly MinusShape Minus = new MinusShape(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly CollapseShape Collapse = new CollapseShape(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly ExpandShape Expand = new ExpandShape(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] + public static readonly InheritanceShape Inherits = new InheritanceShape(); + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallButtonShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallButtonShape.cs new file mode 100644 index 0000000000..5ce3d30ce3 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallButtonShape.cs @@ -0,0 +1,31 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + public class SmallButtonShape : SmallIconShape + { + static Rectangle rect = new Rectangle(0, 0, 10, 10); + static LinearGradientBrush shade = new LinearGradientBrush( + new PointF(0, 0), new PointF(0, 10), + Color.White, Color.LightGray); + static Pen strokePen = Pens.SteelBlue; + + public override void Draw(Graphics graphics) + { + if (graphics == null) return; + graphics.FillRectangle(shade, rect); + graphics.DrawRectangle(strokePen, rect); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallIconShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallIconShape.cs new file mode 100644 index 0000000000..b53b6517f7 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/SmallIconShape.cs @@ -0,0 +1,29 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace ClassDiagram +{ + + public abstract class SmallIconShape : VectorShape + { + public override float ShapeWidth + { + get { return 10.0f; } + } + + public override float ShapeHeight + { + get { return 10.0f; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/VectorShape.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/VectorShape.cs new file mode 100644 index 0000000000..dc56927b32 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/VectorShape.cs @@ -0,0 +1,78 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 28/09/2006 + * Time: 19:04 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +using Tools.Diagrams.Drawables; +using Tools.Diagrams; + +namespace ClassDiagram +{ + public abstract class VectorShape : BaseRectangle, IDrawableRectangle + { + public VectorShape () + { + KeepAspectRatio = true; + } + + public abstract void Draw (Graphics graphics); + + /// + /// Draw the shape to the given graphics object. + /// + /// + public void DrawToGraphics (Graphics graphics) + { + float scalex = base.ActualWidth / ShapeWidth; + float scaley = base.ActualHeight / ShapeHeight; + + if (scalex == 0 || scaley == 0) return; + + DrawToGraphics (graphics, AbsoluteX, AbsoluteY, scalex, scaley); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] + public virtual void DrawToGraphics (Graphics graphics, float x, float y) + { + DrawToGraphics(graphics, x, y, 1); + } + + public virtual void DrawToGraphics (Graphics graphics, float x, float y, float scale) + { + DrawToGraphics(graphics, x, y, scale, scale); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] + public virtual void DrawToGraphics (Graphics graphics, float x, float y, float scaleX, float scaleY) + { + if (graphics == null) return; + + GraphicsState state = graphics.Save(); + graphics.TranslateTransform (x, y); + graphics.ScaleTransform(scaleX, scaleY); + Draw(graphics); + //graphics.DrawRectangle(Pens.Magenta, 0, 0, ShapeWidth, ShapeHeight); + graphics.Restore(state); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] + public virtual bool IsInside (float x, float y) + { + return (x >= AbsoluteX && x < AbsoluteX + ActualWidth && + y >= AbsoluteY && y < AbsoluteY + ActualHeight); + } + + public abstract float ShapeWidth { get; } + public abstract float ShapeHeight { get; } + + public override float GetAbsoluteContentWidth() { return ShapeWidth; } + public override float GetAbsoluteContentHeight() { return ShapeHeight; } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/StructCanvasItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/StructCanvasItem.cs new file mode 100644 index 0000000000..e1757601d9 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/StructCanvasItem.cs @@ -0,0 +1,34 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Drawing; +using System.Drawing.Drawing2D; + +//using System.Reflection; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ClassDiagram +{ + public class StructCanvasItem : ClassCanvasItem + { + public StructCanvasItem (IClass ct) : base (ct) {} + + protected override Color TitleBackground + { + get { return Color.Wheat;} + } + + protected override Brush InnerTitlesBackground + { + get { return Brushes.PapayaWhip;} + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin.sln b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin.sln new file mode 100644 index 0000000000..54361f953a --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin.sln @@ -0,0 +1,120 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# SharpDevelop 2.1.0.2192 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramAddin", "ClassDiagramAddin\ClassDiagramAddin.csproj", "{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassCanvas", "ClassCanvas\ClassCanvas.csproj", "{08F772A1-F0BE-433E-8B37-F6522953DB05}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagrams", "DiagramRouter\Diagrams.csproj", "{0991423A-DBF6-4C89-B365-A1DF1EB32E42}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassEditor", "ClassEditor\ClassEditor.csproj", "{F5E059BB-96C2-4398-BED0-8598CD434173}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharpDevelop", "SharpDevelop", "{7C408F87-A95D-4EEF-B20D-A15200F42640}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeListView", "..\..\Misc\Debugger\TreeListView\Project\TreeListView.csproj", "{B08385CD-F0CC-488C-B4F4-EEB34B6D2688}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramApp", "ClassDiagramApp\ClassDiagramApp.csproj", "{709D6ACE-4921-4DF6-831A-E74E3EFAA742}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Release|Any CPU.Build.0 = Release|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Release|Any CPU.Build.0 = Release|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A66666C9-58CC-4DC1-A6BD-FFD950A3D5B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A66666C9-58CC-4DC1-A6BD-FFD950A3D5B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A66666C9-58CC-4DC1-A6BD-FFD950A3D5B8}.Release|Any CPU.Build.0 = Release|Any CPU + {A66666C9-58CC-4DC1-A6BD-FFD950A3D5B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A7FD990-F2C5-4A99-BD69-07DE56DAD931}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A7FD990-F2C5-4A99-BD69-07DE56DAD931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A7FD990-F2C5-4A99-BD69-07DE56DAD931}.Release|Any CPU.Build.0 = Release|Any CPU + {2A7FD990-F2C5-4A99-BD69-07DE56DAD931}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Release|Any CPU.Build.0 = Release|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Release|Any CPU.Build.0 = Release|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.Build.0 = Release|Any CPU + {80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29FD215C-31A9-4B44-B754-EF4627B30EF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29FD215C-31A9-4B44-B754-EF4627B30EF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29FD215C-31A9-4B44-B754-EF4627B30EF3}.Release|Any CPU.Build.0 = Release|Any CPU + {29FD215C-31A9-4B44-B754-EF4627B30EF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU + {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B08385CD-F0CC-488C-B4F4-EEB34B6D2688}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B08385CD-F0CC-488C-B4F4-EEB34B6D2688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B08385CD-F0CC-488C-B4F4-EEB34B6D2688}.Release|Any CPU.Build.0 = Release|Any CPU + {B08385CD-F0CC-488C-B4F4-EEB34B6D2688}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.Build.0 = Release|Any CPU + {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {709D6ACE-4921-4DF6-831A-E74E3EFAA742}.Debug|Any CPU.Build.0 = Debug|Any CPU + {709D6ACE-4921-4DF6-831A-E74E3EFAA742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {709D6ACE-4921-4DF6-831A-E74E3EFAA742}.Release|Any CPU.Build.0 = Release|Any CPU + {709D6ACE-4921-4DF6-831A-E74E3EFAA742}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {8035765F-D51F-4A0C-A746-2FD100E19419} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {B08385CD-F0CC-488C-B4F4-EEB34B6D2688} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE} = {7C408F87-A95D-4EEF-B20D-A15200F42640} + EndGlobalSection +EndGlobal diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.addin b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.addin new file mode 100644 index 0000000000..3614459989 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.addin @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.cd b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.cd new file mode 100644 index 0000000000..26c35c816c --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.cd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.csproj b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.csproj new file mode 100644 index 0000000000..3126d51f41 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/ClassDiagramAddin.csproj @@ -0,0 +1,104 @@ + + + Library + ClassDiagramAddin + ClassDiagramAddin + Debug + AnyCPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} + ..\..\..\..\..\AddIns\AddIns\DisplayBindings\ClassDiagram\ + False + False + 4 + false + + + obj\Debug\ + False + DEBUG;TRACE + true + Full + True + Program + ..\..\..\..\..\bin\SharpDevelop.exe + + + obj\ + obj\Release\ + True + TRACE + False + None + False + + + False + Auto + 4194304 + AnyCPU + 4096 + + + + + + + + + + + Always + + + Configuration\GlobalAssemblyInfo.cs + + + + + + + + + + PreserveNewest + + + + + + + + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} + ICSharpCode.TextEditor + False + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + False + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + False + + + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} + ICSharpCode.SharpDevelop.Dom + False + + + {08F772A1-F0BE-433E-8B37-F6522953DB05} + ClassCanvas + + + {F5E059BB-96C2-4398-BED0-8598CD434173} + ClassEditor + + + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} + Diagrams + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Configuration/AssemblyInfo.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..6515d2dff5 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Configuration/AssemblyInfo.cs @@ -0,0 +1,22 @@ +// +// +// +// +// $Revision$ +// + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ClassDiagramAddin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Resources/Bitmaps.resources b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Resources/Bitmaps.resources new file mode 100644 index 0000000000000000000000000000000000000000..fa3add4323ed66d8c23cbadd227794430803f437 GIT binary patch literal 4627 zcmdUwcT`hZ9>*^wv?#r*AVQ>z)PM+*P=?+@z>EqKAV35{NP-j*0Z~wJs8R$+kP?(4 zIDiZ)&48$Y6r~PDmTpEsIU-8g7suV%**!CV?Aha4-+RB?f4|@N-1|BAbw6EdWCH-C zLKfg0PNfk7)iDHWPzc3~K>cS6L%@3zC~C5SRIeaP0MS!T)|Eh^5`#!aTIw3CS54M5 zB!Ct|AsCSeAv6j;Kuy*$#4~{CWkU$Z2Kf_6MxJ_lcwH}Dq~;-Q9fF4bA^HDI7DA#C z0}21g?o6PuL!!7LV+r*8vfhk>4<(X()lG=BKs;GZ_K(B=jW7*uA6*|kA5BefT@Ac8 z-VtpEed!n1vMn+1etgGtEx+eg*nO?Q+-5)Vx!XyD)euMx;D9ulKz0LapMtChGF`}? zL7Fv8K>)x5D)gEGBGmE)6sQaY>HrNw01X5|HRbad37R87Zhz_YdpL984FzNcpa9{& z&SVNL3izyp4Cx?18CgAE7yxR&$NP7A<{%7^A*m!N&uT99Qt zTu{09-8LSo*r*r_6HwW`X94PP`l9X708}T#H}KHO0a-6gj2!?G3IIgM0q_wTik=4` zL<4|D4`|o30gxc)H8>eU6Te!Sp|Sc7U1<&iEhxb@-=^@UjFkF%!IqW+Gn1QFxr+U; z8@wx>0Sz^TOCoj(W1WrRhd<@IfR0FOWy&54Vd2Hb72GtXoUng)cFGi{-?Ug%Y97;=Pf{=N}UNe065B2QI~=y+pl9EA}7oTvj<4A@Xx8ZEIEvjt0TgWRdjB0UudPnrhAWnExbM_BD7k#hzZvS&%{=xwc*d( zHczg;A{i=f?1nuYaA7++>sg!Fwye8Y_P!an6OO(Y4d*<8Dhh(viiwY>oBFf&>tuZ_ zN3xw1R$P+Xr2{)*t3~5l>J@HZx+*;1{WquF?iGq6_tVI{vKm)TRkCWehe)IIneg{W z6~u+1BL!Qsr}1gq+q|MAiMn623x%vS{CDG*v7jedBzwqhgxn& zpDW)sUw&sXvU=3<)18Cs9@?9UZd}?=8qQdu-f4b2*e8AMi;#`)H|*P-pOIQM1e4a^ zP8aG2N832TuA-)TZ)4>|pK7y>n5beIli#T)TE8Wdp)<15q}=>0Lq0=H!ds?#a z+rh>AYvTf@zWg_xNBLq=f+3$Mo25TSlxE4PIL=$chBr?Qx5)`RbWdK+7JrZ7cr-kg zLp|-2DQ4|)`*y?@rejm_h0X!)2~moi#4eGHBq^1O{fiHElU|8mUy(VVvy*zZy_Hh+ zQ;@zv=!qqP4|}HIa`Gp2Q(c-vjKq0iae_*V&VmCCs_k_|%^zIpRqPE(8|Kj}`O_3? zOQ`@dX>%baxbZ$29t6AFDO(*o!P|2t((9FKq^W}aO<-r(HC1galK*x}{kTK8xHNd6Vva*n8YiX6@IQk<2{6{~TP&ULP2nV2q~ZwCXHuZ}_gms=yfix0Xr;?nh& zY{K78S#cVz%F4|bSUX)d#uiyu*S}9x;Hx) zP{N&tKK@fwR@6jcqexT7Uj1g0AZI%amsR)pO5l^RUQ7gDZFA+=#eTEa_3soCA9hY* zZ%!+fxhagUs>Q2iIY(*cN(x=>mQ5>RHxJg8vj_hAAQ()6Rp~0Jb-8GcYf^09oGC)6 z!zLA|^mC32ljqp;EON>8o{Kvk^9&`vz%twrpB9g}y_#Ff4CQbi91Ko$Krz3aa}WON z=f3pi+|x$+TTr6r4%-im_aodN2r3K62=ZDTBsyL$5z}EHsY?B>i79@RzR?_AZT~v1 z=*9+wtTJz3i1f|wd-o$u9Lm|fsl|Z>z0_W*aLEyWoI9uSke9?>sf>kfj^@00 zgsT<3Kj+@t6>%LqRTx6}r?(%@GPw|WDa%gv>?MQu`FT^BxQ?Q6Zz~feG4^S9?ERrT`c(cvjW>4WHb_2qAeiDO@#iJ>n{V4kt= z0w#TqZWz9Th?R*D6k2sGR%+uGyH$+ab6qEw>zH+VV$A7GX16zTSV;>G3TNjSfyd~! zBkgy6Q>C6XxV&+XKTvd}hQ8}n!L@ex1dcAOHBl?r_7~*leGTD~GI^ii%j+MLW{{>2 znmnlWURkr2cNOjLu@63A6qYXE9{(tKc6f(EBI9^|rSTPKq5QK3vVCl+{0WsDGVOQd zo5gXR;t2sU9pVXnt@+W7UrL-T!d-e+N#cKjZ)a literal 0 HcmV?d00001 diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramAddItemCommands.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramAddItemCommands.cs new file mode 100644 index 0000000000..ed3d6f51ef --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramAddItemCommands.cs @@ -0,0 +1,73 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; + +using ClassDiagram; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Commands; +using ICSharpCode.SharpDevelop.Dom; + +namespace ClassDiagramAddin +{ + public class AddClassCommand : ClassDiagramAddinCommand + { + public override void Run() + { + // TODO implement AddClassCommand + } + } + + public class AddAbstractClassCommand : ClassDiagramAddinCommand + { + public override void Run() + { + // TODO implement AddAbstractClassCommand + } + } + + public class AddInterfaceCommand : ClassDiagramAddinCommand + { + public override void Run() + { + // TODO implement AddInterfaceCommand + } + } + + public class AddDelegateCommand : ClassDiagramAddinCommand + { + public override void Run() + { + // TODO implement AddDelegateCommand + } + } + + public class AddEnumCommand : ClassDiagramAddinCommand + { + public override void Run() + { + // TODO implement AddEnumCommand + } + } + + public class AddNoteCommand : ClassDiagramAddinCommand + { + public override void Run() + { + NoteCanvasItem item = new NoteCanvasItem(); + item.Width = 200; + item.Height = 200; + item.X = Canvas.LastMouseClickPosition.X; + item.Y = Canvas.LastMouseClickPosition.Y; + Canvas.AddCanvasItem(item); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramCommand.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramCommand.cs new file mode 100644 index 0000000000..f2e7c05a79 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramCommand.cs @@ -0,0 +1,121 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; +using System.Globalization; + +using ClassDiagram; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Commands; +using ICSharpCode.SharpDevelop.Dom; + +namespace ClassDiagramAddin +{ + public abstract class ClassDiagramAddinCommand : AbstractMenuCommand + { + protected ClassCanvas Canvas + { + get { return (ClassCanvas)((ClassDiagramViewContent)this.Owner).Control; } + } + } + + public class AutoArrangeDiagramCommand : ClassDiagramAddinCommand + { + public override void Run() + { + Canvas.AutoArrange(); + } + } + + public class ExpandAllCommand : ClassDiagramAddinCommand + { + public override void Run() + { + Canvas.ExpandAll(); + } + } + + public class CollapseAllCommand : ClassDiagramAddinCommand + { + public override void Run() + { + Canvas.CollapseAll(); + } + } + + public class MatchAllWidthsCommand : ClassDiagramAddinCommand + { + public override void Run() + { + Canvas.MatchAllWidths(); + } + } + + public class ShrinkAllWidthsCommand : ClassDiagramAddinCommand + { + public override void Run() + { + Canvas.ShrinkAllWidths(); + } + } + + public class SetDiagramZoomCommand : AbstractComboBoxCommand + { + protected ClassCanvas Canvas + { + get + { + return (ClassCanvas)((ToolBarComboBox)this.Owner).Owner.Parent; + } + } + + public override void Run() + { + Canvas.Zoom = zoom; + } + + private void ComboBoxTextChanged(object sender, EventArgs e) + { + float zoomPercent = 100.0f; + string s = comboBox.Text.Trim().Trim('%'); + if (float.TryParse (s, out zoomPercent)) + { + zoom = zoomPercent / 100.0f; + this.Run(); + } + } + + protected override void OnOwnerChanged(EventArgs e) + { + base.OnOwnerChanged(e); + ToolBarComboBox box1 = (ToolBarComboBox) this.Owner; + comboBox = box1.ComboBox; + comboBox.DropDownStyle = ComboBoxStyle.DropDown; + comboBox.Items.Add("10%"); + comboBox.Items.Add("25%"); + comboBox.Items.Add("50%"); + comboBox.Items.Add("75%"); + comboBox.Items.Add("100%"); + comboBox.Items.Add("125%"); + comboBox.Items.Add("150%"); + comboBox.Items.Add("175%"); + comboBox.Items.Add("200%"); + comboBox.Items.Add("250%"); + comboBox.Items.Add("300%"); + comboBox.Items.Add("350%"); + comboBox.Items.Add("400%"); + comboBox.TextChanged += new EventHandler(this.ComboBoxTextChanged); + } + + ComboBox comboBox; + float zoom = 1.0f; + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramDisplayBinding.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramDisplayBinding.cs new file mode 100644 index 0000000000..f40c96ea11 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramDisplayBinding.cs @@ -0,0 +1,46 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Reflection; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop; + +namespace ClassDiagramAddin +{ + public class ClassDiagramDisplayBinding : IDisplayBinding + { + public ClassDiagramDisplayBinding () + { + // ResourceService.RegisterImages("ClassDiagram", Assembly.GetExecutingAssembly()); + } + + public bool CanCreateContentForFile(string fileName) + { + return true; + } + + public IViewContent CreateContentForFile(string fileName) + { + ClassDiagramViewContent vc = new ClassDiagramViewContent(); + vc.Load(fileName); + return vc; + } + + public bool CanCreateContentForLanguage(string languageName) + { + return false; + } + + public IViewContent CreateContentForLanguage(string languageName, string content) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramViewContent.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramViewContent.cs new file mode 100644 index 0000000000..3a81dc4664 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassDiagramViewContent.cs @@ -0,0 +1,182 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Windows.Forms; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +using ClassDiagram; + +using System.IO; +using System.Xml; + +namespace ClassDiagramAddin +{ + /// + /// Description of the view content + /// + public class ClassDiagramViewContent : AbstractViewContent + { + private IProjectContent projectContent; + private ClassCanvas canvas = new ClassCanvas(); + private ToolStrip toolstrip; + + public ClassDiagramViewContent () + { + canvas.LayoutChanged += HandleLayoutChange; + ParserService.ParseInformationUpdated += OnParseInformationUpdated; + toolstrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/ViewContent/ClassDiagram/Toolbar"); + toolstrip.GripStyle = ToolStripGripStyle.Hidden; + toolstrip.Stretch = true; + canvas.Controls.Add(toolstrip); + canvas.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/ViewContent/ClassDiagram/ContextMenu"); + canvas.CanvasItemSelected += HandleItemSelected; + } + + public override Control Control + { + get { return canvas; } + } + + public override string TabPageText + { + get { return "Class Diagram"; } + } + + public override void Load(string fileName) + { + FileName = fileName; + TitleName = Path.GetFileName(fileName); + IsDirty = false; + + if (fileName.EndsWith(".cd")) + { + XmlDocument doc = new XmlDocument(); + doc.Load(fileName); + projectContent = ParserService.GetProjectContent(ProjectService.CurrentProject); + canvas.LoadFromXml(doc, projectContent); + } + } + + public override void Save(string fileName) + { + if (!fileName.EndsWith(".cd")) return; + this.IsDirty = false; + this.FileName = fileName; + this.TitleName = Path.GetFileName(fileName); + + XmlWriterSettings settings = new XmlWriterSettings(); + settings.Indent = true; + settings.Encoding = System.Text.Encoding.UTF8; + + XmlWriter xw = XmlWriter.Create(fileName, settings); + canvas.WriteToXml().WriteTo(xw); + xw.Close(); + } + + void OnParseInformationUpdated(object sender, ParseInformationEventArgs e) + { + if (e == null) return; + if (e.CompilationUnit == null) return; + if (e.CompilationUnit.ProjectContent == null) return; + if (e.CompilationUnit.ProjectContent.Classes == null) return; + if (e.CompilationUnit.ProjectContent != projectContent) return; + + List addedItems = new List(); + foreach (IClass ct in e.CompilationUnit.ProjectContent.Classes) + { + if (!canvas.Contains(ct)) + { + ClassCanvasItem item = ClassCanvas.CreateItemFromType(ct); + canvas.AddCanvasItem(item); + addedItems.Add(item); + } + } + + WorkbenchSingleton.SafeThreadAsyncCall>(PlaceNewItems, addedItems); + + foreach (CanvasItem ci in canvas.GetCanvasItems()) + { + ClassCanvasItem cci = ci as ClassCanvasItem; + if (cci != null) + { + if (!e.CompilationUnit.ProjectContent.Classes.Contains(cci.RepresentedClassType)) + canvas.RemoveCanvasItem(cci); + } + } + } + + private void PlaceNewItems (ICollection items) + { + float minX = float.MaxValue, minY = float.MaxValue; + float maxX = float.MinValue, maxY = float.MinValue; + foreach (CanvasItem ci in canvas.GetCanvasItems()) + { + minX = Math.Min(ci.X, minX); + minY = Math.Min(ci.Y, minY); + maxX = Math.Max(ci.X + ci.ActualWidth, maxX); + maxY = Math.Max(ci.Y + ci.ActualHeight, maxY); + } + + float x = 20; + float y = maxY + 20; + float max_h = 0; + + foreach (CanvasItem ci in items) + { + ci.X = x; + ci.Y = y; + x += ci.Width + 20; + if (ci.Height > max_h) + max_h = ci.Height; + if (x > 1000) + { + x = 20; + y += max_h + 20; + max_h = 0; + } + } + } + + public override void RedrawContent() + { + // TODO: Refresh the whole view control here, renew all resource strings + // Note that you do not need to recreate the control. + base.RedrawContent(); + } + + public override void Dispose() + { + canvas.Dispose(); + } + + protected void HandleLayoutChange (object sender, EventArgs args) + { + this.IsDirty = true; + } + + private void HandleItemSelected (object sender, CanvasItemEventArgs args) + { + ClassCanvasItem cci = args.CanvasItem as ClassCanvasItem; + if (cci != null) + { + PadDescriptor padDesc = WorkbenchSingleton.Workbench.GetPad(typeof(ClassEditorPad)); + if (padDesc != null) + { + ((ClassEditor)padDesc.PadContent.Control).SetClass(cci.RepresentedClassType); + } + } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassEditorPad.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassEditorPad.cs new file mode 100644 index 0000000000..2cd42cd7c4 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ClassEditorPad.cs @@ -0,0 +1,82 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; +using ICSharpCode.TextEditor; + +using ClassDiagram; + +namespace ClassDiagramAddin +{ + /// + /// Description of the pad content + /// + public class ClassEditorPad : AbstractPadContent + { + ClassEditor editor = new ClassEditor(); + + /// + /// Creates a new ClassEditorPad object + /// + public ClassEditorPad() + { + editor.MemberActivated += EditorMemberActivated; + } + + private void EditorMemberActivated (object sender, IMemberEventArgs e) + { + ICompilationUnit compUnit = e.Member.DeclaringType.CompilationUnit; + FileService.JumpToFilePosition(compUnit.FileName, + e.Member.Region.BeginLine - 1, + e.Member.Region.BeginColumn - 1); + + } + + /// + /// The representing the pad + /// + public override Control Control + { + get { return editor; } + } + + /// + /// Refreshes the pad + /// + public override void RedrawContent() + { + // TODO: Refresh the whole pad control here, renew all resource strings whatever + // Note that you do not need to recreate the control. + } + + /// + /// Cleans up all used resources + /// + public override void Dispose() + { + editor.Dispose(); + } + + private static TextEditorControl GetTextEditorControl() + { + TextEditorControl tec = null; + IWorkbenchWindow window1 = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; + if ((window1 != null) && (window1.ViewContent is ITextEditorControlProvider)) + { + tec = ((ITextEditorControlProvider) window1.ViewContent).TextEditorControl; + } + return tec; + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/SaveToBitmapCommand.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/SaveToBitmapCommand.cs new file mode 100644 index 0000000000..532d4be19f --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/SaveToBitmapCommand.cs @@ -0,0 +1,36 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; + +using ClassDiagram; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Commands; +using ICSharpCode.SharpDevelop.Dom; + +namespace ClassDiagramAddin +{ + public class SaveToBitmapCommand : ClassDiagramAddinCommand + { + public override void Run() + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Title = "Save Diagram To Bitmap"; + sfd.Filter = "All Image Formats|*.bmp; *.png; *.jpg; *.jpeg; *.gif; *.tif; *.tiff|Bitmap files|*.bmp|Portable Network Graphics|*.png|JPEG files|*.jpg;*.jpeg|Graphics Interchange Format|*.gif|Tagged Image File|*.tif; *.tiff"; + sfd.OverwritePrompt = true; + sfd.DefaultExt = ".png"; + if (sfd.ShowDialog() != DialogResult.Cancel) + { + Canvas.SaveToImage(sfd.FileName); + } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ShowClassDiagramCommand.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ShowClassDiagramCommand.cs new file mode 100644 index 0000000000..afd1f89b6e --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramAddin/Src/ShowClassDiagramCommand.cs @@ -0,0 +1,64 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; + +using ClassDiagram; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Commands; +using ICSharpCode.SharpDevelop.Dom; + +namespace ClassDiagramAddin +{ + public class ShowClassDiagramCommand : AbstractMenuCommand + { + public override void Run() + { + IProject p = ProjectService.CurrentProject; + string filename = p.Directory+System.IO.Path.DirectorySeparatorChar+p.Name+".cd"; + if (p == null) return; + /*if (p.IsFileInProject(filename)) + { + ProjectItem pi = p.Items.Find( + delegate(ProjectItem pItem) + { return pItem.FileName == filename; } + ); + } + else*/ + { + //MessageBox.Show("Creating a new class diagram file named "+"\"+p.Directory+filename); + ClassCanvas classcanvas = new ClassCanvas(); + + IProjectContent pc = ParserService.GetProjectContent(p); + //float x = 20, y = 20; + //float max_h = 0; + + foreach (IClass ct in pc.Classes) + { + ClassCanvasItem classitem = ClassCanvas.CreateItemFromType(ct); + classcanvas.AddCanvasItem(classitem); + } + + classcanvas.AutoArrange(); + classcanvas.WriteToXml().Save(filename); + FileProjectItem fpi = new FileProjectItem(p, ItemType.Content); + fpi.BuildAction = "Content"; + //fpi.BuildAction = FileProjectItem.FileBuildAction.Content; + fpi.FileName = filename; + ProjectService.AddProjectItem(p, fpi); + ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView(); + p.Save(); + FileService.OpenFile(filename); + } + } + } + +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/AssemblyInfo.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/AssemblyInfo.cs new file mode 100644 index 0000000000..94d4cc2770 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/AssemblyInfo.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ClassDiagramApp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ClassDiagramApp")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all values by your own or you can build default build and revision +// numbers with the '*' character (the default): + +[assembly: AssemblyVersion("1.0.*")] diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/ClassDiagramApp.csproj b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/ClassDiagramApp.csproj new file mode 100644 index 0000000000..d3b752f3cc --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/ClassDiagramApp.csproj @@ -0,0 +1,70 @@ + + + WinExe + ClassDiagramApp + ClassDiagramApp + Debug + AnyCPU + {709D6ACE-4921-4DF6-831A-E74E3EFAA742} + + + obj\ + obj\Debug\ + bin\Debug\ + False + DEBUG;TRACE + True + Full + True + + + obj\ + obj\Release\ + bin\Release\ + True + TRACE + False + None + False + + + + + + + + + + + + MainForm.cs + + + + MainForm.cs + + + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + + + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} + ICSharpCode.SharpDevelop.Dom + + + {08F772A1-F0BE-433E-8B37-F6522953DB05} + ClassCanvas + + + {F5E059BB-96C2-4398-BED0-8598CD434173} + ClassEditor + + + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} + Diagrams + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.Designer.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.Designer.cs new file mode 100644 index 0000000000..bf834eef82 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.Designer.cs @@ -0,0 +1,310 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 23/09/2006 + * Time: 14:07 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +namespace ClassDiagramApp +{ + partial class MainForm : System.Windows.Forms.Form + { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.saveImgBtn = new System.Windows.Forms.Button(); + this.addNoteBtn = new System.Windows.Forms.Button(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.shrinkBtn = new System.Windows.Forms.Button(); + this.matchBtn = new System.Windows.Forms.Button(); + this.modifiedBtn = new System.Windows.Forms.Button(); + this.layoutBtn = new System.Windows.Forms.Button(); + this.initBtn = new System.Windows.Forms.Button(); + this.loadBtn = new System.Windows.Forms.Button(); + this.saveBtn = new System.Windows.Forms.Button(); + this.colExpBtn = new System.Windows.Forms.Button(); + this.zoom = new System.Windows.Forms.TrackBar(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.addInterfaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addEnumToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.zoom)).BeginInit(); + this.contextMenuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Size = new System.Drawing.Size(631, 480); + this.splitContainer1.SplitterDistance = 278; + this.splitContainer1.TabIndex = 0; + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.saveImgBtn); + this.splitContainer2.Panel1.Controls.Add(this.addNoteBtn); + this.splitContainer2.Panel1.Controls.Add(this.comboBox1); + this.splitContainer2.Panel1.Controls.Add(this.shrinkBtn); + this.splitContainer2.Panel1.Controls.Add(this.matchBtn); + this.splitContainer2.Panel1.Controls.Add(this.modifiedBtn); + this.splitContainer2.Panel1.Controls.Add(this.layoutBtn); + this.splitContainer2.Panel1.Controls.Add(this.initBtn); + this.splitContainer2.Panel1.Controls.Add(this.loadBtn); + this.splitContainer2.Panel1.Controls.Add(this.saveBtn); + this.splitContainer2.Panel1.Controls.Add(this.colExpBtn); + this.splitContainer2.Panel1.Controls.Add(this.zoom); + this.splitContainer2.Size = new System.Drawing.Size(631, 198); + this.splitContainer2.SplitterDistance = 222; + this.splitContainer2.TabIndex = 5; + // + // saveImgBtn + // + this.saveImgBtn.Location = new System.Drawing.Point(113, 170); + this.saveImgBtn.Name = "saveImgBtn"; + this.saveImgBtn.Size = new System.Drawing.Size(104, 23); + this.saveImgBtn.TabIndex = 16; + this.saveImgBtn.Text = "Save as Bitmap"; + this.saveImgBtn.UseVisualStyleBackColor = true; + this.saveImgBtn.Click += new System.EventHandler(this.SaveImgBtnClick); + // + // addNoteBtn + // + this.addNoteBtn.Location = new System.Drawing.Point(3, 170); + this.addNoteBtn.Name = "addNoteBtn"; + this.addNoteBtn.Size = new System.Drawing.Size(104, 23); + this.addNoteBtn.TabIndex = 15; + this.addNoteBtn.Text = "Add Note"; + this.addNoteBtn.UseVisualStyleBackColor = true; + this.addNoteBtn.Click += new System.EventHandler(this.AddNoteBtnClick); + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "10%", + "25%", + "50%", + "75%", + "100%", + "125%", + "150%", + "175%", + "200%", + "250%", + "300%", + "350%", + "400%"}); + this.comboBox1.Location = new System.Drawing.Point(113, 12); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(104, 21); + this.comboBox1.TabIndex = 14; + this.comboBox1.Text = "100%"; + this.comboBox1.TextChanged += new System.EventHandler(this.ComboBox1TextChanged); + // + // shrinkBtn + // + this.shrinkBtn.Location = new System.Drawing.Point(113, 141); + this.shrinkBtn.Name = "shrinkBtn"; + this.shrinkBtn.Size = new System.Drawing.Size(104, 23); + this.shrinkBtn.TabIndex = 13; + this.shrinkBtn.Text = "Shrink"; + this.shrinkBtn.UseVisualStyleBackColor = true; + this.shrinkBtn.Click += new System.EventHandler(this.ShrinkBtnClick); + // + // matchBtn + // + this.matchBtn.Location = new System.Drawing.Point(113, 112); + this.matchBtn.Name = "matchBtn"; + this.matchBtn.Size = new System.Drawing.Size(104, 23); + this.matchBtn.TabIndex = 12; + this.matchBtn.Text = "Match"; + this.matchBtn.UseVisualStyleBackColor = true; + this.matchBtn.Click += new System.EventHandler(this.MatchBtnClick); + // + // modifiedBtn + // + this.modifiedBtn.Enabled = false; + this.modifiedBtn.Location = new System.Drawing.Point(3, 141); + this.modifiedBtn.Name = "modifiedBtn"; + this.modifiedBtn.Size = new System.Drawing.Size(104, 23); + this.modifiedBtn.TabIndex = 11; + this.modifiedBtn.Text = "Modified"; + this.modifiedBtn.UseVisualStyleBackColor = true; + this.modifiedBtn.Click += new System.EventHandler(this.ModifiedBtnClick); + // + // layoutBtn + // + this.layoutBtn.Location = new System.Drawing.Point(113, 83); + this.layoutBtn.Name = "layoutBtn"; + this.layoutBtn.Size = new System.Drawing.Size(104, 23); + this.layoutBtn.TabIndex = 10; + this.layoutBtn.Text = "Layout"; + this.layoutBtn.UseVisualStyleBackColor = true; + this.layoutBtn.Click += new System.EventHandler(this.LayoutBtnClick); + // + // initBtn + // + this.initBtn.Location = new System.Drawing.Point(3, 54); + this.initBtn.Name = "initBtn"; + this.initBtn.Size = new System.Drawing.Size(104, 23); + this.initBtn.TabIndex = 9; + this.initBtn.Text = "Init"; + this.initBtn.UseVisualStyleBackColor = true; + this.initBtn.Click += new System.EventHandler(this.InitBtnClick); + // + // loadBtn + // + this.loadBtn.Location = new System.Drawing.Point(3, 83); + this.loadBtn.Name = "loadBtn"; + this.loadBtn.Size = new System.Drawing.Size(104, 23); + this.loadBtn.TabIndex = 8; + this.loadBtn.Text = "Load"; + this.loadBtn.UseVisualStyleBackColor = true; + this.loadBtn.Click += new System.EventHandler(this.LoadBtnClick); + // + // saveBtn + // + this.saveBtn.Location = new System.Drawing.Point(3, 112); + this.saveBtn.Name = "saveBtn"; + this.saveBtn.Size = new System.Drawing.Size(104, 23); + this.saveBtn.TabIndex = 7; + this.saveBtn.Text = "Save"; + this.saveBtn.UseVisualStyleBackColor = true; + this.saveBtn.Click += new System.EventHandler(this.SaveBtnClick); + // + // colExpBtn + // + this.colExpBtn.Location = new System.Drawing.Point(113, 54); + this.colExpBtn.Name = "colExpBtn"; + this.colExpBtn.Size = new System.Drawing.Size(104, 23); + this.colExpBtn.TabIndex = 6; + this.colExpBtn.Text = "Collapse All"; + this.colExpBtn.UseVisualStyleBackColor = true; + this.colExpBtn.Click += new System.EventHandler(this.ColExpBtnClick); + // + // zoom + // + this.zoom.Location = new System.Drawing.Point(3, 3); + this.zoom.Maximum = 400; + this.zoom.Minimum = 25; + this.zoom.Name = "zoom"; + this.zoom.Size = new System.Drawing.Size(104, 45); + this.zoom.SmallChange = 25; + this.zoom.TabIndex = 5; + this.zoom.TickFrequency = 25; + this.zoom.Value = 100; + this.zoom.Scroll += new System.EventHandler(this.ZoomValueChanged); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem1, + this.addInterfaceToolStripMenuItem, + this.addEnumToolStripMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(142, 70); + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(141, 22); + this.toolStripMenuItem1.Text = "Add Class"; + this.toolStripMenuItem1.Click += new System.EventHandler(this.ToolStripMenuItem1Click); + // + // addInterfaceToolStripMenuItem + // + this.addInterfaceToolStripMenuItem.Name = "addInterfaceToolStripMenuItem"; + this.addInterfaceToolStripMenuItem.Size = new System.Drawing.Size(141, 22); + this.addInterfaceToolStripMenuItem.Text = "Add Interface"; + // + // addEnumToolStripMenuItem + // + this.addEnumToolStripMenuItem.Name = "addEnumToolStripMenuItem"; + this.addEnumToolStripMenuItem.Size = new System.Drawing.Size(141, 22); + this.addEnumToolStripMenuItem.Text = "Add Enum"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(631, 480); + this.Controls.Add(this.splitContainer1); + this.Name = "MainForm"; + this.Text = "ClassDiagramApp"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainFormFormClosed); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel1.PerformLayout(); + this.splitContainer2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.zoom)).EndInit(); + this.contextMenuStrip1.ResumeLayout(false); + this.ResumeLayout(false); + } + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.Button saveImgBtn; + private System.Windows.Forms.Button addNoteBtn; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Button shrinkBtn; + private System.Windows.Forms.Button matchBtn; + private System.Windows.Forms.Button layoutBtn; + private System.Windows.Forms.Button modifiedBtn; + private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.Button loadBtn; + private System.Windows.Forms.Button initBtn; + private System.Windows.Forms.Button saveBtn; + private System.Windows.Forms.Button colExpBtn; + private System.Windows.Forms.TrackBar zoom; + private System.Windows.Forms.ToolStripMenuItem addEnumToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addInterfaceToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.SplitContainer splitContainer1; + + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.cs new file mode 100644 index 0000000000..0a8a965f3d --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.cs @@ -0,0 +1,185 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Globalization; +using System.Collections.Generic; +using System.Reflection; +using System.Drawing; +using System.Windows.Forms; +using System.Xml; + +using ClassDiagram; + +using ICSharpCode.SharpDevelop.Dom; + +namespace ClassDiagramApp +{ + /// + /// Description of MainForm. + /// + public partial class MainForm + { + [STAThread] + public static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + + ClassCanvas classcanvas = new ClassCanvas(); + ClassEditor classeditor = new ClassEditor(); + ProjectContentRegistry registry = new ProjectContentRegistry(); + IProjectContent pc; + ICompilationUnit cu; + + public MainForm() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + splitContainer1.Panel1.Controls.Add (classcanvas); + classcanvas.Dock = DockStyle.Fill; + splitContainer2.Panel2.Controls.Add (classeditor); + classeditor.Dock = DockStyle.Fill; + + pc = new ReflectionProjectContent(Assembly.LoadFrom("ClassCanvas.dll"), registry); + cu = new DefaultCompilationUnit(pc); + + classcanvas.CanvasItemSelected += OnItemSelected; + classcanvas.LayoutChanged += HandleLayoutChange; + } + + void MainFormFormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e) + { + Application.Exit(); + } + + void ToolStripMenuItem1Click(object sender, System.EventArgs e) + { + ClassCanvasItem item = ClassCanvas.CreateItemFromType(new DefaultClass(cu, "ClassDiagram.ClassCanvasItem")); + item.X = 20; + item.Y = 20; + classcanvas.AddCanvasItem(item); + } + + void ZoomValueChanged(object sender, System.EventArgs e) + { + classcanvas.Zoom = zoom.Value / 100f; + } + + void ColExpBtnClick(object sender, System.EventArgs e) + { + if (colExpBtn.Text == "Collapse All") + { + classcanvas.CollapseAll(); + colExpBtn.Text = "Expand All"; + } + else + { + classcanvas.ExpandAll(); + colExpBtn.Text = "Collapse All"; + } + } + + void OnItemSelected (object sender, CanvasItemEventArgs e) + { + if (e.CanvasItem is ClassCanvasItem) + classeditor.SetClass(((ClassCanvasItem)e.CanvasItem).RepresentedClassType); + else + classeditor.SetClass (null); + } + + void SaveBtnClick(object sender, System.EventArgs e) + { + classcanvas.WriteToXml().Save(@"C:\Documents and Settings\itai\My Documents\test.cd"); + } + + void InitBtnClick(object sender, System.EventArgs e) + { + float x=20, y=20; + float max_h = 0; + + foreach (IClass ct in pc.Classes) + { + ClassCanvasItem classitem = ClassCanvas.CreateItemFromType(ct); + classitem.X = x; + classitem.Y = y; + classcanvas.AddCanvasItem(classitem); + x += classitem.Width + 20; + if (classitem.Height > max_h) + max_h = classitem.Height; + if (x > 1000) + { + x = 20; + y += max_h + 20; + max_h = 0; + } + } + } + + void LoadBtnClick(object sender, System.EventArgs e) + { + XmlDocument doc = new XmlDocument(); + doc.Load(@"C:\Documents and Settings\itai\My Documents\test.cd"); + classcanvas.LoadFromXml(doc, pc); + } + + void ModifiedBtnClick(object sender, System.EventArgs e) + { + modifiedBtn.Enabled = false; + } + + void HandleLayoutChange(object sender, System.EventArgs e) + { + modifiedBtn.Enabled = true; + } + + void LayoutBtnClick(object sender, System.EventArgs e) + { + classcanvas.AutoArrange(); + } + + void MatchBtnClick(object sender, System.EventArgs e) + { + classcanvas.MatchAllWidths(); + } + + void ShrinkBtnClick(object sender, System.EventArgs e) + { + classcanvas.ShrinkAllWidths(); + } + + void ComboBox1TextChanged(object sender, System.EventArgs e) + { + float zoomPercent = 100.0f; + string s = comboBox1.Text.Trim().Trim('%'); + if (float.TryParse (s, out zoomPercent)) + { + classcanvas.Zoom = zoomPercent / 100.0f; + } + } + + void AddNoteBtnClick(object sender, EventArgs e) + { + NoteCanvasItem note = new NoteCanvasItem(); + note.X = 40; + note.Y = 40; + note.Width = 100; + note.Height = 100; + classcanvas.AddCanvasItem(note); + } + + void SaveImgBtnClick(object sender, EventArgs e) + { + classcanvas.SaveToImage(@"C:\Documents and Settings\itai\My Documents\test.png"); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.resx b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.resx new file mode 100644 index 0000000000..383cbec1d0 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassDiagramApp/MainForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 163, 17 + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/AssemblyInfo.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/AssemblyInfo.cs new file mode 100644 index 0000000000..bb5bc5650a --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/AssemblyInfo.cs @@ -0,0 +1,22 @@ +// +// +// +// +// $Revision$ +// + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("ClassEditor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.Designer.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.Designer.cs new file mode 100644 index 0000000000..661144745d --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.Designer.cs @@ -0,0 +1,50 @@ +/* + * Created by SharpDevelop. + * User: itai + * Date: 20/10/2006 + * Time: 20:08 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +namespace ClassDiagram +{ + partial class ClassEditor : System.Windows.Forms.UserControl + { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // ClassEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Name = "ClassEditor"; + this.Size = new System.Drawing.Size(603, 299); + this.ResumeLayout(false); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.cs new file mode 100644 index 0000000000..b63340780f --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.cs @@ -0,0 +1,302 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +using System.IO; +using System.Xml; +using System.Xml.XPath; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; +using ICSharpCode.TextEditor; + +namespace ClassDiagram +{ + /// + /// Description of UserControl1. + /// + public partial class ClassEditor + { + TreeListView membersList = new TreeListView(); + System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ClassEditor)); + + Dictionary addMemberItems = new Dictionary(); + Dictionary addParameterItems = new Dictionary(); + + Dictionary> classTypeGroupCreators = new Dictionary>(); + IClass currClass; + + public event EventHandler MemberActivated = delegate {}; + + public ClassEditor() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + ColumnHeader nameCol = membersList.Columns.Add("Name"); + ColumnHeader typeCol = membersList.Columns.Add("Type"); + ColumnHeader modifierCol = membersList.Columns.Add("Modifier"); + ColumnHeader summaryCol = membersList.Columns.Add("Summary"); + + nameCol.Width = 160; + typeCol.Width = 100; + modifierCol.Width = 100; + summaryCol.Width = 200; + + try + { + membersList.SmallImageList = ClassBrowserIconService.ImageList; + } + catch + { + membersList.SmallImageList = new ImageList(); + } + + //TODO - check with the #D documentation how to add new icons correctly. + membersList.SmallImageList.Images.Add("OpenBrace", (Bitmap)resources.GetObject("openbrace")); + membersList.SmallImageList.Images.Add("Comma", (Bitmap)resources.GetObject("comma")); + membersList.SmallImageList.Images.Add("CloseBrace", (Bitmap)resources.GetObject("closebrace")); + membersList.SmallImageList.Images.Add("EmptyBraces", (Bitmap)resources.GetObject("emptybraces")); + + membersList.Sorting = SortOrder.None; + membersList.ShowPlusMinus = true; + membersList.FullRowSelect = true; + + membersList.Items.Sortable = false; + membersList.HeaderStyle = ColumnHeaderStyle.Nonclickable; + + membersList.DoubleClick += HandleDoubleClick; + + Controls.Add(membersList); + membersList.Dock = DockStyle.Fill; + + classTypeGroupCreators.Add(ClassType.Class, SetClassGroups); + classTypeGroupCreators.Add(ClassType.Interface, SetClassGroups); + classTypeGroupCreators.Add(ClassType.Struct, SetClassGroups); + classTypeGroupCreators.Add(ClassType.Enum, SetEnumGroups); + classTypeGroupCreators.Add(ClassType.Delegate, SetDelegateGroups); + //classTypeGroupCreators[ClassType.Module] = SetClassGroups; //??? + } + + private void HandleDoubleClick (object sender, EventArgs e) + { + if (membersList.SelectedItems.Count == 0) return; + + if (addMemberItems.ContainsValue(membersList.SelectedItems[0])) + { + + } + else if (addParameterItems.ContainsValue(membersList.SelectedItems[0])) + { + + } + else + { + IMember itemMember = membersList.SelectedItems[0].Tag as IMember; + if (itemMember != null) + MemberActivated(this, new IMemberEventArgs(itemMember)); + } + } + + private void SetClassGroups (IClass classType) + { + AddGroup("Methods", "method", classType.Methods); + AddGroup("Properties", "property", classType.Properties); + AddGroup("Fields", "field", classType.Fields); + AddGroup("Events", "event", classType.Events); + } + + private void SetEnumGroups (IClass classType) + { + AddGroup("Fields", "field", classType.Fields); + } + + private void SetDelegateGroups (IClass classType) + { + } + + public void SetClass (IClass classType) + { + membersList.BeginUpdate(); + membersList.Items.Clear(); + + currClass = classType; + if (classType != null) + classTypeGroupCreators[classType.ClassType](classType); + + membersList.EndUpdate(); + } + + private TreeListViewItem AddGroup(string title, string type, ICollection members) where MT : IMember + { + if (members == null) return null; + + TreeListViewItem group = new TreeListViewItem(title); + group.ForeColor = Color.Gray; + group.Font = new Font(group.Font, FontStyle.Bold); + group.Items.Sortable = false; + + if (members.Count != 0) + { + foreach (IMember member in members) + { + + IMethod methodMember = member as IMethod; + IEvent eventMember = member as IEvent; + IProperty propertyMember = member as IProperty; + IField fieldMember = member as IField; + + int icon = -1; + try + { + icon = ClassBrowserIconService.GetIcon(member); + } + catch {} + + IAmbience ambience = GetAmbience(); + string memberName = ""; + + if (methodMember != null) + { + if (methodMember.IsConstructor) + { + if (methodMember.DeclaringType != null) + { + memberName = methodMember.DeclaringType.Name; + } + else + { + memberName = methodMember.Name; + } + } + else + { + memberName = methodMember.Name; + } + } + if (eventMember != null) + { + memberName = eventMember.Name; + } + if (propertyMember != null) memberName = ambience.Convert(propertyMember); + if (fieldMember != null) memberName = ambience.Convert(fieldMember); + + TreeListViewItem memberItem = new TreeListViewItem(memberName, icon); + memberItem.Items.Sortable = false; + memberItem.Items.SortOrder = SortOrder.None; + memberItem.Tag = member; + group.Items.Add(memberItem); + + if (methodMember != null) + FillParams (memberItem, methodMember); + + memberItem.SubItems.Add(ambience.Convert(member.ReturnType)); + memberItem.SubItems.Add(member.Modifiers.ToString()); + + memberItem.SubItems.Add(GetSummary(member)); + } + } + + TreeListViewItem addNewMember = new TreeListViewItem(String.Format("", type)); + addNewMember.ForeColor = Color.Gray; + group.Items.Add(addNewMember); + + addMemberItems[typeof(MT)] = addNewMember; + + membersList.Items.Add(group); + return group; + } + + private string GetSummary (IDecoration decoration) + { + StringReader strReader = new StringReader("" + decoration.Documentation + ""); + XmlDocument doc = new XmlDocument(); + doc.Load(strReader); + XPathNavigator nav = doc.CreateNavigator(); + XPathNodeIterator ni = nav.Select(@"/docroot/summary"); + if (ni.MoveNext()) + return ni.Current.InnerXml; + else + return String.Empty; + } + + private void FillParams(TreeListViewItem item, IMethod method) + { + string imageKey = "OpenBrace"; + foreach (IParameter param in method.Parameters) + { + TreeListViewItem parameter = new TreeListViewItem(param.Name); + parameter.ImageKey = imageKey; + parameter.SubItems.Add (param.ReturnType.Name); + item.Items.Add(parameter); + imageKey = "Comma"; + } + TreeListViewItem addParam = new TreeListViewItem(""); + if (imageKey == "OpenBrace") + addParam.ImageKey = "EmptyBraces"; + else + addParam.ImageKey = "CloseBrace"; + addParam.ForeColor = Color.Gray; + item.Items.Add (addParam); + addParameterItems[method] = addParam; + } + + protected IAmbience GetAmbience() + { + IAmbience ambience = null; + + try + { + ambience = AmbienceService.CurrentAmbience; + } + catch (NullReferenceException) + { + ambience = ICSharpCode.SharpDevelop.Dom.CSharp.CSharpAmbience.Instance; + } + + ambience.ConversionFlags = ConversionFlags.None; + + return ambience; + } + + private static TextEditorControl GetTextEditorControl() + { + TextEditorControl control1 = null; + IWorkbenchWindow window1 = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; + if ((window1 != null) && (window1.ViewContent is ITextEditorControlProvider)) + { + control1 = ((ITextEditorControlProvider) window1.ViewContent).TextEditorControl; + } + return control1; + } + } + + public class IMemberEventArgs : EventArgs + { + IMember member; + + public IMemberEventArgs(IMember member) + { + this.member = member; + } + + public IMember Member + { + get { return member; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.csproj b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.csproj new file mode 100644 index 0000000000..34e3fe6d68 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.csproj @@ -0,0 +1,74 @@ + + + Library + ClassEditor + ClassEditor + Debug + AnyCPU + {F5E059BB-96C2-4398-BED0-8598CD434173} + + + bin\Debug\ + False + DEBUG;TRACE + True + Full + True + + + bin\Release\ + True + TRACE + False + None + False + + + + + + + + + + + GlobalAssemblyInfo.cs + + + + ClassEditor.cs + + + + ClassEditor.cs + + + + + + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} + ICSharpCode.TextEditor + False + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + False + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + False + + + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} + ICSharpCode.SharpDevelop.Dom + False + + + {B08385CD-F0CC-488C-B4F4-EEB34B6D2688} + TreeListView + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.resx b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.resx new file mode 100644 index 0000000000..65b73a8485 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/ClassEditor.resx @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAAAAAADEDgAAxA4AABAAAAAQAAAAAAAA/wAA + gP8AgAD/AICA/4AAAP+AAID/gIAA/4CAgP/AwMD/AAD//wD/AP8A/////wAA//8A/////wD///////// + ////////////8I/////////4CP////////8H/////////wD/////////AP////////8A/////////wD/ + ////////AP////////8A/////////wD/////////AP////////8H////////+Aj////////wj/////// + //////// + + + + + Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAAAAAADEDgAAxA4AABAAAAAQAAAAAAAA/wAA + gP8AgAD/AICA/4AAAP+AAID/gIAA/4CAgP/AwMD/AAD//wD/AP8A/////wAA//8A/////wD///////// + ////////////8A//////////AP////////8A//////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + //////// + + + + + Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAAAAAADEDgAAxA4AABAAAAAQAAAAAAAA/wAA + gP8AgAD/AICA/4AAAP+AAID/gIAA/4CAgP/AwMD/AAD//wD/AP8A/////wAA//8A/////wD///////// + ////////////+A////////+Aj////////3D/////////AP////////8A/////////wD/////////AP// + //////8A/////////wD/////////AP////////8A/////////3D/////////gI/////////4D/////// + //////// + + + + + Qk32AAAAAAAAAHYAAAAoAAAAEAAAABAAAAABAAQAAAAAAAAAAADEDgAAxA4AABAAAAAQAAAAAAAA/wAA + gP8AgAD/AICA/4AAAP+AAID/gIAA/4CAgP/AwMD/AAD//wD/AP8A/////wAA//8A/////wD///////// + //////////+A//8I////+Aj//4CP///3D///8H////AP///wD///8A////AP///wD///8A////AP///w + D///8A////AP///wD///8A////AP///wD///8A////AP///3D///8H////gI//+Aj////4D//wj///// + //////// + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/MembersList.cs b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/MembersList.cs new file mode 100644 index 0000000000..fe7108ec12 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/MembersList.cs @@ -0,0 +1,55 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop; + +namespace ClassDiagram +{ + /// + /// Description of MembersList. + /// + public class MembersList where MT : IMember + { + TreeListViewItem titleItem; + TreeListViewItem addNewMember; + TreeListView treeListView; + + public MembersList(string title, ICollection members, TreeListView tlv) + { + treeListView = tlv; + + + titleItem = tlv.Items.Add(title); + + //tlv.SmallImageList = ClassBrowserIconService.ImageList; + + if (members != null && members.Count != 0) + { + foreach (IMember member in members) + { + int icon = ClassBrowserIconService.GetIcon(member); + TreeListViewItem methodItem = titleItem.Items.Add(member.Name, icon); + } + } + + addNewMember = titleItem.Items.Add("[Add]"); + } + + private void ItemActivated (object sender, EventArgs e) + { + + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/closebrace.bmp b/src/AddIns/DisplayBindings/ClassDiagram/ClassEditor/closebrace.bmp new file mode 100644 index 0000000000000000000000000000000000000000..1cff75e35cf3a8a06ea9f6ca2d054c2e2141bce3 GIT binary patch literal 246 zcmZ?r{l)+RWk5;;hy|dSk%0v)(Eui~5kMJ`WJ3dl0+K)`5H~O!IB)*r7B`5xF$f9GJN +// +// +// +// $Revision$ +// + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following +// attributes. +// +// change them to the information which is associated with the assembly +// you compile. + +[assembly: AssemblyTitle("DiagramRouter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/BaseRectangle.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/BaseRectangle.cs new file mode 100644 index 0000000000..9fa248c4a0 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/BaseRectangle.cs @@ -0,0 +1,185 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace Tools.Diagrams +{ + public abstract class BaseRectangle : IRectangle + { + private float x, y; + private float w = float.NaN, h = float.NaN; + private float b, p; + private float aw = float.NaN, ah = float.NaN; + private bool ar = false; + + private IRectangle container; + + public IRectangle Container + { + get { return container; } + set { container = value; } + } + + #region Geometry + + public virtual float X + { + get { return x; } + set { x = value; } + } + + public virtual float Y + { + get { return y; } + set { y = value; } + } + + public virtual float AbsoluteX + { + get + { + if (container != null) + return container.AbsoluteX + X; + else + return X; + } + } + + public virtual float AbsoluteY + { + get + { + if (container != null) + return container.AbsoluteY + Y; + else + return Y; + } + } + + public virtual float ActualWidth + { + get { return aw; } + set + { + aw = value; + if (ar) + ah = aw * (GetAbsoluteContentHeight() / GetAbsoluteContentWidth()); + OnActualSizeChanged(); + OnActualWidthChanged(); + } + } + + public virtual float ActualHeight + { + get { return ah; } + set + { + ah = value; + if (ar) + aw = ah * (GetAbsoluteContentWidth() / GetAbsoluteContentHeight()); + OnActualSizeChanged(); + OnActualHeightChanged(); + } + } + + public virtual float Width + { + get { return w; } + set + { + w = value; + OnSizeChanged(); + OnWidthChanged(); + } + } + + public virtual float Height + { + get { return h; } + set + { + h = value; + OnSizeChanged(); + OnHeightChanged(); + } + } + + #endregion + + public virtual float Border + { + get { return b; } + set { b = value; } + } + + public virtual float Padding + { + get { return p; } + set { p = value; } + } + + public virtual float GetAbsoluteContentWidth() + { + if (float.IsNaN(w) || w < 0) + return 0; + return w; + } + + public virtual float GetAbsoluteContentHeight() + { + if (float.IsNaN(h) || h < 0) + return 0; + return h; + } + + public bool KeepAspectRatio + { + get { return ar; } + set { ar = value; } + } + + protected virtual void OnSizeChanged() {} + protected virtual void OnWidthChanged() + { + WidthChanged(this, EventArgs.Empty); + } + + protected virtual void OnHeightChanged() + { + HeightChanged(this, EventArgs.Empty); + } + + protected virtual void OnActualSizeChanged() {} + + protected virtual void OnActualWidthChanged() + { + ActualWidthChanged(this, EventArgs.Empty); + } + + protected virtual void OnActualHeightChanged() + { + ActualHeightChanged(this, EventArgs.Empty); + } + + public virtual bool IsHResizable + { + get { return true; } + } + + public virtual bool IsVResizable + { + get { return true; } + } + + public event EventHandler WidthChanged = delegate {}; + public event EventHandler HeightChanged = delegate {}; + public event EventHandler ActualWidthChanged = delegate {}; + public event EventHandler ActualHeightChanged = delegate {}; + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTree.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTree.cs new file mode 100644 index 0000000000..00a73c0888 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTree.cs @@ -0,0 +1,126 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace Tools.Diagrams +{ + public class DependencyTree where T : class, IEquatable + { + DependencyTreeNode root = new DependencyTreeNode(default(T)); + + public DependencyTree() { } + + public static DependencyTreeNode FindNode (DependencyTreeNode root, Predicate> predicate) + { + if (predicate(root)) return root; + DependencyTreeNode ret = null; + foreach (DependencyTreeNode node in root.Dependants) + { + ret = FindNode(node, predicate); + if (ret != null) break; + } + return ret; + } + + public static DependencyTreeNode FindNode (DependencyTreeNode root, Predicate predicate) + { + return FindNode(root, delegate (DependencyTreeNode item) { return predicate (item.Item); } ); + } + + public static DependencyTreeNode FindNode (DependencyTreeNode root, T item) + { + if (item == null) return null; + return FindNode(root, delegate (T nodeItem) + { + bool ret = (item.Equals(nodeItem)); + return ret; + } ); + } + + public static void WalkTreeRootFirst (DependencyTreeNode root, Action> action) + { + action(root); + foreach (DependencyTreeNode node in root.Dependants) + WalkTreeRootFirst(node, action); + } + + public static void WalkTreeRootFirst (DependencyTreeNode root, Action action) + { + WalkTreeRootFirst (root, delegate (DependencyTreeNode item) { action(item.Item); }); + } + + public static void WalkTreeChildrenFirst (DependencyTreeNode root, Action> action) + { + foreach (DependencyTreeNode node in root.Dependants) + WalkTreeChildrenFirst(node, action); + action(root); + } + + public static void WalkTreeChildrenFirst (DependencyTreeNode root, Action action) + { + WalkTreeChildrenFirst (root, delegate (DependencyTreeNode item) { action(item.Item); }); + } + + public DependencyTreeNode FindNode (Predicate predicate) + { + return FindNode(root, predicate); + } + + public DependencyTreeNode FindNode (T item) + { + if (item == null) return null; + return FindNode(root, item); + } + + public void WalkTreeRootFirst (Action action) + { + WalkTreeRootFirst (root, action); + } + + public void WalkTreeRootFirst (Action> action) + { + WalkTreeRootFirst (root, action); + } + + public void WalkTreeChildrenFirst (Action action) + { + WalkTreeChildrenFirst (root, action); + } + + public void WalkTreeChildrenFirst (Action> action) + { + WalkTreeChildrenFirst (root, action); + } + + public void AddDependency (T item, T dependency) + { + DependencyTreeNode depNode = null; + + if (dependency == null) + depNode = root; + else + depNode = FindNode(dependency); + + DependencyTreeNode itemNode = FindNode(item); + + if (depNode == null) + depNode = root.AddDependency(dependency); + + if (itemNode == null) + depNode.AddDependency(item); + else if (dependency != null) + itemNode.Reparent(depNode); + } + + public DependencyTreeNode Root + { + get { return root; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTreeNode.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTreeNode.cs new file mode 100644 index 0000000000..cb91205c79 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DependencyTreeNode.cs @@ -0,0 +1,81 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace Tools.Diagrams +{ + public class DependencyTreeNode + { + private T item; + private DependencyTreeNode parentNode; + private List> dependants = new List>(); + + private DependencyTreeNode(T item, DependencyTreeNode parent) + { + this.item = item; + parentNode = parent; + } + + public DependencyTreeNode(T item) + { + this.item = item; + } + + public T Item + { + get { return item; } + } + + public DependencyTreeNode ParentNode + { + get { return parentNode; } + } + + public DependencyTreeNode AddDependency (T item) + { + DependencyTreeNode node = new DependencyTreeNode(item, this); + dependants.Add (node); + return node; + } + + public void Reparent (DependencyTreeNode parent) + { + parent.dependants.Add(this); + this.parentNode.dependants.Remove(this); + this.parentNode = parent; + } + + public bool IsLeaf + { + get { return dependants.Count == 0; } + } + + public int ChildrenCount + { + get { return dependants.Count; } + } + + public int LeafsCount + { + get + { + int count = 0; + foreach (DependencyTreeNode node in dependants) + if (node.IsLeaf) + count++; + return count; + } + } + + public List > Dependants + { + get { return dependants; } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DiagramRouter.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DiagramRouter.cs new file mode 100644 index 0000000000..e135bfa063 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/DiagramRouter.cs @@ -0,0 +1,269 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace Tools.Diagrams +{ + public class DiagramRouter + { + private IList rects = new List(); + private List routes = new List(); + + private const float XSpacing = 40; + private const float YSpacing = 40; + + private class IRectangleSizeDecorator : IEquatable + { + private IRectangle rect; + + private float size; + private float childrenSize; + private float summedSize; + private float x; + private float y; + private float width; + private float height; + + public IRectangleSizeDecorator (IRectangle rect) + { + this.rect = rect; + } + + public float Size + { + get { return size; } + set { size = value; } + } + + public float SummedSize + { + get { return summedSize; } + set { summedSize = value; } + } + + public float ChildrenSize + { + get { return childrenSize; } + set { childrenSize = value; } + } + + public float X + { + get { return x; } + set { x = value; } + } + + public float Y + { + get { return y; } + set { y = value; } + } + + public float Width + { + get { return width; } + set { width = value; } + } + + public float Height + { + get { return height; } + set { height = value; } + } + + public IRectangle Rectangle + { + get { return rect; } + } + + public bool Equals(IRectangleSizeDecorator other) + { + if (other == null) return false; + return rect.Equals(other.Rectangle); + } + } + + public IList Rectangles + { + get { return rects; } + } + + public void AddItem (IRectangle item) + { + rects.Add(item); + } + + public void RemoveItem (IRectangle item) + { + rects.Remove(item); + } + + public Route AddRoute (IRectangle from, IRectangle to) + { + Route route = new Route (from, to); + routes.Add(route); + return route; + } + + public void RemoveRoute (Route route) + { + routes.Remove(route); + } + + private DependencyTree BuildDependenciesTree () + { + DependencyTree deps = new DependencyTree(); + foreach (Route r in routes) + { + deps.AddDependency(new IRectangleSizeDecorator(r.From), + new IRectangleSizeDecorator(r.To)); + } + + foreach (IRectangle r in rects) + { + deps.AddDependency(new IRectangleSizeDecorator(r), deps.Root.Item); + } + + return deps; + } + + public void RecalcPositions () + { + DependencyTree deps = BuildDependenciesTree(); + + // 1. Make sure each node's initial size is the same as its rectangle size. + deps.WalkTreeRootFirst(CopyPhysicalSize); + + // 2. Arrange the nodes in groups with known width and height. + deps.WalkTreeChildrenFirst(ArrangeNodes); + + // 3. Calculate the physical size of all the nodes. + // Treat the nodes decendants as part of the node itself. + //deps.WalkTreeChildrenFirst(CalcPhysicalSizeRecursive); + + // 4. Sort everything by its physical size. + //deps.WalkTreeChildrenFirst(SortByPhysicalSize); + + // 5. Set the positions of the nodes. + deps.WalkTreeRootFirst(SetupPositions); + + deps.WalkTreeRootFirst(MoveSubTreeByParentPosition); + float y = 0; + foreach (DependencyTreeNode group in deps.Root.Dependants) + { + if (group.Item == null) continue; + MoveSubTreeBy(group, 0, y); + y += group.Item.Height + YSpacing; + } + } + + private void CopyPhysicalSize(IRectangleSizeDecorator rect) + { + if (rect == null) return; + if (rect.Rectangle == null) return; + rect.Width = rect.Rectangle.ActualWidth; + rect.Height = rect.Rectangle.ActualHeight; + } + + private void ArrangeNodes(DependencyTreeNode rectNode) + { + // Don't handle leafs directly. Let their parent arrange them. + if (rectNode.IsLeaf) return; + if (rectNode.Item == null) return; + + float x = XSpacing; + rectNode.Item.X = XSpacing; + rectNode.Item.Y = YSpacing; + float h = rectNode.Item.Height; + foreach (DependencyTreeNode node in rectNode.Dependants) + { + node.Item.X = x; + node.Item.Y = YSpacing; + x += node.Item.Width + XSpacing; + h = Math.Max (h, rectNode.Item.Height + YSpacing + node.Item.Height); + } + rectNode.Item.Height = h; + rectNode.Item.Width = Math.Max (x - XSpacing, rectNode.Item.Width); + } + + private void MoveSubTreeByParentPosition (DependencyTreeNode rectNode) + { + if (rectNode.Item == null) return; + foreach (DependencyTreeNode node in rectNode.Dependants) + MoveSubTreeBy(node, rectNode.Item.X - XSpacing, rectNode.Item.Y - YSpacing); + } + + private void MoveSubTreeBy (DependencyTreeNode root, float x, float y) + { + DependencyTree.WalkTreeRootFirst( + root, + delegate (IRectangleSizeDecorator rect) + { + if (rect == null) return; + rect.Rectangle.X += x; + rect.Rectangle.Y += y; + }); + } + + private void CalcPhysicalSizeRecursive(DependencyTreeNode rectNode) + { + rectNode.Item.Size = (rectNode.Item.Rectangle.ActualWidth + XSpacing) * (rectNode.Item.Rectangle.ActualHeight + YSpacing); + rectNode.Item.ChildrenSize = 0; + rectNode.Item.SummedSize = rectNode.Item.Size; + foreach(DependencyTreeNode dn in rectNode.Dependants) + { + rectNode.Item.ChildrenSize += dn.Item.Size; + rectNode.Item.SummedSize += dn.Item.SummedSize; + } + } + + private void SetupPositions(DependencyTreeNode rectNode) + { + if (rectNode.Item == null) return; + if (rectNode.Item.Rectangle == null) return; + + if (rectNode.ParentNode != null && rectNode.ParentNode.Item != null) + { + IRectangle parent = rectNode.ParentNode.Item.Rectangle; + rectNode.Item.Rectangle.Y = parent.Y + parent.ActualHeight + YSpacing; + rectNode.Item.Rectangle.X = rectNode.Item.X; + } + else + { + rectNode.Item.Rectangle.X = XSpacing; + rectNode.Item.Rectangle.Y = YSpacing; + } + } + + private void SortByPhysicalSize(DependencyTreeNode rectNode) + { + rectNode.Dependants.Sort(ComparePairValue); + } + + private int ComparePairValue ( + DependencyTreeNode a, + DependencyTreeNode b) + { + return a.Item.SummedSize.CompareTo(b.Item.SummedSize); + } + + public void RecalcRoutes () + { + + } + + public Route[] Routes + { + get + { + return routes.ToArray(); + } + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Diagrams.csproj b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Diagrams.csproj new file mode 100644 index 0000000000..361d02226f --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Diagrams.csproj @@ -0,0 +1,56 @@ + + + Library + DiagramRouter + Diagrams + Debug + AnyCPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} + + + bin\Debug\ + False + DEBUG;TRACE + True + Full + True + + + bin\Release\ + True + TRACE + False + None + False + + + + + + + + + GlobalAssemblyInfo.cs + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Direction.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Direction.cs new file mode 100644 index 0000000000..9830831958 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Direction.cs @@ -0,0 +1,15 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace Tools.Diagrams +{ + public enum Direction { Up, Right, Down, Left }; +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableItemsStack.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableItemsStack.cs new file mode 100644 index 0000000000..110e03ead7 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableItemsStack.cs @@ -0,0 +1,35 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +using System.Reflection; + +using System.Drawing; +using System.Drawing.Drawing2D; + + +using System.Xml; +using Tools.Diagrams; + +namespace Tools.Diagrams.Drawables +{ + public class DrawableItemsStack : DrawableItemsStack {} + + public class DrawableItemsStack + : ItemsStack, IDrawableRectangle + where T : IDrawableRectangle + { + public void DrawToGraphics(Graphics graphics) + { + Recalculate(); + foreach (IDrawable d in this) + d.DrawToGraphics(graphics); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableRectangle.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableRectangle.cs new file mode 100644 index 0000000000..ce9e373537 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/DrawableRectangle.cs @@ -0,0 +1,83 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using Tools.Diagrams; + +namespace Tools.Diagrams.Drawables +{ + public class DrawableRectangle : BaseRectangle, IDrawableRectangle + { + private Brush fillBrush; + private Pen strokePen; + private float tlRad, trRad, brRad, blRad; + private GraphicsPath path; + + public DrawableRectangle (Brush fill, Pen stroke) + : this (fill, stroke, 1, 1, 1, 1) + { + } + + public DrawableRectangle (Brush fill, Pen stroke, float tl, float tr, float br, float bl) + { + fillBrush = fill; + strokePen = stroke; + tlRad = tl; + trRad = tr; + brRad = br; + blRad = bl; + } + + public Brush FillBrush + { + get { return fillBrush; } + set { fillBrush = value; } + } + + public Pen StrokePen + { + get { return strokePen; } + set { strokePen = value; } + } + + protected override void OnActualSizeChanged() + { + path = null; + } + + protected override void OnSizeChanged() + { + path = null; + } + + private void RecreatePath() + { + path = new GraphicsPath(); + path.AddArc(AbsoluteX, AbsoluteY, tlRad, tlRad, 180, 90); + path.AddArc(AbsoluteX + ActualWidth-trRad, AbsoluteY, trRad, trRad, 270, 90); + path.AddArc(AbsoluteX + ActualWidth-brRad, AbsoluteY + ActualHeight-brRad, brRad, brRad, 0, 90); + path.AddArc(AbsoluteX, AbsoluteY + ActualHeight-blRad, blRad, blRad, 90, 90); + path.CloseFigure(); + } + + public void DrawToGraphics(Graphics graphics) + { + if (graphics == null) return; + if (path == null) RecreatePath(); + + if (fillBrush != null) + graphics.FillPath(fillBrush, path); + + if (strokePen != null) + graphics.DrawPath(strokePen, path); + } + } +} + diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/HeaderedItem.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/HeaderedItem.cs new file mode 100644 index 0000000000..96d813397c --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/HeaderedItem.cs @@ -0,0 +1,166 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +using Tools.Diagrams; + +namespace Tools.Diagrams.Drawables +{ + public class HeaderedItem : BaseRectangle, IDrawableRectangle + { + bool collapsed; + IDrawableRectangle headerExpanded; + IDrawableRectangle content; + IDrawableRectangle headerCollapsed; + + public event EventHandler RedrawNeeded = delegate {}; + + public HeaderedItem(IDrawableRectangle headerCollapsed, + IDrawableRectangle headerExpanded, + IDrawableRectangle content) + { + this.headerCollapsed = headerCollapsed; + this.headerExpanded = headerExpanded; + this.content = content; + + headerCollapsed.Container = this; + headerExpanded.Container = this; + content.Container = this; + + headerCollapsed.X = 0; + headerCollapsed.Y = 0; + + headerExpanded.X = 0; + headerExpanded.Y = 0; + + content.X = 0; + content.Y = headerExpanded.GetAbsoluteContentHeight(); + + headerExpanded.HeightChanged += delegate { content.Y = headerExpanded.GetAbsoluteContentHeight(); }; + } + + protected IDrawableRectangle HeaderCollapsed + { + get { return headerCollapsed; } + } + + protected IDrawableRectangle HeaderExpanded + { + get { return headerExpanded; } + } + + protected IDrawableRectangle Content + { + get { return content; } + } + + public bool Collapsed + { + get { return collapsed; } + set + { + collapsed = value; + FireRedrawNeeded(); + } + } + + protected void FireRedrawNeeded() + { + RedrawNeeded(this, EventArgs.Empty); + } + + #region Geometry + + public override float ActualHeight + { + get { return GetAbsoluteContentHeight(); } + set { base.Height = value; } + } + + public override float ActualWidth + { + get { return GetAbsoluteContentWidth(); } + set { base.Width = value; } + } + + protected override void OnWidthChanged() + { + headerCollapsed.Width = base.Width; + headerExpanded.Width = base.Width; + content.Width = base.Width; + } + + protected override void OnHeightChanged() + { + headerCollapsed.Height = headerCollapsed.GetAbsoluteContentHeight(); + headerExpanded.Height = headerExpanded.GetAbsoluteContentHeight(); + content.Height = content.GetAbsoluteContentHeight(); + } + + protected override void OnActualWidthChanged() + { + headerCollapsed.ActualWidth = base.ActualWidth; + headerExpanded.ActualWidth = base.ActualWidth; + content.ActualWidth = base.ActualWidth; + } + + protected override void OnActualHeightChanged() + { + headerCollapsed.ActualHeight = headerCollapsed.GetAbsoluteContentHeight(); + headerExpanded.ActualHeight = headerExpanded.GetAbsoluteContentHeight(); + content.ActualHeight = content.GetAbsoluteContentHeight(); + } + + #endregion + + public void DrawToGraphics(Graphics graphics) + { + if (!collapsed) + { + //TODO - add orientation, so the header could also be on the side. + headerExpanded.DrawToGraphics(graphics); + content.DrawToGraphics(graphics); + } + else + { + headerCollapsed.DrawToGraphics(graphics); + } + } + + public override float GetAbsoluteContentWidth() + { + float width = 0; + if (!collapsed) + { + width = Math.Max(width, headerExpanded.GetAbsoluteContentWidth()); + width = Math.Max(width, content.GetAbsoluteContentWidth()); + } + else + width = headerCollapsed.GetAbsoluteContentWidth(); + + return width; + } + + public override float GetAbsoluteContentHeight() + { + float height = 0; + if (!collapsed) + { + height = headerExpanded.GetAbsoluteContentHeight(); + height += content.GetAbsoluteContentHeight(); + } + else + { + height = headerCollapsed.GetAbsoluteContentHeight(); + } + return height; + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawable.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawable.cs new file mode 100644 index 0000000000..c36e38a53e --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawable.cs @@ -0,0 +1,17 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Drawing; + +namespace Tools.Diagrams.Drawables +{ + public interface IDrawable + { + void DrawToGraphics (Graphics graphics); + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawableRectangle.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawableRectangle.cs new file mode 100644 index 0000000000..40b4dcde77 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/IDrawableRectangle.cs @@ -0,0 +1,17 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Tools.Diagrams; + +namespace Tools.Diagrams.Drawables +{ + public interface IDrawableRectangle : IDrawable, IRectangle + { + + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/TextSegment.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/TextSegment.cs new file mode 100644 index 0000000000..693f8409dd --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Drawables/TextSegment.cs @@ -0,0 +1,126 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace Tools.Diagrams.Drawables +{ + public class TextSegment : BaseRectangle, IDrawableRectangle, IDisposable + { + float tw; + Font font; + Brush brush = Brushes.Black; + Graphics g; + string text; + StringFormat sf = new StringFormat(); + + public TextSegment (Graphics graphics, string text) + : this (graphics, text, new Font(System.Drawing.FontFamily.GenericSansSerif, 10.0f), false) + { + } + + public TextSegment (Graphics graphics, string text, Font font, bool resizable) + { + if (graphics == null) throw new ArgumentNullException("graphics"); + this.g = graphics; + this.text = text; + this.font = font; + sf.Trimming = StringTrimming.EllipsisCharacter; + MeasureString(); + if (resizable) + Width = -1; + else + Width = float.NaN; + } + + private void MeasureString () + { + if (text != null && font != null && g != null) + tw = g.MeasureString(text, font).Width; + else + tw = float.NaN; + } + + public override float Width + { + get + { + if (float.IsNaN(base.Width)) return tw; + return base.Width; + } + set { base.Width = value; } + } + + public float TextWidth + { + get { return tw; } + } + + public override float Height + { + get { return font.Size * 1.2f; } + set {} + } + + public override float ActualHeight + { + get { return Height; } + set { base.ActualHeight = value; } + } + + public string Text + { + get { return text; } + set + { + text = value; + MeasureString(); + } + } + + public Font Font + { + get { return font; } + set + { + font = value; + MeasureString(); + } + } + + public Brush Brush + { + get { return brush; } + set { brush = value; } + } + + public void DrawToGraphics (Graphics graphics) + { + if (graphics == null) return; + RectangleF rect = new RectangleF(AbsoluteX, AbsoluteY, ActualWidth, ActualHeight); + graphics.DrawString(Text, Font, Brush, rect, sf); + } + + public void Dispose() + { + brush.Dispose(); + sf.Dispose(); + } + + public override float GetAbsoluteContentWidth() + { + return TextWidth + 20; + } + + public override float GetAbsoluteContentHeight() + { + return Height; + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/IRectangle.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/IRectangle.cs new file mode 100644 index 0000000000..65063d438e --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/IRectangle.cs @@ -0,0 +1,118 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace Tools.Diagrams +{ + public interface IRectangle + { + /// + /// The X position of the rectangular item, relative to its container. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "X")] + float X { get; set; } + + /// + /// The Y position of the rectangular item, relative to its container. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Y")] + float Y { get; set; } + + + /// + /// The X position of the rectangular item, relative to the root container. + /// + float AbsoluteX { get; } + + /// + /// The Y position of the rectangular item, relative to the root container. + /// + float AbsoluteY { get; } + + /// + /// The visible width of the item. + /// Layout managers such as ItemsStack change this value to define the width of + /// the item. + /// The value returned from this property must a positive decimal or zero, and must never + /// be NaN or infinite. + /// + float ActualWidth { get; set; } + + /// + /// The visible height of the item. + /// Layout managers such as ItemsStack change this value to define the height of + /// the item. + /// The value returned from this property must a positive decimal or zero, and must never + /// be NaN or infinite. + /// + float ActualHeight { get; set; } + + /// + /// The defined width of the item. + /// + /// + /// A negative value means the the width is undefined, and is due to change by + /// layout managers, such as ItemsStack. In that case, ActualWidth is set to the + /// wanted value minus twice the border size. + /// + float Width { get; set; } + + /// + /// The defined height of the item. + /// + /// + /// A negative value means the the height is undefined, and is due to change by + /// layout managers, such as ItemsStack. In that case, ActualHeight is set to the + /// wanted value minus twice the border size. + /// + float Height { get; set; } + + /// + /// The distance between the item borders to its container's content borders. + /// + float Border { get; set; } + + /// + /// The distance between the item borders to its content. + /// + float Padding { get; set; } + + /// + /// The width of the item content disregarding defined of visible modifying values, + /// such as border or width. + /// The value returned must a positive decimal or zero, and must never + /// be NaN or infinite. + /// + float GetAbsoluteContentWidth (); + + /// + /// The height of the item content disregarding defined of visible modifying values, + /// such as border or height. + /// The value returned must a positive decimal or zero, and must never + /// be NaN or infinite. + /// + float GetAbsoluteContentHeight (); + + bool KeepAspectRatio { get; set; } + + /// + /// If the implementing object is contained within another rectangle, + /// this property points to the container. + /// + IRectangle Container { get; set; } + + bool IsHResizable { get; } + bool IsVResizable { get; } + + event EventHandler WidthChanged; + event EventHandler HeightChanged; + event EventHandler ActualWidthChanged; + event EventHandler ActualHeightChanged; + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/ItemsStack.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/ItemsStack.cs new file mode 100644 index 0000000000..6db5875480 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/ItemsStack.cs @@ -0,0 +1,410 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; + +namespace Tools.Diagrams +{ + public enum Axis {X, Y, Z}; + + public class ItemsStack : ItemsStack {} + + public class ItemsStack : BaseRectangle where T : IRectangle + { + List items = new List(); + Axis axis = Axis.Y; + bool dontHandleResize; + + public ItemsStack() + { + dontHandleResize = true; + base.Width = float.NaN; + base.Height = float.NaN; + dontHandleResize = false; + } + + float minWidth = 0, minHeight = 0; + float spacing = 0; + bool modified = false; + + public void Add (T item) + { + items.Add(item); + item.Container = this; + modified = true; + } + + public void Remove (T item) + { + items.Remove(item); + item.Container = null; + modified = true; + } + + public void Clear() + { + items.Clear(); + modified = true; + } + + public Axis OrientationAxis + { + get { return axis; } + set + { + axis = value; + modified = true; + } + } + + #region Width Calculations + + private float FindHeight() + { + if (!float.IsNaN(base.Height) || base.Height < 0) return base.Height; + if (!float.IsNaN(base.ActualHeight) || base.ActualHeight < 0) return base.ActualHeight; + float h = 0; + foreach (IRectangle r in items) + if (!float.IsNaN(r.ActualHeight) && r.ActualHeight >= 0) + h = Math.Max(h, r.ActualHeight); + return h; + } + + private bool IsItemWidthValid(IRectangle r) + { + bool ret = true; + if (float.IsNaN(r.Width) || r.Width < 0) + { + if (!r.KeepAspectRatio) + ret = false; + } + return ret; + } + + private float CalcUsedWidthSpace() + { + float usedSpace = 0.0f; + + foreach (IRectangle r in items) + { + if (IsItemWidthValid(r)) + usedSpace += (r.ActualWidth + spacing); + } + + return usedSpace; + } + + private float CalcWidthPerUndefined() + { + float width = base.ActualWidth; + + if (float.IsNaN(width) || width < 0) + width = base.Width; + + if (float.IsNaN(width) || width < 0) + return 0; + + int count = 0; + foreach (IRectangle r in items) + if (!IsItemWidthValid(r)) + count++; + if (count == 0) return 0; + + float usedSpace = CalcUsedWidthSpace(); + return (width - usedSpace - (count-1) * spacing) / count; + } + + private void HRecalc() + { + float x = Padding, w = Padding; + float h = Math.Max(FindHeight(), minHeight); + + foreach (IRectangle r in items) + r.ActualHeight = h - (r.Border + Padding) * 2; + + float spacePerUndefined = CalcWidthPerUndefined(); + + foreach (IRectangle r in items) + { + r.X = x + r.Border; + r.Y = r.Border + Padding; + + if (!IsItemWidthValid(r)) + r.ActualWidth = Math.Max(spacePerUndefined - r.Border * 2, 0); + + w += r.ActualWidth + spacing + r.Border * 2; + x = w; + } + + dontHandleResize = true; + base.ActualWidth = Math.Max(w - spacing, minWidth); + base.ActualHeight = h; + dontHandleResize = false; + } + + #endregion + + #region Height Calculations + + private float FindWidth() + { + if (!float.IsNaN(base.Width) || base.Width < 0) return base.Width; + if (!float.IsNaN(base.ActualWidth) || base.ActualWidth < 0) return base.ActualWidth; + float w = 0; + foreach (IRectangle r in items) + if (!float.IsNaN(r.ActualWidth) && r.ActualWidth >= 0) + w = Math.Max(w, r.ActualWidth); + return w; + } + + private bool IsItemHeightValid(IRectangle r) + { + bool ret = true; + if (float.IsNaN(r.Height) || r.Height < 0) + { + if (!r.KeepAspectRatio) + ret = false; + } + return ret; + } + + private float CalcUsedHeightSpace() + { + float usedSpace = 0; + + foreach (IRectangle r in items) + if (IsItemHeightValid(r)) + usedSpace += r.ActualHeight + spacing; + + return usedSpace; + } + + private float CalcHeightPerUndefined() + { + float height = base.ActualHeight; + + if (float.IsNaN(height) || height < 0) + height = base.Height; + + if (float.IsNaN(height) || height < 0) + return 0; + + int count = 0; + foreach (IRectangle r in items) + if (!IsItemHeightValid(r)) + count++; + if (count == 0) return 0; + + float usedSpace = CalcUsedHeightSpace(); + return(height - usedSpace - (count-1) * spacing) / count; + } + + private void VRecalc() + { + if (items.Count == 0) return; + + float y = Padding, h = Padding; + float w = Math.Max(FindWidth(), minWidth); + + foreach (IRectangle r in items) + r.ActualWidth = w - (r.Border + Padding) * 2; + + float spacePerUndefined = CalcHeightPerUndefined(); + + foreach (IRectangle r in items) + { + r.X = r.Border + Padding; + r.Y = y + r.Border; + + if (!IsItemHeightValid(r)) + r.ActualHeight = Math.Max (spacePerUndefined - r.Border * 2, 0); + + h += r.ActualHeight + spacing + r.Border * 2; + y = h; + } + + dontHandleResize = true; + base.ActualWidth = w; + base.ActualHeight = Math.Max(h - spacing + Padding, minHeight); + dontHandleResize = false; + } + + #endregion + + private void ZRecalc() + { + float w = Math.Max(FindWidth(), minWidth); + float h = Math.Max(FindHeight(), minHeight); + + foreach (IRectangle r in items) + { + r.X = r.Border + Padding; + r.Y = r.Border + Padding; + r.ActualWidth = w - (r.Border + Padding) * 2; + r.ActualHeight = h - (r.Border + Padding) * 2; + } + + dontHandleResize = true; + base.ActualWidth = w; + base.ActualHeight = h; + dontHandleResize = false; + } + + public void Recalculate() + { + if (!modified) return; + if (dontHandleResize) return; + + if (axis == Axis.X) + HRecalc(); + else if (axis == Axis.Y) + VRecalc(); + else if (axis == Axis.Z) + ZRecalc(); + + modified = false; + } + + protected override void OnActualSizeChanged() + { + modified = true; + } + + protected override void OnSizeChanged() + { + modified = true; + base.ActualWidth = float.NaN; + base.ActualHeight = float.NaN; + } + + #region Geometry + + public float MinHeight + { + get { return minHeight; } + set + { + minHeight = value; + modified = true; + } + } + + public float MinWidth + { + get { return minWidth; } + set + { + minWidth = value; + modified = true; + } + } + + public override float Width + { + get + { + Recalculate(); + return base.Width; + } + set { base.Width = value; } + } + + public override float Height + { + get + { + Recalculate(); + return base.Height; + } + set { base.Height = value; } + } + + public override float ActualWidth + { + get + { + Recalculate(); + return base.ActualWidth; + } + set { base.ActualWidth = value; } + } + + public override float ActualHeight + { + get + { + Recalculate(); + return base.ActualHeight; + } + set { base.ActualHeight = value; } + } + #endregion + + public float Spacing + { + get { return spacing; } + set + { + spacing = value; + modified = true; + } + } + + public IEnumerator GetEnumerator() + { + return items.GetEnumerator(); + } + + public int Count + { + get { return items.Count; } + } + + public override float GetAbsoluteContentWidth() + { + float w = 0; + if (axis == Axis.X || axis == Axis.Z) + { + foreach (T item in items) + w += item.GetAbsoluteContentWidth() + item.Border * 2 + spacing; + w = Math.Max(w - spacing, 0); + } + else if (axis == Axis.Y) + { + foreach (T item in items) + w = Math.Max(w, item.GetAbsoluteContentWidth() + item.Border * 2); + } + return w; + } + + public override float GetAbsoluteContentHeight() + { + float h = 0; + if (axis == Axis.X || axis == Axis.Z) + { + foreach (T item in items) + h = Math.Max(h, item.GetAbsoluteContentHeight() + item.Border * 2); + } + else if (axis == Axis.Y) + { + foreach (T item in items) + h += item.GetAbsoluteContentHeight() + item.Border * 2 + spacing; + h = Math.Max(h - spacing, 0); + } + return h; + } + + public override string ToString() + { + if (items.Count > 0) + return "ItemStack - first item: " + items[0].ToString(); + else + return base.ToString(); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Route.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Route.cs new file mode 100644 index 0000000000..24596c8a0b --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/Route.cs @@ -0,0 +1,294 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; + +namespace Tools.Diagrams +{ + public interface IRouteShape + { + + } + + public class Route + { + private IRectangle from; + private IRectangle to; + private LinkedList segments = new LinkedList(); + private IRouteShape startShape; + private IRouteShape endShape; + + private enum ConnectionPoint {North, East, South, West, Center}; + + public Route (IRectangle from, IRectangle to) + { + this.from = from; + this.to = to; + } + + public IRectangle From + { + get { return from; } + set { from = value; } + } + + public IRectangle To + { + get { return to; } + set { to = value; } + } + + public IRouteShape StartShape + { + get { return startShape; } + set { startShape = value; } + } + + public IRouteShape EndShape + { + get { return endShape; } + set { endShape = value; } + } + + private static PointF GetConnectionPointPosition (IRectangle rect, ConnectionPoint point) + { + switch (point) + { + case ConnectionPoint.North: return new PointF(rect.X + rect.ActualWidth / 2, rect.Y); + case ConnectionPoint.East: return new PointF(rect.X + rect.ActualWidth, rect.Y + rect.ActualHeight / 2); + case ConnectionPoint.South: return new PointF(rect.X + rect.ActualWidth / 2, rect.Y + rect.ActualHeight); + case ConnectionPoint.West: return new PointF(rect.X, rect.Y + rect.ActualHeight / 2); + } + return new PointF(rect.X + rect.ActualWidth / 2, rect.Y + rect.ActualHeight / 2); + } + + private void GetClosestConnectionPoints(out ConnectionPoint fromPoint, out ConnectionPoint toPoint) + { + float shortestDist = float.MaxValue; + float dist = shortestDist; + + fromPoint = ConnectionPoint.Center; + toPoint = ConnectionPoint.Center; + + for (int i = 0; i < 4; ++i) + { + PointF posF = GetConnectionPointPosition(from, (ConnectionPoint)i); + for (int j = 0; j < 4; ++j) + { + PointF posT = GetConnectionPointPosition(to, (ConnectionPoint)j); + float dx = posF.X - posT.X; + float dy = posF.Y - posT.Y; + dist = (dx*dx) + (dy*dy); + if (dist < shortestDist) + { + shortestDist = dist; + fromPoint = (ConnectionPoint)i; + toPoint = (ConnectionPoint)j; + } + } + } + } + + public PointF GetStartPoint() + { + ConnectionPoint startPoint = ConnectionPoint.Center; + ConnectionPoint endPoint = ConnectionPoint.Center; + + GetClosestConnectionPoints(out startPoint, out endPoint); + + return GetConnectionPointPosition(from, startPoint); + } + + public PointF GetEndPoint() + { + PointF p = GetStartPoint(); + foreach (RouteSegment seg in segments) + { + p = seg.CreateDestinationPoint(p); + } + return p; + } + + public Direction GetStartDirection() + { + return segments.First.Value.Direction; + } + + public Direction GetEndDirection() + { + return segments.Last.Value.Direction; + } + + public RouteSegment[] RouteSegments + { + get + { + RouteSegment[] rs = new RouteSegment[segments.Count]; + segments.CopyTo(rs, 0); + return rs; + } + } + + private IRectangle FindClosestObstacle (RouteSegment seg, PointF origin, IList rectangles) + { + IRectangle closestRect = null; + float minDist = float.MaxValue; + foreach (IRectangle rect in FindAllSegmentObstacles(seg, origin, rectangles)) + { + if (closestRect != null) + { + float dist = seg.IntersectionDistance(origin, rect); + if (minDist > dist) + { + minDist = dist; + closestRect = rect; + } + } + else + closestRect = rect; + } + return closestRect; + } + + private ICollection FindAllSegmentObstacles (RouteSegment seg, PointF origin, IList rectangles) + { + List obstacles = new List(); + foreach (IRectangle rect in rectangles) + { + if (seg.IntersectsWith(origin, rect)) + obstacles.Add(rect); + } + return obstacles; + } + + private ICollection FindAllRouteObstacles (IList rectangles) + { + PointF fromPoint = GetStartPoint(); + PointF p = fromPoint; + List allobstacles = new List(); + foreach (RouteSegment seg in segments) + { + ICollection rects = FindAllSegmentObstacles(seg, p, rectangles); + foreach (IRectangle rect in rects) + { + if (!allobstacles.Contains(rect)) + allobstacles.Add(rect); + } + p = seg.CreateDestinationPoint(p); + } + return allobstacles; + } + + private void FixRouteSegment (RouteSegment seg) + { + + } + + public void Recalc (IEnumerable rectangles) + { + segments.Clear(); + + ConnectionPoint startPoint = ConnectionPoint.Center; + ConnectionPoint endPoint = ConnectionPoint.Center; + + GetClosestConnectionPoints(out startPoint, out endPoint); + + PointF posF = GetConnectionPointPosition(from, startPoint); + PointF posT = GetConnectionPointPosition(to, endPoint); + + Direction dir1 = default (Direction); + Direction dir2 = default (Direction); + Direction dir3 = default (Direction); + + float l1 = 0; + float l2 = 0; + float l3 = 0; + + switch (startPoint) + { + case ConnectionPoint.North: dir1 = Direction.Up; break; + case ConnectionPoint.East: dir1 = Direction.Right; break; + case ConnectionPoint.South: dir1 = Direction.Down; break; + case ConnectionPoint.West: dir1 = Direction.Left; break; + } + + switch (endPoint) + { + case ConnectionPoint.North: dir3 = Direction.Down; break; + case ConnectionPoint.East: dir3 = Direction.Left; break; + case ConnectionPoint.South: dir3 = Direction.Up; break; + case ConnectionPoint.West: dir3 = Direction.Right; break; + } + + if ((dir1 == Direction.Down && dir3 == Direction.Up) || + (dir3 == Direction.Down && dir1 == Direction.Up)) + { + l1 = l3 = 20; + float h = Math.Abs(posF.Y - posT.Y); + if (posT.Y > posF.Y) + l3 += h; + else + l1 += h; + l2 = Math.Abs(posF.X - posT.X); + dir2 = (posT.X > posF.X) ? Direction.Right : Direction.Left; + } + else if ((dir1 == Direction.Left && dir3 == Direction.Right) || + (dir3 == Direction.Left && dir1 == Direction.Right)) + { + l1 = l3 = 20; + float w = Math.Abs(posF.X - posT.X); + if (posT.X > posF.X) + l3 += w; + else + l1 += w; + l2 = Math.Abs(posF.Y - posT.Y); + dir2 = (posT.Y > posF.Y) ? Direction.Down : Direction.Up; + } + else if ((dir1 == Direction.Down && dir3 == Direction.Down) || + (dir1 == Direction.Up && dir3 == Direction.Up)) + { + l1 = l3 = Math.Abs(posF.Y - posT.Y) / 2; + l2 = Math.Abs(posF.X - posT.X); + dir2 = (posT.X > posF.X) ? Direction.Right : Direction.Left; + } + else if ((dir1 == Direction.Left && dir3 == Direction.Left) || + (dir1 == Direction.Right && dir3 == Direction.Right)) + { + l1 = l3 = Math.Abs(posF.X - posT.X) / 2; + l2 = Math.Abs(posF.Y - posT.Y); + dir2 = (posT.Y > posF.Y) ? Direction.Down : Direction.Up; + } + else if ((dir1 == Direction.Left || dir1 == Direction.Right) && + (dir3 == Direction.Up || dir3 == Direction.Down)) + { + l1 = Math.Abs(posF.X - posT.X); + l3 = Math.Abs(posF.Y - posT.Y); + } + else if ((dir3 == Direction.Left || dir3 == Direction.Right) && + (dir1 == Direction.Up || dir1 == Direction.Down)) + { + l3 = Math.Abs(posF.X - posT.X); + l1 = Math.Abs(posF.Y - posT.Y); + } + + RouteSegment seg2 = null; + + RouteSegment seg1 = new RouteSegment(l1, dir1); + if (l2 > 0) + seg2 = new RouteSegment(l2, dir2); + RouteSegment seg3 = new RouteSegment(l3, dir3); + + segments.AddFirst(seg1); + if (seg2 != null) + segments.AddLast(seg2); + segments.AddLast(seg3); + } + } +} diff --git a/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/RouteSegment.cs b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/RouteSegment.cs new file mode 100644 index 0000000000..4a3eb9fcf8 --- /dev/null +++ b/src/AddIns/DisplayBindings/ClassDiagram/DiagramRouter/RouteSegment.cs @@ -0,0 +1,99 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Drawing; + +namespace Tools.Diagrams +{ + public class RouteSegment + { + private Direction direction; + private float length; + + public RouteSegment (float length, Direction direction) + { + this.length = length; + this.direction = direction; + } + + public Direction Direction + { + get { return direction; } + set { direction = value; } + } + + public float Length + { + get { return length; } + set { length = value; } + } + + public PointF CreateDestinationPoint (PointF origin) + { + PointF dest = new PointF (origin.X, origin.Y); + + switch (direction) + { + case Direction.Up: dest.Y -= length; break; + case Direction.Down: dest.Y += length; break; + case Direction.Left: dest.X -= length; break; + case Direction.Right: dest.X += length; break; + } + + return dest; + } + + public bool IntersectsWith (PointF origin, IRectangle rect) + { + PointF dest = CreateDestinationPoint(origin); + bool xIntersects = false; + bool yIntersects = false; + + if (direction == Direction.Left || direction == Direction.Right) + { + float y = origin.Y; + float x1 = Math.Min(origin.X, dest.X); + float x2 = Math.Max(origin.X, dest.X); + yIntersects = (rect.Y <= y && rect.Y + rect.ActualHeight >= y); + xIntersects = (x2 < rect.X || x1 > rect.X + rect.ActualWidth); + } + else + { + float x = origin.X; + float y1 = Math.Min(origin.Y, dest.Y); + float y2 = Math.Max(origin.Y, dest.Y); + xIntersects = (rect.X <= x && rect.X + rect.ActualWidth >= x); + yIntersects = (y2 < rect.Y || y1 > rect.Y + rect.ActualHeight); + } + return xIntersects && yIntersects; + } + + public float IntersectionDistance (PointF origin, IRectangle rect) + { + PointF dest = CreateDestinationPoint(origin); + float dist = -1; + switch (direction) + { + case Direction.Left: + dist = (origin.X - rect.X + rect.ActualWidth); + break; + case Direction.Right: + dist = rect.X - origin.X; + break; + case Direction.Up: + dist = (origin.Y - rect.Y + rect.ActualHeight); + break; + case Direction.Down: + dist = rect.Y - origin.Y; + break; + } + return dist; + } + } +} diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index 1a5cb1b304..8cc762c5d0 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -897,6 +897,21 @@ + + + + + + + + + + + + + + + @@ -1164,4 +1179,4 @@ - + \ No newline at end of file diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index 06b6f5ca1e..7edb1e1ec7 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -275,6 +275,8 @@ + + diff --git a/src/SharpDevelop.sln b/src/SharpDevelop.sln index 17c9b6656c..7a1143d828 100644 --- a/src/SharpDevelop.sln +++ b/src/SharpDevelop.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -# SharpDevelop 3.0.0.2190 +# SharpDevelop 2.1.0.2192 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}" ProjectSection(SolutionItems) = postProject EndProjectSection @@ -10,6 +10,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display ProjectSection(SolutionItems) = postProject EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{DB137F0B-9B62-4232-AE92-F7BE0280B8D3}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagrams", "AddIns\DisplayBindings\ClassDiagram\DiagramRouter\Diagrams.csproj", "{0991423A-DBF6-4C89-B365-A1DF1EB32E42}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramAddin", "AddIns\DisplayBindings\ClassDiagram\ClassDiagramAddin\ClassDiagramAddin.csproj", "{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassEditor", "AddIns\DisplayBindings\ClassDiagram\ClassEditor\ClassEditor.csproj", "{F5E059BB-96C2-4398-BED0-8598CD434173}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassCanvas", "AddIns\DisplayBindings\ClassDiagram\ClassCanvas\ClassCanvas.csproj", "{08F772A1-F0BE-433E-8B37-F6522953DB05}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IconEditor", "IconEditor", "{0D37CE59-B0EF-4F3C-B9EB-8557E53A448B}" @@ -406,6 +418,22 @@ Global {8C692BAF-108E-4346-B41E-6EE7D20E2E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8C692BAF-108E-4346-B41E-6EE7D20E2E9D}.Release|Any CPU.Build.0 = Release|Any CPU {8C692BAF-108E-4346-B41E-6EE7D20E2E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Release|Any CPU.Build.0 = Release|Any CPU + {08F772A1-F0BE-433E-8B37-F6522953DB05}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Release|Any CPU.Build.0 = Release|Any CPU + {F5E059BB-96C2-4398-BED0-8598CD434173}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Release|Any CPU.Build.0 = Release|Any CPU + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Release|Any CPU.Build.0 = Release|Any CPU + {0991423A-DBF6-4C89-B365-A1DF1EB32E42}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5} @@ -416,6 +444,11 @@ Global {6B717BD1-CD5E-498C-A42E-9E6A4584DC48} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} {85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} + {DB137F0B-9B62-4232-AE92-F7BE0280B8D3} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} + {08F772A1-F0BE-433E-8B37-F6522953DB05} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3} + {F5E059BB-96C2-4398-BED0-8598CD434173} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3} + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3} + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3} {DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B} {DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B} {1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C}