コード例 #1
0
		//Constructors
		public Palette() : base()
		{
			Suspend();
			
			SetRender(new PaletteRender());
			Margin = new Margin(10,10,10,10);
			Tabs = new Tabs();
			Spacing = new Size(20, 22);
			Render.Font = this.Font;
			BackColor  = SystemColors.Control;
			GradientColor = SystemColors.Control;
			BorderColor = Color.Black;
			ForeColor = Color.Black;
			FillColor = Color.White;
			ItemSize = new Size(18, 18);
			Style = PaletteStyle.Multiple;
			DrawScroll = true;

			Resume();
			
			//Set up scroll timer
			mTimer = new Timer();
			mTimer.Interval = 20;
			mTimer.Tick+=new EventHandler(mTimer_Tick);
		}
コード例 #2
0
ファイル: MessageBox.cs プロジェクト: HaKDMoDz/szakdoga
        private MessageBox(string title, string message)
        {
            Style = "frame";
            Modal = true; // make sure its modal
            Scissor = false;
            Padding = new Margin(7);

            TitleLabel = new Label();
            TitleLabel.Size = new Point(100, 35);
            TitleLabel.Dock = DockStyle.Top;
            TitleLabel.Text = title;
            TitleLabel.OnMouseDown += delegate(Control sender) { StartDrag(); };
            TitleLabel.OnMouseUp += delegate(Control sender) { StopDrag(); };
            TitleLabel.Cursor = Cursors.Move;
            TitleLabel.Style = "frame2";
            TitleLabel.Margin = new Margin(0, 0, 0, -1);
            Controls.Add(TitleLabel);

            ButtonFrame = new Frame();
            ButtonFrame.Size = new Point(100, 35);
            ButtonFrame.Dock = DockStyle.Bottom;
            Controls.Add(ButtonFrame);

            MessageLabel = new Label();
            MessageLabel.Dock = DockStyle.Fill;
            MessageLabel.TextWrap = true;
            MessageLabel.Text = message;
            Controls.Add(MessageLabel);
        }
コード例 #3
0
ファイル: Module.cs プロジェクト: NKnusperer/Delta.Console
        /// <summary>
        /// Constructor for this module, will be child of the Application module to
        /// be executed as part of the Application.Run.
        /// </summary>
        /// <param name="bindConsole">The button to open and close the console</param>
        /// <param name="consoleMargin">The space between the screenspace and the console. Pass NULL to use the default value.</param>
        /// <param name="consoleBackground">The console background color or material. Pass NULL to use the default value.</param>
        /// <param name="consoleFontColor">The color for the font to display text. Pass NULL to use the default value.</param>
        /// <param name="maxNumberOfLines">The max. number of lines that will be displayed befor the oldest entry will be deleted. Pass NULL to use the default value.</param>
        public Module(InputButton bindConsoleButton, Margin consoleMargin, Material2DColored consoleBackground, Color consoleFontColor, int? maxNumberOfLines )
            : base("Delta.Console", typeof(Application))
        {

            if (consoleMargin.Left == 0 && consoleMargin.Top == 0 && consoleMargin.Right == 0)
            {
                consoleMargin = new Margin() { Left = 0.01f, Top = 0.01f, Right = 0.02f };
            }

            if (consoleBackground == null)
            {
                consoleBackground = new Material2DColored(new Color(new Color(0, 167, 255), 0.5f));
            }

            if (consoleFontColor.PackedRGBA == 0)
            {
                consoleFontColor = new Color(200, 220, 255);
            }

            if (maxNumberOfLines == null)
            {
                maxNumberOfLines = 20;
            }

            // Initialize
            console = new Delta.Console.Console(bindConsoleButton, consoleMargin, consoleBackground, consoleFontColor, (int)maxNumberOfLines);
            graph = new GraphManager();

            // Add command to the console to enable or disable the graph
            console.AddCmdToConsole(typeof(Module).GetMethod("SetGraphState"), this);
        }
コード例 #4
0
ファイル: Bordered.cs プロジェクト: WardBenjamin/gwen-dotnet
        private void Init(Texture texture, float x, float y, float w, float h, Margin inMargin, float drawMarginScale = 1.0f)
        {
            m_Texture = texture;

            m_Margin = inMargin;

            SetRect(0, x, y, m_Margin.Left, m_Margin.Top);
            SetRect(1, x + m_Margin.Left, y, w - m_Margin.Left - m_Margin.Right, m_Margin.Top);
            SetRect(2, (x + w) - m_Margin.Right, y, m_Margin.Right, m_Margin.Top);

            SetRect(3, x, y + m_Margin.Top, m_Margin.Left, h - m_Margin.Top - m_Margin.Bottom);
            SetRect(4, x + m_Margin.Left, y + m_Margin.Top, w - m_Margin.Left - m_Margin.Right,
                    h - m_Margin.Top - m_Margin.Bottom);
            SetRect(5, (x + w) - m_Margin.Right, y + m_Margin.Top, m_Margin.Right, h - m_Margin.Top - m_Margin.Bottom - 1);

            SetRect(6, x, (y + h) - m_Margin.Bottom, m_Margin.Left, m_Margin.Bottom);
            SetRect(7, x + m_Margin.Left, (y + h) - m_Margin.Bottom, w - m_Margin.Left - m_Margin.Right, m_Margin.Bottom);
            SetRect(8, (x + w) - m_Margin.Right, (y + h) - m_Margin.Bottom, m_Margin.Right, m_Margin.Bottom);

            m_Margin.Left = (int)(m_Margin.Left*drawMarginScale);
            m_Margin.Right = (int)(m_Margin.Right*drawMarginScale);
            m_Margin.Top = (int)(m_Margin.Top*drawMarginScale);
            m_Margin.Bottom = (int)(m_Margin.Bottom*drawMarginScale);

            m_Width = w - x;
            m_Height = h - y;
        }
