예제 #1
0
파일: CText.cs 프로젝트: bohning/Vocaluxe
        public CText()
        {
            _Theme = new SThemeText();
            _ThemeLoaded = false;
            _ButtonText = false;

            X = 0f;
            Y = 0f;
            Z = 0f;
            Height = 1f;
            MaxWidth = 0f;
            Bounds = new SRectF();
            Align = EAlignment.Left;
            Style = EStyle.Normal;
            Fon = "Normal";

            Color = new SColorF();
            SColor = new SColorF();
            Reflection = false;
            ReflectionSpace = 0f;
            ReflectionHeight = 0f;

            Text = String.Empty;
            Selected = false;
            Visible = true;
            Alpha = 1f;
        }
예제 #2
0
파일: CText.cs 프로젝트: bohning/Vocaluxe
        public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight)
        {
            _Theme = new SThemeText();
            _ThemeLoaded = false;
            _ButtonText = false;

            X = x;
            Y = y;
            Z = z;
            Height = h;
            MaxWidth = mw;
            Align = align;
            Style = style;
            Fon = font;

            Color = new SColorF(r, g, b, a);
            SColor = new SColorF(r, g, b, a);

            text = Text;

            Selected = false;

            if (MaxWidth > 0)
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, MaxWidth, 3f * CSettings.iRenderH, 0f);
            }
            else
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, 3f * CSettings.iRenderW, 3f * CSettings.iRenderH, 0f);
            }

            Reflection = true;
            ReflectionSpace = rspace;
            ReflectionHeight = rheight;
        }
예제 #3
0
        public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string fontFamily, SColorF col, string text, int partyModeID = -1,
                     float rheight = 0,
                     float rspace  = 0) : this(partyModeID)
        {
            _Theme = new SThemeText {
                FontFamily = fontFamily, FontStyle = style, FontHeight = h, Text = text, Color = { A = col.A, B = col.B, G = col.G, R = col.R }
            };
            ThemeLoaded = false;
            _ButtonText = false;

            MaxRect      = new SRectF(x, y, mw, h, z);
            Align        = align;
            ResizeAlign  = EHAlignment.Center;
            _Font.Name   = fontFamily;
            _Font.Style  = style;
            _Font.Height = h;

            Color    = col;
            SelColor = col;

            Text = text;

            Selected = false;

            _ReflectionSpace  = rspace;
            _ReflectionHeight = rheight;
        }
예제 #4
0
        public void LoadSkin()
        {
            if (!ThemeLoaded)
            {
                return;
            }
            _Theme.Color.Get(_PartyModeID, out Color);
            _Theme.SelColor.Get(_PartyModeID, out SelColor);

            X = _Theme.X;
            Y = _Theme.Y;
            if (!_ButtonText)
            {
                Z = _Theme.Z;
            }
            W            = _Theme.MaxWidth;
            H            = _Theme.FontHeight;
            _Align       = _Theme.Align;
            _ResizeAlign = _Theme.ResizeAlign;
            Font         = new CFont(_Theme.FontFamily, _Theme.FontStyle, _Theme.FontHeight);

            if (_Theme.Reflection.HasValue)
            {
                _ReflectionSpace  = _Theme.Reflection.Value.Space;
                _ReflectionHeight = _Theme.Reflection.Value.Height;
            }

            Text     = _Theme.Text;
            Selected = false;
        }
예제 #5
0
파일: cmdAlignOne.cs 프로젝트: mff-uk/xcase
        public cmdAlignOne(MainWindow mainWindow, Control control, EAlignment alignment)
            : base(mainWindow, control)
        {
            Alignment = alignment;

            MainWindow.DiagramSelectionChanged += delegate { OnCanExecuteChanged(null); };
        }
예제 #6
0
파일: CText.cs 프로젝트: zhaozw/Vocaluxe
        public CText(float x, float y, float z, EAlignment align, float h, float mw, float r, float g, float b, float a, EStyle style, string font, string text, float rspace, float rheight)
        {
            _Theme       = new SThemeText();
            _ThemeLoaded = false;
            _ButtonText  = false;

            X        = x;
            Y        = y;
            Z        = z;
            Height   = h;
            MaxWidth = mw;
            Align    = align;
            Style    = style;
            Fon      = font;

            Color  = new SColorF(r, g, b, a);
            SColor = new SColorF(r, g, b, a);

            Text = text;

            Selected = false;

            if (MaxWidth > 0)
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, MaxWidth, 3f * CSettings.iRenderH, 0f);
            }
            else
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, 3f * CSettings.iRenderW, 3f * CSettings.iRenderH, 0f);
            }

            Reflection       = true;
            ReflectionSpace  = rspace;
            ReflectionHeight = rheight;
        }
예제 #7
0
파일: CText.cs 프로젝트: zhaozw/Vocaluxe
        public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text)
        {
            _Theme       = new SThemeText();
            _ThemeLoaded = false;
            _ButtonText  = false;

            X        = x;
            Y        = y;
            Z        = z;
            Height   = h;
            MaxWidth = mw;
            Align    = align;
            Style    = style;
            Fon      = font;

            Color  = col;
            SColor = new SColorF(col);

            Text = text;

            Selected = false;

            if (MaxWidth > 0)
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, MaxWidth, 3f * CSettings.iRenderH, 0f);
            }
            else
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, 3f * CSettings.iRenderW, 3f * CSettings.iRenderH, 0f);
            }

            Reflection = false;
        }
예제 #8
0
 public CDoubleLink(string caption_1, string caption_2, EAlignment alignmode1, EAlignment alignmode2)
     : base("")
 {
     _link1       = new CLink(caption_1);
     _link1.Align = alignmode1;
     _link2       = new CLink(caption_2);
     _link2.Align = alignmode2;
 }
