示例#1
0
        public void AddItem(ConnectionDropDownItem connectionDropDownItem)
        {
            // *begin-nonstandard-formatting*
            connectionItems ??= new List <ConnectionDropDownItem>();
            // *end-nonstandard-formatting*
            // this is a hack to show switch connected over ethernet in devices
            if (connectionDropDownItem.IP == "127.0.0.1" && ProfilerDriver.GetConnectionIdentifier(connectionDropDownItem.m_ConnectionId).StartsWith("Switch"))
            {
                connectionDropDownItem.m_TopLevelGroup = ConnectionDropDownItem.ConnectionMajorGroup.Local;
                connectionDropDownItem.m_SubGroup      = "Devices";
                connectionDropDownItem.IsDevice        = true;
                connectionDropDownItem.IconContent     = ConnectionUIHelper.GetIcon("Switch");
                var fullName = ProfilerDriver.GetConnectionIdentifier(connectionDropDownItem.m_ConnectionId);
                var start    = fullName.IndexOf('-') + 1;
                var end      = fullName.IndexOf('(');
                connectionDropDownItem.DisplayName = $"{fullName.Substring(start, end - start)} - {ProfilerDriver.GetProjectName(connectionDropDownItem.m_ConnectionId)}";
            }

            var dupes = connectionItems.FirstOrDefault(x => x.DisplayName == connectionDropDownItem.DisplayName && x.IP == connectionDropDownItem.IP && x.Port == connectionDropDownItem.Port);

            if (dupes != null)
            {
                connectionItems.Remove(dupes);
            }

            connectionItems.Add(connectionDropDownItem);
        }
示例#2
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (CurrentPage == 1)
            {
                switch (page1.Mode)
                {
                case Pages.ImportMode.UseExistingDs:
                    if (page1.CurrentDataSource != null)
                    {
                        if (!page2.Init(TypedDataSource.GetFromTabularDs(page1.CurrentDataSource)))
                        {
                            return;
                        }
                        CurrentPage = 2; return;
                    }
                    break;

                case Pages.ImportMode.UseNewDs:
                    var connectionDialog = ShowConnectionDialog();
                    if (connectionDialog == null)
                    {
                        return;
                    }
                    var source    = TypedDataSource.GetFromConnectionUi(connectionDialog);
                    var tabularDs = Model.AddDataSource(source.SuggestSourceName());
                    ConnectionUIHelper.ApplyToTabularDs(connectionDialog, tabularDs);
                    source = TypedDataSource.GetFromTabularDs(tabularDs);
                    page2.Init(source);
                    CurrentPage = 2;
                    return;


                case Pages.ImportMode.UseTempDs:
                    connectionDialog = ShowConnectionDialog();
                    if (connectionDialog == null)
                    {
                        return;
                    }
                    source = TypedDataSource.GetFromConnectionUi(connectionDialog);
                    source.TabularDsName = "(Temporary connection)";
                    page2.Init(source);
                    CurrentPage = 2;
                    return;

                case Pages.ImportMode.UseClipboard:
                    page3.Visible = true;
                    page3.BringToFront();
                    CurrentPage = 3;
                    break;
                }
            }
        }
示例#3
0
        public ConnectionDropDownItem(string content, int connectionId, string subGroup, ConnectionMajorGroup topLevelGroup, Func <bool> connected, Action onSelected,
                                      bool isDevice = false, string iconString = null)
        {
            var idString = ConnectionUIHelper.GetIdString(content);

            DisplayName     = subGroup == ConnectionUIHelper.kDevices ? content : ConnectionUIHelper.GetPlayerNameFromIDString(idString);
            DisplayNameSize = ConnectionDropDownStyles.sTVLine.CalcSize(GUIContent.Temp(DisplayName)).x;

            ProjectName     = subGroup == ConnectionUIHelper.kDevices ? "" : ConnectionUIHelper.GetProjectNameFromConnectionIdentifier(connectionId);
            ProjectNameSize = ConnectionDropDownStyles.sTVLine.CalcSize(GUIContent.Temp(ProjectName)).x;

            IP     = ConnectionUIHelper.GetIP(connectionId);
            IPSize = ConnectionDropDownStyles.sTVLine.CalcSize(GUIContent.Temp(IP)).x;

            Port     = ConnectionUIHelper.GetPort(connectionId);
            PortSize = ConnectionDropDownStyles.sTVLine.CalcSize(GUIContent.Temp(Port)).x;

            m_ConnectionId  = connectionId;
            m_Connected     = connected;
            m_OnSelected    = onSelected;
            m_SubGroup      = string.IsNullOrEmpty(subGroup) ? ConnectionUIHelper.GetRuntimePlatformFromIDString(idString) : subGroup;
            m_TopLevelGroup = topLevelGroup == ConnectionMajorGroup.Unknown ? (m_SubGroup == Content.DirectConnection ? ConnectionMajorGroup.Direct : (ProfilerDriver.IsIdentifierOnLocalhost(connectionId) ? ConnectionMajorGroup.Local : ConnectionMajorGroup.Remote)) : topLevelGroup;

            if (m_TopLevelGroup == ConnectionMajorGroup.Direct)
            {
                DisplayName = content;
            }

            if (string.IsNullOrEmpty(m_SubGroup))
            {
                if (idString == "Editor" || idString == "Main Editor Process")
                {
                    m_TopLevelGroup = ConnectionMajorGroup.Editor;
                    m_SubGroup      = "Editor";
                }
                else
                {
                    DisplayName         = content;
                    m_TopLevelGroup     = ConnectionMajorGroup.ConnectionsWithoutID;
                    OldConnectionFormat = true;
                }
            }

            displayName = DisplayName + ProjectName;
            id          = GenerateID();
            IsDevice    = isDevice;
            if (isDevice)
            {
                IconContent = ConnectionUIHelper.GetIcon(iconString);
            }
        }
        void LogMessage(MessageEventArgs messageEventArgs)
        {
            var    body = messageEventArgs.data.Skip(4).ToArray();
            string text = System.Text.Encoding.UTF8.GetString(body);

            var logType = (LogType)messageEventArgs.data[0];

            if (!Enum.IsDefined(typeof(LogType), logType))
            {
                logType = LogType.Log;
            }
            var oldStackTraceType = Application.GetStackTraceLogType(logType);

            // We don't want stack traces from editor code in player log messages.
            Application.SetStackTraceLogType(logType, StackTraceLogType.None);
            string name = ConnectionUIHelper.GetPlayerNameFromId(messageEventArgs.playerId);
            string t    = ConnectionUIHelper.GetPlayerType(ProfilerDriver.GetConnectionIdentifier(messageEventArgs.playerId));

            text = $"<i>{t} \"{name}\"</i> {text}";
            Debug.unityLogger.Log(logType, text);
            Application.SetStackTraceLogType(logType, oldStackTraceType);
        }
