Example #1
1
 /// <summary>
 /// Construct a new <see cref="Table" />.
 /// </summary>
 /// <param name="tableName">
 /// The name of the <see cref="Table" />.
 /// </param>
 /// <param name="headerAlignment">
 /// The method to use to align the text in the table's header.
 /// Defaults to <see cref="StringFormatting.LeftJustified" />.
 /// </param>
 public Table(string tableName=null, Alignment headerAlignment=null)
 {
     Title = tableName ?? string.Empty;
     HeaderAlignment = headerAlignment ?? StringFormatting.LeftJustified;
     Columns = new ColumnCollection();
     Rows = new RowCollection(this);
 }
Example #2
0
        /// <summary>
        /// Finds the <see cref="Vector2"/> that represents the position to align an object
        /// to another object based on the given <see cref="Alignment"/>. The object being aligned
        /// to is assumed to be at {0,0).
        /// </summary>
        /// <param name="alignment">The <see cref="Alignment"/> describing how to align the target
        /// to the source.</param>
        /// <param name="sourceSize">The object that is being aligned to the target.</param>
        /// <param name="targetSize">The size of the object being aligned to.</param>
        /// <returns>The <see cref="Vector2"/> that represents the position to align an object
        /// to another object based on the given <paramref name="alignment"/>.</returns>
        /// <exception cref="ArgumentException"><paramref name="alignment"/> is not a defined value of the <see cref="Alignment"/>
        /// enum.</exception>
        public static Vector2 FindOffset(Alignment alignment, Vector2 sourceSize, Vector2 targetSize)
        {
            switch (alignment)
            {
                case Alignment.TopLeft:
                    return new Vector2(0, 0);

                case Alignment.TopRight:
                    return new Vector2(targetSize.X - sourceSize.X, 0);

                case Alignment.BottomLeft:
                    return new Vector2(0, targetSize.Y - sourceSize.Y);

                case Alignment.BottomRight:
                    return targetSize - sourceSize;

                case Alignment.Top:
                    return new Vector2(targetSize.X / 2f - sourceSize.X / 2f, 0);

                case Alignment.Bottom:
                    return new Vector2(targetSize.X / 2f - sourceSize.X / 2f, targetSize.Y - sourceSize.Y);

                case Alignment.Left:
                    return new Vector2(0, targetSize.Y / 2f - sourceSize.Y / 2f);

                case Alignment.Right:
                    return new Vector2(targetSize.X - sourceSize.X, targetSize.Y / 2f - sourceSize.Y / 2f);

                case Alignment.Center:
                    return targetSize / 2f - sourceSize / 2f;

                default:
                    throw new ArgumentException("Unknown alignment value specified", "alignment");
            }
        }
 public void ApplyTextPositionAndAlignment(Position pos, Alignment alignment)
 {
     new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight)
         .SetPosition(pos)
         .SetAlignment(alignment)
         .StartBoxing();
 }
 public TabWidgetModel(String id, Alignment alignment, String href)
 {
     this.Id = "tab" + id;
     this.Alignment = alignment;
     this.TabImage = "~/Content/img/tabs/" + id + ".png";
     this.Href = href;
 }
        //------------------------------------------------------------------------------
        // Function: ItemText
        // Author: nholmes
        // Summary: item constructor, allows user to specify text, vertical position,
        //          alignment and font as well as whether the text is selectable
        //------------------------------------------------------------------------------
        public ItemText(Menu menu, Game game, string text, int y, Alignment alignment, SpriteFont font, Color fontColor, int textOffset, bool selectable)
            : base(menu, game, textOffset)
        {
            // store the text font and font color to use
            this.text = text;
            this.font = font;
            this.fontColor = fontColor;

            // store whether this item is selectable
            this.selectable = selectable;

            // set the vy position of this text item
            position.Y = y;

            // calculate position based on alignment provided
            switch (alignment)
            {
                case Alignment.left:
                    position.X = 0;
                    break;
                case Alignment.centre:
                    position.X = (int)((menu.ItemArea.Width - font.MeasureString(text).X) / 2);
                    break;
                case Alignment.right:
                    position.X = (int)(menu.ItemArea.Width - font.MeasureString(text).X);
                    break;
                default:
                    position.X = 0;
                    break;
            }

            // store the size of this text item
            size = font.MeasureString(text);
        }
 public ExcelContentFormat(string fontName, short fontSize, bool fontBold, Alignment align)
 {
     FontName = fontName;
     FontSize = fontSize;
     FontBold = fontBold;
     Align = align;
 }
Example #7
0
 public TemplGraphic(Stream data, Alignment? align, double scalar = 1.0)
 {
     Data = new MemoryStream();
     data.CopyTo(Data);
     this.Scalar = scalar;
     this.Alignment = align;
 }
Example #8
0
		/// <summary>
		/// Creates a resized version of a Bitmap. Gained space will be empty, lost space will crop the image.
		/// </summary>
		/// <param name="bm">The original Bitmap.</param>
		/// <param name="w">The desired width.</param>
		/// <param name="h">The desired height.</param>
		/// <param name="origin">The desired resize origin in the original image.</param>
		/// <returns>A new Bitmap that has the specified size.</returns>
		public static Bitmap Resize(this Bitmap bm, int w, int h, Alignment origin = Alignment.TopLeft)
		{
			int x = 0;
			int y = 0;

			if (origin == Alignment.Right || 
				origin == Alignment.TopRight || 
				origin == Alignment.BottomRight)
				x = w - bm.Width;
			else if (
				origin == Alignment.Center || 
				origin == Alignment.Top || 
				origin == Alignment.Bottom)
				x = (w - bm.Width) / 2;

			if (origin == Alignment.Bottom || 
				origin == Alignment.BottomLeft || 
				origin == Alignment.BottomRight)
				y = h - bm.Height;
			else if (
				origin == Alignment.Center || 
				origin == Alignment.Left || 
				origin == Alignment.Right)
				y = (h - bm.Height) / 2;

			return bm.SubImage(-x, -y, w, h);
		}
		public static void DrawLabel (string _text, GUIStyle _style, Alignment _alignment = Alignment.None)
		{
			GUILayout.BeginHorizontal();
			{
				switch (_alignment)
				{
				case Alignment.None:
					GUILayout.Label(_text, _style);
					break;
					
				case Alignment.Left:
					GUILayout.Label(_text, _style);
					GUILayout.FlexibleSpace();
					break;
					
				case Alignment.Center:
					GUILayout.FlexibleSpace();
					GUILayout.Label(_text, _style);
					GUILayout.FlexibleSpace();
					break;
					
				case Alignment.Right:
					GUILayout.FlexibleSpace();
					GUILayout.Label(_text, _style);
					break;
				}
			}
			GUILayout.EndHorizontal();
		}
 public AlignmentCriterion(XmlJointType centerJoint, XmlJointType[] joints, float variance)
     : base(variance)
 {
     this.Alignment = Alignment.Point;
     this.CenterJoint = centerJoint;
     this.Joints = joints;
 }
Example #11
0
        public WordPairViewModel(IWordAligner aligner, WordPair wordPair, bool areVarietiesInOrder)
        {
            _wordPair = wordPair;
            _areVarietiesInOrder = areVarietiesInOrder;
            _meaning = new MeaningViewModel(_wordPair.Word1.Meaning);
            _variety1 = new VarietyViewModel(_wordPair.VarietyPair.Variety1);
            _variety2 = new VarietyViewModel(_wordPair.VarietyPair.Variety2);

            IWordAlignerResult results = aligner.Compute(_wordPair);
            _alignment = results.GetAlignments().First();
            _prefixNode = new AlignedNodeViewModel(_alignment.Prefixes[0], _alignment.Prefixes[1]);
            var nodes = new List<AlignedNodeViewModel>();
            int i = 0;
            for (int column = 0; column < _alignment.ColumnCount; column++)
            {
                string note = null;
                if (i < _wordPair.AlignmentNotes.Count)
                    note = _wordPair.AlignmentNotes[i];
                nodes.Add(new AlignedNodeViewModel(column, _alignment[0, column], _alignment[1, column], note));
                i++;
            }
            _suffixNode = new AlignedNodeViewModel(_alignment.Suffixes[0], _alignment.Suffixes[1]);

            _alignedNodes = new ReadOnlyCollection<AlignedNodeViewModel>(nodes);

            _showInMultipleWordAlignmentCommand = new RelayCommand(ShowInMultipleWordAlignment);
        }
Example #12
0
    static IEnumerable<string> alignText(IEnumerable<string> lines, Alignment alignment, int width)
    {
        switch (alignment)
        {
            case Alignment.LEFT:
                return lines;

            case Alignment.RIGHT:
                return lines.Select(t => new String(' ', width - t.Length) + t);

            case Alignment.CENTER:
                return lines.Select(t => new String(' ', (width - t.Length) / 2) + t);

            case Alignment.JUSTIFY:
                return lines.Select(t =>
                {
                    var words = t.Split();
                    var spaceRequired = width - t.Length;
                    var spacing = spaceRequired / (words.Length - 1) + 1;
                    return string.Join(new String(' ', spacing), words);
                });

            default:
                throw new NotImplementedException();
        }
    }