예제 #9
0
        protected float DrawLine(TextPortion.TextLine _textLine,
                                 FColor _color,
                                 int _lineNumber,
                                 float _indent,
                                 EAlignment _alignment)
        {
            var line           = _textLine.Text;
            var part           = line.Split(TextPortion.Punctuation).ToArray();
            var processedChars = 0;
            var x = (float)ContentRct.Left * Constants.TILE_SIZE;

            var lineSize = DrawHelper.MeasureString(Font, line);

            switch (_alignment)
            {
            case EAlignment.NORMAL:
                x += _indent + _textLine.Left;
                break;

            case EAlignment.LEFT:
                x += _indent;
                break;

            case EAlignment.RIGHT:
                x += ContentRct.Width * Constants.TILE_SIZE - lineSize.Width - _indent;
                break;

            case EAlignment.CENTER:
                x += ContentRct.Width * Constants.TILE_SIZE / 2f - lineSize.Width / 2f;
                break;
            }

            var y = ContentRct.Top * Constants.TILE_SIZE + _lineNumber * LineHeight;

            for (var partIndex = 0; partIndex < part.Length; partIndex++)
            {
                var    color  = _color;
                var    addStr = part[partIndex];
                FColor highlight;
                if (_textLine.Highlights != null && _textLine.Highlights.TryGetValue(addStr, out highlight))
                {
                    color           = highlight;
                    processedChars += addStr.Length;
                }
                else
                {
                    processedChars += addStr.Length;
                    addStr         += (processedChars >= line.Length) ? "" : line[processedChars].ToString();
                    processedChars++;
                }
                var size = DrawHelper.MeasureString(Font, addStr);
                DrawHelper.DrawString(Font, addStr, x, y, color);
                x += size.Width + 2;
            }
            return(x);
        }
예제 #10
0
		public SkinText(SkinText source)
			: base(source) {
			if (source != null) {
				this.Font = new SkinFont(source.Font);
				this.OffsetX = source.OffsetX;
				this.OffsetY = source.OffsetY;
				this.Alignment = source.Alignment;
				this.Colors = source.Colors;
			}
		}
예제 #11
0
        public void eraseCheckBox(int positionId, string caption, EAlignment justify)
        {
            int alignPos = 0;

            if (EAlignment.justify_right == justify)
            {
                alignPos = caption.Length;
            }
            eraseText(positionId, caption.Insert(alignPos, " "), justify);
        }
예제 #12
0
        public void drawTextBox(int posY, int lines, string caption, EAlignment alignmode)
        {
            // max lines
            int linesCnt = caption.Length / maxColumns;

            for (int i = 0; i < linesCnt; i++)
            {
                drawText(i + posY, caption.Substring(i * maxColumns, maxColumns), alignmode);
            }
            drawText(posY + linesCnt, caption.Substring(linesCnt * maxColumns, caption.Length % maxColumns), alignmode);
        }
예제 #13
0
        public void eraseTextBox(int posY, int lines, string caption, EAlignment alignmode)
        {
            int linesCnt = caption.Length / maxColumns;

            for (int i = 0; i < linesCnt; i++)
            {
                string subniz = caption.Substring(i * maxColumns, maxColumns);
                eraseText(i + posY, subniz, alignmode);
            }
            eraseText(posY + linesCnt, caption.Substring(linesCnt * maxColumns, caption.Length % maxColumns), alignmode);
        }
예제 #14
0
 public SkinText(SkinText source)
     : base(source)
 {
     if (source != null)
     {
         this.Font      = new SkinFont(source.Font);
         this.OffsetX   = source.OffsetX;
         this.OffsetY   = source.OffsetY;
         this.Alignment = source.Alignment;
         this.Colors    = source.Colors;
     }
 }
예제 #15
0
		protected float DrawLine(TextPortion.TextLine _textLine,
		                         FColor _color,
		                         int _lineNumber,
		                         float _indent,
		                         EAlignment _alignment)
		{
			var line = _textLine.Text;
			var part = line.Split(TextPortion.Punctuation).ToArray();
			var processedChars = 0;
			var x = (float) ContentRct.Left*Constants.TILE_SIZE;

			var lineSize = DrawHelper.MeasureString(Font, line);
			switch (_alignment)
			{
				case EAlignment.NORMAL:
					x += _indent + _textLine.Left;
					break;
				case EAlignment.LEFT:
					x += _indent;
					break;
				case EAlignment.RIGHT:
					x += ContentRct.Width*Constants.TILE_SIZE - lineSize.Width - _indent;
					break;
				case EAlignment.CENTER:
					x += ContentRct.Width*Constants.TILE_SIZE/2f - lineSize.Width/2f;
					break;
			}

			var y = ContentRct.Top*Constants.TILE_SIZE + _lineNumber*LineHeight;

			for (var partIndex = 0; partIndex < part.Length; partIndex++)
			{
				var color = _color;
				var addStr = part[partIndex];
				FColor highlight;
				if (_textLine.Highlights != null && _textLine.Highlights.TryGetValue(addStr, out highlight))
				{
					color = highlight;
					processedChars += addStr.Length;
				}
				else
				{
					processedChars += addStr.Length;
					addStr += (processedChars >= line.Length) ? "" : line[processedChars].ToString();
					processedChars++;
				}
				var size = DrawHelper.MeasureString(Font, addStr);
				DrawHelper.DrawString(Font, addStr, x, y, color);
				x += size.Width + 2;
			}
			return x;
		}
예제 #16
0
        public void drawLink(int positionId, string caption, EAlignment justify)
        {
            this.drawText(positionId, caption, justify);
            int x = 0;

            if (justify == EAlignment.justify_right)
            {
                x = maxColumns;
            }
            else if (justify == EAlignment.justify_center)
            {
                x = (maxColumns) / 2;
            }

            //formDrawButton(x, positionId);
        }
예제 #17
0
        public void drawCheckBox(int positionId, string caption, EAlignment justify, bool ischecked)
        {
            int alignPos = 0;

            if (EAlignment.justify_right == justify)
            {
                alignPos = caption.Length;
            }

            if (ischecked)
            {
                drawText(positionId, caption.Insert(alignPos, "*"), justify);
            }
            else
            {
                drawText(positionId, caption.Insert(alignPos, " "), justify);
            }
        }