コード例 #5
0
ファイル: GameObjectTreeNode.cs プロジェクト: Tokter/TokED
        public GameObjectTreeNode(GameObject gameObject)
        {
            _gameObject = gameObject;
            _gameObject.PropertyChanged += GameObject_PropertyChanged;

            this.Expanded = gameObject.Expanded;

            Margin = new Margin(1);
            Size = new Point(100, 18);

            var buttonFrame = this.AddFrame(9, 9, DockStyle.Left);
            Elements.Add(buttonFrame);

            this.Bind("Expanded", _gameObject, "Expanded");
            buttonFrame.AddCheckBox("treeButton", 9, 9)
                .Bind(_gameObject, "Expanded")
                .Bind("Opacity", _gameObject, "NumChildrens", (num) => { return (int)num > 0 ? 1.0f : 0.0f; });

            var imageFrame = this.AddFrame(18, 18, DockStyle.Left);
            imageFrame.AddImage(gameObject.ExportName, 14, 14, DockStyle.Center);
            Elements.Add(imageFrame);

            _label = this.AddButton("item", 1, 1, DockStyle.Fill);
            _label.AllowDrop = true;
            _label.Text = gameObject.Name;
            _label.MouseClick += label_MouseClick;
            _label.Update += label_Update;
            _label.DragDrop += label_DragDrop;
            _label.MouseDrag += label_MouseDrag;
            Elements.Add(_label);

            var eyeButtonFrame = this.AddFrame(13, 14, DockStyle.Right);
            eyeButtonFrame.AddCheckBox("eyeButton", 13, 9).Bind(_gameObject, "Visible");
            Elements.Add(eyeButtonFrame);
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CameraSettings2D" /> struct.
 /// </summary>
 /// <param name="camera">The camera.</param>
 /// <param name="screenWorldHeight">Height of the screen in world units.</param>
 /// <param name="leftMostEdge">The left most edge.</param>
 /// <param name="rightMostEdge">The right most edge.</param>
 /// <param name="bottomMostEdge">The bottom most edge.</param>
 /// <param name="topMostEdge">The top most edge.</param>
 /// <param name="margin">The margin.</param>
 public CameraSettings2D(Camera camera, float screenWorldHeight, float leftMostEdge, float rightMostEdge, float bottomMostEdge, float topMostEdge, Margin margin) {
     this.ScreenWidth = Screen.width;
     this.ScreenHeight = Screen.height;
     this.Margin = margin;
     this.ScreenWorldHeight = screenWorldHeight + this.Margin.Bottom + this.Margin.Top;
     this.OrthographicSize = this.ScreenWorldHeight * 0.5f;
     this.ScreenWorldWidth = this.ScreenWorldHeight * this.ScreenWidth / this.ScreenHeight;
     var halfScreenWorldWidth = this.ScreenWorldWidth * 0.5f;
     this.MinimumPosition = new Vector2(leftMostEdge + halfScreenWorldWidth - this.Margin.Left, bottomMostEdge + this.OrthographicSize - this.Margin.Bottom);
     this.MaximumPosition = new Vector2(rightMostEdge - halfScreenWorldWidth + this.Margin.Right, topMostEdge - this.OrthographicSize + this.Margin.Top);
 }
コード例 #7
0
ファイル: Bordered.cs プロジェクト: WardBenjamin/gwen-dotnet
        public Bordered(Texture texture, float x, float y, float w, float h, Margin inMargin, float drawMarginScale = 1.0f)
            : this()
        {
            m_Rects = new SubRect[9];
            for (int i = 0; i < m_Rects.Length; i++)
            {
                m_Rects[i].uv = new float[4];
            }

            Init(texture, x, y, w, h, inMargin, drawMarginScale);
        }
コード例 #8
0
ファイル: Area.cs プロジェクト: zedr0n/testJS
        public Area(string selection)
        {
            jquery = jQuery.Select(selection);

            // create properties
            mMargin = new Margin(jquery);
            mHeight = new Height(jquery);
            mOuterHeight = new OuterHeight(jquery, mHeight);

            updateCss = true;
        }
コード例 #9
0
ファイル: Bordered.cs プロジェクト: FloodProject/flood
        public Bordered(ResourceHandle<Image> imageHandle, float x, float y, float w, float h, Margin inMargin, float drawMarginScale = 1.0f)
            : this()
        {
            m_Rects = new SubRect[9];
            for (int i = 0; i < m_Rects.Length; i++)
            {
                m_Rects[i].uv = new float[4];
            }

            Init(imageHandle, x, y, w, h, inMargin, drawMarginScale);
        }
コード例 #10
0
ファイル: DoomWindow.cs プロジェクト: doomtactics/doomtactics
        protected override void Initialize()
        {
            AllowDragOut = true;
            Padding = new Margin(7);

            TitleBar = new TitleBar();
            TitleBar.Dock = DockStyle.Top;
            TitleBar.Size = new Squid.Point(122, 35);
            TitleBar.OnMouseDown += (ctl, args) => StartDrag();
            TitleBar.OnMouseUp += (ctl, args) => StopDrag();
            TitleBar.Cursor = Cursors.Move;
            TitleBar.Style = "frame2";
            TitleBar.Margin = new Margin(0, 0, 0, -1);

            AllowDragOut = false;

            Controls.Add(TitleBar);
        }
コード例 #11
0
ファイル: ComboBox.cs プロジェクト: FloodProject/flood
        /// <summary>
        /// Initializes a new instance of the <see cref="ComboBox"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public ComboBox(Control parent)
            : base(parent)
        {
            SetSize(100, 20);
            m_Menu = new Menu(this);
            m_Menu.IsHidden = true;
            m_Menu.IconMarginDisabled = true;
            m_Menu.IsTabable = false;

            DownArrow arrow = new DownArrow(this);
            m_Button = arrow;

            Alignment = Pos.Left | Pos.CenterV;
            Margin = new Margin(3, 0, 0, 0);

            IsTabable = true;
            KeyboardInputEnabled = true;
        }
コード例 #12
0
ファイル: SampleWindow.cs プロジェクト: ndssia/Corsair3
        public SampleWindow()
        {
            AllowDragOut = true;
            Padding = new Margin(7);

            Titlebar = new TitleBar();
            Titlebar.Dock = DockStyle.Top;
            Titlebar.Size = new Point(122, 35);
            Titlebar.MouseDown += delegate(Control sender, MouseEventArgs args) { StartDrag(); };
            Titlebar.MouseUp += delegate(Control sender, MouseEventArgs args) { StopDrag(); };
            Titlebar.Cursor = Cursors.Move;
            Titlebar.Style = "frame";
            Titlebar.Margin = new Margin(0, 0, 0, -1);
            Titlebar.Button.MouseClick += Button_OnMouseClick;
            Titlebar.TextAlign = Alignment.MiddleLeft;
            Titlebar.BBCodeEnabled = true;
            AllowDragOut = false;

            Controls.Add(Titlebar);
        }
コード例 #13
0
ファイル: WindowsBase.cs プロジェクト: HaKDMoDz/szakdoga
        protected override void Initialize()
        {
            base.Initialize();

            AllowDragOut = true;
            Padding = new Margin();

            titlebar = new TitleBar();
            titlebar.Dock = DockStyle.Top;
            titlebar.Size = new Squid.Point(122, 35);
            titlebar.OnMouseDown += delegate(Control sender) { StartDrag(); };
            titlebar.OnMouseUp += delegate(Control sender) { StopDrag(); };
            titlebar.Cursor = Cursors.Move;
            titlebar.Style = "header";
            titlebar.Margin = new Margin(0, 0, 0, -1);
            titlebar.Button.OnMouseClick += Button_Close;

            Controls.Add(titlebar);

            initializeComponent();
        }
コード例 #14
0
ファイル: ComboSystem.cs プロジェクト: KudaJingkrak/SiTongkol
 public bool IsBetween(float value, Margin margin)
 {
     return(value >= margin.bottom && value <= margin.top);
 }
コード例 #15
0
ファイル: HexEditor.cs プロジェクト: pearsonsjp/monodevelop
 public void RepaintMarginArea(Margin margin, double x, double y, double width, double height)
 {
     QueueDraw(new Rectangle(x, y, width, height));
 }
コード例 #16
0
ファイル: AnimatedImage.cs プロジェクト: flyingpie/AVA
        public override void Draw(Vector2 size, Vector4 tintColor, Vector4 borderColor, Vector4 backgroundColor, Margin padding, ScaleMode scaleMode = ScaleMode.Fit)
        {
            UpdateActiveTile();

            base.Draw(size, tintColor, borderColor, backgroundColor, padding, scaleMode);
        }
コード例 #17
0
        public void Relayout()
        {
            m_horizontalBarVisible = (m_horizontalScroll & WidgetScrollType.Visible) != 0;
            m_verticalBarVisible   = (m_verticalScroll & WidgetScrollType.Visible) != 0;

            if (m_horizontalBarVisible)
            {
                // TODO: load padding from WidgetManager
                Margin horizontalScrollBarPadding       = m_verticalBarVisible ? new Margin(2, 0, 18, 1) : new Margin(2, 0, 2, 1);
                Margin horizontalScrollIndicatorPadding = new Margin(3, 3, 3, 3);
                float  horizontalScrollBarHeight        = 21;
                float  horizontalScrollIndicatorHeight  = 15;
                float  horizontalScrollIndicatorWidth   = 60;

                m_horizontalScrollBar.Size     = new Vector2(Size.X - horizontalScrollBarPadding.Right - horizontalScrollBarPadding.Left, horizontalScrollBarHeight);
                m_horizontalScrollBar.Position = new Vector2(horizontalScrollBarPadding.Left, Size.Y - m_horizontalScrollBar.Size.Y - horizontalScrollBarPadding.Bottom);

                float maxLength     = m_horizontalScrollBar.Size.X - horizontalScrollIndicatorPadding.Left - horizontalScrollIndicatorPadding.Right;
                float indicatorSize = (maxLength * Size.X / m_contentView.Size.X);

                if (indicatorSize < horizontalScrollIndicatorWidth)
                {
                    indicatorSize = horizontalScrollIndicatorWidth;
                }
                if (indicatorSize > maxLength)
                {
                    indicatorSize = maxLength;
                }

                m_horizontalScrollBarIndicator.Size = new Vector2(indicatorSize, horizontalScrollIndicatorHeight);

                if ((m_horizontalScroll & WidgetScrollType.AutoHide) != 0)
                {
                    m_horizontalBarVisible = indicatorSize < maxLength;
                }
            }

            if (m_verticalBarVisible)
            {
                // TODO: load padding from WidgetManager
                Margin verticalScrollBarPadding       = m_horizontalBarVisible ? new Margin(0, 2, 1, 18) : new Margin(0, 2, 1, 2);
                Margin verticalScrollIndicatorPadding = new Margin(3, 3, 3, 3);
                float  verticalScrollBarWidth         = 21;
                float  verticalScrollIndicatorWidth   = 15;
                float  verticalScrollIndicatorHeight  = 60;

                m_verticalScrollBar.Size     = new Vector2(verticalScrollBarWidth, Size.Y - verticalScrollBarPadding.Top - verticalScrollBarPadding.Bottom);
                m_verticalScrollBar.Position = new Vector2(Size.X - m_verticalScrollBar.Size.X - verticalScrollBarPadding.Right, verticalScrollBarPadding.Top);

                float maxLength     = m_verticalScrollBar.Size.Y - verticalScrollIndicatorPadding.Left - verticalScrollIndicatorPadding.Right;
                float indicatorSize = (maxLength * Size.Y / m_contentView.Size.Y);

                if (indicatorSize < verticalScrollIndicatorHeight)
                {
                    indicatorSize = verticalScrollIndicatorHeight;
                }
                if (indicatorSize > maxLength)
                {
                    indicatorSize = maxLength;
                }

                m_verticalScrollBarIndicator.Size = new Vector2(verticalScrollIndicatorWidth, indicatorSize);

                if ((m_verticalScroll & WidgetScrollType.AutoHide) != 0)
                {
                    m_verticalBarVisible = indicatorSize < maxLength;
                }
            }

            UpdateScroll();

            m_needLayout = false;
        }
コード例 #18
0
ファイル: ThemeManager.cs プロジェクト: algz/GDIDrawFlow
 private void ExtractMargin()
 {
     Margin m = new Margin();
     m.Left = Int32.Parse(this.tokenizer.NextToken());
     m.Top = Int32.Parse(this.tokenizer.NextToken());
     m.Bottom = Int32.Parse(this.tokenizer.NextToken());
     m.Right = Int32.Parse(this.tokenizer.NextToken());
     if (style == MAINSECTIONTASKSS)
     {
         if (section == DESTINATIONTASK)
         {
             info.TaskItem.Margin = m;
         }
         else if (section == ACTIONTASK)
         {
             info.TaskItem.Margin = m;
         }
     }
     else if (style == SECTIONTASKSS)
     {
         if (section == DESTINATIONTASK)
         {
             info.TaskItem.Margin = m;
         }
         else if (section == ACTIONTASK)
         {
             info.TaskItem.Margin = m;
         }
     }
 }
コード例 #19
0
        public List <Tuple <string, string> > ToList()
        {
            var paramList = new List <Tuple <string, string> >
            {
                new Tuple <string, string>("startfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StartFreqUnit, "mhz", StartFreq))),
                new Tuple <string, string>("stopfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StopFreqUnit, "mhz", StopFreq))),
                new Tuple <string, string>("rbw", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(RbwUnit, "khz", Rbw))),
                new Tuple <string, string>("polarization", RmtpDefaultCollection.PolarizationSource[Polarization].ToString()),
                new Tuple <string, string>("smoothmode", RmtpDefaultCollection.SmoothWaySource[SmoothMode].ToString()),
                new Tuple <string, string>("storage", Storage?"on":"off"),
                new Tuple <string, string>("gainmode", RmtpDefaultCollection.GainModeSource[GainMode].ToString()),
            };

            if (RmtpDefaultCollection.SmoothWaySource[SmoothMode] != SmoothWay.none)
            {
                paramList.Add(new Tuple <string, string>("smoothparam", SmoothParam.ToString(CultureInfo.InvariantCulture)));
            }

            if (RmtpDefaultCollection.GainModeSource[GainMode] == Rmtp.GainMode.mgc)
            {
                paramList.Add(new Tuple <string, string>("gainparam", string.Format("{0}dBuV", GainParam)));
            }

            if (!IsStudy)
            {
                if (HasThreshold)
                {
                    var    tt = RmtpDefaultCollection.SignalSholdSource[ThresholdType].ToString();
                    string signalthreshold;
                    if (tt == "horizontal")
                    {
                        signalthreshold = string.Format("{0}dBμV", SignalThreshold);
                        paramList.Add(new Tuple <string, string>("thresholdtype", tt));
                        paramList.Add(new Tuple <string, string>("signalthreshold", signalthreshold));
                    }
                    else if (tt == "background")
                    {
                        //自定义门限
                        paramList.Add(new Tuple <string, string>("thresholdtype", "custom"));
                        paramList.Add(new Tuple <string, string>("thresholddesc", ThresholdDesc));
                        paramList.Add(new Tuple <string, string>("customthreshold", CustomThresholdValues));
                    }
                    else if (tt == "noise")
                    {
                        paramList.Add(new Tuple <string, string>("thresholdtype", tt));
                    }

                    if (tt != "horizontal")
                    {
                        paramList.Add(new Tuple <string, string>("margin", Margin.ToString(CultureInfo.InvariantCulture)));
                    }
                }
            }

            if (ChannelizeBands.Count > 0)
            {
                var sb = new StringBuilder();
                foreach (var cb in ChannelizeBands)
                {
                    sb.AppendFormat("{0};", cb);
                }
                if (sb.Length > 0)
                {
                    sb = sb.Remove(sb.Length - 1, 1);
                }
                paramList.Add(new Tuple <string, string>("channelizebands", sb.ToString()));
            }
            return(paramList);
        }
コード例 #20
0
        public virtual void WriteXml(System.Xml.XmlWriter writer)
        {
            //if (!string.IsNullOrWhiteSpace(Title))
            //    writer.WriteAttributeString("Title", Title);

            //if (IconSource != null)
            //    writer.WriteAttributeString("IconSource", IconSource.ToString());

            //if (IsSelected)
            //    writer.WriteAttributeString("IsSelected", IsSelected.ToString());

            //if (IsLastFocusedDocument)
            //    writer.WriteAttributeString("IsLastFocusedDocument", IsLastFocusedDocument.ToString());

            if (!string.IsNullOrWhiteSpace(ContentId))
            {
                writer.WriteAttributeString("ContentId", ContentId);
            }
            if (Margin != 0)
            {
                writer.WriteAttributeString("Margin", Margin.ToString());
            }
            if (BorderThickness != 0)
            {
                writer.WriteAttributeString("BorderThickness", BorderThickness.ToString());
            }
            if (BorderColor != Colors.Black)
            {
                writer.WriteAttributeString("BorderColor", BorderColor.ToString());
            }
            if (BackgroundColor != Colors.Transparent)
            {
                writer.WriteAttributeString("BackgroundColor", BackgroundColor.ToString());
            }
            //if (ToolTip != null && ToolTip is string)
            //    if (!string.IsNullOrWhiteSpace((string)ToolTip))
            //        writer.WriteAttributeString("ToolTip", (string)ToolTip);

            //if (FloatingLeft != 0.0)
            //    writer.WriteAttributeString("FloatingLeft", FloatingLeft.ToString(CultureInfo.InvariantCulture));
            //if (FloatingTop != 0.0)
            //    writer.WriteAttributeString("FloatingTop", FloatingTop.ToString(CultureInfo.InvariantCulture));
            //if (FloatingWidth != 0.0)
            //    writer.WriteAttributeString("FloatingWidth", FloatingWidth.ToString(CultureInfo.InvariantCulture));
            //if (FloatingHeight != 0.0)
            //    writer.WriteAttributeString("FloatingHeight", FloatingHeight.ToString(CultureInfo.InvariantCulture));

            //if (IsMaximized)
            //    writer.WriteAttributeString("IsMaximized", IsMaximized.ToString());
            //if (!CanClose)
            //    writer.WriteAttributeString("CanClose", CanClose.ToString());
            //if (!CanFloat)
            //    writer.WriteAttributeString("CanFloat", CanFloat.ToString());

            //if (LastActivationTimeStamp != null)
            //    writer.WriteAttributeString("LastActivationTimeStamp", LastActivationTimeStamp.Value.ToString(CultureInfo.InvariantCulture));

            //if (_previousContainer != null)
            //{
            //    var paneSerializable = _previousContainer as ILayoutPaneSerializable;
            //    if (paneSerializable != null)
            //    {
            //        writer.WriteAttributeString("PreviousContainerId", paneSerializable.Id);
            //        writer.WriteAttributeString("PreviousContainerIndex", _previousContainerIndex.ToString());
            //    }
            //}
        }
コード例 #21
0
        private void ScVxTipsProgressBar_SizeChanged(object sender, SizeF oldSize)
        {
            //
            float tipsRowHeight = Height * tipsRowHeightRatio;
            float barRowHeight  = Height * barRowHeightRatio;

            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 3, 1);

            Margin margin = new Margin(0, 5, 0, 5);

            mainTable.SetCellMargin(0, 0, margin);
            mainTable.SetCellMargin(2, 0, margin);

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.ABSOLUTE;

            tableLine.computeParam = tipsRowHeight;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = barRowHeight;
            mainTable.SetLineArea(1, tableLine);

            tableLine.computeParam = Height - tipsRowHeight - barRowHeight;
            mainTable.SetLineArea(2, tableLine);

            mainTable.ComputeLinesArea(LineDir.HORIZONTAL);


            RectangleF tipsRowRect = mainTable.GetCellContentRect(0, 0);
            RectangleF barRowRect  = mainTable.GetCellContentRect(1, 0);
            RectangleF numRowRect  = mainTable.GetCellContentRect(2, 0);

            progressBar.BarHeight = barHeight;
            progressBar.Height    = barRowHeight;
            progressBar.Location  = new PointF(barRowRect.X, barRowRect.Y);


            //
            RectangleF[]        progressNodeRects = progressBar.progressNodeRects;
            List <ScVxPageTips> tipsList          = new List <ScVxPageTips>();
            List <RectangleF>   numRectList       = new List <RectangleF>();
            ScVxPageTips        tips;
            RectangleF          r;
            float x;

            string[] nodeNames = progressBar.progressNodeNames;



            for (int i = 0; i < progressNodeRects.Count(); i++)
            {
                r = progressNodeRects[i];
                x = r.X + r.Width / 2 - tipsWidth / 2;

                tips                = new ScVxPageTips();
                tips.txt            = nodeNames[i];
                tips.triWidthScale  = 4f;
                tips.triHeightScale = 5f;
                tips.bgColor        = Color.Black;
                tips.txtColor       = Color.White;
                tips.isDisplaySide  = true;
                tips.alpha          = 0;

                tips.Width    = tipsWidth;
                tips.Height   = tipsRowRect.Height;
                tips.Location = new PointF(x, tipsRowRect.Y);


                Add(tips);
                tipsList.Add(tips);

                //
                x = r.X + r.Width / 2 - r.Width;
                RectangleF r2 = new RectangleF(x, numRowRect.Y, r.Width * 2, numRowRect.Height);
                numRectList.Add(r2);
            }

            tipsSet          = tipsList.ToArray();
            progressNumRects = numRectList.ToArray();

            //
        }
コード例 #22
0
ファイル: BarcodeTextElement.cs プロジェクト: wanaxe/Study
 public bool ShouldSerialize()
 {
     return(Visible == false || Margin.ShouldSerialize() || Color.HasValue() || Font.HasValue());
 }
コード例 #23
0
 public override bool CanDrawForeground(Margin margin)
 {
     return(drawInIconMarging ? margin is IconMargin : margin is GutterMargin);
 }
コード例 #24
0
        public List <Tuple <string, string> > ToTupleString()
        {
            var paramList = new List <Tuple <string, string> >();

            paramList.Add(new Tuple <string, string>("startfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StartFreqUnit, "mhz", StartFreq))));
            paramList.Add(new Tuple <string, string>("stopfreq", string.Format("{0}MHz", WMonitorUtile.ConvertFreqValue(StopFreqUnit, "mhz", StopFreq))));
            paramList.Add(new Tuple <string, string>("step", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(StepUnit, "khz", Step))));
            paramList.Add(new Tuple <string, string>("ifbw", string.Format("{0}kHz", WMonitorUtile.ConvertFreqValue(IfbwUnit, "khz", Ifbw))));
            paramList.Add(new Tuple <string, string>("polarization", RmtpDefaultCollection.PolarizationSource[Polarization].ToString()));
            paramList.Add(new Tuple <string, string>("detector", RmtpDefaultCollection.DetectorSource[SmoothMode].ToString()));
            //paramList.Add(new Tuple<string, string>("storage", Storage ? "on" : "off"));
            paramList.Add(new Tuple <string, string>("storage", "on"));

            if (RmtpDefaultCollection.DetectorSource[SmoothMode] != Detector.fast && RmtpDefaultCollection.DetectorSource[SmoothMode] != Detector.qbk && RmtpDefaultCollection.DetectorSource[SmoothMode] != Detector.avg)
            {
                paramList.Add(new Tuple <string, string>("smoothparam", SmoothParam.ToString(CultureInfo.InvariantCulture)));
            }

            paramList.Add(new Tuple <string, string>("ifbwmode", "xdb"));
            paramList.Add(new Tuple <string, string>("ifbwparam", "26"));
            paramList.Add(new Tuple <string, string>("statwindowtime", 5.ToString()));

            paramList.Add(new Tuple <string, string>("gainmode", RmtpDefaultCollection.GainModeSource[GainMode].ToString()));
            if (RmtpDefaultCollection.GainModeSource[GainMode] == Rmtp.GainMode.mgc)
            {
                paramList.Add(new Tuple <string, string>("gainparam", string.Format("{0}dBuV", GainParam)));
            }

            if (!IsStudy)
            {
                if (HasThreshold)
                {
                    if (ConfigurationManager.AppSettings["FscanSignalShold"].Equals("1"))
                    {
                        var    tt = RmtpDefaultCollection.SignalSholdSource[ThresholdType].ToString();
                        string signalthreshold;
                        if (tt == "horizontal")
                        {
                            signalthreshold = string.Format("{0}dBμV", SignalThreshold);
                            paramList.Add(new Tuple <string, string>("thresholdtype", tt));
                            paramList.Add(new Tuple <string, string>("signalthreshold", signalthreshold));
                        }
                        else if (tt == "background")
                        {
                            //自定义门限
                            paramList.Add(new Tuple <string, string>("thresholdtype", "custom"));
                            paramList.Add(new Tuple <string, string>("thresholddesc", ThresholdDesc));
                            paramList.Add(new Tuple <string, string>("customthreshold", CustomThresholdValues));
                        }
                        else if (tt == "noise")
                        {
                            paramList.Add(new Tuple <string, string>("thresholdtype", tt));
                        }

                        if (tt != "horizontal")
                        {
                            //paramList.Add(new Tuple<string, string>("margin", Margin.ToString(CultureInfo.InvariantCulture)));
                            paramList.Add(new Tuple <string, string>("signalthreshold", Margin.ToString(CultureInfo.InvariantCulture)));
                        }
                    }
                    else
                    {
                        string signalthreshold = string.Format("{0}dBμV", SignalThreshold);
                        paramList.Add(new Tuple <string, string>("thresholdtype", ThresholdType));
                        paramList.Add(new Tuple <string, string>("signalthreshold", signalthreshold));
                    }
                }
            }

            return(paramList);
        }
コード例 #25
0
ファイル: EditorUtil.cs プロジェクト: yas/uLipSync
        public static void DrawFormants(Profile profile, LipSyncInfo result = null)
        {
            var origColor = Handles.color;

            var area = GUILayoutUtility.GetRect(Screen.width, 300f);

            area = EditorGUI.IndentedRect(area);
            var margin = new Margin(10, 10f, 30f, 40f);
            var range  = new Vector2(1200f, 4000f);

            DrawGrid(
                area,
                Color.white,
                new Color(1f, 1f, 1f, 0.5f),
                margin,
                range,
                new Vector2(6f, 4f));

            if (!profile)
            {
                return;
            }

            float xMin   = area.x + margin.left;
            float xMax   = area.xMax - margin.right;
            float yMin   = area.y + margin.top;
            float yMax   = area.yMax - margin.bottom;
            float width  = xMax - xMin;
            float height = yMax - yMin;

            var colors = new Color[]
            {
                new Color(1f, 0f, 0f, 1f),
                new Color(0f, 1f, 0f, 1f),
                new Color(0f, 0f, 1f, 1f),
                new Color(1f, 1f, 0f, 1f),
                new Color(0f, 1f, 1f, 1f),
            };

            var formants = new FormantPair[]
            {
                profile.formantA,
                profile.formantI,
                profile.formantU,
                profile.formantE,
                profile.formantO,
            };

            var vowelLabels = new string[]
            {
                "A",
                "I",
                "U",
                "E",
                "O",
            };

            float dx = width / range.x;
            float dy = height / range.y;

            for (int i = 0; i < formants.Length; ++i)
            {
                var   f      = formants[i];
                float x      = xMin + dx * f.f1;
                float y      = yMin + (height - dy * f.f2);
                float rx     = profile.maxErrorRange * dx;
                float ry     = profile.maxErrorRange * dy;
                var   center = new Vector3(x, y, 0f);
                var   color  = colors[i];
                Handles.color = color;
                Handles.DrawSolidDisc(center, Vector3.forward, 5f);
                float factor = result != null ? result.vowels[(Vowel)i] : 0f;
                color.a       = Mathf.Lerp(0.15f, 0.5f, factor);
                Handles.color = color;
                DrawEllipse(center, rx, ry, new Rect(xMin, yMin, width, height));
                EditorGUI.LabelField(new Rect(x + 5f, y - 20f, 50f, 20f), vowelLabels[i]);
            }

            if (result != null)
            {
                float x      = xMin + result.formant.f1 * dx;
                float y      = yMin + (height - result.formant.f2 * dy);
                float size   = Mathf.Lerp(2f, 20f, Mathf.Min(result.volume / 0.1f, 1f));
                var   center = new Vector3(x, y, 0f);
                Handles.color = Color.white;
                Handles.DrawWireDisc(center, Vector3.forward, size);
            }

            Handles.color = origColor;
        }
コード例 #26
0
ファイル: EditorUtil.cs プロジェクト: yas/uLipSync
        public static void DrawGrid(Rect area, Color axisColor, Color gridColor, Margin margin, Vector2 range, Vector2 div)
        {
            var origColor = Handles.color;

            float xMin   = area.x + margin.left;
            float xMax   = area.xMax - margin.right;
            float yMin   = area.y + margin.top;
            float yMax   = area.yMax - margin.bottom;
            float yRange = yMax - yMin;
            float xRange = xMax - xMin;

            // axes
            Handles.DrawSolidRectangleWithOutline(new Vector3[]
            {
                new Vector2(xMin, yMin),
                new Vector2(xMax, yMin),
                new Vector2(xMax, yMax),
                new Vector2(xMin, yMax)
            }, new Color(0f, 0f, 0f, 0f), axisColor);

            // grids
            Handles.color = gridColor;
            int subDiv = 5;

            for (int i = 1; i < div.y * subDiv; ++i)
            {
                float y = yRange / (div.y * subDiv) * i;
                if (i % subDiv == 0)
                {
                    Handles.DrawLine(
                        new Vector2(xMin, yMin + y),
                        new Vector2(xMax, yMin + y));
                }
                else
                {
                    Handles.DrawDottedLine(
                        new Vector2(xMin, yMin + y),
                        new Vector2(xMax, yMin + y),
                        1f);
                }
            }

            for (int i = 1; i < div.x * subDiv; ++i)
            {
                float x = xRange / (div.x * subDiv) * i;
                if (i % subDiv == 0)
                {
                    Handles.DrawLine(
                        new Vector2(xMin + x, yMin),
                        new Vector2(xMin + x, yMax));
                }
                else
                {
                    Handles.DrawDottedLine(
                        new Vector2(xMin + x, yMin),
                        new Vector2(xMin + x, yMax),
                        1f);
                }
            }

            for (int i = 0; i <= div.y; ++i)
            {
                float y    = yRange * ((div.y - i) / div.y);
                var   rect = new Rect(margin.left / 2, area.y + y, 100f, 20f);
                EditorGUI.LabelField(rect, (range.y * i / div.y).ToString());
            }

            for (int i = 0; i <= div.x; ++i)
            {
                float x    = margin.left + xRange * (i / div.x);
                var   rect = new Rect(x, yMax, 100f, 20f);
                EditorGUI.LabelField(rect, (range.x * i / div.x).ToString());
            }

            Handles.color = origColor;
        }
コード例 #27
0
ファイル: TutorialPopup.cs プロジェクト: sodomon2/dwarfcorp
        public override void Construct()
        {
            //Set size and center on screen.
            Rect = new Rectangle(0, 0, 450, 300);

            Border = "border-fancy";

            Text           = Message == null || String.IsNullOrEmpty(Message.Title) ? "Tutorial" : Message.Title;
            Font           = "font16";
            InteriorMargin = new Margin(20, 0, 0, 0);

            if (!String.IsNullOrEmpty(Message.Name) && AssetManager.DoesTextureExist("newgui\\tutorials\\" + Message.Name))
            {
                var asset = "newgui\\tutorials\\" + Message.Name;
                AddChild(new GameStates.TutorialIcon()
                {
                    ImageSource = asset,
                    MinimumSize = new Point(256, 128),
                    MaximumSize = new Point(256, 128),
                    AutoLayout  = AutoLayout.DockTop
                });
                Rect           = new Rectangle(0, 0, 450, 450);
                InteriorMargin = new Margin(32, 0, 0, 0);
            }
            else if (Message.Icon != null)
            {
                AddChild(new Play.ResourceGuiGraphicIcon()
                {
                    Resource    = Message.Icon,
                    MinimumSize = new Point(128, 128),
                    MaximumSize = new Point(128, 128),
                    AutoLayout  = AutoLayout.DockTop
                });
                Rect           = new Rectangle(0, 0, 450, 450);
                InteriorMargin = new Margin(32, 0, 0, 0);
            }

            AddChild(new Button
            {
                Text = "Dismiss",
                Font = "font16",
                TextHorizontalAlign = HorizontalAlign.Center,
                TextVerticalAlign   = VerticalAlign.Center,
                Border             = "border-button",
                OnClick            = (sender, args) => { this.Close(); SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_gui_window_close, 0.015f); },
                AutoLayout         = AutoLayout.FloatBottomRight,
                ChangeColorOnHover = true,
            });

            DisableBox = AddChild(new Gui.Widgets.CheckBox
            {
                Text = "Disable tutorial",
                ChangeColorOnHover = true,
                Font       = "font8",
                AutoLayout = AutoLayout.FloatBottomLeft
            }) as Gui.Widgets.CheckBox;

            AddChild(new Widget
            {
                Text       = Message == null ? "" : "\n" + Message.Text,
                Font       = "font10",
                AutoLayout = AutoLayout.DockTop
            });

            Layout();
        }
コード例 #28
0
ファイル: DataViewTests.cs プロジェクト: serge4k/GraphControl
        private static IDrawing StartCreateAndDrawDataLines(int pointsNumber, bool drawInBitmap, bool runProvider)
        {
            var linesNumber = pointsNumber - 1;
            var linesToDraw = 0;
            IDataProviderService provider = null;

            TestDrawingWrapper drawingTester = null;
            DrawingBuffer      buffer        = null;
            Drawing2DWrapper   drawingBitmap = null;
            IDrawing           drawing       = null;
            var size = new Size(800, 600);

            if (drawInBitmap)
            {
                size          = new Size(8000, 4500);
                buffer        = new DrawingBuffer(size);
                drawingBitmap = new Drawing2DWrapper(buffer.Graphics);
                drawing       = drawingBitmap;
            }
            else
            {
                drawingTester = new TestDrawingWrapper(100);
                drawing       = drawingTester;
            }

            IScaleService           scaleService           = null;
            IDataService            dataService            = null;
            var                     controller             = GraphControlFactory.CreateController();
            IBufferedDrawingService bufferedDrawingService = new BufferedDrawingService();
            int                     receivedPoints         = 0;

            try
            {
                // Create all services
                provider = TestSinusDataProviderService.Create(pointsNumber);
                var view = TestDataView.Create(controller, provider, bufferedDrawingService);

                var margin  = new Margin(100, 5, 5, 60);
                var options = new DataDrawOptions(size, true, true, null, new DataDrawState());
                scaleService = controller.GetInstance <IScaleService>();
                scaleService.UpdateScale(options); // to prepare scaling service without presenter

                dataService = controller.GetInstance <IDataService>();

                dataService.DataUpdated += (sender, e) =>
                {
                    scaleService.UpdateScale(options);
                    drawingTester?.Reset();
                    view.Draw(drawing, options, margin);
                    receivedPoints += e.Items.Count;
                };

                if (pointsNumber > 0)
                {
                    provider.Run();

                    // Wait to draw at least test points
                    while (receivedPoints < pointsNumber)
                    {
                        Thread.Sleep(0);
                    }
                }
                else
                {
                    view.Draw(drawing, options, margin);
                }

                linesToDraw = dataService.GetItems(scaleService.State.X1, scaleService.State.X2).Count();
            }
            finally
            {
                bufferedDrawingService.Dispose();
            }

            Assert.IsTrue(bufferedDrawingService.LastQueueOverflow.Ticks == 0, $"drawing queue overflow, last time: {bufferedDrawingService.LastQueueOverflow.ToLongTimeString()}");

            Assert.IsTrue(linesToDraw == pointsNumber,
                          $"dataService.GetItems({new DateTime((long)scaleService.State.X1 * TimeSpan.TicksPerMillisecond).ToString("HH:mm:ss.fff")}"
                          + $", {new DateTime((long)scaleService.State.X1 * TimeSpan.TicksPerMillisecond).ToString("HH:mm:ss.fff")}) {linesToDraw} ({dataService.ItemCount}) != generated points {pointsNumber}");

            if (!drawInBitmap)
            {
                Assert.IsTrue(drawingTester.Lines.Count >= linesNumber, $"lines count is {drawingTester.Lines.Count} less than {linesNumber}");
            }

            return(drawing);
        }
コード例 #29
0
        public ImageParagraph Image(string imageName, Size?imageSize = null, Rectangle?textureRect = null, Color?imageColor = null, Margin margin = new Margin(), int indent = 0)
        {
            ImageParagraph paragraph = new ImageParagraph(margin, indent);

            paragraph.Image(imageName, imageSize, textureRect, imageColor);

            m_Paragraphs.Add(paragraph);

            return(paragraph);
        }
コード例 #30
0
        public static void Resize(UIElement script, bool child = true)
        {
            Transform rect    = script.transform;
            Vector3   loclpos = rect.localPosition;
            Vector2   psize   = Vector2.zero;
            Vector2   v       = script.m_sizeDelta;
            var       pp      = Anchors[0];

            if (script.parentType == ParentType.Tranfrom)
            {
                var p = rect.parent;
                if (p != null)
                {
                    var t = p.GetComponent <UIElement>();
                    if (t != null)
                    {
                        psize = t.SizeDelta;
                        pp    = t.Pivot;
                    }
                }
            }
            else
            {
                var t = rect.root.GetComponent <UIElement>();
                if (t != null)
                {
                    psize = t.SizeDelta;
                }
            }
            switch (script.marginType)
            {
            case MarginType.None:
                break;

            case MarginType.Margin:
                var mar = script.margin;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                MarginEx(script, mar, pp, psize);
                break;

            case MarginType.MarginRatio:
                mar       = new Margin();
                mar.left  = script.margin.left * psize.x;
                mar.right = script.margin.right * psize.x;
                mar.top   = script.margin.top * psize.y;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                mar.down = script.margin.down * psize.y;
                MarginEx(script, mar, pp, psize);
                break;

            case MarginType.MarginX:
                mar = script.margin;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                MarginX(script, mar, pp, psize);
                break;

            case MarginType.MarginY:
                mar = script.margin;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                MarginY(script, mar, pp, psize);
                break;

            case MarginType.MarginRatioX:
                break;

            case MarginType.MarginRatioY:
                break;
            }
            //Scaling(script, script.scaleType, psize, script.DesignSize);
            switch (script.anchorType)
            {
            case AnchorType.None:
                break;

            case AnchorType.Anchor:
                AnchorEx(script, script.anchorPointType, script.anchorOffset, pp, psize);
                break;

            case AnchorType.Alignment:
                AlignmentEx(script, script.anchorPointType, script.anchorOffset, pp, psize);
                break;
            }

            if (child)
            {
                ResizeChild(rect, child);
            }
            else if (script.scaleType != ScaleType.None | script.anchorType != AnchorType.None | script.marginType != MarginType.None)
            {
                ResizeChild(rect, false);
                if (v != script.m_sizeDelta)
                {
                    script.ReSized();
                }
            }
        }
コード例 #31
0
        ///// <summary>Return new AutoScrollPosition for applied muse-wheel scroll.</summary>
        //static Point WheelPanel(ScrollProperties scroll, int delta, ref int remainder,
        //  Func<int,Point> newAutoScroll)
        //{
        //  if (Math.Sign(delta) != Math.Sign(remainder)) remainder = 0;
        //  var steps = (delta+remainder)
        //            / (SystemInformation.MouseWheelScrollDelta / SystemInformation.MouseWheelScrollLines);
        //  remainder = (delta+remainder)
        //            % (SystemInformation.MouseWheelScrollDelta / SystemInformation.MouseWheelScrollLines);
        //  return newAutoScroll(scroll.SmallChange * steps);
        //}
        ///// <summary>TODO</summary>
        //static ScrollEventArgs GetScrollEventArgs(bool isHorizontal, Point oldScroll, Point newScroll) {
        //  return new ScrollEventArgs(
        //    ScrollEventType.ThumbTrack,
        //    isHorizontal ? -oldScroll.X : -oldScroll.Y,
        //    isHorizontal ? -newScroll.X : -newScroll.Y,
        //    isHorizontal ? ScrollOrientation.HorizontalScroll : ScrollOrientation.VerticalScroll
        //  );
        //}

        /// <summary>TODO</summary>
        //public void SetModel(IMapDisplayWinForms model) {
        //  Model = model;
        //}

        IHexgrid GetHexgrid()
        {
            var margin = Margin.OffsetSize();

            return(TransposableHexgrid.GetNewGrid(IsTransposed, Model.GridSize, MapScale, margin));
        }
コード例 #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Base"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public GUIControl(ZComponent parent): base(parent)
        {
            m_Children = new List<GUIControl>();
            m_Accelerators = new Dictionary<string, GwenEventHandler>();

            if (parent == null || parent is GUIControl)
                ParentControl = parent as GUIControl;
            else
                ParentControl = App.Canvas;            

            m_Hidden = false;
            m_Bounds = new Rectangle(0, 0, 10, 10);
            m_Padding = Padding.Zero;
            m_Margin = Margin.Zero;

            RestrictToParent = false;

            MouseInputEnabled = true;
            KeyboardInputEnabled = false;

            Invalidate();
            Cursor = Cursors.Default;
            //ToolTip = null;
            IsTabable = false;
            ShouldDrawBackground = true;
            m_Disabled = false;
            m_CacheTextureDirty = true;
            m_CacheToTexture = false;

            BoundsOutlineColor = Color.Red;
            MarginOutlineColor = Color.Green;
            PaddingOutlineColor = Color.Blue;
        }
コード例 #33
0
        public static string ToDescriptionString(this Margin val)
        {
            var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
        }
コード例 #34
0
 public static extern void AreoFrame(IntPtr handle, Margin margin);
コード例 #35
0
 public override bool CanDrawForeground(Margin margin)
 {
     return(margin is ActionMargin);
 }
コード例 #36
0
        public static void Margin(UIElement script)
        {
            Transform rect    = script.transform;
            Vector3   loclpos = rect.localPosition;
            Vector2   psize   = Vector2.zero;
            Vector2   v       = script.m_sizeDelta;
            var       pp      = Anchors[0];

            if (script.parentType == ParentType.Tranfrom)
            {
                var p = rect.parent;
                if (p != null)
                {
                    var t = p.GetComponent <UIElement>();
                    if (t != null)
                    {
                        psize = t.SizeDelta;
                        pp    = t.Pivot;
                    }
                }
            }
            else
            {
                var t = rect.root.GetComponent <UIElement>();
                if (t != null)
                {
                    psize = t.SizeDelta;
                }
            }
            switch (script.marginType)
            {
            case MarginType.None:
                break;

            case MarginType.Margin:
                var mar = script.margin;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                MarginEx(script, mar, pp, psize);
                break;

            case MarginType.MarginRatio:
                mar       = new Margin();
                mar.left  = script.margin.left * psize.x;
                mar.right = script.margin.right * psize.x;
                mar.top   = script.margin.top * psize.y;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                mar.down = script.margin.down * psize.y;
                MarginEx(script, mar, pp, psize);
                break;

            case MarginType.MarginX:
                mar = script.margin;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                MarginX(script, mar, pp, psize);
                break;

            case MarginType.MarginY:
                mar = script.margin;
                if (script.parentType == ParentType.BangsScreen)
                {
                    if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                    {
                        mar.top += 88;
                    }
                }
                MarginY(script, mar, pp, psize);
                break;

            case MarginType.MarginRatioX:
                break;

            case MarginType.MarginRatioY:
                break;
            }
        }
コード例 #37
0
 ///<summary>Set Slot Padding</summary>
 public void SetSlotPadding(Margin InSlotPadding) =>
 UniformGridPanel_methods.SetSlotPadding_method.Invoke(ObjPointer, InSlotPadding);
コード例 #38
0
            public override void InformMousePress(TextEditor editor, Margin margin, MarginMouseEventArgs args)
            {
                if (menu != null)
                {
                    menu.Destroy();
                }
                var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode();

                menu = new Menu();
                if (unitTest.IsFixture)
                {
                    var menuItem = new MenuItem("_Run All");
                    menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, false).Run;
                    menu.Add(menuItem);
                    if (debugModeSet != null)
                    {
                        menuItem            = new MenuItem("_Debug All");
                        menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, true).Run;
                        menu.Add(menuItem);
                    }
                    menuItem            = new MenuItem("_Select in Test Pad");
                    menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, true).Select;
                    menu.Add(menuItem);
                }
                else
                {
                    if (unitTest.TestCases.Count == 0)
                    {
                        var menuItem = new MenuItem("_Run");
                        menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, false).Run;
                        menu.Add(menuItem);
                        if (debugModeSet != null)
                        {
                            menuItem            = new MenuItem("_Debug");
                            menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, true).Run;
                            menu.Add(menuItem);
                        }
                        menuItem            = new MenuItem("_Select in Test Pad");
                        menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, true).Select;
                        menu.Add(menuItem);
                    }
                    else
                    {
                        var menuItem = new MenuItem("_Run All");
                        menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, false).Run;
                        menu.Add(menuItem);
                        if (debugModeSet != null)
                        {
                            menuItem            = new MenuItem("_Debug All");
                            menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier, true).Run;
                            menu.Add(menuItem);
                        }
                        menu.Add(new SeparatorMenuItem());
                        foreach (var id in unitTest.TestCases)
                        {
                            var submenu = new Menu();
                            menuItem            = new MenuItem("_Run");
                            menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier + id, false).Run;
                            submenu.Add(menuItem);
                            if (debugModeSet != null)
                            {
                                menuItem            = new MenuItem("_Debug");
                                menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier + id, true).Run;
                                submenu.Add(menuItem);
                            }

                            var    label   = "Test" + id;
                            string tooltip = null;
                            var    test    = NUnitService.Instance.SearchTestById(unitTest.UnitTestIdentifier + id);
                            if (test != null)
                            {
                                var result = test.GetLastResult();
                                if (result != null && result.IsFailure)
                                {
                                    tooltip = result.Message;
                                    label  += "!";
                                }
                            }

                            menuItem            = new MenuItem("_Select in Test Pad");
                            menuItem.Activated += new TestRunner(doc, unitTest.UnitTestIdentifier + id, true).Select;
                            submenu.Add(menuItem);


                            var subMenuItem = new MenuItem(label);
                            if (!string.IsNullOrEmpty(tooltip))
                            {
                                subMenuItem.TooltipText = tooltip;
                            }
                            subMenuItem.Submenu = submenu;
                            menu.Add(subMenuItem);
                        }
                    }
                }
                menu.ShowAll();
                editor.TextArea.ResetMouseState();
                GtkWorkarounds.ShowContextMenu(menu, editor, new Gdk.Rectangle((int)args.X, (int)args.Y, 1, 1));
            }