Example #13
0
        public AlignmentButton()
        {
            InitializeComponent();

            m_alignment = Alignment.Centre;
            m_image = Resources.DefaultButtonImage;
        }
Example #14
0
 public void AddComponent(MSGUIUnclickable component, Alignment alignment)
 {
     switch (alignment)
     {
         case Alignment.TOP_LEFT:
             component.Position = boundedPosition;
             break;
         case Alignment.TOP_CENTER:
             component.Position = boundedPosition + new Vector2((boundedSize.X - component.Size.X) / 2, 0);
             break;
         case Alignment.TOP_RIGHT:
             component.Position = boundedPosition + new Vector2(boundedSize.X - component.Size.X, 0);
             break;
         case Alignment.MIDDLE_LEFT:
             component.Position = boundedPosition + new Vector2(0, (boundedSize.Y - component.Size.Y) / 2);
             break;
         case Alignment.MIDDLE_CENTER:
             component.Position = boundedPosition + (boundedSize - component.Size) / 2;
             break;
         case Alignment.MIDDLE_RIGHT:
             component.Position = boundedPosition + new Vector2(boundedSize.X - component.Size.X, (boundedSize.Y - component.Size.Y) / 2);
             break;
         case Alignment.BOTTOM_LEFT:
             component.Position = boundedPosition + new Vector2(0, boundedSize.Y - component.Size.Y);
             break;
         case Alignment.BOTTOM_CENTER:
             component.Position = boundedPosition + new Vector2((boundedSize.X - component.Size.X) / 2, boundedSize.Y - component.Size.Y);
             break;
         case Alignment.BOTTOM_RIGHT:
             component.Position = boundedPosition + new Vector2(boundedSize.X - component.Size.X, boundedSize.Y - component.Size.Y);
             break;
     }
     components.Add(component);
 }
Example #15
0
        public void Center(Rectangle theDisplayArea, Alignment theAlignment)
        {
            Vector2 theTextSize = mFont.MeasureString(mText);

            switch (theAlignment)
            {
                case Alignment.Horizonatal:
                    {
                        Position.X = theDisplayArea.X + (theDisplayArea.Width / 2 - theTextSize.X / 2);
                        break;
                    }

                case Alignment.Vertical:
                    {
                        Position.Y = theDisplayArea.Y + (theDisplayArea.Height / 2 - theTextSize.Y / 2);
                        break;
                    }

                case Alignment.Both:
                    {
                        Position.X = theDisplayArea.X + (theDisplayArea.Width / 2 - theTextSize.X / 2);
                        Position.Y = theDisplayArea.Y + (theDisplayArea.Height / 2 - theTextSize.Y / 2);
                        break;
                    }
            }
        }
        //------------------------------------------------------------------------------
        // Function: ItemSelector
        // Author: nholmes
        // Summary: item constructor, allows user to specify the width of the button,
        //          the options that can be selected from, the vertical position, the
        //          alignment and the font
        //------------------------------------------------------------------------------
        public ItemSelector(Menu menu, Game game, string[] optionsText, int selectedOption, int y, int width, Alignment alignment, SpriteFont font, Color fontColor, int textOffset)
            : base(menu, game, textOffset)
        {
            // store the width of the button, options text, selected option and the font to use
            this.width = width;
            this.optionsText = optionsText;
            this.selectedOption = selectedOption;
            this.font = font;
            this.fontColor = fontColor;

            // set the vy position of this button item
            position.Y = y;

            // calculate position based on alignment provided
            switch (alignment)
            {
                case Alignment.left:
                    position.X = 0;
                    break;
                case Alignment.centre:
                    position.X = (menu.ItemArea.Width / 2) - (width / 2);
                    break;
                case Alignment.right:
                    position.X = width - (int)font.MeasureString(optionsText[selectedOption]).X;
                    break;
                default:
                    position.X = 0;
                    break;
            }

            // store the size of this button item
            size.X = width;
            size.Y = menu.ButtonTexture.Height;
        }
Example #17
0
    protected void OnButtonClicked(object sender, EventArgs e)
    {
        if (sender == button1)
        {

            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel",  ResponseType.Cancel, "Insert Spacer",  ResponseType.None, "Add", ResponseType.Accept);

            Gtk.Alignment align = new Alignment (1, 0, 0, 1);
            Gtk.Frame frame = new Frame ("Position");
            Gtk.HBox hbox = new HBox (false, 4);

            RadioButton rbRight;
            rbRight = new RadioButton ("Right");
            hbox.PackEnd(rbRight, false, false, 1);
            hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1);

            frame.Add (hbox);
            align.Add (frame);
            align.ShowAll ();
            dialog.ExtraWidget = align;

            ResponseType response = (ResponseType)dialog.Run ();
            if (response == ResponseType.Accept) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock");
            } else if (response == ResponseType.None) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock");
            }
            dialog.Destroy ();

        }
    }
Example #18
0
 public Button(Vector2 position, Texture2D texture, Texture2D textureDown, Alignment align, string text, SpriteFont font)
     : this(position,texture,textureDown)
 {
     this.font = font;
     this.text = text;
     this.align = align;
 }
        //------------------------------------------------------------------------------
        // Function: ItemSlider
        // Author: nholmes
        // Summary: item constructor, allows user to specify the width of the slider,
        //          the values that can be selected between, the vertical position, the
        //          alignment and the font
        //------------------------------------------------------------------------------
        public ItemSlider(Menu menu, Game game, int minValue, int maxValue, int initialValue, int y, int width, Alignment alignment, SpriteFont font, Color fontColor, int textOffset)
            : base(menu, game, textOffset)
        {
            // store the width of the button, options text, selected option and the font to use
            this.width = width;
            this.minValue = minValue;
            this.maxValue = maxValue;
            this.currentValue = initialValue;
            this.font = font;
            this.fontColor = fontColor;

            // set the vy position of this button item
            position.Y = y;

            // calculate position based on alignment provided
            switch (alignment)
            {
                case Alignment.left:
                    position.X = 0;
                    break;
                case Alignment.centre:
                    position.X = (menu.ItemArea.Width / 2) - (width / 2);
                    break;
                case Alignment.right:
                    position.X = width;
                    break;
                default:
                    position.X = 0;
                    break;
            }

            // store the size of this button item
            size.X = width;
            size.Y = menu.ButtonTexture.Height;
        }
Example #20
0
        int sightRange; // how far a character can see in squares

        #endregion Fields

        #region Constructors

        public Unit(int str, int mag, int dex, int agi, int def, int res, int spd,
            int strGrowth, int magGrowth, int dexGrowth, int agiGrowth, int defGrowth, int resGrowth, int spdGrowth,
            int strCap, int magCap, int dexCap, int agiCap, int defCap, int resCap, int spdCap,
            string name, Alignment ali, Role role)
        {
            attributes = new Dictionary<string, int>();

            attributes["strength"] = str;
            attributes["magic"] = mag;
            attributes["dexterity"] = dex;
            attributes["agility"] = agi;
            attributes["defense"] = def;
            attributes["resistance"] = res;
            attributes["speed"] = spd;

            caps["strength"] = strCap;
            caps["magic"] = magCap;
            caps["dexterity"] = dexCap;
            caps["agility"] = agiCap;
            caps["defense"] = defCap;
            caps["resistance"] = resCap;
            caps["speed"] = spdCap;

            growths["strength"] = strGrowth;
            growths["magic"] = magGrowth;
            growths["dexterity"] = dexGrowth;
            growths["agility"] = agiGrowth;
            growths["defense"] = defGrowth;
            growths["resistance"] = resGrowth;
            growths["speed"] = spdGrowth;

            alignment = ali;
        }
Example #21
0
		public RotateExtrude(double[] points, double axisOffset = 0, Alignment alignment = Alignment.z, string name = "")
		{
			if ((points.Length % 2) != 0)
			{
				throw new Exception("You must pass in an even number of points so they can be converted to Vector2s.");
			}
			List<Vector2> vectorPoints = new List<Vector2>();
			for (int i = 0; i < points.Length; i += 2)
			{
				vectorPoints.Add(new Vector2(points[i], points[i + 1]));
			}
			root = new RotateExtrudePrimitive(vectorPoints.ToArray(), axisOffset, name);
			switch (alignment)
			{
				case Alignment.x:
					root = new Rotate(root, y: MathHelper.DegreesToRadians(90));
					break;

				case Alignment.y:
					root = new Rotate(root, x: MathHelper.DegreesToRadians(90));
					break;

				case Alignment.z:
					// don't need to do anything
					break;

				default:
					throw new NotImplementedException();
			}
		}
Example #22
0
 public TabStop(float position, IDrawInterface leader, Alignment alignment, char anchorChar)
 {
     this.position = position;
     this.leader = leader;
     this.alignment = alignment;
     this.anchorChar = anchorChar;
 }