예제 #18
0
        public void eraseText(int positionId, string caption, EAlignment justify)
        {
            int xaxis = 0;

            if (justify == EAlignment.justify_right)
            {
                xaxis = maxColumns - caption.Length;
            }
            if (justify == EAlignment.justify_center)
            {
                xaxis = (maxColumns - caption.Length) / 2;
            }
            if (xaxis < 0)
            {
                xaxis = 0;
            }
            formWriter(xaxis, positionId, new string(' ', caption.Length));
        }
예제 #19
0
파일: CLyric.cs 프로젝트: da-ka/Vocaluxe
        public CLyric(CLyric l)
        {
            _PartyModeID = l._PartyModeID;
            _Theme       = l._Theme;

            _Color          = l._Color;
            _ColorProcessed = l._ColorProcessed;
            MaxRect         = l.MaxRect;

            _Line    = l._Line;
            _Text    = new CText(l._Text);
            Width    = l.Width;
            MaxWidth = l.MaxWidth;

            _Align = l._Align;

            LyricStyle = l.LyricStyle;
        }
예제 #20
0
		public SkinLayer(SkinLayer source)
			: base(source) {
			if (source != null) {
				this.Image = new SkinImage(source.Image);
				this.Width = source.Width;
				this.Height = source.Height;
				this.OffsetX = source.OffsetX;
				this.OffsetY = source.OffsetY;
				this.Alignment = source.Alignment;
				this.SizingMargins = source.SizingMargins;
				this.ContentMargins = source.ContentMargins;
				this.States = source.States;
				this.Overlays = source.Overlays;
				this.Text = new SkinText(source.Text);
				this.Attributes = new SkinList<SkinAttribute>(source.Attributes);
			} else {
				throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
			}
		}
예제 #21
0
        /*
         * private void formDrawButton(int xaxis, int yaxis)
         * {
         * mform.Invoke(new drawButtonDelegate(mform.drawButton), new object[2] { xaxis, yaxis});
         * }
         *
         * private void formErasebutton()
         * {
         * mform.Invoke(new eraseButtonDelegate(mform.eraseButton));
         * }
         */
        ///////////////////////////////////////////////////////////////////////////////////////

        public void drawText(int positionId, string caption, EAlignment justify)
        {
            int xaxis = 0;

            // clipping
            if (positionId > maxLines)
            {
                return;
            }

            switch (justify)
            {
            case EAlignment.justify_right: xaxis = maxColumns - caption.Length; break;

            case EAlignment.justify_center: xaxis = (maxColumns - caption.Length) / 2; break;
            }
            if (xaxis < 0)
            {
                xaxis = 0;
            }
            formWriter(xaxis, positionId, caption);
        }
예제 #22
0
        public CText(CText text)
        {
            _PartyModeID   = text._PartyModeID;
            _TranslationID = text._TranslationID;

            MaxRect = text.MaxRect;
            _Rect   = text._Rect;
            _PositionNeedsUpdate = false;
            _Align       = text._Align;
            _ResizeAlign = text._ResizeAlign;
            Font         = new CFont(text.Font); //Use setter to set observer

            Color             = text.Color;
            SelColor          = text.SelColor;
            _ReflectionSpace  = text._ReflectionSpace;
            _ReflectionHeight = text._ReflectionHeight;

            Text    = text.Text;
            Visible = text.Visible;
            Alpha   = text.Alpha;

            _EditMode = text._EditMode;
        }
예제 #23
0
 public SkinLayer(SkinLayer source)
     : base(source)
 {
     if (source != null)
     {
         this.Image          = new SkinImage(source.Image);
         this.Width          = source.Width;
         this.Height         = source.Height;
         this.OffsetX        = source.OffsetX;
         this.OffsetY        = source.OffsetY;
         this.Alignment      = source.Alignment;
         this.SizingMargins  = source.SizingMargins;
         this.ContentMargins = source.ContentMargins;
         this.States         = source.States;
         this.Overlays       = source.Overlays;
         this.Text           = new SkinText(source.Text);
         this.Attributes     = new SkinList <SkinAttribute>(source.Attributes);
     }
     else
     {
         throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
     }
 }
예제 #24
0
        private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, EAlignment alignment, int index)
        {
            Rectangle rect = new Rectangle();
            int       xc   = (int)((float)imageSize.Width / partSize.Width);
            int       yc   = (int)((float)imageSize.Height / partSize.Height);

            int xm = (index) % xc;
            int ym = (index) / xc;

            int adj = 1;

            margins.Left   += margins.Left > 0 ? adj : 0;
            margins.Top    += margins.Top > 0 ? adj : 0;
            margins.Right  += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
            switch (alignment)
            {
            case EAlignment.TopLeft: {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (0 + (ym * partSize.Height)),
                                     margins.Left,
                                     margins.Top);
                break;
            }

            case EAlignment.TopCenter: {
                rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                     (0 + (ym * partSize.Height)),
                                     partSize.Width - margins.Left - margins.Right,
                                     margins.Top);
                break;
            }

            case EAlignment.TopRight: {
                rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                     (0 + (ym * partSize.Height)),
                                     margins.Right,
                                     margins.Top);
                break;
            }

            case EAlignment.MiddleLeft: {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (0 + (ym * partSize.Height)) + margins.Top,
                                     margins.Left,
                                     partSize.Height - margins.Top - margins.Bottom);
                break;
            }

            case EAlignment.MiddleCenter: {
                rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                     (0 + (ym * partSize.Height)) + margins.Top,
                                     partSize.Width - margins.Left - margins.Right,
                                     partSize.Height - margins.Top - margins.Bottom);
                break;
            }

            case EAlignment.MiddleRight: {
                rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                     (0 + (ym * partSize.Height)) + margins.Top,
                                     margins.Right,
                                     partSize.Height - margins.Top - margins.Bottom);
                break;
            }

            case EAlignment.BottomLeft: {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     margins.Left,
                                     margins.Bottom);
                break;
            }

            case EAlignment.BottomCenter: {
                rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     partSize.Width - margins.Left - margins.Right,
                                     margins.Bottom);
                break;
            }

            case EAlignment.BottomRight: {
                rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     margins.Right,
                                     margins.Bottom);
                break;
            }
            }

            return(rect);
        }