示例#5
0
        void CellGUI(Rect cellRect, TreeViewItem item, ConnectionDropDownColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);
            ConnectionDropDownItem cddi = null;

            if (item is ConnectionDropDownItem downItem)
            {
                cddi = downItem;
            }

            switch (column)
            {
            case ConnectionDropDownColumns.DisplayName:
                if (cddi != null)
                {    //actual connections
                    var rect = cellRect;
                    rect.x += GetContentIndent(item) - foldoutWidth;

                    EditorGUI.BeginChangeCheck();
                    rect.width = ConnectionDropDownStyles.ToggleRectWidth;
                    var isConnected = cddi.m_Connected?.Invoke() ?? false;
                    GUI.Label(rect, (isConnected ? EditorGUIUtility.IconContent("Valid") : GUIContent.none));
                    rect.x += ConnectionDropDownStyles.ToggleRectWidth;
                    if (cddi.IsDevice)
                    {
                        EditorGUI.LabelField(new Rect(rect.x, rect.y, rowHeight, rowHeight), cddi.IconContent);
                        rect.x += rowHeight;
                    }
                    var textRect = cellRect;
                    textRect.x     = rect.x;
                    textRect.width = cellRect.width - (textRect.x - cellRect.x);

                    GUI.Label(textRect, ConnectionUIHelper.TruncateString(cddi.DisplayName, ConnectionDropDownStyles.sTVLine, textRect.width));
                    if (EditorGUI.EndChangeCheck())
                    {
                        cddi.m_OnSelected.Invoke();
                    }
                }
                else
                {
                    var r = cellRect;
                    if (item.depth <= 0)
                    {    // major group headers
                        if (args.row != 0)
                        {
                            EditorGUI.DrawRect(new Rect(r.x, r.y, args.rowRect.width, 1f), ConnectionDropDownStyles.SeparatorColor);
                        }
                        r.x    += GetContentIndent(item);
                        r.width = args.rowRect.width - GetContentIndent(item);
                        GUI.Label(r, item.displayName, EditorStyles.boldLabel);
                    }
                    else
                    {    // sub group headers
                        r.x += GetContentIndent(item);
                        EditorGUI.LabelField(new Rect(r.x, r.y, rowHeight, rowHeight), ConnectionUIHelper.GetIcon(item.displayName));
                        GUI.Label(new Rect(r.x + rowHeight, r.y, r.width - rowHeight, r.height), item.displayName, EditorStyles.miniBoldLabel);
                    }
                }
                break;

            case ConnectionDropDownColumns.ProjectName:
                if (item.depth > 1)
                {
                    DrawVerticalSeparatorLine(cellRect);
                    GUI.Label(cellRect, ConnectionUIHelper.TruncateString(cddi.ProjectName, ConnectionDropDownStyles.sTVLine, cellRect.width));
                }
                break;

            case ConnectionDropDownColumns.IP:
                if (item.depth > 1)
                {
                    DrawVerticalSeparatorLine(cellRect);
                    GUI.Label(cellRect, ConnectionUIHelper.TruncateString(cddi.IP, ConnectionDropDownStyles.sTVLine, cellRect.width));
                }
                break;

            case ConnectionDropDownColumns.Port:
                if (item.depth > 1)
                {
                    DrawVerticalSeparatorLine(cellRect);
                    GUI.Label(cellRect, ConnectionUIHelper.TruncateString(cddi.Port, ConnectionDropDownStyles.sTVLine, cellRect.width));
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(column), column, null);
            }
        }