Example #23
0
 public ButtonCell(ButtonCell bc)
     : base(bc)
 {
     this.m_bColor = SystemColors.ControlDark;
     this.m_pForeColor = SystemColors.HighlightText;
     this.m_pBgColor = SystemColors.ControlDark;
     this.m_pBorderColor = SystemColors.ControlDarkDark;
     this.m_text = "";
     this.m_DetachImageList = new EventHandler(this.OnDetachImageList);
     this.m_buttonStyle = bc.m_buttonStyle;
     this.m_font = new Font(bc.m_font.Name, bc.m_font.Size, bc.m_font.Style);
     this.m_text = bc.m_text;
     this.m_textAlignment = bc.m_textAlignment;
     this.m_textPosition = bc.m_textPosition;
     this.m_imageAlignment = bc.m_imageAlignment;
     this.m_imagePosition = bc.m_imagePosition;
     this.m_autoResizeImage = bc.m_autoResizeImage;
     this.m_ia = new ImageAttributes();
     this.m_bColor = bc.m_bColor;
     this.m_pBgColor = bc.m_pBgColor;
     this.m_pBorderColor = bc.m_pBorderColor;
     this.m_pForeColor = bc.m_pForeColor;
     this.m_transparentColor = bc.m_transparentColor;
     this.m_bAutoTransparent = bc.m_bAutoTransparent;
     this.m_touchMargin = bc.m_touchMargin;
     this.m_bPressed = bc.m_bPressed;
     this.m_defaultImage = bc.m_defaultImage;
     this.m_defaultImageVGA = bc.m_defaultImageVGA;
     this.m_pressedImage = bc.m_pressedImage;
     this.m_pressedImageVGA = bc.m_pressedImageVGA;
     base.Selectable = bc.Selectable;
 }
Example #24
0
        public static void Draw(SpriteBatch spriteBatch,int number, Alignment aligment ,Rectangle rect, int scale = 1)
        {
            var numbers = number.ToString ().ToCharArray ().Select (n => n.ToString ());
            var images = numbers.Select (n => textures [n]).ToList ();
            var width = images.Sum (n => n.Width* scale) + ((images.Count - 1) * padding*scale);

            int x = rect.Left;
            if (aligment == Alignment.Right)
                x = rect.Right - width;
            else if (aligment == Alignment.Center)
                x = (rect.Right / 2) - (width / 2);
            int y = rect.Top;
            var drawRect = new Rectangle (x, y, 0, 0);

            images.ForEach (i => {
                drawRect.X =x;
                drawRect.Width = i.Width*scale;
                drawRect.Height = i.Height*scale;
                spriteBatch.Draw (
                    i,
                    null,
                    drawRect,
                    null,
                    null,
                    0,
                    new Vector2(scale),
                    Color.White,
                    SpriteEffects.None,
                    0.0f);

                spriteBatch.Draw(i,drawRect,Color.White);
                x += i.Width * scale + padding*scale;
            });
        }
Example #25
0
 public AlignmentState (Alignment alignment, float padding, uint[] numberOfItems)
     : this()
 {
     Alignment = alignment;
     Padding = padding;
     NumberOfItemsPer = numberOfItems;
 }
Example #26
0
 public Vector2 Place( Vector2 size, float horizontalMargin,
     float verticalMargine, Alignment alignment)
 {
     Rectangle rc = new Rectangle( 0, 0, (int)size.X, (int)size.Y );
       rc = Place( rc, horizontalMargin, verticalMargine, alignment );
       return new Vector2( rc.X, rc.Y );
 }
Example #27
0
        public static void DrawString(SpriteBatch spriteBatch, SpriteFont font, string text, Rectangle bounds, Alignment align, Color color)
        {
            Vector2 size = font.MeasureString(text);
            Vector2 pos = new Vector2(bounds.X + (bounds.Width >> 1), bounds.Y + (bounds.Height >> 1));
            Vector2 origin = size * 0.5f;

            switch (align)
            {
                case Alignment.Left:
                    origin.X += (bounds.Width - size.X) / 2;
                    break;
                case Alignment.Right:
                    origin.X -= (bounds.Width - size.X) / 2;
                    break;
                case Alignment.Top:
                    origin.Y += (bounds.Height - size.Y) / 2;
                    break;
                case Alignment.Bottom:
                    origin.Y -= (bounds.Height - size.Y) / 2;
                    break;
                case Alignment.Center:
                    break;
            }
            spriteBatch.DrawString(font, text, pos, color, 0, origin, 1, SpriteEffects.None, 0);
        }
Example #28
0
        // public Collection<TableColumn> SubColumns { get; set; }

        public TableColumn(string header, string path, string stringFormat=null, Alignment alignment=Alignment.Center)
        {
            Header = header;
            Path = path;
            StringFormat = stringFormat;
            Alignment = alignment;
            // SubColumns = new Collection<TableColumn>();
        }
 public ConnectionButton( NodeWindow window, ConnectionButtonType type, string label, Alignment align )
 {
     ButtonLabel = label;
     LabelAlignment = align;
     LastPosition = new Vector2();
     m_type = type;
     m_parentWindow = window;
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ItemsTableField" /> class.
 /// </summary>
 /// <param name="header">The header.</param>
 /// <param name="path">The path.</param>
 /// <param name="stringFormat">The string format.</param>
 /// <param name="alignment">The alignment.</param>
 public ItemsTableField(
     string header, string path, string stringFormat = null, Alignment alignment = Alignment.Center)
 {
     this.Header = header;
     this.Path = path;
     this.StringFormat = stringFormat;
     this.Alignment = alignment;
 }
Example #31
0
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, Alignment alignment,
                                       int offsetX, int offsetY, bool ellipsis)
        {
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

// Truncate text that doesn't fit?
            if (ellipsis)
            {
                const string elli = "...";
                var          size = (int)Math.Ceiling(font.MeasureString(text).X);
// Text is wider then the destination region?
                if (size > rect.Width)
                {
                    var es = (int)Math.Ceiling(font.MeasureString(elli).X);
                    for (var i = text.Length - 1; i > 0; i--)
                    {
                        var c = 1;
// Remove two letters if the preceding character is a space.
                        if (char.IsWhiteSpace(text[i - 1]))
                        {
                            c = 2;
                            i--;
                        }
// Chop off the tail of the string and remeasure the width.
                        text = text.Remove(i, c);
                        size = (int)Math.Ceiling(font.MeasureString(text).X);
// Text is short enough?
                        if (size + es <= rect.Width)
                        {
                            break;
                        }
                    }
// Append the ellipsis to the truncated string.
                    text += elli;
                }
            }
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

// Destination region is not degenerate?
            if (rect.Width > 0 && rect.Height > 0)
            {
// Text starts from the destination region origin.
                var pos  = new Vector2(rect.Left, rect.Top);
                var size = font.MeasureString(text);
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

                var x = 0;
                var y = 0;
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

// Adjust the text position to account for the specified alignment.
                switch (alignment)
                {
                case Alignment.TopLeft:
                    break;

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

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

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

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

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

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

                case Alignment.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;
                }

// Add the text position offsets to the mix.
                pos.X = (int)(pos.X + x);
                pos.Y = (int)(pos.Y + y);

                DrawString(font, text, (int)pos.X + offsetX, (int)pos.Y + offsetY, color);
            }
        }
Example #32
0
        setBldgElevRef(Alignment objAlign)
        {
            TinSurface objSurface = null;
            bool       exists     = false;

            try
            {
                objSurface = Surf.getTinSurface("CPNT-ON", out exists);
                if (!exists)
                {
                    Stake_GetSurfaceCPNT.getSurfaceFromXRef("STAKE", "STAKE");
                    objSurface = Surf.getTinSurface("CPNT-ON", out exists);
                }
            }
            catch (System.Exception)
            {
            }
            ObjectId idBldg = objAlign.GetPolyline();
            Point3d  pnt3d  = idBldg.getCentroid();

            Point3d pnt3dCen = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

            if (pnt3dCen.Z == -99999.99)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Invalid Elevation at Reference Point - Exiting.......");
                return;
            }

            //Set objCircle = addcircle(pnt3dCEN, 3)
            //objCircle.color = acRed
            //objCircle.Update

            double dblAngTar = 0;
            int    intMark   = 0;

            idBldg.getEastWestBaseLineDir(ref dblAngTar, ref intMark);

            Point3d pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

            double dblSlope = System.Math.Round((pnt3dTar.Z - pnt3dCen.Z) / 100, 4);

            //Set objCircle = addcircle(pnt3dTAR, 3)
            //objCircle.color = acYellow
            //objCircle.Update

            if (dblSlope == 0)
            {
                dblAngTar = dblAngTar + PI / 2;

                if (dblAngTar > 2 * PI)
                {
                    dblAngTar = dblAngTar - 2 * PI;
                }

                pnt3d    = pnt3dCen.traverse(dblAngTar, 100);
                pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                //   Set objCircle = addcircle(pnt3dTAR, 3)
                //   objCircle.color = acGreen
                //   objCircle.Update

                if (System.Math.Round(dblSlope, 3) == 0)
                {
                    pnt3d = pnt3dCen.traverse(dblAngTar - PI / 2, 100);
                    //back to original orientation
                    pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                    //     Set objCircle = addcircle(pnt3dTAR, 3)
                    //     objCircle.color = acCyan
                    //     objCircle.Update
                }
            }
            else if (dblSlope < 0)
            {
                dblAngTar = dblAngTar + PI;

                if (dblAngTar > 2 * PI)
                {
                    dblAngTar = dblAngTar - 2 * PI;
                }

                pnt3dTar = new Point3d(pnt3d.X, pnt3d.Y, objSurface.FindElevationAtXY(pnt3d.X, pnt3d.Y));

                //   Set objCircle = addcircle(pnt3dTAR, 3)
                //   objCircle.color = acBlue
                //   objCircle.Update

                dblSlope = -dblSlope;
            }

            BlockReference objBlkRef = null;

            using (Transaction tr = BaseObjs.startTransactionDb())
            {
                try
                {
                    List <string> attVals = new List <string> {
                        dblSlope.ToString()
                    };
                    objBlkRef       = Blocks.addBlockRef("G:\\TOOLBOX\\Slparrow_STAKE.dwg", pnt3dCen, dblAngTar, attVals);
                    objBlkRef.Layer = string.Format("STAKE-BLDG-{0}-LABEL", objAlign.Name);
                }
                catch (System.Exception)
                {
                }
                tr.Commit();
            }

            idBldg.delete();

            TypedValue[] tvs = new TypedValue[6] {
                new TypedValue(1001, "BLDG"),
                new TypedValue(1040, pnt3dCen.X),
                new TypedValue(1040, pnt3dCen.Y),
                new TypedValue(1040, pnt3dCen.Z),
                new TypedValue(1040, dblAngTar),
                new TypedValue(1040, dblSlope)
            };

            objAlign.ObjectId.setXData(tvs, "STAKE");
        }