예제 #25
0
 public static CText GetNewText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text)
 {
     return(new CText(x, y, z, h, mw, align, style, font, col, text));
 }
예제 #26
0
 public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, EAlignment alignment, bool ellipsis)
 {
     DrawString(font, text, rect, color, alignment, 0, 0, ellipsis);
 }
예제 #27
0
 public void eraseLink(int positionId, string caption, EAlignment justify)
 {
     this.eraseText(positionId, caption, justify);
     //formErasebutton();
 }
예제 #28
0
파일: platform.cs 프로젝트: AngieToro/sipek
 public void eraseLink(int positionId, string caption, EAlignment justify)
 {
     this.eraseText(positionId, caption, justify);
       //formErasebutton();
 }
예제 #29
0
파일: platform.cs 프로젝트: AngieToro/sipek
 public void eraseTextBox(int posY, int lines, string caption, EAlignment alignmode)
 {
     int linesCnt = caption.Length / maxColumns;
       for (int i = 0; i < linesCnt; i++)
       {
     string subniz = caption.Substring(i * maxColumns, maxColumns);
     eraseText(i + posY, subniz, alignmode);
       }
       eraseText(posY + linesCnt, caption.Substring(linesCnt * maxColumns, caption.Length % maxColumns), alignmode);
 }
예제 #30
0
파일: cmdAlignOne.cs 프로젝트: mff-uk/xcase
        public static CommandBase CreateMoveCommand(IEnumerable <IAlignable> affectedObjects, EAlignment alignment, XCaseCanvas diagramView)
        {
            MacroCommand <DiagramController> moveMacroCommand =
                MacroCommandFactory <DiagramController> .Factory().Create(diagramView.Controller);

            List <Point> aidsPointsForDiagram = VisualAidsAdorner.GetVisualAidsPointsForDiagram(diagramView, ignoredTypes);

            double minTop, nextTop;
            double maxBottom, nextBottom;
            double minLeft, nextLeft;
            double maxRight, nextRight;
            double delta;

            switch (alignment)
            {
            case EAlignment.Top:
                minTop = affectedObjects.Min(item => item.Top);
                if (minTop > 0)
                {
                    nextTop = aidsPointsForDiagram.Where(point => point.Y < minTop).Max(point => point.Y);
                    delta   = nextTop - minTop;
                    foreach (IAlignable element in affectedObjects)
                    {
                        var cmd = ViewController.CreateMoveCommand(null, element.Top + delta, element.ViewHelper,
                                                                   diagramView.Controller);
                        moveMacroCommand.Commands.Add(cmd);
                    }
                }
                break;

            case EAlignment.Bottom:
                maxBottom = affectedObjects.Max(item => item.Bottom);
                IEnumerable <Point> candidatesBottom = aidsPointsForDiagram.Where(point => point.Y > maxBottom);
                if (candidatesBottom.Count() > 0)
                {
                    nextBottom = candidatesBottom.Min(point => point.Y);
                    delta      = nextBottom - maxBottom;
                    foreach (IAlignable element in affectedObjects)
                    {
                        var cmd = ViewController.CreateMoveCommand(null, element.Top + delta, element.ViewHelper, diagramView.Controller);
                        moveMacroCommand.Commands.Add(cmd);
                    }
                }
                break;

            case EAlignment.Left:
                minLeft = affectedObjects.Min(item => item.Left);
                if (minLeft > 0)
                {
                    nextLeft = aidsPointsForDiagram.Where(point => point.X < minLeft).Max(point => point.X);
                    delta    = nextLeft - minLeft;
                    foreach (IAlignable element in affectedObjects)
                    {
                        var cmd = ViewController.CreateMoveCommand(element.Left + delta, null, element.ViewHelper, diagramView.Controller);
                        moveMacroCommand.Commands.Add(cmd);
                    }
                }
                break;

            case EAlignment.Right:
                maxRight = affectedObjects.Max(item => item.Right);
                IEnumerable <Point> candidatesRight = aidsPointsForDiagram.Where(point => point.X > maxRight);
                if (candidatesRight.Count() > 0)
                {
                    nextRight = candidatesRight.Min(point => point.X);
                    delta     = nextRight - maxRight;
                    foreach (IAlignable element in affectedObjects)
                    {
                        var cmd = ViewController.CreateMoveCommand(element.Left + delta, null, element.ViewHelper, diagramView.Controller);
                        moveMacroCommand.Commands.Add(cmd);
                    }
                }
                break;

            case EAlignment.CenterV:
            case EAlignment.CenterH:
            case EAlignment.DistributeV:
            case EAlignment.DistributeH:
                throw new ArgumentException("Not valid for this command: " + alignment);
            }

            return(moveMacroCommand);
        }
예제 #31
0
파일: platform.cs 프로젝트: AngieToro/sipek
 public void drawTextBox(int posY, int lines, string caption, EAlignment alignmode)
 {
     // max lines
       int linesCnt = caption.Length / maxColumns;
       for (int i = 0; i < linesCnt; i++)
       {
     drawText(i + posY, caption.Substring(i*maxColumns, maxColumns), alignmode);
       }
       drawText(posY + linesCnt, caption.Substring(linesCnt * maxColumns, caption.Length % maxColumns), alignmode);
 }