コード例 #39
0
 public RedrawRequest(Margin margin, Gdk.Rectangle area)
 {
     this.Margin = margin;
     this.Area   = area;
 }
 /// <summary>
 /// store a default margin which we can revert to later with the RestoreDefaultMargin
 /// </summary>
 public void StoreDefaultMargin(double left, double right, double bottom, double top)
 {
     defaultMargin = new Margin { Left = left, Right = right, Bottom = bottom, Top = top };
 }
コード例 #41
0
ファイル: Console.cs プロジェクト: NKnusperer/Delta.Console
        public Console(InputButton bindConsoleButton, Margin consoleMargin, Material2DColored consoleBackground, Color consoleFontColor, int maxNumberOfLines)
        {
            // Set the Material2DColored
            this.consoleBackground = consoleBackground;
            // The console should be topmost
            this.consoleBackground.DrawLayer = Delta.ContentSystem.Rendering.RenderLayer.Front;

            // Set the margin and max. line count
            this.consoleMargin = consoleMargin;
            this.maxNumberOfLines = maxNumberOfLines;

            // Initialize the console dimension
            consoleDimension = new Rectangle();

            // Initialize empty history
            history = new List<string>();
            cmdHistory = new Stack<string>();

            // Initialize empty suggestions
            autoCompletionCache = new List<string>();

            // Initialize with empty string
            inputText = "";
            lastInputText = "";

            // Set the console font with the given color
            consoleFont = new Font(Font.Default, consoleFontColor, HorizontalAlignment.Left, VerticalAlignment.Top);

            // Create a new instance of the CommandManager
            cmdManager = new CommandManager();

            // Register input commands
            registerInputCommands(bindConsoleButton);

            // Initialize calculation
            calculateConsoleDimension();
        }