Example #33
0
        /// <returns>Returns a rectangle that specifies the location and size of the asset that was requested.</returns>
        /// <param name="index">Index specifying where on the source image, the asset we want is located.</param>
        /// <param name="alignment">???</param>
        /// <param name="margins">???</param>
        /// <param name="partSize">Size of the asset piece to retrieve the source region for.</param>
        /// <param name="imageSize">Size of the entire image.</param>
        /// <summary>
        /// when multiple assets are packed into a single image file.
        /// Used to grab a piece of the source region of a skin resource
        /// </summary>
        private static Rectangle GetSourceArea(Size imageSize, Size partSize, Margins margins, Alignment alignment,
                                               int index)
        {
            var rect = new Rectangle();
// Break the image down into rows and columns.
            var xc = (int)((float)imageSize.Width / partSize.Width);
            var yc = (int)((float)imageSize.Height / partSize.Height);

// Figure out which row and column the asset is located at.
            var xm = (index) % xc;
            var ym = (index) / xc;

            var 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);
// Adjust the text position to account for the specified alignment.
            switch (alignment)
            {
            case Alignment.TopLeft:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (0 + (ym * partSize.Height)),
                                     margins.Left,
                                     margins.Top);
                break;
            }

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

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

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

            case Alignment.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 Alignment.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 Alignment.BottomLeft:
            {
                rect = new Rectangle((0 + (xm * partSize.Width)),
                                     (partSize.Height + (ym * partSize.Height)) - margins.Bottom,
                                     margins.Left,
                                     margins.Bottom);
                break;
            }

            case Alignment.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 Alignment.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);
        }
Example #34
0
 public virtual void Insert(Control item, Control exists, RelativeAlignment at, int xspan, int yspan, int hexpand, Alignment halign, int vexpand, Alignment valign)
 {
     uiGridInsertAt(Owner.Handle, item.Handle, exists.Handle, at, xspan, yspan, hexpand, halign, vexpand, valign);
     base.Insert(exists.Index, item);
 }
Example #35
0
        public void SetTitle(Gtk.Widget page, Gdk.Pixbuf icon, string label)
        {
            this.label = label;
            this.page  = page;
            if (Child != null)
            {
                Gtk.Widget oc = Child; // keep a handle to the Child widget to prevent it from being garbage collected
                Remove(oc);            // remove Child from parent. After this, Child==null

                oc.Destroy();          // now that no reference from the parent points to the child anymore, destroy it.
                //oc.Dispose();          // not sure if this is additionally needed to .Destroy()
            }

            Gtk.HBox box = new HBox();
            box.Spacing = 2;

            if (icon != null)
            {
                tabIcon = new Gtk.Image(icon);
                tabIcon.Show();
                box.PackStart(tabIcon, false, false, 0);
            }
            else
            {
                tabIcon = null;
            }

            if (!string.IsNullOrEmpty(label))
            {
                labelWidget = new ExtendedLabel(label);
                labelWidget.DropShadowVisible = true;
                labelWidget.UseMarkup         = true;
                box.PackStart(labelWidget, true, true, 0);
            }
            else
            {
                labelWidget = null;
            }

            btnDock             = new ImageButton();
            btnDock.Image       = pixAutoHide;
            btnDock.TooltipText = "Auto Hide";
            btnDock.CanFocus    = false;
//       btnDock.WidthRequest = btnDock.HeightRequest = 17;
            btnDock.Clicked          += OnClickDock;
            btnDock.ButtonPressEvent += (o, args) => args.RetVal = true;
            btnDock.WidthRequest      = btnDock.SizeRequest().Width;

            btnClose             = new ImageButton();
            btnClose.Image       = pixClose;
            btnClose.TooltipText = "Close";
            btnClose.CanFocus    = false;
//       btnClose.WidthRequest = btnClose.HeightRequest = 17;
            btnClose.WidthRequest      = btnDock.SizeRequest().Width;
            btnClose.Clicked          += delegate { item.Close(); };
            btnClose.ButtonPressEvent += (o, args) => args.RetVal = true;

            Gtk.Alignment al     = new Alignment(0, 0, 1, 1);
            HBox          btnBox = new HBox(false, 3);

            btnBox.PackStart(btnDock, false, false, 0);
            btnBox.PackStart(btnClose, false, false, 0);
            al.Add(btnBox);
            al.LeftPadding = 3;
            al.TopPadding  = 1;
            box.PackEnd(al, false, false, 0);

            Add(box);

            // Get the required size before setting the ellipsize property, since ellipsized labels
            // have a width request of 0
            box.ShowAll();
            Show();

            UpdateBehavior();
            UpdateVisualStyle();
        }
Example #36
0
        /// <returns>The region where the partial source piece should be drawn.</returns>
        /// <param name="alignment">Which piece of the asset is this?</param>
        /// <param name="margins">Margin values applied to the region.</param>
        /// <param name="area">Entire destination region where the image should be drawn.</param>
        /// <summary>
        /// Calculates the correct piece of the destination region where the partial source area should be drawn.
        /// </summary>
        public static Rectangle GetDestinationArea(Rectangle area, Margins margins, Alignment alignment)
        {
            var rect = new Rectangle();

            var 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);

// Adjust the text position to account for the specified alignment.
            switch (alignment)
            {
            case Alignment.TopLeft:
            {
                rect = new Rectangle(area.Left + 0,
                                     area.Top + 0,
                                     margins.Left,
                                     margins.Top);
                break;
            }

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

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

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

            case Alignment.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 Alignment.MiddleRight:
            {
                rect = new Rectangle(area.Left + area.Width - margins.Right,
                                     area.Top + margins.Top,
                                     margins.Right,
                                     area.Height - margins.Top - margins.Bottom);
                break;
            }

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

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

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

            return(rect);
        }
 /// <summary>
 /// Creates a new subitem which can draw text on a node.
 /// </summary>
 /// <param name="backgroundNormal">The background brush used when the subitem is not selected.</param>
 /// <param name="backgroundSelected">The background brush used when the subitem is selected. If it cannot be selected, use null.</param>
 /// <param name="labelFont">The font used to draw the label.</param>
 /// <param name="labelBrush">The brush used to draw the label.</param>
 /// <param name="alignment">The alignment of the label.</param>
 /// <param name="showParallelToLabel">Holds if the subitem will be drawn next to the node's label or below it.</param>
 protected SubItemText(Brush backgroundNormal, Brush backgroundSelected, Font labelFont, Brush labelBrush, Alignment alignment, bool showParallelToLabel) : base(showParallelToLabel)
 {
     _backgroundNormal   = backgroundNormal;
     _backgroundSelected = backgroundSelected;
     _labelFont          = labelFont;
     _labelBrush         = labelBrush;
     _alignment          = alignment;
 }
Example #38
0
        public override void SetAlignment(object backend, Alignment alignment)
        {
            LayoutInfo li = (LayoutInfo)backend;

            li.TextAlignment = alignment;
        }
Example #39
0
 protected Panel(Alignment horizontalAlignment = Alignment.Stretch, Alignment verticalAlignment = Alignment.Stretch)
     : base(horizontalAlignment, verticalAlignment)
 {
     IsFocusable = false;
 }