예제 #32
0
        void ClientArea_Draw(object sender, DrawEventArgs e)
        {
            SkinLayer  layer    = Skin.Layers[lrTextBox];
            Color      col      = Skin.Layers[lrTextBox].Text.Colors.Enabled;
            SkinLayer  cursor   = Skin.Layers[lrCursor];
            EAlignment al       = mode == ETextBoxMode.Multiline ? EAlignment.TopLeft : EAlignment.MiddleLeft;
            Renderer   renderer = e.Renderer;
            Rectangle  r        = e.Rectangle;
            bool       drawsel  = !selection.IsEmpty;
            string     tmpText  = "";

            font = (Skin.Layers[lrTextBox].Text != null) ? Skin.Layers[lrTextBox].Text.Font.Resource : null;

            if (Text != null && font != null)
            {
                DeterminePages();

                if (mode == ETextBoxMode.Multiline)
                {
                    shownText = Text;
                    tmpText   = Lines[PosY];
                }
                else if (mode == ETextBoxMode.Password)
                {
                    shownText = "";
                    for (int i = 0; i < Text.Length; i++)
                    {
                        shownText = shownText + passwordChar;
                    }
                    tmpText = shownText;
                }
                else
                {
                    shownText = Text;
                    tmpText   = Lines[PosY];
                }

                if (TextColor != UndefinedColor && ControlState != EControlState.Disabled)
                {
                    col = TextColor;
                }

                if (mode != ETextBoxMode.Multiline)
                {
                    linesDrawn = 0;
                    vert.Value = 0;
                }

                if (drawsel)
                {
                    DrawSelection(e.Renderer, r);

                    /*
                     *                renderer.End();
                     *                renderer.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true;
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.SourceBlend = Blend.DestinationColor;
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.DestinationBlend = Blend.SourceColor;
                     *                renderer.SpriteBatch.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Subtract;
                     *                //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaFunction = CompareFunction.Equal;
                     *                //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One;
                     *                //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.DestinationAlpha;
                     */
                }

                int sizey = (int)font.LineSpacing;

                if (showCursor && caretVisible)
                {
                    Vector2 size = Vector2.Zero;
                    if (PosX > 0 && PosX <= tmpText.Length)
                    {
                        size = font.MeasureString(tmpText.Substring(0, PosX));
                    }
                    if (size.Y == 0)
                    {
                        size   = font.MeasureString(" ");
                        size.X = 0;
                    }

                    int m = r.Height - font.LineSpacing;

                    Rectangle rc = new Rectangle(r.Left - horz.Value + (int)size.X, r.Top + m / 2, cursor.Width, font.LineSpacing);

                    if (mode == ETextBoxMode.Multiline)
                    {
                        rc = new Rectangle(r.Left + (int)size.X - horz.Value, r.Top + (int)((PosY - vert.Value) * font.LineSpacing), cursor.Width, font.LineSpacing);
                    }
                    cursor.Alignment = al;
                    renderer.DrawLayer(cursor, rc, col, 0);
                }

                for (int i = 0; i < linesDrawn + 1; i++)
                {
                    int ii = i + vert.Value;
                    if (ii >= Lines.Count || ii < 0)
                    {
                        break;
                    }

                    if (Lines[ii] != "")
                    {
                        if (mode == ETextBoxMode.Multiline)
                        {
                            renderer.DrawString(font, Lines[ii], r.Left - horz.Value, r.Top + (i * sizey), col);
                        }
                        else
                        {
                            Rectangle rx = new Rectangle(r.Left - horz.Value, r.Top, r.Width, r.Height);
                            renderer.DrawString(font, shownText, rx, col, al, false);
                        }
                    }
                }

                /*  if (drawsel)
                 * {
                 *      renderer.End();
                 *      renderer.Begin(BlendingMode.Premultiplied);
                 * }*/
            }
        }