コード例 #42
0
ファイル: GwenConverter.cs プロジェクト: slagusev/gwen-dotnet
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jsObject = JObject.Load(reader);
            Dictionary <string, JToken> properties = jsObject.Properties().ToDictionary(x => x.Name, x => x.Value);

            string[] strs = properties["$type"].Value <string>().Split(',').
                            Where(x => !string.IsNullOrWhiteSpace(x) && x != ",").ToArray();

            for (int i = 0; i < strs.Length; i++)
            {
                strs[i] = strs[i].Trim();
            }

            Type t = Assembly.Load(strs[1]).GetType(strs[0]);

            object obj = GetObjectInstance(t, stashCv);

            foreach (var item in properties)
            {
                if (item.Key == "$type")
                {
                    continue;
                }

                PropertyInfo pinfo = t.GetProperty(item.Key);
                if (pinfo == null)
                {
                    continue;
                }

                object o = item.Value.Value <object>();

                if (item.Key == "Margin")
                {
                    var props = (o as JObject).Properties();

                    int left = 0, top = 0, right = 0, bottom = 0;

                    foreach (var prop in props)
                    {
                        if (prop.Name == "Left")
                        {
                            left = prop.Value.Value <int>();
                        }
                        if (prop.Name == "Top")
                        {
                            top = prop.Value.Value <int>();
                        }
                        if (prop.Name == "Right")
                        {
                            right = prop.Value.Value <int>();
                        }
                        if (prop.Name == "Bottom")
                        {
                            bottom = prop.Value.Value <int>();
                        }
                    }

                    Margin m = new Margin(left, top, right, bottom);

                    pinfo.SetValue(obj, m, null);
                }
                else if (item.Key == "Padding")
                {
                    var props = (o as JObject).Properties();

                    int left = 0, top = 0, right = 0, bottom = 0;

                    foreach (var prop in props)
                    {
                        if (prop.Name == "Left")
                        {
                            left = prop.Value.Value <int>();
                        }
                        if (prop.Name == "Top")
                        {
                            top = prop.Value.Value <int>();
                        }
                        if (prop.Name == "Right")
                        {
                            right = prop.Value.Value <int>();
                        }
                        if (prop.Name == "Bottom")
                        {
                            bottom = prop.Value.Value <int>();
                        }
                    }

                    Padding m = new Padding(left, top, right, bottom);

                    pinfo.SetValue(obj, m, null);
                }
                else
                {
                    if (item.Value.Type == JTokenType.Array)
                    {
                        o = (o as JArray).ToObject(pinfo.PropertyType);
                    }
                    else if (item.Value.Type == JTokenType.Object)
                    {
                        o = (o as JObject).ToObject(pinfo.PropertyType);
                    }
                    else
                    {
                        o = Convert.ChangeType(o, pinfo.PropertyType);
                    }

                    pinfo.SetValue(obj, o, null);
                }
            }

            return(obj);
        }
 /// <summary>
 /// store a the current margin as the default which we can revert to later with the RestoreDefaultMargin
 /// </summary>
 public void StoreDefaultMargin()
 {
     defaultMargin = new Margin { Left = LeftMargin, Right = RightMargin, Bottom = BottomMargin, Top = TopMargin };
 }