Example #40
0
                public Canvas(CreateParams parentParams, XmlReader reader)
                {
                    Initialize( );

                    // Always get our style first
                    mStyle = parentParams.Style;
                    Styles.Style.ParseStyleAttributesWithDefaults(reader, ref mStyle, ref ControlStyles.mCanvas);

                    // check for attributes we support
                    RectangleF bounds     = new RectangleF( );
                    SizeF      parentSize = new SizeF(parentParams.Width, parentParams.Height);

                    ParseCommonAttribs(reader, ref parentSize, ref bounds);

                    // Get margins and padding
                    RectangleF padding;
                    RectangleF margin;

                    GetMarginsAndPadding(ref mStyle, ref parentSize, ref bounds, out margin, out padding);

                    // apply margins to as much of the bounds as we can (bottom must be done by our parent container)
                    ApplyImmediateMargins(ref bounds, ref margin, ref parentSize);
                    Margin = margin;

                    // check for border styling
                    int borderPaddingPx = 0;

                    if (mStyle.mBorderColor.HasValue)
                    {
                        BorderView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if (mStyle.mBorderRadius.HasValue)
                    {
                        BorderView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if (mStyle.mBorderWidth.HasValue)
                    {
                        BorderView.BorderWidth = mStyle.mBorderWidth.Value;
                        borderPaddingPx        = (int)Rock.Mobile.Graphics.Util.UnitToPx(mStyle.mBorderWidth.Value + PrivateNoteConfig.BorderPadding);
                    }

                    if (mStyle.mBackgroundColor.HasValue)
                    {
                        BorderView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }
                    //

                    // now calculate the available width based on padding. (Don't actually change our width)
                    float availableWidth = bounds.Width - padding.Left - padding.Width - (borderPaddingPx * 2);

                    // now read what our children's alignment should be
                    // check for alignment
                    string result = reader.GetAttribute("ChildAlignment");

                    if (string.IsNullOrEmpty(result) == false)
                    {
                        switch (result)
                        {
                        case "Left":
                            ChildHorzAlignment = Alignment.Left;
                            break;

                        case "Right":
                            ChildHorzAlignment = Alignment.Right;
                            break;

                        case "Center":
                            ChildHorzAlignment = Alignment.Center;
                            break;

                        default:
                            ChildHorzAlignment = mStyle.mAlignment.Value;
                            break;
                        }
                    }
                    else
                    {
                        // if it wasn't specified, use OUR alignment.
                        ChildHorzAlignment = mStyle.mAlignment.Value;
                    }

                    // Parse Child Controls
                    bool finishedParsing = false;

                    while (finishedParsing == false && reader.Read( ))
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Element:
                        {
                            // let each child have our available width.
                            Style style = new Style( );
                            style            = mStyle;
                            style.mAlignment = ChildHorzAlignment;
                            IUIControl control = Parser.TryParseControl(new CreateParams(this, availableWidth, parentParams.Height, ref style), reader);
                            if (control != null)
                            {
                                ChildControls.Add(control);
                            }
                            break;
                        }

                        case XmlNodeType.EndElement:
                        {
                            // if we hit the end of our label, we're done.
                            //if( reader.Name == "Canvas" || reader.Name == "C" )
                            if (ElementTagMatches(reader.Name))
                            {
                                finishedParsing = true;
                            }

                            break;
                        }
                        }
                    }


                    // layout all controls
                    float yOffset = bounds.Y + padding.Top + borderPaddingPx; //vertically they should just stack
                    float height  = 0;

                    // now we must center each control within the stack.
                    foreach (IUIControl control in ChildControls)
                    {
                        RectangleF controlFrame  = control.GetFrame( );
                        RectangleF controlMargin = control.GetMargin( );

                        // horizontally position the controls according to their
                        // requested alignment
                        Alignment controlAlignment = control.GetHorzAlignment( );

                        // adjust by our position
                        float xAdjust = 0;
                        switch (controlAlignment)
                        {
                        case Alignment.Center:
                            xAdjust = bounds.X + ((availableWidth / 2) - (controlFrame.Width / 2));
                            break;

                        case Alignment.Right:
                            xAdjust = bounds.X + (availableWidth - (controlFrame.Width + controlMargin.Width));
                            break;

                        case Alignment.Left:
                            xAdjust = bounds.X;
                            break;
                        }

                        // adjust the next sibling by yOffset
                        control.AddOffset(xAdjust + padding.Left + borderPaddingPx, yOffset);

                        // track the height of the grid by the control lowest control
                        height = (control.GetFrame( ).Bottom +  +controlMargin.Height) > height ? (control.GetFrame( ).Bottom +  +controlMargin.Height) : height;
                    }

                    // we need to store our bounds. We cannot
                    // calculate them on the fly because we
                    // would lose any control defined offsets, which would throw everything off.
                    bounds.Height = height + padding.Height + borderPaddingPx;

                    // setup our bounding rect for the border
                    bounds = new RectangleF(bounds.X,
                                            bounds.Y,
                                            bounds.Width,
                                            bounds.Height);

                    // and store that as our bounds
                    BorderView.Frame = bounds;

                    Frame = bounds;

                    // store our debug frame
                    SetDebugFrame(Frame);

                    // sort everything
                    ChildControls.Sort(BaseControl.Sort);
                }
        public static Vector3 GetCameraPoint(this Camera camera, Alignment pointAlignment)
        {
            if (pointAlignment == Alignment.Middle)
            {
                return(camera.transform.position);
            }

            var thisCam = camera;
            var farClip = thisCam.farClipPlane;

            var topLeftPosition  = thisCam.ViewportToWorldPoint(new Vector3(0, 1, farClip));
            var topRightPosition = thisCam.ViewportToWorldPoint(new Vector3(1, 1, farClip));
            var btmRightPosition = thisCam.ViewportToWorldPoint(new Vector3(1, 0, farClip));
            var btmLeftPosition  = thisCam.ViewportToWorldPoint(new Vector3(0, 0, farClip));


            if (pointAlignment == Alignment.MiddleLeft || pointAlignment == Alignment.MiddleRight ||
                pointAlignment == Alignment.TopMiddle || pointAlignment == Alignment.BottomMiddle)
            {
                var width      = Math.Abs(topLeftPosition.x - topRightPosition.x);
                var height     = Math.Abs(topLeftPosition.y - btmLeftPosition.y);
                var halfWidth  = width / 2;
                var halfHeight = height / 2;

                if (pointAlignment == Alignment.MiddleLeft)
                {
                    return(new Vector3(camera.transform.position.x - halfWidth, camera.transform.position.y));
                }
                if (pointAlignment == Alignment.MiddleRight)
                {
                    return(new Vector3(camera.transform.position.x + halfWidth, camera.transform.position.y));
                }

                if (pointAlignment == Alignment.TopMiddle)
                {
                    return(new Vector3(camera.transform.position.x, camera.transform.position.y + halfHeight));
                }
                if (pointAlignment == Alignment.BottomMiddle)
                {
                    return(new Vector3(camera.transform.position.x, camera.transform.position.y - halfHeight));
                }
            }

            if (pointAlignment == Alignment.BottomLeft)
            {
                return(btmLeftPosition);
            }
            if (pointAlignment == Alignment.BottomRight)
            {
                return(btmRightPosition);
            }
            if (pointAlignment == Alignment.TopLeft)
            {
                return(topLeftPosition);
            }
            if (pointAlignment == Alignment.TopRight)
            {
                return(topRightPosition);
            }

            return(camera.transform.position);
        }
Example #42
0
        public void addTwoImagesToText(string textBetween, string image1Path, string image2Path, Document document, Alignment alignment,
                                       string fontName, double fontSize, System.Drawing.Color color)
        {
            Image image1 = document.AddImage(image1Path);

            // Create a picture (A custom view of an Image).
            Picture picture1 = image1.CreatePicture();

            Image image2 = document.AddImage(image2Path);

            // Create a picture (A custom view of an Image).
            Picture picture2 = image2.CreatePicture();

            picture2.Height = 114;
            picture2.Width  = 251;

            // Insert a new Paragraph into the document.
            Paragraph p1 = document.InsertParagraph();

            // Append content to the Paragraph
            p1.AppendPicture(picture1).Append(textBetween).Font(fontName).AppendPicture(picture2).
            FontSize(fontSize).Color(color);
        }
Example #43
0
 /// <summary>
 /// Sets the image of the button to the specified value with the specified alignment.
 /// All states of the button show the same image.
 /// </summary>
 /// <param name="image">The images for the button</param>
 /// <param name="align">The alignment of the image</param>
 public void SetImage(Bitmap image, Alignment align)
 {
     SetImage(new Bitmap[] { image }, align, 0, 0, 0, 0);
 }
