System.Collections.Generic.List.IndexOf(string)

Here are the examples of the csharp api System.Collections.Generic.List.IndexOf(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

591 Examples 7

19 Source : ResourceAnalyzer.cs
with MIT License
from EllanJiang

private void OnScatteredreplacedetsOrderOrFilterChanged()
        {
            m_CachedScatteredreplacedetNames = m_Controller.GetScatteredreplacedetNames(m_ScatteredreplacedetsOrder, m_ScatteredreplacedetsFilter);
            if (!string.IsNullOrEmpty(m_SelectedScatteredreplacedetName))
            {
                m_SelectedScatteredreplacedetIndex = new List<string>(m_CachedScatteredreplacedetNames).IndexOf(m_SelectedScatteredreplacedetName);
            }
        }

19 Source : ResourceAnalyzer.cs
with MIT License
from EllanJiang

private void DrawreplacedetDependencyViewer()
        {
            if (!m_replacedyzed)
            {
                DrawreplacedyzeButton();
                return;
            }

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(5f);
                EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.4f));
                {
                    GUILayout.Space(5f);
                    string replacedle = null;
                    if (string.IsNullOrEmpty(m_replacedetsFilter))
                    {
                        replacedle = Utility.Text.Format("replacedets In Resources ({0})", m_replacedetCount);
                    }
                    else
                    {
                        replacedle = Utility.Text.Format("replacedets In Resources ({0}/{1})", m_CachedreplacedetNames.Length, m_replacedetCount);
                    }
                    EditorGUILayout.LabelField(replacedle, EditorStyles.boldLabel);
                    EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height - 150f));
                    {
                        m_replacedetsScroll = EditorGUILayout.BeginScrollView(m_replacedetsScroll);
                        {
                            int selectedIndex = GUILayout.SelectionGrid(m_SelectedreplacedetIndex, m_CachedreplacedetNames, 1, "toggle");
                            if (selectedIndex != m_SelectedreplacedetIndex)
                            {
                                m_SelectedreplacedetIndex = selectedIndex;
                                m_SelectedreplacedetName = m_CachedreplacedetNames[selectedIndex];
                                m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedreplacedetName);
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical("box");
                    {
                        EditorGUILayout.LabelField("replacedet Name", m_SelectedreplacedetName ?? "<None>");
                        EditorGUILayout.LabelField("Resource Name", m_SelectedreplacedetName == null ? "<None>" : m_Controller.Getreplacedet(m_SelectedreplacedetName).Resource.FullName);
                        EditorGUILayout.BeginHorizontal();
                        {
                            replacedetsOrder replacedetsOrder = (replacedetsOrder)EditorGUILayout.EnumPopup("Order by", m_replacedetsOrder);
                            if (replacedetsOrder != m_replacedetsOrder)
                            {
                                m_replacedetsOrder = replacedetsOrder;
                                OnreplacedetsOrderOrFilterChanged();
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        {
                            string replacedetsFilter = EditorGUILayout.TextField("replacedets Filter", m_replacedetsFilter);
                            if (replacedetsFilter != m_replacedetsFilter)
                            {
                                m_replacedetsFilter = replacedetsFilter;
                                OnreplacedetsOrderOrFilterChanged();
                            }
                            EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(m_replacedetsFilter));
                            {
                                if (GUILayout.Button("x", GUILayout.Width(20f)))
                                {
                                    m_replacedetsFilter = null;
                                    GUI.FocusControl(null);
                                    OnreplacedetsOrderOrFilterChanged();
                                }
                            }
                            EditorGUI.EndDisabledGroup();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.6f - 14f));
                {
                    GUILayout.Space(5f);
                    EditorGUILayout.LabelField(Utility.Text.Format("Dependency Resources ({0})", m_SelectedDependencyData.DependencyResourceCount), EditorStyles.boldLabel);
                    EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height * 0.2f));
                    {
                        m_DependencyResourcesScroll = EditorGUILayout.BeginScrollView(m_DependencyResourcesScroll);
                        {
                            Resource[] dependencyResources = m_SelectedDependencyData.GetDependencyResources();
                            foreach (Resource dependencyResource in dependencyResources)
                            {
                                GUILayout.Label(dependencyResource.FullName);
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.LabelField(Utility.Text.Format("Dependency replacedets ({0})", m_SelectedDependencyData.DependencyreplacedetCount), EditorStyles.boldLabel);
                    EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height * 0.3f));
                    {
                        m_DependencyreplacedetsScroll = EditorGUILayout.BeginScrollView(m_DependencyreplacedetsScroll);
                        {
                            replacedet[] dependencyreplacedets = m_SelectedDependencyData.GetDependencyreplacedets();
                            foreach (replacedet dependencyreplacedet in dependencyreplacedets)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    if (GUILayout.Button("GO", GUILayout.Width(30f)))
                                    {
                                        m_SelectedreplacedetName = dependencyreplacedet.Name;
                                        m_SelectedreplacedetIndex = new List<string>(m_CachedreplacedetNames).IndexOf(m_SelectedreplacedetName);
                                        m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedreplacedetName);
                                    }

                                    GUILayout.Label(dependencyreplacedet.Name);
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.LabelField(Utility.Text.Format("Scattered Dependency replacedets ({0})", m_SelectedDependencyData.ScatteredDependencyreplacedetCount), EditorStyles.boldLabel);
                    EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height * 0.5f - 116f));
                    {
                        m_ScatteredDependencyreplacedetsScroll = EditorGUILayout.BeginScrollView(m_ScatteredDependencyreplacedetsScroll);
                        {
                            string[] scatteredDependencyreplacedetNames = m_SelectedDependencyData.GetScatteredDependencyreplacedetNames();
                            foreach (string scatteredDependencyreplacedetName in scatteredDependencyreplacedetNames)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    int count = m_Controller.GetHostreplacedets(scatteredDependencyreplacedetName).Length;
                                    EditorGUI.BeginDisabledGroup(count < 2);
                                    {
                                        if (GUILayout.Button("GO", GUILayout.Width(30f)))
                                        {
                                            m_SelectedScatteredreplacedetName = scatteredDependencyreplacedetName;
                                            m_SelectedScatteredreplacedetIndex = new List<string>(m_CachedScatteredreplacedetNames).IndexOf(m_SelectedScatteredreplacedetName);
                                            m_SelectedHostreplacedets = m_Controller.GetHostreplacedets(m_SelectedScatteredreplacedetName);
                                            m_ToolbarIndex = 2;
                                            GUI.FocusControl(null);
                                        }
                                    }
                                    EditorGUI.EndDisabledGroup();
                                    GUILayout.Label(count > 1 ? Utility.Text.Format("{0} ({1})", scatteredDependencyreplacedetName, count) : scatteredDependencyreplacedetName);
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }

19 Source : TocGenerator.cs
with MIT License
from Ellerbach

private static void GetFiles(DirectoryInfo folder, List<string> order, TocItem yamlNode, Dictionary<string, string> overrides)
        {
            message.Verbose($"Process {folder.FullName} for files.");

            List<FileInfo> files = folder
                .GetFiles("*.md")
                .OrderBy(f => f.Name)
                .ToList();

            if (files == null)
            {
                message.Verbose($"No MD files found in {folder.FullName}.");
                return;
            }

            foreach (FileInfo fi in files)
            {
                if (fi.Name.StartsWith(".", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                // see if the file is mentioned in the order-list for ordering.
                int sequence = int.MaxValue;
                if (order.Contains(Path.GetFileNameWithoutExtension(fi.Name)))
                {
                    sequence = order.IndexOf(Path.GetFileNameWithoutExtension(fi.Name));
                }

                string replacedle = string.Empty;
                if (options.UseOverride && (overrides.Count > 0))
                {
                    // get possible replacedle override from the .override file
                    var key = fi.Name.Substring(0, fi.Name.Length - 3);
                    if (overrides.ContainsKey(key))
                    {
                        replacedle = overrides[key];
                    }
                }

                replacedle = replacedle.Length == 0 ? GetCleanedFileName(fi) : replacedle;

                yamlNode.AddItem(new TocItem
                {
                    Sequence = sequence,
                    Filename = fi.FullName,
                    replacedle = replacedle,
                    Href = GetRelativePath(fi.FullName, options.DocFolder),
                });

                message.Verbose($"Add file seq={sequence} replacedle={replacedle} href={GetRelativePath(fi.FullName, options.DocFolder)}");
            }
        }

19 Source : ResourceAnalyzer.cs
with MIT License
from EllanJiang

private void DrawScatteredreplacedetViewer()
        {
            if (!m_replacedyzed)
            {
                DrawreplacedyzeButton();
                return;
            }

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(5f);
                EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.4f));
                {
                    GUILayout.Space(5f);
                    string replacedle = null;
                    if (string.IsNullOrEmpty(m_ScatteredreplacedetsFilter))
                    {
                        replacedle = Utility.Text.Format("Scattered replacedets ({0})", m_ScatteredreplacedetCount.ToString());
                    }
                    else
                    {
                        replacedle = Utility.Text.Format("Scattered replacedets ({0}/{1})", m_CachedScatteredreplacedetNames.Length.ToString(), m_ScatteredreplacedetCount.ToString());
                    }
                    EditorGUILayout.LabelField(replacedle, EditorStyles.boldLabel);
                    EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height - 132f));
                    {
                        m_ScatteredreplacedetsScroll = EditorGUILayout.BeginScrollView(m_ScatteredreplacedetsScroll);
                        {
                            int selectedIndex = GUILayout.SelectionGrid(m_SelectedScatteredreplacedetIndex, m_CachedScatteredreplacedetNames, 1, "toggle");
                            if (selectedIndex != m_SelectedScatteredreplacedetIndex)
                            {
                                m_SelectedScatteredreplacedetIndex = selectedIndex;
                                m_SelectedScatteredreplacedetName = m_CachedScatteredreplacedetNames[selectedIndex];
                                m_SelectedHostreplacedets = m_Controller.GetHostreplacedets(m_SelectedScatteredreplacedetName);
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical("box");
                    {
                        EditorGUILayout.LabelField("Scattered replacedet Name", m_SelectedScatteredreplacedetName ?? "<None>");
                        EditorGUILayout.BeginHorizontal();
                        {
                            ScatteredreplacedetsOrder scatteredreplacedetsOrder = (ScatteredreplacedetsOrder)EditorGUILayout.EnumPopup("Order by", m_ScatteredreplacedetsOrder);
                            if (scatteredreplacedetsOrder != m_ScatteredreplacedetsOrder)
                            {
                                m_ScatteredreplacedetsOrder = scatteredreplacedetsOrder;
                                OnScatteredreplacedetsOrderOrFilterChanged();
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        {
                            string scatteredreplacedetsFilter = EditorGUILayout.TextField("replacedets Filter", m_ScatteredreplacedetsFilter);
                            if (scatteredreplacedetsFilter != m_ScatteredreplacedetsFilter)
                            {
                                m_ScatteredreplacedetsFilter = scatteredreplacedetsFilter;
                                OnScatteredreplacedetsOrderOrFilterChanged();
                            }
                            EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(m_ScatteredreplacedetsFilter));
                            {
                                if (GUILayout.Button("x", GUILayout.Width(20f)))
                                {
                                    m_ScatteredreplacedetsFilter = null;
                                    GUI.FocusControl(null);
                                    OnScatteredreplacedetsOrderOrFilterChanged();
                                }
                            }
                            EditorGUI.EndDisabledGroup();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical(GUILayout.Width(position.width * 0.6f - 14f));
                {
                    GUILayout.Space(5f);
                    EditorGUILayout.LabelField(Utility.Text.Format("Host replacedets ({0})", m_SelectedHostreplacedets.Length.ToString()), EditorStyles.boldLabel);
                    EditorGUILayout.BeginVertical("box", GUILayout.Height(position.height - 68f));
                    {
                        m_HostreplacedetsScroll = EditorGUILayout.BeginScrollView(m_HostreplacedetsScroll);
                        {
                            foreach (replacedet hostreplacedet in m_SelectedHostreplacedets)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    if (GUILayout.Button("GO", GUILayout.Width(30f)))
                                    {
                                        m_SelectedreplacedetName = hostreplacedet.Name;
                                        m_SelectedreplacedetIndex = new List<string>(m_CachedreplacedetNames).IndexOf(m_SelectedreplacedetName);
                                        m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedreplacedetName);
                                        m_ToolbarIndex = 1;
                                        GUI.FocusControl(null);
                                    }

                                    GUILayout.Label(Utility.Text.Format("{0} [{1}]", hostreplacedet.Name, hostreplacedet.Resource.FullName));
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }

19 Source : ResourceAnalyzer.cs
with MIT License
from EllanJiang

private void DrawCircularDependencyViewer()
        {
            if (!m_replacedyzed)
            {
                DrawreplacedyzeButton();
                return;
            }

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Space(5f);
                EditorGUILayout.BeginVertical();
                {
                    GUILayout.Space(5f);
                    EditorGUILayout.LabelField(Utility.Text.Format("Circular Dependency ({0})", m_CircularDependencyCount), EditorStyles.boldLabel);
                    m_CircularDependencyScroll = EditorGUILayout.BeginScrollView(m_CircularDependencyScroll);
                    {
                        int count = 0;
                        foreach (string[] circularDependencyData in m_CachedCircularDependencyDatas)
                        {
                            GUILayout.Label(Utility.Text.Format("{0}) {1}", ++count, circularDependencyData[circularDependencyData.Length - 1]), EditorStyles.boldLabel);
                            EditorGUILayout.BeginVertical("box");
                            {
                                foreach (string circularDependency in circularDependencyData)
                                {
                                    EditorGUILayout.BeginHorizontal();
                                    {
                                        GUILayout.Label(circularDependency);
                                        if (GUILayout.Button("GO", GUILayout.Width(30f)))
                                        {
                                            m_SelectedreplacedetName = circularDependency;
                                            m_SelectedreplacedetIndex = new List<string>(m_CachedreplacedetNames).IndexOf(m_SelectedreplacedetName);
                                            m_SelectedDependencyData = m_Controller.GetDependencyData(m_SelectedreplacedetName);
                                            m_ToolbarIndex = 1;
                                            GUI.FocusControl(null);
                                        }
                                    }
                                    EditorGUILayout.EndHorizontal();
                                }
                            }
                            EditorGUILayout.EndVertical();
                            GUILayout.Space(5f);
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }

19 Source : TocGenerator.cs
with MIT License
from Ellerbach

private static void GetDirectories(DirectoryInfo folder, List<string> order, TocItem yamlNode, Dictionary<string, string> overrides, List<string> ignore)
        {
            message.Verbose($"Process {folder.FullName} for sub-directories.");

            // Now find all the subdirectories under this directory.
            DirectoryInfo[] subDirs = folder.GetDirectories();
            foreach (DirectoryInfo dirInfo in subDirs)
            {
                // skip hidden folders (starting with .)
                if (dirInfo.Name.StartsWith(".", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                // If in the ignore file, then continue
                if (ignore.Contains(dirInfo.Name))
                {
                    continue;
                }

                // Get all the md files only
                FileInfo[] subFiles = dirInfo.GetFiles("*.md");
                if (subFiles.Any() == false)
                {
                    message.Warning($"WARNING: Folder {dirInfo.FullName} skipped as it doesn't contain MD files. This might skip further sub-folders. Solve this by adding a README.md or INDEX.md in the folder.");
                    continue;
                }

                TocItem newTocItem = new TocItem();

                // if the directory is in the .order file, take the index as sequence nr
                if (order.Contains(Path.GetFileName(dirInfo.Name)))
                {
                    newTocItem.Sequence = order.IndexOf(Path.GetFileName(dirInfo.Name));
                }

                string replacedle = string.Empty;
                if (options.UseOverride)
                {
                    // if in the .override file, override the replacedle with it
                    if (overrides.ContainsKey(dirInfo.Name))
                    {
                        replacedle = overrides[dirInfo.Name];
                    }
                }

                // Cleanup the replacedle to be readable
                replacedle = replacedle.Length == 0 ? ToreplacedleCase(dirInfo.Name) : replacedle;
                newTocItem.Filename = dirInfo.FullName;
                newTocItem.replacedle = replacedle;
                string entryFile = WalkDirectoryTree(dirInfo, newTocItem);
                if (subFiles.Length == 1 && dirInfo.GetDirectories().Length == 0)
                {
                    newTocItem.Href = GetRelativePath(subFiles[0].FullName, options.DocFolder);
                }
                else
                {
                    newTocItem.Href = GetRelativePath(entryFile, options.DocFolder);
                }

                message.Verbose($"Add directory seq={newTocItem.Sequence} replacedle={newTocItem.replacedle} href={newTocItem.Href}");

                yamlNode.AddItem(newTocItem);
            }
        }

19 Source : BandPowerDataBuffer.cs
with MIT License
from Emotiv

public int GetPowerIndex(Channel_t channel, BandPowerType powerType) {
        if (channel == Channel_t.CHAN_TIME_SYSTEM)
            return 0;
        string chanStr  = ChannelStringList.ChannelToString(channel);
        string powStr   = BandPowerMap[powerType];
        int chanIndex = _bandPowerList.IndexOf(chanStr+ "/" + powStr); // TODO check chanIndex = -1
        return chanIndex;
    }

19 Source : PMDataBuffer.cs
with MIT License
from Emotiv

public int GetLabelIndex(string chan) 
        {
            int chanIndex = _pmList.IndexOf(chan);
            return (int)chanIndex;
        }

19 Source : StringListInstance.cs
with MIT License
from EncompassRest

public int IndexOf(string item) => _values.IndexOf(item);

19 Source : Program.cs
with MIT License
from endlesstravel

static void GenCSImplement()
        {
            var str = File.ReadAllText("./code");
            Dictionary<string, LinkedList<string>> dict = new Dictionary<string, LinkedList<string>>();
            List<ClreplacedOfThem> alllist = new List<ClreplacedOfThem>();

            foreach(Match match in firstRegex.Matches(str))
            {
                var retValue = match.Groups[1].Value;
                if (retValue != "bool4" && retValue != "void")
                    throw new Exception("retValue" + retValue);
                var funcName = "wrap_love_dll_" + match.Groups[2].Value;
                var tsd = new TypeStructDefine(match.Groups[2].Value);

                var li = alllist.Find(item => item.clreplacedName == tsd.topName);
                if (li == null)
                {
                    li = new ClreplacedOfThem(tsd.topName);
                    alllist.Add(li);
                }

                var paramList = paramsRegex.Matches("(" + match.Groups[3].Value)
                    .Select(m => new Params(m.Groups[3].Value, m.Groups[4].Value, m.Groups[5].Value));
                var line = CSDLLImplementTemplate(funcName, tsd, paramList);
                li.list.AddLast(line);
            }

            List<string> sortIndex = new List<string>{
                "Body",
                "Contact",
                "Fixture",
                "Shape",
                "Joint",
                "World",
                "physics",
                "ChainShape",
                "CircleShape",
                "EdgeShape",
                "PolygonShape",
                "DistanceJoint",
                "FrictionJoint",
                "GearJoint",
                "MotorJoint",
                "MouseJoint",
                "PrismaticJoint",
                "PulleyJoint",
                "RevoluteJoint",
                "WeldJoint",
                "WheelJoint",
            };

            var lll = alllist
                .Select(a => a)
                .OrderBy(ca => sortIndex.IndexOf(ca.clreplacedName));

            foreach (var c in lll)
            {
                var comeFrom = "LoveObject";
                if (c.clreplacedName != "Shape" && c.clreplacedName.EndsWith("Shape"))
                    comeFrom = "Shape";
                if (c.clreplacedName != "Joint" && c.clreplacedName.EndsWith("Joint"))
                    comeFrom = "Joint";

                Console.WriteLine($"public clreplaced {c.clreplacedName}: {comeFrom}");
                Console.WriteLine("{");
                Console.WriteLine("    /// <summary>");
                Console.WriteLine("    /// disable construct");
                Console.WriteLine("    /// </summary>");
                Console.WriteLine($"    protected {c.clreplacedName}() {{ }}");
                Console.WriteLine(string.Join("\n", c.list));
                Console.WriteLine("}");
            }
        }

19 Source : CoreModuleSettings.cs
with MIT License
from EverestAPI

public void CreateInputGuiEntry(TextMenu menu, bool inGame) {
            // Get all Input GUI prefixes and add a slider for switching between them.
            List<string> inputGuiPrefixes = new List<string> {
                "" // Auto
            };
            foreach (KeyValuePair<string, MTexture> kvp in GFX.Gui.GetTextures()) {
                string path = kvp.Key;
                if (!path.StartsWith("controls/"))
                    continue;
                path = path.Substring(9);
                int indexOfSlash = path.IndexOf('/');
                if (indexOfSlash == -1)
                    continue;
                path = path.Substring(0, indexOfSlash);
                if (!inputGuiPrefixes.Contains(path))
                    inputGuiPrefixes.Add(path);
            }

            menu.Add(
                new TextMenu.Slider(Dialog.Clean("modoptions_coremodule_inputgui"), i => {
                    string inputGuiPrefix = inputGuiPrefixes[i];
                    string fullName = $"modoptions_coremodule_inputgui_{inputGuiPrefix.ToLowerInvariant()}";
                    return fullName.DialogCleanOrNull() ?? inputGuiPrefix.ToUpperInvariant();
                }, 0, inputGuiPrefixes.Count - 1, Math.Max(0, inputGuiPrefixes.IndexOf(InputGui)))
                .Change(i => {
                    InputGui = inputGuiPrefixes[i];
                    Input.OverrideInputPrefix = inputGuiPrefixes[i];
                })
            );
        }

19 Source : Emoji.cs
with MIT License
from EverestAPI

public static void Register(string name, MTexture emoji) {
            if (!Initialized) {
                Queue.Enqueue(new KeyValuePair<string, MTexture>(name, emoji));
                return;
            }

            bool monochrome;
            if (monochrome = name.EndsWith(".m")) {
                name = name.Substring(0, name.Length - 2);
            }

            XmlElement xml = FakeXML;
            xml.SetAttr("x", 0);
            xml.SetAttr("y", 0);
            xml.SetAttr("width", emoji.Width);
            xml.SetAttr("height", emoji.Height);
            xml.SetAttr("xoffset", 0);
            xml.SetAttr("yoffset", 0);
            xml.SetAttr("xadvance", emoji.Width);

            int id = _Registered.IndexOf(name);
            if (id < 0) {
                id = _Registered.Count;
                _Registered.Add(name);

                lock (_IDs) {
                    _IDs[name] = id;
                }

                _IsMonochrome.Add(monochrome);

            } else {
                _IsMonochrome[id] = monochrome;
            }

            _Chars.Add(new PixelFontCharacter(Start + id, emoji, xml));
        }

19 Source : CoreModuleSettings.cs
with MIT License
from EverestAPI

public void CreateMainMenuModeEntry(TextMenu menu, bool inGame) {
            if (!inGame) {
                // TODO: Let mods register custom main menu modes?
                List<string> types = new List<string>() {
                    "",
                    "rows"
                };

                menu.Add(
                    new TextMenu.Slider(Dialog.Clean("modoptions_coremodule_mainmenumode"), i => {
                        string prefix = types[i];
                        string fullName = $"modoptions_coremodule_mainmenumode_{prefix.ToLowerInvariant()}";
                        return fullName.DialogCleanOrNull() ?? prefix.ToUpperInvariant();
                    }, 0, types.Count - 1, Math.Max(0, types.IndexOf(MainMenuMode)))
                    .Change(i => {
                        MainMenuMode = types[i];
                    })
                );
            }
        }

19 Source : Embeddings.cs
with MIT License
from FaceONNX

public void Remove(string label)
        {
            int index = Labels.IndexOf(label);

            if (index != -1)
            {
                Remove(index);
            }
            else
            {
                throw new Exception("Embedding with selected label does not exist.");
            }
        }

19 Source : DynamicMethodBuilder.cs
with GNU General Public License v3.0
from faib920

private void CheckGenericMethod(MethodInfo method)
        {
            if (method.IsGenericMethod)
            {
                var types = method.GetGenericArguments();
                var list = types.Select(type => type.Name).ToList();
                if (method.ReturnType.IsGenericType)
                {
                    var index = list.IndexOf(method.ReturnType.Name);
                    if (index >= 0)
                    {
                        list.Add(list[index]);
                    }
                }

                GenericArguments = list.ToArray();
                if (methodBuilder != null)
                {
                    ProcessGenericMethod();
                }
            }
        }

19 Source : DynamicMethodBuilder.cs
with GNU General Public License v3.0
from faib920

private void ProcessGenericMethod()
        {
            if (GenericArguments == null || methodBuilder == null)
            {
                return;
            }

            var array = new Dictionary<int, int>();
            var list = new List<string>();
            var l = 0;
            var v = Math.Min(GenericArguments.Length, ParameterTypes.Length);
            for (var i = 0; i < v; i++)
            {
                if (!string.IsNullOrEmpty(GenericArguments[i]))
                {
                    array.Add(i, l++);
                    list.Add(GenericArguments[i]);
                }
            }

            var gpas = methodBuilder.DefineGenericParameters(list.ToArray());
            foreach (var kvp in array)
            {
                ParameterTypes[kvp.Key] = gpas[kvp.Value];
            }

            MethodBuilder.SetParameters(ParameterTypes);
            if (GenericArguments.Length == ParameterTypes.Length + 1)
            {
                var index = list.IndexOf(GenericArguments[GenericArguments.Length - 1]);
                ReturnType = gpas[index];
            }
        }

19 Source : UserActivityAPI.cs
with GNU General Public License v3.0
from faush01

public object Post(CustomQuery request)
        {
            _logger.Info("CustomQuery : " + request.CustomQueryString);

            Dictionary<string, object> responce = new Dictionary<string, object>();

            AuthorizationInfo user_info = _ac.GetAuthorizationInfo(Request);
            UserPolicy policy = _userManager.GetUserPolicy(user_info.User);
            if (!policy.IsAdministrator)
            {
                return responce;
            }

            List<List<object>> result = new List<List<object>>();
            List<string> colums = new List<string>();
            string message = repository.RunCustomQuery(request.CustomQueryString, colums, result);

            int index_of_user_col = colums.IndexOf("UserId");
            if (request.ReplaceUserId && index_of_user_col > -1)
            {
                colums[index_of_user_col] = "UserName";

                Dictionary<string, string> user_map = new Dictionary<string, string>();
                foreach (var user in _userManager.Users)
                {
                    user_map.Add(user.Id.ToString("N"), user.Name);
                }

                foreach(var row in result)
                {
                    String user_id = (string)row[index_of_user_col];
                    if(user_map.ContainsKey(user_id))
                    {
                        row[index_of_user_col] = user_map[user_id];
                    }
                }
            }


            /*
            List<object> row = new List<object>();
            row.Add("Shaun");
            row.Add(12);
            row.Add("Some Date");
            result.Add(row);

            colums.Add("Name");
            colums.Add("Age");
            colums.Add("Started");
            */

            responce.Add("colums", colums);
            responce.Add("results", result);
            responce.Add("message", message);
            
            return responce;
        }

19 Source : DarkComboBoxWithBackingItems.cs
with MIT License
from FenPhoenix

[PublicAPI]
        internal int BackingIndexOf(string item) => BackingItems.IndexOf(item);

19 Source : SystemMessagesProcessor.cs
with MIT License
from Foglio1024

private static string GetFieldBossKillerName(string parameters)
        {
            // only for 'SMT_FIELDBOSS_*'
            var ret = "";
            var srvMsgSplit = parameters.Split('\v').ToList();
            var idx = srvMsgSplit.IndexOf("userName") + 1;
            if (idx != -1 && idx < srvMsgSplit.Count) ret = srvMsgSplit[idx];
            return ret;
        }

19 Source : SystemMessagesProcessor.cs
with MIT License
from Foglio1024

private static string GetFieldBossKillerGuild(string parameters)
        {
            // only for 'SMT_FIELDBOSS_*'
            var ret = "";
            var srvMsgSplit = parameters.Split('\v').ToList();
            var idx = srvMsgSplit.IndexOf("guildName") + 1;
            if (idx != -1 && idx < srvMsgSplit.Count) ret = srvMsgSplit[idx];
            return ret;
        }

19 Source : Program.cs
with GNU General Public License v3.0
from Foxlider

private static void MigrateTo17()
        {
            var sourcePath = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData") ?? throw new InvalidOperationException(), "FoxliCorp", "FASTER_StrongName_r3kmcr0zqf35dnhwrlga5cvn2azjfziz");
            var versions = Directory.GetDirectories(sourcePath).ToList();
            Console.WriteLine("Select your version to update from");
            foreach (var path in versions)
            {
                var version = path.Replace(sourcePath, "").Replace("\\", "");
                if(version.StartsWith("1.7"))
                    continue;
                Console.WriteLine($"{versions.IndexOf(path)} : v{version} ({Directory.GetLastWriteTime(path):dd:MM::yyyy}");
            }
            var key = Console.ReadKey(true).KeyChar;
            switch (key)
            {
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                    var selected = versions[int.Parse(key.ToString())];
                    if (selected == null || selected.Contains("1.7.")) return;

                    Console.WriteLine("\n\nDo you want to backup your data ? (Y/n)");
                    var backupKey = Console.ReadKey(true).Key;
                    if (backupKey != ConsoleKey.N)
                    {
                        BackupSettings();
                        if(_exitCode == 0)
                            _exitCode = -1;
                        else
                            return;
                    }

                    Console.WriteLine("Press any key to start the migration process...");
                    Console.ReadKey();

                    Console.WriteLine("Migrating...");
                    XmlSerializer                  serializer16 = new XmlSerializer(typeof(Models._16Models.Configuration));
                    XmlSerializer                  serializer17 = new XmlSerializer(typeof(Models._17Models.Configuration));
                    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                    ns.Add("", "");
                    Models._16Models.Configuration conf16;
                    Models._17Models.Configuration conf17 = new Models._17Models.Configuration();

                    using (Stream reader = new FileStream($"{selected}\\user.config", FileMode.Open))
                    {
                        // Call the Deserialize method to restore the object's state.
                        conf16 = (Models._16Models.Configuration) serializer16.Deserialize(reader);
                    }
                    Console.WriteLine($"\tRead config from '{selected}\\user.config'");

                    var servers = conf16.UserSettings.Settings.Setting.FirstOrDefault(s => s.Name == "Servers");
                    conf16.UserSettings.Settings.Setting.Remove(servers);
                    conf17.UserSettings = new Models._17Models.UserSettings { Settings = new Models._17Models.Settings { Setting = conf16.UserSettings.Settings.Setting } };
                    Console.WriteLine("\tConverted standard values to 1.7");

                    Debug.replacedert(servers != null, nameof(servers) + " != null");
                    var node = ((XmlNode[]) servers.Value)[0];
                    var ser = new XmlSerializer(typeof(ServerCollection));
                    MemoryStream stm = new MemoryStream();

                    StreamWriter stw = new StreamWriter(stm);
                    stw.Write(node.OuterXml);
                    stw.Flush();

                    stm.Position = 0;
                    ServerCollection collec = ser.Deserialize(stm) as ServerCollection;
                    Console.WriteLine("\tExtracted profiles");

                    var newProfiles = new List<FASTER.Models.ServerProfile>();
                    Debug.replacedert(collec != null, nameof(collec) + " != null");
                    foreach (var profile in collec.ServerProfile)
                    {
                        var newProfile = ConvertProfile(profile);
                        newProfiles.Add(newProfile);
                    }
                    
                    conf17.UserSettings.Settings.Setting.Add(new Setting
                    {
                        Name = "Profiles",
                        SerializeAs = "Xml",
                        Value = new Value
                        {
                            ArrayOfServerProfile = new ArrayOfServerProfile
                            {
                                ServerProfile = newProfiles
                            }
                        }
                    }); 
                    
                    Console.WriteLine("\tAdded new profiles to settings");
                    Console.WriteLine("Started serialization process...");
                   
                    
                    using (MemoryStream stream = new MemoryStream())
                    using (XmlTextWriter tw = new XmlTextWriter( stream, Encoding.UTF8))
                    {
                        tw.Formatting  = Formatting.Indented;
                        tw.Indentation = 4;
                        serializer17.Serialize(tw, conf17, ns);
                        tw.BaseStream.Position = 0;
                        Console.WriteLine("Serialization process complete.");

                        using StreamReader reader = new StreamReader(stream);
                        string text   = reader.ReadToEnd();
                        string output = Path.Combine(sourcePath, "1.7.1.0");
                        if (!Directory.Exists(output))
                            Directory.CreateDirectory(output);
                        File.WriteAllText(Path.Combine(output, "user.config"), text);
                        Console.WriteLine($"Settings were written to {output}\\user.config");
                    }
                    _exitCode = 0;
                    break;
                default :
                    Console.WriteLine("Invalid selection.");
                    break;
            }
        }

19 Source : ListViewItemRenderer.cs
with GNU General Public License v3.0
from freezy

protected void RenderId(Dictionary<string, TStatus> statuses, ref string id, Action<string> setId, TListData listData, Rect cellRect, Action<TListData> updateAction)
		{
			const float idWidth = 25f;
			const float padding = 2f;

			// add some padding
			cellRect.x += padding;
			cellRect.width -= 2 * padding;

			var dropdownRect = cellRect;
			dropdownRect.width -= idWidth + 2 * padding;

			var idRect = cellRect;
			idRect.width = idWidth;
			idRect.x += cellRect.width - idWidth;

			var options = new List<string>(GleItems.Select(entry => entry.Id).ToArray());
			if (options.Count > 0) {
				options.Add("");
			}
			options.Add("Add...");

			if (Application.isPlaying && statuses != null) {

				var iconRect = cellRect;
				iconRect.width = 20;

				if (Mouse.current.leftButton.wasPressedThisFrame && !MouseDownOnIcon && iconRect.Contains(Event.current.mousePosition)) {
					OnIconClick(listData, true);
					MouseDownOnIcon = true;
				}
				if (Mouse.current.leftButton.wasReleasedThisFrame && MouseDownOnIcon && iconRect.Contains(Event.current.mousePosition)) {
					OnIconClick(listData, false);
					MouseDownOnIcon = false;
				}

				dropdownRect.x += 25;
				dropdownRect.width -= 25;
				if (statuses.ContainsKey(id)) {
					var status = statuses[id];
					var icon = StatusIcon(status);
					var guiColor = GUI.color;
					GUI.color = Color.clear;
					EditorGUI.DrawTextureTransparent(iconRect, icon, ScaleMode.ScaleToFit);
					GUI.color = guiColor;
				}
			}

			EditorGUI.BeginChangeCheck();
			var index = EditorGUI.Popup(dropdownRect, options.IndexOf(id), options.ToArray());
			if (EditorGUI.EndChangeCheck()) {
				if (index == options.Count - 1) {
					PopupWindow.Show(dropdownRect, new ManagerListTextFieldPopup("ID", "", newId => {
						if (!GleItems.Exists(entry => entry.Id == newId)) {
							GleItems.Add(InstantiateGleItem(newId));
						}

						setId(newId);
						updateAction(listData);
					}));

				} else {
					setId(GleItems[index].Id);
					updateAction(listData);
				}
			}

			EditorGUI.BeginChangeCheck();
			var value = EditorGUI.IntField(idRect, listData.InternalId);
			if (EditorGUI.EndChangeCheck()) {
				listData.InternalId = value;
				updateAction(listData);
			}
		}

19 Source : ModuleImageFile.cs
with MIT License
from FutureAIGuru

public void SetParameters(List<string> paths, string curPath, bool cycle, bool useFileName)
        {
            Init();

            cycleThroughFolder = cycle;
            useDescription = useFileName;

            //if the path is empty, don't mess with the file list
            if (paths != null)
            {
                fileList = paths;
                filePath = curPath;
                fileCounter = fileList.IndexOf(curPath);
            }
            if (fileList != null && fileList.Count > 0 && paths != null)
            {
                if (fileCounter >= fileList.Count) fileCounter = 0;
                fileList = paths;
                LoadImage(fileList[fileCounter]);
                SetDescription(fileList[fileCounter]);
            }
            if (cycleThroughFolder)
            {
                fileCounter++;
                countDown = 3;
            }
            else
                countDown = -1; //setting the decrement counter to -1 suspends future file loading
        }

19 Source : GenericEnum.cs
with MIT License
from FuzzySlipper

public static T ByName(string name) {
            if (!IsDefinedName(name)) {
                if (_allowInstanceExceptions) {
                    throw new ArgumentException(string.Format("'{0}' is not a defined name of {1}", name, typeof(T).Name));
                }
                return null;
            }
            T t = new T();
            t._index = _names.IndexOf(name);
            return t;
        }

19 Source : GenericEnum.cs
with MIT License
from FuzzySlipper

public static int IndexOf(string name) {
            return _names.IndexOf(name);
        }

19 Source : GenericEnum.cs
with MIT License
from FuzzySlipper

public static bool IsDefinedName(string name) {
            if (_names.IndexOf(name) >= 0) {
                return true;
            }
            return false;
        }

19 Source : GenericEnum.cs
with MIT License
from FuzzySlipper

public static U ValueOf(string name) {
            int index = _names.IndexOf(name);
            if (index >= 0) {
                return _values[index];
            }
            throw new ArgumentException(string.Format("'{0}' is not a defined name of {1}", name, typeof(T).Name));
        }

19 Source : GenericEnum.cs
with MIT License
from FuzzySlipper

public static bool TryValueOf(string name, out U val) {
            int index = _names.IndexOf(name);
            if (index >= 0) {
                val = _values[index];
                return true;
            }
            val = default(U);
            return false;
        }

19 Source : MaterialManager.cs
with Apache License 2.0
from fy0

public int GetFlagsByKeywords(IList<string> keywords)
        {
            if (_addKeywords == null)
                _addKeywords = new List<string>();

            int flags = 0;
            for (int i = 0; i < keywords.Count; i++)
            {
                string s = keywords[i];
                if (string.IsNullOrEmpty(s))
                    continue;
                int j = _addKeywords.IndexOf(s);
                if (j == -1)
                {
                    j = _addKeywords.Count;
                    _addKeywords.Add(s);
                }
                flags += (1 << (j + internalKeywordsCount));
            }

            return flags;
        }

19 Source : Controller.cs
with Apache License 2.0
from fy0

public void RemovePage(string name)
        {
            int i = _pageNames.IndexOf(name);
            if (i != -1)
            {
                _pageIds.RemoveAt(i);
                _pageNames.RemoveAt(i);
                if (_selectedIndex >= _pageIds.Count)
                    this.selectedIndex = _selectedIndex - 1;
                else
                    parent.ApplyController(this);
            }
        }

19 Source : Controller.cs
with Apache License 2.0
from fy0

internal int GetPageIndexById(string aId)
        {
            return _pageIds.IndexOf(aId);
        }

19 Source : Controller.cs
with Apache License 2.0
from fy0

internal string GetPageNameById(string aId)
        {
            int i = _pageIds.IndexOf(aId);
            if (i != -1)
                return _pageNames[i];
            else
                return null;
        }

19 Source : Controller.cs
with Apache License 2.0
from fy0

public string GetPageIdByName(string aName)
        {
            int i = _pageNames.IndexOf(aName);
            if (i != -1)
                return _pageIds[i];
            else
                return null;
        }

19 Source : GComboBox.cs
with Apache License 2.0
from fy0

override public void Setup_AfterAdd(ByteBuffer buffer, int beginPos)
        {
            base.Setup_AfterAdd(buffer, beginPos);

            if (!buffer.Seek(beginPos, 6))
                return;

            if ((ObjectType)buffer.ReadByte() != packageItem.objectType)
                return;

            string str;
            int itemCount = buffer.ReadShort();
            for (int i = 0; i < itemCount; i++)
            {
                int nextPos = buffer.ReadShort();
                nextPos += buffer.position;

                _items.Add(buffer.ReadS());
                _values.Add(buffer.ReadS());
                str = buffer.ReadS();
                if (str != null)
                {
                    if (_icons == null)
                        _icons = new List<string>();
                    _icons.Add(str);
                }

                buffer.position = nextPos;
            }

            str = buffer.ReadS();
            if (str != null)
            {
                this.text = str;
                _selectedIndex = _items.IndexOf(str);
            }
            else if (_items.Count > 0)
            {
                _selectedIndex = 0;
                this.text = _items[0];
            }
            else
                _selectedIndex = -1;

            str = buffer.ReadS();
            if (str != null)
                this.icon = str;

            if (buffer.ReadBool())
                this.replacedleColor = buffer.ReadColor();
            int iv = buffer.ReadInt();
            if (iv > 0)
                visibleItemCount = iv;
            _popupDirection = (PopupDirection)buffer.ReadByte();

            iv = buffer.ReadShort();
            if (iv >= 0)
                _selectionController = parent.GetControllerAt(iv);

            if (buffer.version >= 5)
            {
                str = buffer.ReadS();
                if (str != null)
                    sound = UIPackage.GereplacedemreplacedetByURL(str) as NAudioClip;
                soundVolumeScale = buffer.ReadFloat();
            }
        }

19 Source : Controller.cs
with Apache License 2.0
from fy0

public void SetSelectedPage(string value)
        {
            int i = _pageNames.IndexOf(value);
            if (i == -1)
                i = 0;
            this.SetSelectedIndex(i);
        }

19 Source : Controller.cs
with Apache License 2.0
from fy0

public bool HasPage(string aName)
        {
            return _pageNames.IndexOf(aName) != -1;
        }

19 Source : HeartBeatHandler.cs
with GNU Affero General Public License v3.0
from GameProgressive

private void CheckSpamGameServer()
        {
            List<string> tempKeyVal = _dataParreplacedion.Split('\0').ToList();
            int indexOfGameName = tempKeyVal.IndexOf("gamename");
            string gameName = tempKeyVal[indexOfGameName + 1];

            string gameServerRedisKey = GameServer.GenerateKey(_session.RemoteEndPoint, gameName);

            //make sure one ip address create one server on each game
            List<string> redisSimilarKeys =
                GameServer.GetSimilarKeys(_session.RemoteEndPoint, gameName);

            //we check if the database have multiple game server if it contains
            if (redisSimilarKeys.Contains(gameServerRedisKey))
            {
                //save remote server data to local
                _gameServer = GameServer.GetServers(gameServerRedisKey).First();
                //delete all servers except this server
                foreach (var key in redisSimilarKeys)
                {
                    if (key == gameServerRedisKey)
                    {
                        continue;
                    }
                    GameServer.DeleteSpecificServer(key);
                }
            }
            else //redis do not have this server we create then update
            {
                _gameServer = new GameServer();
                _gameServer.Parse(_session.RemoteEndPoint);
            }
        }

19 Source : RecentlyUsedList.cs
with MIT License
from garora

private void AvoidDuplicateInsertion(string lisreplacedem)
        {
            var indexOccurenceofItem = _listofuniquestrings.IndexOf(lisreplacedem);

            if (indexOccurenceofItem > -1)
                _listofuniquestrings.RemoveAt(indexOccurenceofItem);
        }

19 Source : WordPieceTokenizer.cs
with MIT License
from GerjanVlot

private IEnumerable<(string Token, int VocabularyIndex)> TokenizeSubwords(string word)
        {
            if (_vocabulary.Contains(word))
            {
                return new (string, int)[] { (word, _vocabulary.IndexOf(word)) };
            }

            var tokens = new List<(string, int)>();
            var remaining = word;

            while (!string.IsNullOrEmpty(remaining) && remaining.Length > 2)
            {
                var prefix = _vocabulary.Where(remaining.StartsWith)
                    .OrderByDescending(o => o.Count())
                    .FirstOrDefault();

                if (prefix == null)
                {
                    tokens.Add((DefaultTokens.Unknown, _vocabulary.IndexOf(DefaultTokens.Unknown)));

                    return tokens;
                }

                remaining = remaining.Replace(prefix, "##");

                tokens.Add((prefix, _vocabulary.IndexOf(prefix)));
            }

            if (!string.IsNullOrWhiteSpace(word) && !tokens.Any())
            {
                tokens.Add((DefaultTokens.Unknown, _vocabulary.IndexOf(DefaultTokens.Unknown)));
            }

            return tokens;
        }

19 Source : StringTable.cs
with zlib License
from gibbed

public int WriteIndex(string value)
        {
            if (this._Strings.Contains(value) == false)
            {
                this._Strings.Add(value);
            }

            return this._Strings.IndexOf(value);
        }

19 Source : StringTable.cs
with zlib License
from gibbed

public void WriteIndex(Stream output, Endian endian, string value)
        {
            if (this._Strings.Contains(value) == false)
            {
                this._Strings.Add(value);
            }

            output.WriteValueS32(this._Strings.IndexOf(value), endian);
        }

19 Source : DataTransferColumnCollection.cs
with MIT License
from gimlichael

internal int? GetIndex(string name)
        {
            if (name == null) { return null; }
            var index = Names.IndexOf(name);
            return index < 0 ? null : (int?)index;
        }

19 Source : ActCreatePDFChart.cs
with Apache License 2.0
from Ginger-Automation

public int getIndexOfParam()
        {
            if(!string.IsNullOrEmpty(GetDataFileName()))
            {
                StreamReader sr = new StreamReader(GetDataFileName());
                var lines = new List<string[]>();

                while (!sr.EndOfStream && lines.Count<=0)
                {
                    string[] Line = sr.ReadLine().Split(',').Select(a=>a.Trim()).ToArray();
                    lines.Add(Line);
                }
                if (lines[0]!=null)
                    Params = lines[0].ToList();
             }
             if (Params != null)
                return Params.IndexOf(ParamName);
             else
                return -1;
        }

19 Source : ActCreatePDFChart.cs
with Apache License 2.0
from Ginger-Automation

public void GenerateChart()
        {
            try
            {
                Chart chart = new Chart(ChartType.Column2D);
                Series series = null;
                string dataFileName = GetDataFileName();
                if(string.IsNullOrEmpty(dataFileName))
                {
                    this.Error = " Empty File Name ";
                    return;
                }
                var daraSeries = GetRenderingData(dataFileName);

                if (daraSeries != null)
                {
                    foreach (string key in daraSeries.Keys)
                    {
                        series = chart.SeriesCollection.AddSeries();
                        series.Name = key;

                        series.Add(new double[] { Convert.ToDouble(daraSeries[key][Params.IndexOf(ParamName)]) });
                    }
                }

                //  chart.XAxis.TickLabels.Format = "00";
                chart.XAxis.MajorTickMark = TickMarkType.Outside;
                chart.XAxis.replacedle.Caption = Path.GetFileNameWithoutExtension(DataFileName);

                chart.YAxis.MajorTickMark = TickMarkType.Outside;
                chart.YAxis.HasMajorGridlines = true;

                chart.PlotArea.LineFormat.Color = XColors.DarkGray;
                chart.PlotArea.LineFormat.Width = 1;
                chart.PlotArea.LineFormat.Visible = true;

                chart.Legend.Docking = DockingType.Right;
                
                chart.DataLabel.Type = DataLabelType.Value;
                chart.DataLabel.Position = DataLabelPosition.OutsideEnd;


                string filename = System.IO.Path.Combine(SolutionFolder , @"Doreplacedents\", Guid.NewGuid().ToString().ToUpper() + ".pdf");
                PdfDoreplacedent doreplacedent = new PdfDoreplacedent(filename);
                chartFrame.Location = new XPoint(30, 30);
                chartFrame.Size = new XSize(500, 600);
                chartFrame.Add(chart);

                PdfPage page = doreplacedent.AddPage();
                page.Size = PageSize.Letter;        

                XGraphics gfx = XGraphics.FromPdfPage(page);
                chartFrame.Draw(gfx);
                doreplacedent.Close();
                Process.Start(filename);
            }
            catch 
            {
                this.Error = "Something went wrong when generating the PDF reports";
            }
        }

19 Source : HTMLHelper.cs
with Apache License 2.0
from Ginger-Automation

public string SelectFromDropDown(IHTMLElement element, string value, string attribute = "value")
        {
            var currentAttribute = "";
            string temp;
            try
            {
                element.setAttribute(attribute, value);
                try
                {
                    if (element.getAttribute(attribute) != null)
                    {
                        currentAttribute = element.getAttribute(attribute).ToString();
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                }
                if (!currentAttribute.Equals(value))
                {
                    currentAttribute = SelectFromDropDownByChild(element, value, attribute);
                    if(currentAttribute.Equals("NoSelection"))
                    {
                        int idex = -1, j = -1;
                        IEnumerator enm = ((HTMLSelectElement)element).GetEnumerator();
                        while (enm.MoveNext())
                        {
                            j++;
                            if (((IHTMLElement)(enm.Current)).innerText.Equals(value))
                            {
                                idex = j;
                                temp = value;
                                break;
                            }
                        }

                    ((HTMLSelectElement)element).selectedIndex = idex;
                        if (idex == -1)
                        {
                            temp = (dynamic)element.getAttribute("innerText");
                            List<string> lst = temp.Split(' ').ToList<string>();
                            int idx = lst.IndexOf(value);
                            if (idx < 10)
                                element.setAttribute(attribute, "0" + idx.ToString());
                            else
                                element.setAttribute(attribute, idx.ToString());
                            temp = element.getAttribute(attribute);
                            currentAttribute = temp;
                        }
                    }
                }
                return currentAttribute;
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                return currentAttribute;
            }
        }

19 Source : ProjectWindowInterface.cs
with MIT License
from github-for-unity

private static void OnProjectWindowItemGUI(string guid, Rect itemRect)
        {
            if (!EnsureInitialized())
                return;

            if (Event.current.type != EventType.Repaint || string.IsNullOrEmpty(guid))
            {
                return;
            }

            var index = guids.IndexOf(guid);
            var indexLock = guidsLocks.IndexOf(guid);

            if (index < 0 && indexLock < 0)
            {
                return;
            }

            GitStatusEntry? gitStatusEntry = null;
            GitFileStatus status = GitFileStatus.None;

            if (index >= 0)
            {
                gitStatusEntry = entries[index];
                status = gitStatusEntry.Value.Status;
            }

            var isLocked = indexLock >= 0;
            var texture = Styles.GetFileStatusIcon(status, isLocked);

            if (texture == null)
            {
                var path = gitStatusEntry.HasValue ? gitStatusEntry.Value.Path : string.Empty;
                Logger.Warning("Unable to retrieve texture for Guid:{0} EntryPath:{1} Status: {2} IsLocked:{3}", guid, path, status.ToString(), isLocked);
                return;
            }

            Rect rect;

            // End of row placement
            if (itemRect.width > itemRect.height)
            {
                rect = new Rect(itemRect.xMax - texture.width, itemRect.y, texture.width,
                    Mathf.Min(texture.height, EditorGUIUtility.singleLineHeight));
            }
            // Corner placement
            // TODO: Magic numbers that need reviewing. Make sure this works properly with long filenames and wordwrap.
            else
            {
                var scale = itemRect.height / 90f;
                var size = new Vector2(texture.width * scale, texture.height * scale);
                size = size / EditorGUIUtility.pixelsPerPoint;
                var offset = new Vector2(itemRect.width * Mathf.Min(.4f * scale, .2f), itemRect.height * Mathf.Min(.2f * scale, .2f));
                rect = new Rect(itemRect.center.x - size.x * .5f + offset.x, itemRect.center.y - size.y * .5f + offset.y, size.x, size.y);
            }

            GUI.DrawTexture(rect, texture, ScaleMode.ScaleToFit);
        }

19 Source : Localization.cs
with GNU General Public License v3.0
from GitHub-TC

public string GetName(string name, string language)
        {
            if (string.IsNullOrEmpty(name)) return string.Empty;
            if (!LocalisationData.TryGetValue(name, out List<string> i18nData)) return name;

            var languagePos = LocalisationData["KEY"].IndexOf(language);
            return languagePos == -1 || languagePos >= i18nData.Count
                ? name
                : i18nData[languagePos];
        }

19 Source : BinaryTree.cs
with MIT License
from gleblebedev

private uint GetMask(string name)
        {
            var index = _keys.IndexOf(name);
            if (index < 0)
            {
                index = _keys.Count;
                _keys.Add(name);
            }

            return 1u << index;
        }

19 Source : NamedFormatter.cs
with MIT License
from golava

private static IEnumerable<string> ParsePattern(string pattern, out string replacedPattern, object item)
        {
            var sb = new StringBuilder();
            var lastIndex = 0;
            var arguments = new List<string>();
            var lowerArguments = new List<string>();

            var itemType = item.GetType();
            foreach (var match in RegexFormatPlaceHolder.Matches(pattern).Cast<Match>())
            {
                var key = match.Value;
                var property = itemType.GetProperty(key);
                if (property != null)
                {
                    var lowerKey = key.ToLowerInvariant();
                    var index = lowerArguments.IndexOf(lowerKey);
                    if (index < 0)
                    {
                        index = lowerArguments.Count;
                        lowerArguments.Add(lowerKey);
                        arguments.Add(key);
                    }

                    sb.Append(pattern.Substring(lastIndex, match.Index - lastIndex));
                    sb.Append(index);
                    if (property.PropertyType == typeof(DateTime))
                        sb.Append(":o");
                    lastIndex = match.Index + match.Length;
                } 
                else 
                {
                    sb.Append(pattern.Substring(lastIndex, match.Index - lastIndex - 1));
                    lastIndex = match.Index + match.Length + 1;
                }
            }

            sb.Append(pattern.Substring(lastIndex));
            replacedPattern = sb.ToString();
            return arguments;
        }

19 Source : PackageEnumStorage.cs
with Apache License 2.0
from googleapis

internal int GetOrAddEnumValue(string key, string originalTextValue)
        {
            if (!_nameToValuesMap.TryGetValue(key, out var list))
            {
                _nameToValuesMap[key] = list = new List<string>();
            }
            int index = list.IndexOf(originalTextValue);
            if (index != -1)
            {
                return index;
            }
            list.Add(originalTextValue);
            return list.Count - 1;
        }

See More Examples