コード例 #44
0
ファイル: TabStrip.cs プロジェクト: FloodProject/flood
        /// <summary>
        /// Lays out the control's interior according to alignment, padding, dock etc.
        /// </summary>
        /// <param name="skin">Skin to use.</param>
        protected override void Layout(Skins.Skin skin)
        {
            Vector2i largestTab = new Vector2i(5, 5);

            int num = 0;
            foreach (var child in Children)
            {
                TabButton button = child as TabButton;
                if (null == button) continue;

                button.SizeToContents();

                Margin m = new Margin();
                int notFirst = num > 0 ? -1 : 0;

                if (Dock == Pos.Top)
                {
                    m.Left = notFirst;
                    button.Dock = Pos.Left;
                }

                if (Dock == Pos.Left)
                {
                    m.Top = notFirst;
                    button.Dock = Pos.Top;
                }

                if (Dock == Pos.Right)
                {
                    m.Top = notFirst;
                    button.Dock = Pos.Top;
                }

                if (Dock == Pos.Bottom)
                {
                    m.Left = notFirst;
                    button.Dock = Pos.Left;
                }

                largestTab.X = Math.Max(largestTab.X, button.Width);
                largestTab.Y = Math.Max(largestTab.Y, button.Height);

                button.Margin = m;
                num++;
            }

            if (Dock == Pos.Top || Dock == Pos.Bottom)
                SetSize(Width, largestTab.Y);

            if (Dock == Pos.Left || Dock == Pos.Right)
                SetSize(largestTab.X, Height);

            base.Layout(skin);
        }