예제 #33
0
		public static Rectangle GetDestinationArea(Rectangle area, Margins margins, EAlignment alignment) {
			Rectangle rect = new Rectangle();

			int adj = 1;
			margins.Left += margins.Left > 0 ? adj : 0;
			margins.Top += margins.Top > 0 ? adj : 0;
			margins.Right += margins.Right > 0 ? adj : 0;
			margins.Bottom += margins.Bottom > 0 ? adj : 0;

			margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);

			switch (alignment) {
				case EAlignment.TopLeft: {
						rect = new Rectangle(area.Left + 0,
											 area.Top + 0,
											 margins.Left,
											 margins.Top);
						break;

					}
				case EAlignment.TopCenter: {
						rect = new Rectangle(area.Left + margins.Left,
											 area.Top + 0,
											 area.Width - margins.Left - margins.Right,
											 margins.Top);
						break;

					}
				case EAlignment.TopRight: {
						rect = new Rectangle(area.Left + area.Width - margins.Right,
											 area.Top + 0,
											 margins.Right,
											 margins.Top);
						break;

					}
				case EAlignment.MiddleLeft: {
						rect = new Rectangle(area.Left + 0,
											 area.Top + margins.Top,
											 margins.Left,
											 area.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.MiddleCenter: {
						rect = new Rectangle(area.Left + margins.Left,
											 area.Top + margins.Top,
											 area.Width - margins.Left - margins.Right,
											 area.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.MiddleRight: {
						rect = new Rectangle(area.Left + area.Width - margins.Right,
											 area.Top + margins.Top,
											 margins.Right,
											 area.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.BottomLeft: {
						rect = new Rectangle(area.Left + 0,
											 area.Top + area.Height - margins.Bottom,
											 margins.Left,
											 margins.Bottom);
						break;
					}
				case EAlignment.BottomCenter: {
						rect = new Rectangle(area.Left + margins.Left,
											 area.Top + area.Height - margins.Bottom,
											 area.Width - margins.Left - margins.Right,
											 margins.Bottom);
						break;
					}
				case EAlignment.BottomRight: {
						rect = new Rectangle(area.Left + area.Width - margins.Right,
											 area.Top + area.Height - margins.Bottom,
											 margins.Right,
											 margins.Bottom);
						break;
					}
			}

			return rect;
		}
예제 #34
0
        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, EAlignment alignment, int offsetX, int offsetY, bool ellipsis)
        {
            if (ellipsis)
            {
                const string elli = "...";
                int          size = (int)Math.Ceiling(font.MeasureString(text).X);
                if (size > rect.Width)
                {
                    int es = (int)Math.Ceiling(font.MeasureString(elli).X);
                    for (int i = text.Length - 1; i > 0; i--)
                    {
                        int c = 1;
                        if (char.IsWhiteSpace(text[i - 1]))
                        {
                            c = 2;
                            i--;
                        }
                        text = text.Remove(i, c);
                        size = (int)Math.Ceiling(font.MeasureString(text).X);
                        if (size + es <= rect.Width)
                        {
                            break;
                        }
                    }
                    text += elli;
                }
            }

            if (rect.Width > 0 && rect.Height > 0)
            {
                Vector2 pos  = new Vector2(rect.Left, rect.Top);
                Vector2 size = font.MeasureString(text);

                int x = 0;
                int y = 0;

                switch (alignment)
                {
                case EAlignment.TopLeft:
                    break;

                case EAlignment.TopCenter:
                    x = GetTextCenter(rect.Width, size.X);
                    break;

                case EAlignment.TopRight:
                    x = rect.Width - (int)size.X;
                    break;

                case EAlignment.MiddleLeft:
                    y = GetTextCenter(rect.Height, size.Y);
                    break;

                case EAlignment.MiddleRight:
                    x = rect.Width - (int)size.X;
                    y = GetTextCenter(rect.Height, size.Y);
                    break;

                case EAlignment.BottomLeft:
                    y = rect.Height - (int)size.Y;
                    break;

                case EAlignment.BottomCenter:
                    x = GetTextCenter(rect.Width, size.X);
                    y = rect.Height - (int)size.Y;
                    break;

                case EAlignment.BottomRight:
                    x = rect.Width - (int)size.X;
                    y = rect.Height - (int)size.Y;
                    break;

                default:
                    x = GetTextCenter(rect.Width, size.X);
                    y = GetTextCenter(rect.Height, size.Y);
                    break;
                }

                pos.X = (int)(pos.X + x);
                pos.Y = (int)(pos.Y + y);

                DrawString(font, text, (int)pos.X + offsetX, (int)pos.Y + offsetY, color);
            }
        }
예제 #35
0
		public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, EAlignment alignment) {
			DrawString(font, text, rect, color, alignment, 0, 0, true);
		}
예제 #36
0
		public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, EAlignment alignment, bool ellipsis) {
			DrawString(font, text, rect, color, alignment, 0, 0, ellipsis);
		}
예제 #37
0
파일: platform.cs 프로젝트: AngieToro/sipek
        public void drawLink(int positionId, string caption, EAlignment justify)
        {
            this.drawText(positionId, caption, justify);
              int x = 0;
              if (justify == EAlignment.justify_right)
            x = maxColumns ;
              else if (justify == EAlignment.justify_center)
            x = (maxColumns) / 2;

              //formDrawButton(x, positionId);
        }
예제 #38
0
파일: Control.cs 프로젝트: GodLesZ/svn-dump
		private void GetResizePosition(MouseEventArgs e) {
			int x = e.Position.X - AbsoluteLeft;
			int y = e.Position.Y - AbsoluteTop;
			bool l = false, t = false, r = false, b = false;

			resizeArea = EAlignment.None;

			if (CheckResizableArea(e.Position)) {
				if (x < resizerSize)
					l = true;
				if (x >= Width - resizerSize)
					r = true;
				if (y < resizerSize)
					t = true;
				if (y >= Height - resizerSize)
					b = true;

				if (l && t)
					resizeArea = EAlignment.TopLeft;
				else if (l && b)
					resizeArea = EAlignment.BottomLeft;
				else if (r && t)
					resizeArea = EAlignment.TopRight;
				else if (r && b)
					resizeArea = EAlignment.BottomRight;
				else if (l)
					resizeArea = EAlignment.MiddleLeft;
				else if (t)
					resizeArea = EAlignment.TopCenter;
				else if (r)
					resizeArea = EAlignment.MiddleRight;
				else if (b)
					resizeArea = EAlignment.BottomCenter;
			} else {
				resizeArea = EAlignment.None;
			}
		}
예제 #39
0
파일: platform.cs 프로젝트: AngieToro/sipek
        /*
        private void formDrawButton(int xaxis, int yaxis)
        {
          mform.Invoke(new drawButtonDelegate(mform.drawButton), new object[2] { xaxis, yaxis});
        }

        private void formErasebutton()
        {
          mform.Invoke(new eraseButtonDelegate(mform.eraseButton));
        }
        */
        ///////////////////////////////////////////////////////////////////////////////////////
        public void drawText(int positionId, string caption, EAlignment justify)
        {
            int xaxis = 0;
              // clipping
              if (positionId > maxLines) return;

              switch (justify)
              {
            case EAlignment.justify_right: xaxis = maxColumns  - caption.Length; break;
            case EAlignment.justify_center: xaxis = (maxColumns - caption.Length) / 2; break;
              }
              if (xaxis < 0) xaxis = 0;
              formWriter(xaxis, positionId, caption);
        }
예제 #40
0
		private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, EAlignment alignment, int index) {
			Rectangle rect = new Rectangle();
			int xc = (int)((float)imageSize.Width / partSize.Width);
			int yc = (int)((float)imageSize.Height / partSize.Height);

			int xm = (index) % xc;
			int ym = (index) / xc;

			int adj = 1;
			margins.Left += margins.Left > 0 ? adj : 0;
			margins.Top += margins.Top > 0 ? adj : 0;
			margins.Right += margins.Right > 0 ? adj : 0;
			margins.Bottom += margins.Bottom > 0 ? adj : 0;

			margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);
			switch (alignment) {
				case EAlignment.TopLeft: {
						rect = new Rectangle((0 + (xm * partSize.Width)),
											 (0 + (ym * partSize.Height)),
											 margins.Left,
											 margins.Top);
						break;
					}
				case EAlignment.TopCenter: {
						rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
											 (0 + (ym * partSize.Height)),
											 partSize.Width - margins.Left - margins.Right,
											 margins.Top);
						break;
					}
				case EAlignment.TopRight: {
						rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
											 (0 + (ym * partSize.Height)),
											 margins.Right,
											 margins.Top);
						break;
					}
				case EAlignment.MiddleLeft: {
						rect = new Rectangle((0 + (xm * partSize.Width)),
											 (0 + (ym * partSize.Height)) + margins.Top,
											 margins.Left,
											 partSize.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.MiddleCenter: {
						rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
											 (0 + (ym * partSize.Height)) + margins.Top,
											 partSize.Width - margins.Left - margins.Right,
											 partSize.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.MiddleRight: {
						rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
											 (0 + (ym * partSize.Height)) + margins.Top,
											 margins.Right,
											 partSize.Height - margins.Top - margins.Bottom);
						break;
					}
				case EAlignment.BottomLeft: {
						rect = new Rectangle((0 + (xm * partSize.Width)),
											 (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
											 margins.Left,
											 margins.Bottom);
						break;
					}
				case EAlignment.BottomCenter: {
						rect = new Rectangle((0 + (xm * partSize.Width)) + margins.Left,
											 (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
											 partSize.Width - margins.Left - margins.Right,
											 margins.Bottom);
						break;
					}
				case EAlignment.BottomRight: {
						rect = new Rectangle((partSize.Width + (xm * partSize.Width)) - margins.Right,
											 (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
											 margins.Right,
											 margins.Bottom);
						break;
					}
			}

			return rect;
		}
예제 #41
0
파일: platform.cs 프로젝트: AngieToro/sipek
 public void eraseCheckBox(int positionId, string caption, EAlignment justify)
 {
     int alignPos = 0;
       if (EAlignment.justify_right == justify)
       {
     alignPos = caption.Length;
       }
       eraseText(positionId, caption.Insert(alignPos, " "), justify);
 }
예제 #42
0
 public float DrawLine(string _text, FColor _color, int _lineNumber, float _indent, EAlignment _alignment)
 {
     return(DrawLine(new TextPortion.TextLine(_text, 0, null), _color, _lineNumber, _indent, _alignment));
 }
예제 #43
0
파일: platform.cs 프로젝트: AngieToro/sipek
 public void eraseText(int positionId, string caption, EAlignment justify)
 {
     int xaxis = 0;
       if (justify == EAlignment.justify_right) xaxis = maxColumns - caption.Length;
       if (justify == EAlignment.justify_center) xaxis = (maxColumns - caption.Length) / 2;
       if (xaxis < 0) xaxis = 0;
       formWriter(xaxis, positionId, new string(' ', caption.Length));
 }
예제 #44
0
		public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, EAlignment alignment, int offsetX, int offsetY, bool ellipsis) {

			if (ellipsis) {
				const string elli = "...";
				int size = (int)Math.Ceiling(font.MeasureString(text).X);
				if (size > rect.Width) {
					int es = (int)Math.Ceiling(font.MeasureString(elli).X);
					for (int i = text.Length - 1; i > 0; i--) {
						int c = 1;
						if (char.IsWhiteSpace(text[i - 1])) {
							c = 2;
							i--;
						}
						text = text.Remove(i, c);
						size = (int)Math.Ceiling(font.MeasureString(text).X);
						if (size + es <= rect.Width) {
							break;
						}
					}
					text += elli;
				}
			}

			if (rect.Width > 0 && rect.Height > 0) {
				Vector2 pos = new Vector2(rect.Left, rect.Top);
				Vector2 size = font.MeasureString(text);

				int x = 0;
				int y = 0;

				switch (alignment) {
					case EAlignment.TopLeft:
						break;
					case EAlignment.TopCenter:
						x = GetTextCenter(rect.Width, size.X);
						break;
					case EAlignment.TopRight:
						x = rect.Width - (int)size.X;
						break;
					case EAlignment.MiddleLeft:
						y = GetTextCenter(rect.Height, size.Y);
						break;
					case EAlignment.MiddleRight:
						x = rect.Width - (int)size.X;
						y = GetTextCenter(rect.Height, size.Y);
						break;
					case EAlignment.BottomLeft:
						y = rect.Height - (int)size.Y;
						break;
					case EAlignment.BottomCenter:
						x = GetTextCenter(rect.Width, size.X);
						y = rect.Height - (int)size.Y;
						break;
					case EAlignment.BottomRight:
						x = rect.Width - (int)size.X;
						y = rect.Height - (int)size.Y;
						break;

					default:
						x = GetTextCenter(rect.Width, size.X);
						y = GetTextCenter(rect.Height, size.Y);
						break;
				}

				pos.X = (int)(pos.X + x);
				pos.Y = (int)(pos.Y + y);

				DrawString(font, text, (int)pos.X + offsetX, (int)pos.Y + offsetY, color);
			}
		}
예제 #45
0
		public float DrawLine(string _text, FColor _color, int _lineNumber, float _indent, EAlignment _alignment) { return DrawLine(new TextPortion.TextLine(_text, 0, null), _color, _lineNumber, _indent, _alignment); }
예제 #46
0
 public CStatusBar(EAlignment alignmode)
     : base("    ",alignmode)
 {
 }
예제 #47
0
 public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, EAlignment alignment)
 {
     DrawString(font, text, rect, color, alignment, 0, 0, true);
 }
예제 #48
0
 public CDoubleLink(string caption_1, string caption_2, EAlignment alignmode1, EAlignment alignmode2)
     : base("")
 {
     _link1 = new CLink(caption_1);
       _link1.Align = alignmode1;
     _link2 = new CLink(caption_2);
       _link2.Align = alignmode2;
 }
예제 #49
0
        public static Rectangle GetDestinationArea(Rectangle area, Margins margins, EAlignment alignment)
        {
            Rectangle rect = new Rectangle();

            int adj = 1;

            margins.Left   += margins.Left > 0 ? adj : 0;
            margins.Top    += margins.Top > 0 ? adj : 0;
            margins.Right  += margins.Right > 0 ? adj : 0;
            margins.Bottom += margins.Bottom > 0 ? adj : 0;

            margins = new Margins(margins.Left, margins.Top, margins.Right, margins.Bottom);

            switch (alignment)
            {
            case EAlignment.TopLeft: {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + 0,
                                     margins.Left,
                                     margins.Top);
                break;
            }

            case EAlignment.TopCenter: {
                rect = new Rectangle(area.Left + margins.Left,
                                     area.Top + 0,
                                     area.Width - margins.Left - margins.Right,
                                     margins.Top);
                break;
            }

            case EAlignment.TopRight: {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + 0,
                                     margins.Right,
                                     margins.Top);
                break;
            }

            case EAlignment.MiddleLeft: {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + margins.Top,
                                     margins.Left,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

            case EAlignment.MiddleCenter: {
                rect = new Rectangle(area.Left + margins.Left,
                                     area.Top + margins.Top,
                                     area.Width - margins.Left - margins.Right,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

            case EAlignment.MiddleRight: {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + margins.Top,
                                     margins.Right,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

            case EAlignment.BottomLeft: {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + area.Height - margins.Bottom,
                                     margins.Left,
                                     margins.Bottom);
                break;
            }

            case EAlignment.BottomCenter: {
                rect = new Rectangle(area.Left + margins.Left,
                                     area.Top + area.Height - margins.Bottom,
                                     area.Width - margins.Left - margins.Right,
                                     margins.Bottom);
                break;
            }

            case EAlignment.BottomRight: {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + area.Height - margins.Bottom,
                                     margins.Right,
                                     margins.Bottom);
                break;
            }
            }

            return(rect);
        }
예제 #50
0
파일: platform.cs 프로젝트: AngieToro/sipek
        public void drawCheckBox(int positionId, string caption, EAlignment justify, bool ischecked)
        {
            int alignPos = 0;
              if (EAlignment.justify_right == justify)
              {
            alignPos = caption.Length;
              }

              if (ischecked)
            drawText(positionId, caption.Insert(alignPos, "*"), justify);
              else
            drawText(positionId, caption.Insert(alignPos, " "), justify);
        }
예제 #51
0
 public CStatusBar(EAlignment alignmode)
     : base("    ", alignmode)
 {
 }
예제 #52
0
        public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text)
        {
            _Theme = new SThemeText();
            _ThemeLoaded = false;
            _ButtonText = false;

            X = x;
            Y = y;
            Z = z;
            Height = h;
            MaxWidth = mw;
            Align = align;
            HAlign = EHAlignment.Center;
            Style = style;
            Fon = font;

            Color = col;
            SColor = new SColorF(col);

            Text = text;

            Selected = false;

            if (MaxWidth > 0)
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, MaxWidth, 3f * CSettings.iRenderH, 0f);
            }
            else
            {
                Bounds = new SRectF(-CSettings.iRenderW, -CSettings.iRenderH, 3f * CSettings.iRenderW, 3f * CSettings.iRenderH, 0f);
            }

            Reflection = false;
        }
