/// <summary> /// Initializes a new instance of the <see cref="ArchiveGenerationParameters"/> class. /// </summary> /// <param name="args">The application's command line arguments.</param> public ArchiveGenerationParameters(String[] args) { if (args == null || !args.Any()) throw new InvalidCommandLineException(); var parser = new CommandLineParser(args); if (!parser.IsParameter(args.First())) throw new InvalidCommandLineException(); switch (args.First().ToLowerInvariant()) { case "-pack": Command = ArchiveGenerationCommand.Pack; ProcessPackParameters(args, parser); break; case "-list": Command = ArchiveGenerationCommand.List; ProcessListParameters(args, parser); break; default: throw new InvalidCommandLineException(); } }
/// <summary> /// Initializes a new instance of the <see cref="FontGenerationParameters"/> class. /// </summary> /// <param name="args">The application's command line arguments.</param> public FontGenerationParameters(String[] args) { if (args == null || !args.Any()) throw new InvalidCommandLineException(); var parser = new CommandLineParser(args.Skip(1)); if (parser.IsParameter(args.First())) { throw new InvalidCommandLineException(); } NoBold = parser.HasArgument("nobold"); NoItalic = parser.HasArgument("noitalic"); FontName = args.First(); FontSize = parser.GetArgumentOrDefault<Single>("fontsize", 16f); Overhang = parser.GetArgumentOrDefault<Int32>("overhang", 0); PadLeft = parser.GetArgumentOrDefault<Int32>("pad-left", 0); PadRight = parser.GetArgumentOrDefault<Int32>("pad-right", 0); SuperSamplingFactor = parser.GetArgumentOrDefault<Int32>("supersample", 2); if (SuperSamplingFactor < 1) SuperSamplingFactor = 1; SourceText = parser.GetArgumentOrDefault<String>("sourcetext"); SourceFile = parser.GetArgumentOrDefault<String>("sourcefile"); SourceCulture = parser.GetArgumentOrDefault<String>("sourceculture"); if (SourceText != null && SourceFile != null) throw new InvalidCommandLineException("Both a source text and a source file were specified. Pick one!"); SubstitutionCharacter = parser.GetArgumentOrDefault<Char>("sub", '?'); }
public static void enqueueChatLine(String line) { ChatLine chat_line = new ChatLine(line); //Check if the message has a name if (line.Length > 3 && line.First() == '[') { int name_length = line.IndexOf(']'); if (name_length > 0) { name_length = name_length - 1; String name = line.Substring(1, name_length); if (name == "Server") chat_line.color = new Color(0.65f, 1.0f, 1.0f); else chat_line.color = KLFVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR + Color.white * (1.0f-NAME_COLOR_SATURATION_FACTOR); } } chatLineQueue.Enqueue(chat_line); while (chatLineQueue.Count > MAX_CHAT_LINES) chatLineQueue.Dequeue(); scrollPos.y += 100; }
public static String ToUpperFirst(this String data_control) { if (data_control != null && data_control.Length >= 1) { return(data_control.First().ToString().ToUpper() + data_control.Substring(1)); } return(data_control); }
public AIRCH(String host, int port, String channel = "#terraria", String nick="IRCage", String username="******", String realname="IRC support for TDSM",String nspass="", String pass = "", String quitMessage = "Bye bye!", String commandDelim = "+", bool ircColors=false) { this.host = host; this.port = port; this.nick = nick; this.username = username; this.realname = realname; this.channel = channel; this.nspass = nspass; this.pass = pass; this.quitMessage = quitMessage; this.commandDelim = commandDelim.First(); this.ircColors = ircColors; }
private static void StartDirect(String[] args) { try { Common.Initialize(); switch (args.First()) { case "-game": Common.StartGame(args.Skip(1).ToArray()); break; case "-editor": Common.StartEditor(args.Skip(1).ToArray()); break; default: throw new ArgumentException(@"Invalid start argument: """ + args[0] + @""", valid arguments are ""-game"" or ""-editor"""); } } catch (Exception e) { MessageBox.Show(e.ToString(), e.GetType().Name); } }
public static Byte[] ToByteArray(String s) { BigInteger bi = 0; // Decode base58 foreach (Char c in s) { int charVal = base58chars.IndexOf(c); if (charVal >= 0) { bi *= 58; bi += charVal; } } Byte[] b = bi.ToByteArray(); // Remove 0x00 sign byte if present. if (b[b.Length - 1] == 0x00) b = b.Take(b.Length - 1).ToArray(); // Add leading 0x00 bytes int num0s = s.IndexOf(s.First(c => c != '1')); return b.Concat(new Byte[num0s]).Reverse().ToArray(); }
public static void Line(String line) { ChatLine chatLine = new ChatLine(line); if (line.Length > 3 && line.First() == '[') {//Check if the message starts with name int nameLength = line.IndexOf(']'); if (nameLength > 0) {//render name colour nameLength = nameLength - 1; String name = line.Substring(1, nameLength); if (name == "Server") chatLine.Color = new Color(0.65f, 1.0f, 1.0f); else chatLine.Color = KLFVessel.GenerateActiveColor(name) * NameColorSaturationFactor + Color.white * (1.0f - NameColorSaturationFactor); } } ChatLineQueue.Enqueue(chatLine); while (ChatLineQueue.Count > MaxChatLines) ChatLineQueue.Dequeue(); ScrollPos.y += 100; }
public ChatLine(String line) { this.color = Color.yellow; this.name = ""; this.message = line; //Check if the message has a name if (line.Length > 3 && line.First() == '[') { int name_length = line.IndexOf(']'); if (name_length > 0) { name_length = name_length - 1; this.name = line.Substring(1, name_length); this.message = line.Substring(name_length + 2); if (this.name == "Server") this.color = Color.magenta; else this.color = KMPVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR + Color.white * (1.0f - NAME_COLOR_SATURATION_FACTOR); } } }
public ChatLine(String line) { this.color = Color.yellow; this.name = ""; this.message = line; this.isAdmin = false; //Check if the message has a name if (line.Length > 3 && (line.First() == '<' || (line.StartsWith("["+KMPCommon.ADMIN_MARKER+"]") && line.Contains('<')))) { int name_start = line.IndexOf('<'); int name_end = line.IndexOf('>'); int name_length = name_end - name_start - 1; if (name_length > 0) { this.name = line.Substring(name_start+1, name_length); this.message = line.Substring(name_end + 1); if (this.name == "Server") this.color = Color.magenta; else if (line.StartsWith("["+KMPCommon.ADMIN_MARKER+"]")) { this.color = Color.red; this.isAdmin = true; } else this.color = KMPVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR + Color.white * (1.0f - NAME_COLOR_SATURATION_FACTOR); } } }
public static System.String FirstToCapital(System.String input) { return(input.First().ToString().ToUpper() + input.Substring(1)); }
private String[] GetConfigLine(String CompanyName, String UserName) { String[] RDConfigLine = new String[] { }; foreach (String RDConfiguration in RDConfigurations.Values) { if (!String.IsNullOrEmpty(RDConfiguration)) { RDConfigLine = RDConfiguration.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if ((RDConfigLine.First() == CompanyName) && (GetValue(RDConfigLine[1]) == UserName)) { break; } } } return (RDConfigLine); }
/// <summary> /// Gets the one line of description string from the resource via a label and the value. /// </summary> /// <param name="label">The label in the resource.</param> /// <param name="value">The value in the resource.</param> /// <returns>The description line.</returns> private static String GetDescriptionLine(String label, object value) { if (value is bool) { if ((bool)value) return String.Format("{0}", label); else { // A small hack for western languages: remove the uppercase from the start of the sentence. char startChar = label.First(); if (startChar >= 'A' && startChar <= 'Z') startChar = (char) ((int)startChar + 32); string newLabel = startChar + label.Substring(1); return String.Format(Properties.Resources.Dont, newLabel); } } else return String.Format("{0}: {1}", label, value.ToString()); }
/// <summary> /// Get current col & row based on cell name /// </summary> /// <param name="name">Cell selected</param> /// <param name="col">Column number</param> /// <param name="row">Row number</param> private void GetSelectedColRow(String cellName, out int col, out int row) { int rowNum; int.TryParse(cellName.Substring(1), out rowNum); col = cellName.First<char>() - 'A'; row = rowNum - 1; }
/// <summary> /// Creates a <see cref="TextExpression"/> that represents a string or a character from specified source string. /// </summary> /// <param name="symbols">The symbol table for the expression.</param> /// <param name="text">The string which contains quoting characters..</param> /// <returns>An <see cref="TextExpression"/> which generates a string or a character from specified string.</returns> public static TextExpression Text(SymbolTable symbols, String text) { return String.IsNullOrEmpty(text) || text.First() != text.Last() ? Text(symbols, default(Char), text) : Text(symbols, text.First(), text.Substring(1, text.Length - 2)); }
public static String TrimNonLetterPrefix(String word) { var firstLetter = word.First(Char.IsLetter); if (word.IndexOf(firstLetter) != 0) return word.Substring(word.IndexOf(firstLetter)); else return word; }
public void HandleClientTextMessage(int clientIndex, String messageText) { if (Clients[clientIndex].MessagesThrottled) { MessageFloodIncrement(clientIndex); return; } MessageFloodIncrement(clientIndex); StringBuilder sb = new StringBuilder(); if (messageText.Length > 0 && messageText.First() == '/') { string msgLow = messageText.ToLower(); if (msgLow == "/list") {//Compile list of usernames sb.Append("Connected users:\n"); for (int i = 0; i < Clients.Length; i++) { if (ClientIsReady(i)) { sb.Append(Clients[i].Username); sb.Append('\n'); } } SendTextMessage(clientIndex, sb.ToString()); return; } else if (msgLow == "/quit") { DisconnectClient(clientIndex, "Requested quit"); return; } else if(msgLow.Length > (KLFCommon.GetCraftCommand.Length + 1) && msgLow.Substring(0, KLFCommon.GetCraftCommand.Length) == KLFCommon.GetCraftCommand) { String playerName = msgLow.Substring(KLFCommon.GetCraftCommand.Length + 1); //Find the player with the given name int targetIndex = GetClientIndexByName(playerName); if (ClientIsReady(targetIndex)) { //Send the client the craft data lock (Clients[targetIndex].SharedCraftLock) { if(Clients[targetIndex].SharedCraftName.Length > 0 && Clients[targetIndex].SharedCraftFile != null && Clients[targetIndex].SharedCraftFile.Length > 0) { SendCraftFile( clientIndex , Clients[targetIndex].SharedCraftName , Clients[targetIndex].SharedCraftFile , Clients[targetIndex].SharedCraftType); StampedConsoleWriteLine("Sent craft " + Clients[targetIndex].SharedCraftName + " to client " + Clients[clientIndex].Username); } } } return; } } //Compile full message sb.Append('['); sb.Append(Clients[clientIndex].Username); sb.Append("] "); sb.Append(messageText); String fullMessage = sb.ToString(); //Console.SetCursorPosition(0, Console.CursorTop); StampedConsoleWriteLine(fullMessage); //Send the update to all other Clients SendTextMessageToAll(fullMessage, clientIndex); }
public void handleClientTextMessage(int client_index, String message_text) { if (clients[client_index].messagesThrottled) { messageFloodIncrement(client_index); return; } messageFloodIncrement(client_index); StringBuilder sb = new StringBuilder(); if (message_text.Length > 0 && message_text.First() == '!') { string message_lower = message_text.ToLower(); if (message_lower == "!list") { //Compile list of usernames sb.Append("Connected users:\n"); for (int i = 0; i < clients.Length; i++) { if (clientIsReady(i)) { sb.Append(clients[i].username); sb.Append('\n'); } } sendTextMessage(client_index, sb.ToString()); return; } else if (message_lower == "!quit") { disconnectClient(client_index, "Requested quit"); return; } else if (message_lower.Length > (KLFCommon.GET_CRAFT_COMMAND.Length + 1) && message_lower.Substring(0, KLFCommon.GET_CRAFT_COMMAND.Length) == KLFCommon.GET_CRAFT_COMMAND) { String player_name = message_lower.Substring(KLFCommon.GET_CRAFT_COMMAND.Length + 1); //Find the player with the given name int target_index = getClientIndexByName(player_name); if (clientIsReady(target_index)) { //Send the client the craft data lock (clients[target_index].sharedCraftLock) { if (clients[target_index].sharedCraftName.Length > 0 && clients[target_index].sharedCraftFile != null && clients[target_index].sharedCraftFile.Length > 0) { sendCraftFile(client_index, clients[target_index].sharedCraftName, clients[target_index].sharedCraftFile, clients[target_index].sharedCraftType); stampedConsoleWriteLine("Sent craft " + clients[target_index].sharedCraftName + " to client " + clients[client_index].username); } } } return; } } //Compile full message sb.Append('['); sb.Append(clients[client_index].username); sb.Append("] "); sb.Append(message_text); String full_message = sb.ToString(); //Console.SetCursorPosition(0, Console.CursorTop); stampedConsoleWriteLine(full_message); //Send the update to all other clients sendTextMessageToAll(full_message, client_index); }
public static String getPathToTrim(String[] paths) { string pathToTrim = ""; try { String aPath = paths.First(); string[] dirsInFilePath = aPath.Split('\\'); int highestMatchingIndex = 0; for (int i = 0; i < dirsInFilePath.Length; i++) { for (int j = 0; j < paths.Length; j++) { string[] splitPath = paths[j].Split('\\'); if (!dirsInFilePath[i].Equals(splitPath[i])) { highestMatchingIndex = i - 1; break; } } } if (highestMatchingIndex == 0) { pathToTrim = "." + "\\"; } else { pathToTrim = string.Join("\\", dirsInFilePath, 0, highestMatchingIndex); } } catch (InvalidOperationException) { Console.WriteLine("No Entrypoints with the specified search parameters found."); } catch( Exception e) { Console.WriteLine(e.ToString()); } return pathToTrim; }
private void OpenFirmware(String[] Files) { if (Files == null) Source.OpenFirmware(); else Source.OpenFirmware(Files.First()); }
/// <summary> /// The build subfields. /// </summary> /// <returns>The <see cref="bool" />.</returns> private bool BuildSubfields() { var subFields = new String(this._arrayDescription.Skip(this._arrayDescription.LastIndexOf('*')).ToArray()); if (subFields.First() == '*') { this.RepeatingSubfields = true; } List<string> subfieldNames = subFields.Split('!').ToList(); foreach (string subField in subfieldNames) { this.SubFieldDefinitions.Add(new DdfSubFieldDefinition { Name = subField }); } return true; }
/// <summary> /// Helper method that takes the grid number for the cell and inserts the value /// of the cell into the grid, displaying the value in the spreadsheet /// </summary> /// <param name="name"></param> private void updateCellValue(String name) { //Need location of cell selected int cell_row; int.TryParse(name.Substring(1), out cell_row); cell_row--; int cell_col = name.First<char>() - 'A'; //Set the cell to the new value if (ss.GetCellValue(name).GetType() == typeof(FormulaError)) //TODO needs to return a message? { return; } else { spreadsheetPanel1.SetValue(cell_col, cell_row, ss.GetCellValue(name).ToString()); } }