コード例 #45
0
        public void Write(AssetWriter writer)
        {
            GUIStyleLayout layout = writer.Layout.Serialized.GUIStyle;

            writer.Write(Name);
            Normal.Write(writer);
            Hover.Write(writer);
            Active.Write(writer);
            Focused.Write(writer);
            OnNormal.Write(writer);
            OnHover.Write(writer);
            OnActive.Write(writer);
            OnFocused.Write(writer);
            Border.Write(writer);
            if (layout.IsBuiltinFormat)
            {
                Margin.Write(writer);
                Padding.Write(writer);
            }
            else
            {
                Padding.Write(writer);
                Margin.Write(writer);
            }

            Overflow.Write(writer);
            Font.Write(writer);
            if (layout.IsBuiltinFormat)
            {
                writer.Write(FontSize);
                writer.Write((int)FontStyle);
                writer.Write((int)Alignment);
                writer.Write(WordWrap);
                writer.Write(RichText);
                writer.AlignStream();

                writer.Write((int)TextClipping);
                writer.Write((int)ImagePosition);
                ContentOffset.Write(writer);
                writer.Write(FixedWidth);
                writer.Write(FixedHeight);
                writer.Write(StretchWidth);
                writer.Write(StretchHeight);
                writer.AlignStream();
            }
            else
            {
                writer.Write((int)ImagePosition);
                writer.Write((int)Alignment);
                writer.Write(WordWrap);
                writer.AlignStream();

                writer.Write((int)TextClipping);
                ContentOffset.Write(writer);
                ClipOffset.Write(writer);
                writer.Write(FixedWidth);
                writer.Write(FixedHeight);
                if (layout.HasFontSize)
                {
                    writer.Write(FontSize);
                    writer.Write((int)FontStyle);
                }
                writer.Write(StretchWidth);
                writer.AlignStream();
                writer.Write(StretchHeight);
                writer.AlignStream();
            }
        }