Example #44
0
        /// <summary>
        /// Sets the images of the button to the specified value with the specified alignment and margins.
        /// </summary>
        /// <param name="images">The images for the button.</param>
        /// <param name="align">The alignment of the image</param>
        /// <param name="leftMargin">The left margin of the image in pixels</param>
        /// <param name="topMargin">The top margin of the image in pixels</param>
        /// <param name="rightMargin">The right margin of the image in pixels</param>
        /// <param name="bottomMargin">The bottom margin of the image in pixels</param>
        public void SetImage(Bitmap[] images,
                             Alignment align, int leftMargin, int topMargin, int rightMargin,
                             int bottomMargin)
        {
            if (GenerateDisabledImage)
            {
                if (images.Length == 1)
                {
                    Bitmap image = images[0];
                    images = new Bitmap[] { image, image, image, image, image };
                }

                images[3] = DrawImageDisabled(images[3]);
            }

            if (ComCtlMajorVersion < 0)
            {
                DLLVERSIONINFO dllVersion = new DLLVERSIONINFO();
                dllVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));
                GetCommonControlDLLVersion(ref dllVersion);
                ComCtlMajorVersion = dllVersion.dwMajorVersion;
            }

            if (ComCtlMajorVersion >= 6 && FlatStyle == FlatStyle.System)
            {
                RECT rect = new RECT();
                rect.left   = leftMargin;
                rect.top    = topMargin;
                rect.right  = rightMargin;
                rect.bottom = bottomMargin;

                BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST();
                buttonImageList.margin = rect;
                buttonImageList.uAlign = (int)align;

                ImageList            = GenerateImageList(images);
                buttonImageList.himl = ImageList.Handle;

                SendMessage(this.Handle, BCM_SETIMAGELIST, 0, ref buttonImageList);
            }
            else
            {
                FlatStyle = FlatStyle.Standard;

                if (images.Length > 0)
                {
                    Image = images[0];
                }

                switch (align)
                {
                case Alignment.Bottom:
                    ImageAlign = ContentAlignment.BottomCenter;
                    break;

                case Alignment.Left:
                    ImageAlign = ContentAlignment.MiddleLeft;
                    break;

                case Alignment.Right:
                    ImageAlign = ContentAlignment.MiddleRight;
                    break;

                case Alignment.Top:
                    ImageAlign = ContentAlignment.TopCenter;
                    break;

                case Alignment.Center:
                    ImageAlign = ContentAlignment.MiddleCenter;
                    break;
                }
            }
        }
Example #45
0
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, Alignment alignment,
                                       bool ellipsis)
        {
            DrawString(font, text, rect, color, alignment, 0, 0, ellipsis);
        }
        internal MonoDevelopStatusBar()
        {
            BorderWidth   = 0;
            Spacing       = 0;
            HasResizeGrip = true;

            Accessible.Role = Atk.Role.Filler;

            HeaderBox hb = new HeaderBox(1, 0, 0, 0);

            hb.Accessible.Role = Atk.Role.Filler;
            hb.StyleSet       += (o, args) => {
                hb.BorderColor     = Styles.DockSeparatorColor.ToGdkColor();
                hb.BackgroundColor = Styles.DockBarBackground.ToGdkColor();
            };
            var mainBox = new HBox();

            mainBox.Accessible.Role = Atk.Role.Filler;
            var alignment = new Alignment(0f, 0f, 0f, 0f);

            alignment.Accessible.Role = Atk.Role.Filler;
            mainBox.PackStart(alignment, true, true, 0);
            hb.Add(mainBox);
            hb.ShowAll();
            PackStart(hb, true, true, 0);

            // Dock area

            CustomFrame dfr = new CustomFrame(0, 0, 1, 0);

            dfr.Accessible.Role = Atk.Role.Filler;
            dfr.StyleSet       += (o, args) => {
                dfr.BorderColor = Styles.DockSeparatorColor.ToGdkColor();
            };
            dfr.ShowAll();
            DefaultWorkbench wb = (DefaultWorkbench)IdeApp.Workbench.RootWindow;
            var dockBar         = wb.DockFrame.ExtractDockBar(PositionType.Bottom);

            dockBar.AlignToEnd = true;
            dockBar.ShowBorder = false;
            dockBar.NoShowAll  = true;
            dfr.Add(dockBar);
            mainBox.PackStart(dfr, false, false, 0);

            // Resize grip

            resizeGrip.Accessible.SetRole(AtkCocoa.Roles.AXGrowArea);
            resizeGrip.WidthRequest  = ResizeGripWidth;
            resizeGrip.HeightRequest = 0;
            resizeGrip.VisibleWindow = false;
            mainBox.PackStart(resizeGrip, false, false, 0);

            resizeGrip.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) {
                if (args.Event.Button == 1)
                {
                    GdkWindow.BeginResizeDrag(Gdk.WindowEdge.SouthEast, (int)args.Event.Button, (int)args.Event.XRoot, (int)args.Event.YRoot, args.Event.Time);
                }
            };

            this.ShowAll();

//			// todo: Move this to the CompletionWindowManager when it's possible.
//			StatusBarContext completionStatus = null;
//			CompletionWindowManager.WindowShown += delegate {
//				CompletionListWindow wnd = CompletionWindowManager.Wnd;
//				if (wnd != null && wnd.List != null && wnd.List.CategoryCount > 1) {
//					if (completionStatus == null)
//						completionStatus = CreateContext ();
//					completionStatus.ShowMessage (string.Format (GettextCatalog.GetString ("To toggle categorized completion mode press {0}."), IdeApp.CommandService.GetCommandInfo (Commands.TextEditorCommands.ShowCompletionWindow).AccelKey));
//				}
//			};
        }
Example #47
0
// currentMonster.Name, Color.Red.ToHex(true));
// string.Format("You attempt to hit the [color:#FFFF0000]{0}[/color] but [color:{1}]MISS[/color]!",
// example:

        public virtual void DrawString(SpriteFont font, string text, Rectangle rect, Color color, Alignment alignment)
        {
            DrawString(font, text, rect, color, alignment, 0, 0, true);
        }
Example #48
0
        public static CsgObject CreateNegativeBevel(double innerRadius, double outerRadius, double height, Alignment alignment = Alignment.z, double extraDimension = defaultExtraRadialDimension, string name = "")
        {
            double         width  = outerRadius - innerRadius;
            List <Vector2> points = new List <Vector2>();

            int numCurvePoints = 6;

            for (int curvePoint = 0; curvePoint <= numCurvePoints; curvePoint++)
            {
                double x = width - Math.Cos((MathHelper.Tau / 4 * curvePoint / numCurvePoints)) * width;
                double y = height - Math.Sin((MathHelper.Tau / 4 * curvePoint / numCurvePoints)) * height;
                points.Add(new Vector2(x, y));
            }
            points.Add(new Vector2(width, 0));
            points.Add(new Vector2(width, height));

            CsgObject bevel = new RotateExtrude(points.ToArray(), innerRadius, alignment, name);

            points.Clear();
            points.Add(new Vector2(0, -extraDimension));
            points.Add(new Vector2(width + extraDimension, -extraDimension));
            points.Add(new Vector2(width + extraDimension, height + extraDimension));
            points.Add(new Vector2(0, height + extraDimension));

            CsgObject cut = new RotateExtrude(points.ToArray(), innerRadius, alignment, name);

            cut = new Align(cut, Face.Bottom, bevel, Face.Bottom, 0, 0, .1);
            //return cut;
            bevel = cut - bevel;

            return(bevel);
        }
Example #49
0
 public SkinnedList(Colors selectedColor, Colors shadowColor, int imageWidth = 10, int imageHeight = 10, int itemTextXOffset = 10, int itemTextYOffset = 2, int itemHeight = 27, int space = 2, Alignment alignmentY = Alignment.CENTER_Y) :
     base(-10, -10, 1, 1, Path.Combine(Skin.DefautSkin.Images, "List", "MenuItemNF.png"),
          Path.Combine(Skin.DefautSkin.Images, "List", "MenuItemFO.png"),
          selectedColor, shadowColor, imageWidth: imageWidth, imageHeight: imageHeight, itemTextXOffset: itemTextXOffset, itemTextYOffset: itemTextYOffset, itemHeight: itemHeight, space: space, alignmentY: alignmentY)
 {
 }
