コード例 #1
0
ファイル: ConsoleDialogData.cs プロジェクト: KIT-ISAS/iviz
        string UpdateStats()
        {
            var listener = ConnectionManager.LogListener;

            if (listener == null)
            {
                return("Error: No Log Listener");
            }

            var description = BuilderPool.Rent();

            try
            {
                listener.WriteDescriptionTo(description);
                string kbPerSecond = (listener.Stats.BytesPerSecond * 0.001f).ToString("#,0.#", UnityUtils.Culture);
                description.Append(" | ").Append(listener.Stats.MessagesPerSecond).Append(" Hz | ")
                .Append(kbPerSecond).Append(" kB/s");

                return(description.ToString());
            }
            finally
            {
                BuilderPool.Return(description);
            }
        }
コード例 #2
0
ファイル: NetworkDialogData.cs プロジェクト: KIT-ISAS/iviz
        public override void UpdatePanel()
        {
            var description = BuilderPool.Rent();

            try
            {
                if (!ConnectionManager.IsConnected)
                {
                    description.Append("<b>State: </b> Disconnected. Nothing to show!").AppendLine();
                }
                else
                {
                    try
                    {
                        GenerateReport(description, ConnectionManager.Connection.Client);
                    }
                    catch (InvalidOperationException)
                    {
                        description.AppendLine("EE Interrupted!").AppendLine();
                    }
                }

                description.AppendLine().AppendLine();

                panel.Text.SetText(description);
            }
            finally
            {
                BuilderPool.Return(description);
            }
        }
コード例 #3
0
        public string Split([NotNull] string str, int maxWidth, int maxLines = 2)
        {
            if (str == null)
            {
                throw new ArgumentNullException(nameof(str));
            }

            int usableWidth = maxWidth - dotWidth;

            int totalWidth = str.Sum(CharWidth);

            if (totalWidth <= usableWidth)
            {
                return(str);
            }

            var description = BuilderPool.Rent();

            try
            {
                description.Length = 0;
                int usedWidth = 0;
                int numLines  = 0;
                for (int i = 0; i < str.Length; i++)
                {
                    int charWidth = CharWidth(str[i]);
                    if (usedWidth + charWidth > usableWidth)
                    {
                        if (i >= str.Length - 2)
                        {
                            description.Append(str[i]);
                            continue;
                        }

                        if (numLines != maxLines - 1)
                        {
                            description.Append("...\n→ ").Append(str[i]);
                            usedWidth = arrowWidth;
                            numLines  = 1;
                        }
                        else
                        {
                            description.Append("...");
                            return(description.ToString());
                        }
                    }
                    else
                    {
                        description.Append(str[i]);
                        usedWidth += charWidth;
                    }
                }

                return(description.ToString());
            }
            finally
            {
                BuilderPool.Return(description);
            }
        }
コード例 #4
0
ファイル: MarkerDialogData.cs プロジェクト: KIT-ISAS/iviz
        public override void UpdatePanel()
        {
            if (Listener == null)
            {
                return;
            }

            var description = BuilderPool.Rent();

            try
            {
                Listener.GenerateLog(description);
                panel.Text.SetText(description);
            }
            finally
            {
                BuilderPool.Return(description);
            }
        }
コード例 #5
0
        void Update()
        {
            if (highlightFrameStart == null)
            {
                return;
            }

            float srcAlpha = 1 - (Time.time - highlightFrameStart.Value) / HighlightDuration;

            if (srcAlpha < 0)
            {
                this.ReturnToPool();
                return;
            }

            float alpha = Mathf.Sqrt(srcAlpha);
            var   color = Color.white.WithAlpha(alpha);

            axisResource.Tint       = color;
            tooltip.CaptionColor    = color;
            tooltip.BackgroundColor = Resource.Colors.HighlighterBackground.WithAlpha(alpha);

            var(pX, pY, pZ) = TfListener.RelativePositionToFixedFrame(node.Transform.position).Unity2RosVector3();
            string px = pX.ToString("#,0.##", UnityUtils.Culture);
            string py = pY.ToString("#,0.##", UnityUtils.Culture);
            string pz = pZ.ToString("#,0.##", UnityUtils.Culture);

            StringBuilder str = BuilderPool.Rent();

            try
            {
                str.Append("<font=Bold>").Append(node.ParentId).Append("</font>\n");
                str.Append(px).Append(", ").Append(py).Append(", ").Append(pz);
                tooltip.SetCaption(str);
            }
            finally
            {
                BuilderPool.Return(str);
            }
        }