コード例 #46
0
 public static Account ToAccount(Margin margin)
 {
     return(AccountInfo.Merge(new Account(), margin));
 }
コード例 #47
0
ファイル: Image.cs プロジェクト: flyingpie/AVA
        public virtual void Draw(Vector2 size, Vector4 tintColor, Vector4 borderColor, Vector4 backgroundColor, Margin padding, ScaleMode scaleMode = ScaleMode.Fit)
        {
            var drawAreaOffset = new Vector2(padding.Left, padding.Right);
            var drawAreaSize   = new Vector2(size.X - padding.Left - padding.Right, size.Y - padding.Top - padding.Bottom);

            // Save current cursor position
            var cursorPosBefore = ImGui.GetCursorScreenPos();

            // Draw background color
            ImGui.Image(ResourceManager.Instance.WhiteImage.Pointer, size, Vector2.Zero, Vector2.One, backgroundColor, Vector4.Zero);

            // Reset cursor position
            ImGui.SetCursorScreenPos(cursorPosBefore);

            ImageMath.CalculateScaledImageBounds(new Vector2(Width, Height), drawAreaSize, scaleMode, out var cursorScreenPos, out var targetImageSize);

            ImGui.SetCursorScreenPos(cursorPosBefore + cursorScreenPos + drawAreaOffset);
            ImGui.PushClipRect(cursorPosBefore + drawAreaOffset, cursorPosBefore + drawAreaOffset + drawAreaSize, true);

            // Draw image
            DrawImage(tintColor, targetImageSize);

            ImGui.PopClipRect();

            // Reset cursor position
            var cursorPosAfter = ImGui.GetCursorScreenPos();

            ImGui.SetCursorScreenPos(cursorPosBefore);

            // Draw border
            ImGui.Image(ResourceManager.Instance.WhiteImage.Pointer, new Vector2(size.X - 2, size.Y - 2), Vector2.Zero, Vector2.One, new Vector4(0f), borderColor);
        }