Example #50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GamePage"/> class. The given package group and node tree are
        /// wrapped by the page.
        /// </summary>
        /// <param name="packageGroup">The package group which the node tree maps to.</param>
        /// <param name="nodeTree">The prebuilt node tree to display.</param>
        /// <param name="version">The Warcraft version that the game page is contextually relevant for.</param>
        public GamePage(PackageGroup packageGroup, OptimizedNodeTree nodeTree, WarcraftVersion version)
        {
            this.Packages         = packageGroup;
            this.Version          = version;
            this.DatabaseProvider = new ClientDatabaseProvider(this.Version, this.Packages);

            this.TreeModel = new FileTreeModel(nodeTree);

            this.TreeAlignment = new Alignment(0.5f, 0.5f, 1.0f, 1.0f)
            {
                TopPadding    = 1,
                BottomPadding = 1
            };

            this.TreeFilter = new TreeModelFilter(new TreeModelAdapter(this.TreeModel), null)
            {
                VisibleFunc = TreeModelVisibilityFunc
            };

            this.TreeSorter = new TreeModelSort(this.TreeFilter);

            this.TreeSorter.SetSortFunc(0, SortGameTreeRow);
            this.TreeSorter.SetSortColumnId(0, SortType.Descending);

            this.Tree = new TreeView(this.TreeSorter)
            {
                HeadersVisible  = true,
                EnableTreeLines = true
            };

            CellRendererPixbuf nodeIconRenderer = new CellRendererPixbuf
            {
                Xalign = 0.0f
            };
            CellRendererText nodeNameRenderer = new CellRendererText
            {
                Xalign = 0.0f
            };

            TreeViewColumn column = new TreeViewColumn
            {
                Title   = "Data Files",
                Spacing = 4
            };

            column.PackStart(nodeIconRenderer, false);
            column.PackStart(nodeNameRenderer, false);

            column.SetCellDataFunc(nodeIconRenderer, RenderNodeIcon);
            column.SetCellDataFunc(nodeNameRenderer, RenderNodeName);

            this.Tree.AppendColumn(column);

            ScrolledWindow sw = new ScrolledWindow
            {
                this.Tree
            };

            this.TreeAlignment.Add(sw);

            this.Tree.RowActivated      += OnRowActivated;
            this.Tree.ButtonPressEvent  += OnButtonPressed;
            this.Tree.Selection.Changed += OnSelectionChanged;

            this.TreeContextMenu = new Menu();

            // Save item context button
            this.SaveItem = new ImageMenuItem
            {
                UseStock     = true,
                Label        = Stock.Save,
                CanFocus     = false,
                TooltipText  = "Save the currently selected item to disk.",
                UseUnderline = true
            };
            this.SaveItem.Activated += OnSaveItem;
            this.TreeContextMenu.Add(this.SaveItem);

            // Export item context button
            this.ExportItem = new ImageMenuItem("Export")
            {
                Image       = new Image(Stock.Convert, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Exports the currently selected item to another format.",
            };
            this.ExportItem.Activated += OnExportItemRequested;
            this.TreeContextMenu.Add(this.ExportItem);

            // Open item context button
            this.OpenItem = new ImageMenuItem
            {
                UseStock     = true,
                Label        = Stock.Open,
                CanFocus     = false,
                TooltipText  = "Open the currently selected item.",
                UseUnderline = true
            };
            this.OpenItem.Activated += OnOpenItem;
            this.TreeContextMenu.Add(this.OpenItem);

            // Queue for export context button
            this.QueueForExportItem = new ImageMenuItem("Queue for export")
            {
                Image       = new Image(Stock.Convert, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Queues the currently selected item for batch export.",
            };
            this.QueueForExportItem.Activated += OnQueueForExportRequested;
            this.TreeContextMenu.Add(this.QueueForExportItem);

            // Separator
            SeparatorMenuItem separator = new SeparatorMenuItem();

            this.TreeContextMenu.Add(separator);

            // Copy path context button
            this.CopyPathItem = new ImageMenuItem("Copy path")
            {
                Image       = new Image(Stock.Copy, IconSize.Button),
                CanFocus    = false,
                TooltipText = "Copy the path of the currently selected item.",
            };
            this.CopyPathItem.Activated += OnCopyPath;
            this.TreeContextMenu.Add(this.CopyPathItem);

            this.TreeAlignment.ShowAll();
        }
Example #51
0
        public static CsgObject CreateFillet(double innerRadius, double outerRadius, double height, Alignment alignment = Alignment.z, double extraDimension = defaultExtraRadialDimension, string name = "")
        {
            double         width  = outerRadius - innerRadius;
            List <Vector2> points = new List <Vector2>();

            int numCurvePoints = 8;

            for (int curvePoint = numCurvePoints; curvePoint >= 0; curvePoint--)
            {
                double x = width - Math.Cos((MathHelper.Tau / 4 * curvePoint / numCurvePoints)) * width;
                double y = height - Math.Sin((MathHelper.Tau / 4 * curvePoint / numCurvePoints)) * height;
                points.Add(new Vector2(x, y));
            }
            points.Add(new Vector2(-extraDimension, height));
            points.Add(new Vector2(-extraDimension, 0));

            return(new RotateExtrude(points.ToArray(), innerRadius, alignment, name));
        }
Example #52
0
 public SkinnedList(int imageWidth = 10, int imageHeight = 10, int itemTextXOffset = 10, int itemTextYOffset = 2, int itemHeight = 27, int space = 2, Alignment alignmentY = Alignment.CENTER_Y) :
     this(Colors.None, Colors.None, imageWidth : imageWidth, imageHeight : imageHeight, itemTextXOffset : itemTextXOffset, itemTextYOffset : itemTextYOffset, itemHeight : itemHeight, space : space, alignmentY : alignmentY)
 {
 }
Example #53
0
 public FontStyle(string fontName, uint fontSize, Color fontColor, bool underline, bool italic, bool bold, Alignment align, Color bgColor)
 {
     this.FontName    = fontName;
     this.FontSize    = fontSize;
     this.FontColor   = fontColor;
     this.IsUnderLine = underline;
     this.IsItalic    = italic;
     this.IsBold      = bold;
     this.Align       = align;
     this.BgColor     = bgColor;
     this.Link        = "";
     this.Raise       = RaiseType.Normal;
 }
Example #54
0
 public CellBuilder Alignment(Alignment alignment) => Chain(_ => this.alignment = alignment);
        /// <summary>
        /// Hashtable constructor, in order to automatically convert&amp;understand input
        /// </summary>
        /// <param name="Table">The hashtable to parse</param>
        public ColumnTransformation(Hashtable Table)
        {
            // FilterViewName
            if (Table.ContainsKey("T"))
            {
                FilterViewName = (string)Table["T"];
            }
            if (Table.ContainsKey("Type"))
            {
                FilterViewName = (string)Table["Type"];
            }
            if (Table.ContainsKey("TypeName"))
            {
                FilterViewName = (string)Table["TypeName"];
            }
            if (Table.ContainsKey("FilterViewName"))
            {
                FilterViewName = (string)Table["FilterViewName"];
            }

            // FilterColumnName
            if (Table.ContainsKey("C"))
            {
                FilterColumnName = (string)Table["C"];
            }
            if (Table.ContainsKey("Column"))
            {
                FilterColumnName = (string)Table["Column"];
            }
            if (Table.ContainsKey("Name"))
            {
                FilterColumnName = (string)Table["Name"];
            }
            if (Table.ContainsKey("P"))
            {
                FilterColumnName = (string)Table["P"];
            }
            if (Table.ContainsKey("Property"))
            {
                FilterColumnName = (string)Table["Property"];
            }
            if (Table.ContainsKey("PropertyName"))
            {
                FilterColumnName = (string)Table["PropertyName"];
            }

            // Append
            if (Table.ContainsKey("A"))
            {
                Append = (bool)Table["A"];
            }
            if (Table.ContainsKey("Append"))
            {
                Append = (bool)Table["Append"];
            }

            // ScriptBlock
            if (Table.ContainsKey("S"))
            {
                ScriptBlock = (ScriptBlock)Table["S"];
            }
            if (Table.ContainsKey("Script"))
            {
                ScriptBlock = (ScriptBlock)Table["Script"];
            }
            if (Table.ContainsKey("ScriptBlock"))
            {
                ScriptBlock = (ScriptBlock)Table["ScriptBlock"];
            }

            // Label
            if (Table.ContainsKey("L"))
            {
                Label = (string)Table["L"];
            }
            if (Table.ContainsKey("Label"))
            {
                Label = (string)Table["Label"];
            }

            // Width
            if (Table.ContainsKey("W"))
            {
                Width = (int)Table["W"];
            }
            if (Table.ContainsKey("Width"))
            {
                Width = (int)Table["Width"];
            }

            // Alignment
            string align = "";

            if (Table.ContainsKey("Align"))
            {
                align = (string)Table["Align"];
            }
            if (Table.ContainsKey("Alignment"))
            {
                align = (string)Table["Alignment"];
            }
            if (!String.IsNullOrEmpty(align))
            {
                Alignment = (Alignment)Enum.Parse(typeof(Alignment), align, false);
            }
        }
Example #56
0
 /// <summary>
 /// Sets the image of the button to the specified value with the specified alignment and margins.
 /// All states of the button show the same image.
 /// </summary>
 /// <param name="image">The images for the button</param>
 /// <param name="align">The alignment of the image</param>
 /// <param name="leftMargin">The left margin of the image in pixels</param>
 /// <param name="topMargin">The top margin of the image in pixels</param>
 /// <param name="rightMargin">The right margin of the image in pixels</param>
 /// <param name="bottomMargin">The bottom margin of the image in pixels</param>
 public void SetImage(Bitmap image, Alignment align, int leftMargin, int topMargin, int rightMargin,
                      int bottomMargin)
 {
     SetImage(new Bitmap[] { image }, align, leftMargin, topMargin, rightMargin, bottomMargin);
 }
Example #57
0
        private void DrawButtonsBlock(float widthOffset)
        {
            if (GUI.Button(new Rect(widthOffset, 36, ButtonSize, ButtonSize), "↻"))
            {
                //_camObject.transform.Rotate(new Vector3(0, 0, 180f));
                _camObject.transform.Rotate(new Vector3(0, 0, 90f));
                _isUpsideDown = !_isUpsideDown;
                _alignment++;
                if ((int)_alignment > 3)
                {
                    _alignment = Alignment.up;
                }
            }
            if (GUI.RepeatButton(new Rect(widthOffset + ButtonSize, 36, ButtonSize, ButtonSize), "↑"))
            {
                switch (_alignment)
                {
                case Alignment.up: RotateY += _rotateStep; break;

                case Alignment.right: RotateZ -= _rotateStep; break;

                case Alignment.down: RotateY -= _rotateStep; break;

                case Alignment.left: RotateZ += _rotateStep; break;
                }
            }
            if (GUI.Button(new Rect(widthOffset + ButtonSize * 2, 36, ButtonSize, ButtonSize), "⦿"))
            {
                if (ThisPart.vessel.Equals(FlightGlobals.ActiveVessel))
                {
                    if (!TargetHelper.IsTargetSelect)
                    {
                        ScreenMessages.PostScreenMessage("NO TARGET FOR SCANNING", 3f, ScreenMessageStyle.UPPER_CENTER);
                    }
                    else
                    {
                        if (Hits <= 0)
                        {
                            ScreenMessages.PostScreenMessage("BULLETS DEPLETED", 3f, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            var    id = PartResourceLibrary.Instance.GetDefinition(_resourceName).id;
                            double amount;
                            double maxAmount;
                            ThisPart.GetConnectedResourceTotals(id, out amount, out maxAmount);
                            if (amount > _resourceUsage)
                            {
                                ThisPart.RequestResource(id, (double)_resourceUsage);
                                var hit = PartGameObject.GetChild($"{_bulletName}{Hits:000}");
                                Object.Destroy(hit);
                                Hits--;
                                _isRayEnabled      = true;
                                IsWaitForRay       = true;
                                _isScienceActivate = false;
                            }
                            else
                            {
                                ScreenMessages.PostScreenMessage("NOT ENOUGH ELECTRICITY FOR SCAN", 3f, ScreenMessageStyle.UPPER_CENTER);
                            }
                        }
                        //if (HitCounter() && UseResourceForScanning())
                        //{
                        //    _isRayEnabled = true;
                        //    IsWaitForRay = true;
                        //    _isScienceActivate = false;
                        //}
                    }
                }
                else
                {
                    ScreenMessages.PostScreenMessage("Camera not on active vessel", 3f, ScreenMessageStyle.UPPER_CENTER);
                }
            }
            if (GUI.RepeatButton(new Rect(widthOffset, 36 + ButtonSize, ButtonSize, ButtonSize), "←"))
            {
                switch (_alignment)
                {
                case Alignment.up: RotateZ -= _rotateStep; break;

                case Alignment.right: RotateY -= _rotateStep; break;

                case Alignment.down: RotateZ += _rotateStep; break;

                case Alignment.left: RotateY += _rotateStep; break;
                }
            }
            if (GUI.Button(new Rect(widthOffset + ButtonSize, 36 + ButtonSize, ButtonSize, ButtonSize), "o"))
            {
                IsToZero = true;
            }
            if (GUI.RepeatButton(new Rect(widthOffset + ButtonSize * 2, 36 + ButtonSize, ButtonSize, ButtonSize), "→"))
            {
#if false
                if (!_isUpsideDown)
                {
                    RotateZ += _rotateStep;
                }
                else
                {
                    RotateZ -= _rotateStep;
                }
#endif
                switch (_alignment)
                {
                case Alignment.up: RotateZ += _rotateStep; break;

                case Alignment.right: RotateY += _rotateStep; break;

                case Alignment.down: RotateZ -= _rotateStep; break;

                case Alignment.left: RotateY -= _rotateStep; break;
                }
            }
            if (GUI.Button(new Rect(widthOffset, 36 + ButtonSize * 2, ButtonSize, ButtonSize), "-"))
            {
                CurrentZoom += 0.5f;
                if (CurrentZoom > MaxZoom)
                {
                    CurrentZoom = MaxZoom;
                }
            }
            if (GUI.RepeatButton(new Rect(widthOffset + ButtonSize, 36 + ButtonSize * 2, ButtonSize, ButtonSize), "↓"))
            {
#if false
                if (_rotateYbuffer > 0)
                {
                    if (!_isUpsideDown)
                    {
                        RotateY -= _rotateStep;
                    }
                    else
                    {
                        RotateY += _rotateStep;
                    }
                }
#endif
                switch (_alignment)
                {
                case Alignment.up: RotateY -= _rotateStep; break;

                case Alignment.right: RotateZ += _rotateStep; break;

                case Alignment.down: RotateY += _rotateStep; break;

                case Alignment.left: RotateZ -= _rotateStep; break;
                }
            }
            if (GUI.Button(new Rect(widthOffset + ButtonSize * 2, 36 + ButtonSize * 2, ButtonSize, ButtonSize), "+"))
            {
                CurrentZoom -= 0.5f;
                if (CurrentZoom < MinZoom)
                {
                    CurrentZoom = MinZoom;
                }
            }
        }
Example #58
0
        public void addTextWithImageInFront(string text, string imagePath, int width, int height, Document document, Alignment alignment,
                                            string fontName, double fontSize, System.Drawing.Color color)
        {
            // Add an image into the document.
            Image image = document.AddImage(imagePath);

            // Create a picture (A custom view of an Image).
            Picture picture = image.CreatePicture();

            if (height > 0 || width > 0)
            {
                picture.Height = 300;
                picture.Width  = 300;
            }

            // Insert a new Paragraph into the document.
            Paragraph p1 = document.InsertParagraph();

            // Append content to the Paragraph
            p1.AppendPicture(picture).Append(text).Font(fontName).FontSize(fontSize)
            .Color(color);
        }
Example #59
0
        public PreviewVisualizerWindow(ObjectValue val, Gtk.Widget invokingWidget) : base(Gtk.WindowType.Toplevel)
        {
            this.TypeHint  = WindowTypeHint.PopupMenu;
            this.Decorated = false;
            TransientFor   = (Gtk.Window)invokingWidget.Toplevel;

            Theme.SetFlatColor(new Cairo.Color(245 / 256.0, 245 / 256.0, 245 / 256.0));
            Theme.Padding = 3;
            ShowArrow     = true;
            var mainBox     = new VBox();
            var headerTable = new Table(1, 3, false);

            headerTable.ColumnSpacing = 5;
            var closeButton = new ImageButton()
            {
                InactiveImage = ImageService.GetIcon("md-popup-close", IconSize.Menu),
                Image         = ImageService.GetIcon("md-popup-close-hover", IconSize.Menu)
            };

            closeButton.Clicked += delegate {
                this.Destroy();
            };
            var hb = new HBox();
            var vb = new VBox();

            hb.PackStart(vb, false, false, 0);
            vb.PackStart(closeButton, false, false, 0);
            headerTable.Attach(hb, 0, 1, 0, 1);

            var headerTitle = new Label();

            headerTitle.ModifyFg(StateType.Normal, new Color(36, 36, 36));
            var font = headerTitle.Style.FontDescription.Copy();

            font.Weight = Pango.Weight.Bold;
            headerTitle.ModifyFont(font);
            headerTitle.Text = val.TypeName;
            var vbTitle = new VBox();

            vbTitle.PackStart(headerTitle, false, false, 3);
            headerTable.Attach(vbTitle, 1, 2, 0, 1);

            if (DebuggingService.HasValueVisualizers(val))
            {
                var openButton = new Button();
                openButton.Label    = "Open";
                openButton.Relief   = ReliefStyle.Half;
                openButton.Clicked += delegate {
                    PreviewWindowManager.DestroyWindow();
                    DebuggingService.ShowValueVisualizer(val);
                };
                var hbox = new HBox();
                hbox.PackEnd(openButton, false, false, 2);
                headerTable.Attach(hbox, 2, 3, 0, 1);
            }
            else
            {
                headerTable.Attach(new Label(), 2, 3, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill | AttachOptions.Expand, 10, 0);
            }
            mainBox.PackStart(headerTable);
            mainBox.ShowAll();

            var previewVisualizer = DebuggingService.GetPreviewVisualizer(val);

            if (previewVisualizer == null)
            {
                previewVisualizer = new GenericPreviewVisualizer();
            }
            Control widget = null;

            try {
                widget = previewVisualizer.GetVisualizerWidget(val);
            } catch (Exception e) {
                DebuggingService.DebuggerSession.LogWriter(true, "Exception during preview widget creation: " + e.Message);
            }
            if (widget == null)
            {
                widget = new GenericPreviewVisualizer().GetVisualizerWidget(val);
            }
            var alignment = new Alignment(0, 0, 1, 1);

            alignment.SetPadding(3, 5, 5, 5);
            alignment.Show();
            alignment.Add(widget);
            mainBox.PackStart(alignment);
            ContentBox.Add(mainBox);
        }
Example #60
0
 public BattleFaction(Battle battle, Alignment align)
 {
     this.align  = align;
     this.battle = battle;
 }