예제 #53
0
        public static string EAlignmentToString(EAlignment eAlignment)
        {
            string str = string.Empty;

            switch (eAlignment)
            {
                case EAlignment.eLeft:
                    str = "Left";
                    break;
                case EAlignment.eCenter:
                    str = "Center";
                    break;
                case EAlignment.eRight:
                    str = "Right";
                    break;
                default:
                    break;
            }

            return str;
        }
예제 #54
0
        public static CommandBase CreateMoveCommand(IEnumerable <IAlignable> affectedObjects, EAlignment alignment, XCaseCanvas diagramView)
        {
            MacroCommand <DiagramController> moveMacroCommand =
                MacroCommandFactory <DiagramController> .Factory().Create(diagramView.Controller);

            double minTop;
            double maxBottom;
            double distance;
            double offset;

            switch (alignment)
            {
            case EAlignment.Top:
                minTop = affectedObjects.Min(item => item.Top);
                foreach (IAlignable element in affectedObjects)
                {
                    var cmd = ViewController.CreateMoveCommand(null, minTop, element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);
                }
                break;

            case EAlignment.Bottom:
                maxBottom = affectedObjects.Max(item => item.Bottom);
                foreach (IAlignable element in affectedObjects)
                {
                    var cmd = ViewController.CreateMoveCommand(null, maxBottom - (element.Bottom - element.Top), element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);
                }
                break;

            case EAlignment.Left:
                double minLeft = affectedObjects.Min(item => item.Left);
                foreach (IAlignable element in affectedObjects)
                {
                    var cmd = ViewController.CreateMoveCommand(minLeft, null, element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);
                }
                break;

            case EAlignment.Right:
                double maxRight = affectedObjects.Max(item => item.Right);
                foreach (IAlignable element in affectedObjects)
                {
                    var cmd = ViewController.CreateMoveCommand(maxRight - (element.Right - element.Left), null, element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);
                }
                break;

            case EAlignment.CenterV:
                double centerH = Math.Round(affectedObjects.Average(item => item.Top + (item.Bottom - item.Top) / 2));
                foreach (IAlignable element in affectedObjects)
                {
                    var cmd = ViewController.CreateMoveCommand(null, (centerH - (element.Bottom - element.Top) / 2), element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);
                }
                break;

            case EAlignment.CenterH:
                double centerV = Math.Round(affectedObjects.Average(item => item.Left + (item.Right - item.Left) / 2));
                foreach (IAlignable element in affectedObjects)
                {
                    var cmd = ViewController.CreateMoveCommand(centerV - (element.Right - element.Left) / 2, null, element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);
                }
                break;

            case EAlignment.DistributeV:
                minTop    = affectedObjects.Min(item => item.Top);
                maxBottom = affectedObjects.Max(item => item.Bottom);
                double sumHeight = affectedObjects.Sum(item => item.Bottom - item.Top);

                distance = Math.Max(0, (maxBottom - minTop - sumHeight) / (affectedObjects.Count() - 1));
                offset   = minTop;

                foreach (IAlignable element in affectedObjects.OrderBy(item => item.Top))
                {
                    double delta = offset - element.Top;
                    var    cmd   = ViewController.CreateMoveCommand(null, element.Top + delta, element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);

                    offset = offset + element.Bottom - element.Top + distance;
                }

                break;

            case EAlignment.DistributeH:
                minLeft  = affectedObjects.Min(item => item.Left);
                maxRight = affectedObjects.Max(item => item.Right);
                double sumWidth = affectedObjects.Sum(item => item.Right - item.Left);

                distance = Math.Max(0, (maxRight - minLeft - sumWidth) / (affectedObjects.Count() - 1));
                offset   = minLeft;

                foreach (IAlignable element in affectedObjects.OrderBy(item => item.Left))
                {
                    double delta = offset - element.Left;
                    var    cmd   = ViewController.CreateMoveCommand(element.Left + delta, null, element.ViewHelper, diagramView.Controller);
                    moveMacroCommand.Commands.Add(cmd);

                    offset = offset + element.Right - element.Left + distance;
                }

                break;
            }

            return(moveMacroCommand);
        }