コード例 #48
0
ファイル: LaunchPanel.cs プロジェクト: sodomon2/dwarfcorp
        public override void Construct()
        {
            Padding = new Margin(2, 2, 0, 0);

            StartButton = AddChild(new Gui.Widget
            {
                Text               = "Start Game",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockBottom,
                OnClick            = (sender, args) =>
                {
                    var saveName = DwarfGame.GetWorldDirectory() + Path.DirectorySeparatorChar + Settings.Name + Path.DirectorySeparatorChar + String.Format("{0}-{1}", (int)Settings.InstanceSettings.Origin.X, (int)Settings.InstanceSettings.Origin.Y);
                    var saveGame = SaveGame.LoadMetaFromDirectory(saveName);
                    if (saveGame != null)
                    {
                        DwarfGame.LogSentryBreadcrumb("WorldGenerator", "User is loading a saved game.");
                        Settings.InstanceSettings.LoadType = LoadType.LoadFromFile;

                        GameStateManager.ClearState();
                        GameStateManager.PushState(new LoadState(Game, Settings, LoadTypes.UseExistingOverworld));
                    }
                    else
                    {
                        DwarfGame.LogSentryBreadcrumb("WorldGenerator", string.Format("User is starting a game with a {0} x {1} world.", Settings.Width, Settings.Height));
                        Settings.InstanceSettings.LoadType = LoadType.CreateNew;

                        var message = "";
                        var valid   = InstanceSettings.ValidateEmbarkment(Settings, out message);
                        if (valid == InstanceSettings.ValidationResult.Pass)
                        {
                            LaunchNewGame();
                        }
                        else if (valid == InstanceSettings.ValidationResult.Query)
                        {
                            var popup = new Gui.Widgets.Confirm()
                            {
                                Text    = message,
                                OnClose = (_sender) =>
                                {
                                    if ((_sender as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY)
                                    {
                                        LaunchNewGame();
                                    }
                                }
                            };
                            Root.ShowModalPopup(popup);
                        }
                        else if (valid == InstanceSettings.ValidationResult.Reject)
                        {
                            var popup = new Gui.Widgets.Confirm()
                            {
                                Text       = message,
                                CancelText = ""
                            };
                            Root.ShowModalPopup(popup);
                        }
                    }
                }
            });

            CellInfo = AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill,
                TextColor  = new Vector4(0, 0, 0, 1),
                Font       = "font10"
            });

            ZoomedPreview = AddChild(new Gui.Widget
            {
                AutoLayout = Gui.AutoLayout.DockBottom,
                OnLayout   = (sender) =>
                {
                    sender.Rect.Height = StartButton.Rect.Width;
                    sender.Rect.Width  = StartButton.Rect.Width;
                    sender.Rect.Y      = StartButton.Rect.Top - StartButton.Rect.Width - 2;
                    sender.Rect.X      = StartButton.Rect.X;
                }
            });

            UpdateCellInfo();
            this.Layout();

            base.Construct();
        }
コード例 #49
0
ファイル: Base.cs プロジェクト: LawlietRyuuzaki/gwen-dotnet
        /// <summary>
        /// Initializes a new instance of the <see cref="Base"/> class.
        /// </summary>
        /// <param name="parent">Parent control.</param>
        public Base(Base parent = null)
        {
            m_Children = new List<Base>();
            m_Accelerators = new Dictionary<string, GwenEventHandler<EventArgs>>();

            Parent = parent;

            m_Hidden = false;
            m_Bounds = new Rectangle(0, 0, 10, 10);
            m_Padding = Padding.Zero;
            m_Margin = Margin.Zero;

            RestrictToParent = false;

            MouseInputEnabled = true;
            KeyboardInputEnabled = false;

            Invalidate();
            Cursor = Cursors.Default;
            //ToolTip = null;
            IsTabable = false;
            ShouldDrawBackground = true;
            m_Disabled = false;
            m_CacheTextureDirty = true;
            m_CacheToTexture = false;

            BoundsOutlineColor = Color.Red;
            MarginOutlineColor = Color.Green;
            PaddingOutlineColor = Color.Blue;
        }
コード例 #50
0
ファイル: ScVxTxtInfoPlane.cs プロジェクト: zanderzhg/Sc
        public void ReCreateTable()
        {
            int        n    = 1;
            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 1, 1);

            Margin defaultCellMargin = new Margin(hPadding, vPadding, hPadding, vPadding);

            mainTable.SetDefaultCellMargin(defaultCellMargin);

            if (isHorLayout == false)
            {
                if (isShowFieldTitle)
                {
                    n = 2;
                }
                //
                txtTable = new Table(mainTable.GetCellContentRect(0, 0), TxtRowCount, n);

                for (int j = 0; j < TxtRowCount; j++)
                {
                    int    m      = 0;
                    Margin margin = new Margin(20, 0, 0, 0);

                    if (n == 2)
                    {
                        m = 1;
                    }

                    txtTable.SetCellMargin(j, m, margin);
                }


                TableLine tableLine = new TableLine(LineDir.HORIZONTAL);
                tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
                int i = 0;

                foreach (ScTxtInfo txtInfo in rowTextInfoList)
                {
                    tableLine.computeParam = rowTextInfoList[i].lineHeight;
                    txtTable.SetLineArea(i, tableLine);
                    i++;
                }

                txtTable.ComputeLinesArea(LineDir.HORIZONTAL);


                if (isShowFieldTitle)
                {
                    //
                    tableLine = new TableLine(LineDir.VERTICAL);
                    tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

                    tableLine.computeParam = titleRatio;
                    txtTable.SetLineArea(0, tableLine);

                    tableLine.computeParam = 1 - titleRatio;
                    txtTable.SetLineArea(1, tableLine);

                    txtTable.ComputeLinesArea(LineDir.VERTICAL);
                }
            }
            else
            {
                if (isShowFieldTitle)
                {
                    n = 2;
                }

                txtTable = new Table(mainTable.GetCellContentRect(0, 0), n, TxtRowCount);

                TableLine tableLine = new TableLine(LineDir.VERTICAL);
                tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
                int i = 0;

                foreach (ScTxtInfo txtInfo in rowTextInfoList)
                {
                    tableLine.computeParam = rowTextInfoList[i].lineHeight;
                    txtTable.SetLineArea(i, tableLine);
                    i++;
                }

                txtTable.ComputeLinesArea(LineDir.VERTICAL);


                if (isShowFieldTitle)
                {
                    //
                    tableLine = new TableLine(LineDir.HORIZONTAL);
                    tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

                    tableLine.computeParam = titleRatio;
                    txtTable.SetLineArea(0, tableLine);

                    tableLine.computeParam = 1 - titleRatio;
                    txtTable.SetLineArea(1, tableLine);

                    txtTable.ComputeLinesArea(LineDir.HORIZONTAL);
                }
            }
        }
コード例 #51
0
ファイル: EventArgs.cs プロジェクト: elayaraja007/sql-dbdiff
		/// <summary>
		/// Initializes a new instance of the MarginClickEventArgs class.
		/// </summary>
		/// <param name="modifiers"></param>
		/// <param name="position"></param>
		/// <param name="line"></param>
		/// <param name="margin"></param>
		/// <param name="toggleMarkerNumber"></param>
		/// <param name="toggleFold"></param>
		public MarginClickEventArgs(Keys modifiers, int position, Line line, Margin margin, int toggleMarkerNumber, bool toggleFold)
		{
			_modifiers = modifiers;
			_position = position;
			_line = line;
			_margin = margin;
			_toggleMarkerNumber = toggleMarkerNumber;
			_toggleFold = toggleFold;
		}
コード例 #52
0
        public override void Construct()
        {
            Height      = 28;
            Rect        = new Rectangle(0, 0, Commands.Count * 64 + 32, Height);
            MaximumSize = new Point(Commands.Count * 64 + 32, Height);
            MaximumSize = new Point(Commands.Count * 64 + 32, Height);
            TextColor   = Color.White.ToVector4();
            Padding     = new Margin(2, 2, 8, 8);
            Root.RegisterForUpdate(this);
            base.Construct();

            foreach (var command in Commands)
            {
                var iconSheet     = Root.GetTileSheet(command.Icon.Sheet);
                var lambdaCommand = command;
                AddChild(new Gui.Widget()
                {
                    AutoLayout          = AutoLayout.DockLeft,
                    Font                = "font10",
                    TextVerticalAlign   = VerticalAlign.Center,
                    TextHorizontalAlign = HorizontalAlign.Center,
                    Background          = new TileReference("basic", 0),
                    BackgroundColor     = new Vector4(0.2f, 0.2f, 0.2f, 0.75f),
                    MinimumSize         = new Point(Height, 16),
                    InteriorMargin      = new Margin(2, 2, 2, 2),
                    Text                = command.Name,
                    Tooltip             = command.Description,
                    OnClick             = (sender, args) =>
                    {
                        if (MultiBody != null && MultiBody.Count > 0)
                        {
                            foreach (var body in MultiBody.Where(body => !body.IsDead && lambdaCommand.CanBeAppliedTo(body, body.World)))
                            {
                                lambdaCommand.Apply(body, World);
                            }
                        }
                        else
                        {
                            lambdaCommand.Apply(Body, World);
                        }
                        if (ClickAction != null)
                        {
                            ClickAction.Invoke();
                        }
                        sender.Parent.Close();
                    },
                    ChangeColorOnHover = true,
                    HoverTextColor     = GameSettings.Default.Colors.GetColor("Highlight", Color.DarkRed).ToVector4()
                });
            }

            OnUpdate += (sender, time) =>
            {
                if (Body == null)
                {
                    return;
                }

                if (Body.IsDead)
                {
                    this.Close();
                    return;
                }

                var menuCenter = World.Renderer.Camera.Project(Body.Position) / Root.RenderData.ScaleRatio;
                Rect = new Rectangle((int)menuCenter.X, (int)menuCenter.Y, Commands.Count * 16 + 32, Height);
                Layout();
                Invalidate();
            };
        }