/// <summary> /// 获取完整的变量名 /// </summary> /// <param name="expr"></param> /// <param name="startPos"></param> /// <param name="funcStr"></param> /// <param name="endPos"></param> private void GetCompleteVarible(string expr, int startPos, out string varStr, out int endPos) { //int cpnum = 0; for (int i = startPos; i <= expr.Length - 1; i++) { char c = expr[i]; LetterType lt = JudgeLetterType(c); //if (lt == LetterType.OpeningParenthesis) // cpnum++; //else if (lt == LetterType.ClosingParenthesis) //{ // cpnum--;//考虑到函数嵌套的情况,消除掉内部括号 // if (cpnum == 0) // { // endPos = i; // varStr = expr.Substring(startPos, endPos - startPos + 1); // return; // } //} if (lt != LetterType.Variable && c != '.') { endPos = i - 1; varStr = expr.Substring(startPos, endPos - startPos + 1); return; } } varStr = expr.Substring(startPos); endPos = expr.Length - 1; }
public async Task <LetterTemplate> GetTemplate(LetterType type) { return(await _requestProvider.BuildUpon(_url) .Uri($"/api/letter/template/{(int)type}") .AddInterceptor(new JsonDeserializerInterceptor()) .Execute <LetterTemplate>()); }
/// <summary> /// 获取完整的函数表达式 /// </summary> /// <param name="expr"></param> /// <param name="startPos"></param> /// <param name="funcStr"></param> /// <param name="endPos"></param> private void GetCompleteFunction(string expr, int startPos, out string funcStr, out int endPos) { int cpnum = 0; for (int i = startPos; i <= expr.Length - 1; i++) { char c = expr[i]; LetterType lt = JudgeLetterType(c); if (lt == LetterType.OpeningParenthesis) { cpnum++; } else if (lt == LetterType.ClosingParenthesis) { cpnum--;//考虑到函数嵌套的情况,消除掉内部括号 if (cpnum == 0) { endPos = i; funcStr = expr.Substring(startPos, endPos - startPos + 1); return; } } } funcStr = expr.Substring(startPos); endPos = expr.Length - 1; }
/// <summary> /// Draw the ascii clock, only redraws what has changed. /// </summary> /// <param name="a_elapsed"></param> private void Draw(ElapsedResult a_elapsed) { int posX = StartX; int posY = StartY; int storedPosition = 0; foreach (char letter in a_elapsed.hours) { LetterType type = GetLetterType(letter); TryDraw(type, ref posX, posY, ref storedPosition); } TryDraw(LetterType.Colon, ref posX, posY, ref storedPosition); foreach (char letter in a_elapsed.minutes) { LetterType type = GetLetterType(letter); TryDraw(type, ref posX, posY, ref storedPosition); } TryDraw(LetterType.Colon, ref posX, posY, ref storedPosition); foreach (char letter in a_elapsed.seconds) { LetterType type = GetLetterType(letter); TryDraw(type, ref posX, posY, ref storedPosition); } }
public void SetFullLetter(LetterView letterView) { if (letterView != null) { LetterType letterType = ClientRequests.GetLetterType(letterView.Type); ILetterPropertiesUIPlugin clientUIPlugin; disableControls(splitContainer1.Panel2.Controls); if (!_letterPropertiesUIPlugins.TryGetValue(letterType.TypeClientUI, out clientUIPlugin)) { clientUIPlugin = ((PluginService)(ServiceProvider.GetService(typeof(PluginService)))).GetLetterPropetiesPlugin(letterType); _letterPropertiesUIPlugins.Add(letterType.TypeClientUI, clientUIPlugin); splitContainer1.Panel2.Controls.Add((Control)clientUIPlugin); } clientUIPlugin.LetterView = letterView; clientUIPlugin.ReadOnly = true; this.Size = new Size(splitContainer2.Size.Width + ((Control)clientUIPlugin).Size.Width, Math.Max(splitContainer2.Size.Height, ((Control)clientUIPlugin).Size.Height)); enableControl((Control)clientUIPlugin); } }
public LetterResult(bool isLetter = false, bool isUpper = false, LetterType type = LetterType.Default, bool isMark = false) { IsLetter = isLetter; IsUpper = isUpper; Type = type; IsMark = false; }
static void SendWelcomeLetter(OG_OutpostData outpostData) { string eventTitle = ""; string eventText = ""; LetterType letterType = LetterType.BadNonUrgent; int sectorCoordX = Find.Map.WorldCoords.x; int sectorCoordZ = Find.Map.WorldCoords.z; int rimLawNumber = Rand.RangeInclusive(25, 1350); if (outpostData.isMilitary) { eventTitle = "MiningCo. military outpost"; eventText = " MiningCo. warning message\n\n" + " Hello! I am Coralie, the AI in charge of outpost X" + sectorCoordX + ".Z" + sectorCoordZ + " Mil.\n\n" + "My scanners detected the signature of your escape pods crashing nearby.\n\n" + "WARNING! You are entering an MiningCo. military sector. No activity is authorized here.\n\n" + "Please notice that anyone found in the sector will be shot on sight with regards to the RimLaw RL-" + rimLawNumber + ".\n\n" + "---- End of transmision ---"; letterType = LetterType.BadUrgent; } else { eventTitle = "MiningCo. civil outpost"; eventText = " MiningCo. information message\n\n" + " Hello! I am Coralie, the AI in charge of outpost X" + sectorCoordX + ".Z" + sectorCoordZ + " Civ.\n\n" + "My scanners detected the signature of your escape pods crashing nearby.\n" + "My emotional analyzer tells me to be sorry for your ship and the people who most probably died within.\n\n" + "I remind you this sector is the legal property of MiningCo. However, the company generously grants you the right to pass through this sector.\n\n" + "Please notice that any intruder found inside the outpost perimeter will be shot on sight with regards to the RimLaw RL-" + rimLawNumber + ".\n\n" + "---- End of transmision ---"; letterType = LetterType.Good; } Find.LetterStack.ReceiveLetter(eventTitle, eventText, letterType); }
public Letter( long LoginID = default, string MsgID = default, long OtherID = default, string OtherName = default, bool IsReceived = default, bool Unread = default, LetterType LetterType = default, bool OtherIsOnline = default, string Content = default, DateTime STime = default, string Photo = default) { AddCell("ID", 0); AddCell("LoginID", LoginID); AddCell("MsgID", MsgID); AddCell("OtherID", OtherID); AddCell("OtherName", OtherName); AddCell("IsReceived", IsReceived); AddCell("Unread", Unread); AddCell("LetterType", LetterType); AddCell("OtherIsOnline", OtherIsOnline); AddCell("Content", Content); AddCell("STime", STime); AddCell("Photo", Photo); IsAdded = true; AttachHook(); }
public IEnumerable <LetterType> GetAllLetterTypes() { using (IDbConnection connection = DatabaseService.CreateOpenConnection()) { using (IDbCommand command = DatabaseService.CreateStoredProcCommand(SpGetAllLetterTypes, connection)) { using (IDataReader reader = command.ExecuteReader()) { var allTypes = new List <LetterType>(); while (reader.Read()) { var type = new LetterType() { Id = reader.GetInt32(reader.GetOrdinal(Id)), TypeClientUI = reader.GetString(reader.GetOrdinal(TypeClientUI)), Name = reader.GetString(reader.GetOrdinal(Name)) }; if (!string.IsNullOrEmpty(type.TypeClientUI)) { allTypes.Add(type); } } if (allTypes.Count == 0) { throw new Exception("No types"); } return(allTypes); } } } }
private void ReceiverReceived(ILetter receivedLetter) { ResetHeartbeatTimer(); LetterType letterType = receivedLetter.Type; if (letterType == LetterType.Ack) { HandleLetterSent(_queue.Dequeue()); } else { if ((receivedLetter.Options & LetterOptions.Ack) == LetterOptions.Ack) { if (_options.Notification.ReceivedNotifyOnAllAckStates && ((letterType & LetterType.User) == LetterType.User || (letterType & LetterType.Batch) == LetterType.Batch)) { HandleReceivedLetter(receivedLetter, AckState.BeforeAck); } QueueAck(receivedLetter); } else { HandleReceivedLetter(receivedLetter, AckState.NoAck); } } }
public GcnPlayerMail(Save saveFile, Player owner, int index) { Index = index; switch (saveFile.SaveType) { case SaveType.DoubutsuNoMoriPlus: break; case SaveType.AnimalCrossing: Offset = owner.Offset + 0x4E0 + index * 0x12A; RecipientInfo = new GCMailName(saveFile, Offset); SenderInfo = new GCMailName(saveFile, Offset + 0x16); Present = new Item(saveFile.ReadUInt16(Offset + 0x2C, true)); // TODO: There has to be a flag that tells the game if the item is wrapped or a quest item. LetterType = (LetterType)saveFile.ReadByte(Offset + 0x2E); // "Font" HeaderReceipiantStartOffset = saveFile.ReadByte(Offset + 0x2F); // How many characters until the recipient's name should be inserted SenderType = (LetterSenderType)saveFile.ReadByte(Offset + 0x30); StationaryType = new Item((ushort)(0x2000 | saveFile.ReadByte(Offset + 0x31))); Header = saveFile.ReadString(Offset + 0x32, 0x18); Contents = saveFile.ReadString(Offset + 0x4A, 0xC0); Footer = saveFile.ReadString(Offset + 0x10A, 0x20); break; case SaveType.DoubutsuNoMoriEPlus: break; } }
public void AddBag() { bag = GameObject.Instantiate(bagPrefab); List <LetterType> acceptedTypes = new List <LetterType>(); LetterType accepted = (LetterType)random.Next(1, Enum.GetNames(typeof(LetterType)).Length); acceptedTypes.Add(accepted); acceptedTypes.Add(LetterType.Gold); bag.GetComponent <Bag>().Initialise(sprites[(int)accepted], acceptedTypes); bag.transform.SetParent(this.transform); bag.transform.position = this.bagPositions[0].transform.position; currentBagNumber += 1; bagPositions[0].currentBag = bag; //GameEvents.current.PushBags(); for (int i = bagPositions.Count - 1; i > 0; i--) { bagPositions[i].pushBag(bagPositions[i - 1].currentBag); } CheckBagQueue(); }
//========================================================================================= /// <summary>Найти позицию первого символа с указанным типом.</summary> static int GetFirstLetter(string line, int chr, LetterType letterType) { while (chr > 0 && GetLetterType(line[chr - 1]) == letterType) { chr--; } return(chr); }
private static Boolean IsOperator(LetterType letterType) { if (letterType == LetterType.LeftParentheses || letterType == LetterType.RightParentheses || letterType == LetterType.Operator) { return(true); } return(false); }
private LetterTypeDTO ToLetterTypeDTO(LetterType item) { LetterTypeDTO result = new LetterTypeDTO(); result.ID = item.ID; result.Name = item.Name; return(result); }
public async Task <string> UpdateLetterTemplate(LetterType type, [FromBody] LetterTemplate template) { template.Type = type; await _masterService.UpdateLetterTemplate(template); return("Ok"); }
//========================================================================================= /// <summary>Найти позицию последнего символа с указанным типом + 1.</summary> static int GetLastLetter(string line, int chr, LetterType letterType) { while (chr < line.Length && GetLetterType(line[chr]) == letterType) { chr++; } return(chr); }
/// <summary> /// It tries to draw the letter type. /// It will only draw if the letter types are different. /// </summary> /// <param name="type"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="a_storedPosition"></param> private void TryDraw(LetterType type, ref int x, int y, ref int a_storedPosition) { if (type != m_storedLetters[a_storedPosition]) { DrawLetterType(type, x, y); m_storedLetters[a_storedPosition] = type; } a_storedPosition++; x += GetLetterLength(type); }
private int GetLetterLength(LetterType a_type) { switch (a_type) { case LetterType.Colon: return(2); default: return(4); } }
public void TryToCaptureOutpost(string eventTitle, string eventText, LetterType letterType, Faction turretsNewFaction, bool deactivateTurrets, Faction doorsNewFaction, bool deactivateDoors, int dropPodsNumber, PawnKindDef securityForcesDef) { SetOutpostSecurityForcesHostileToColony(); this.outpostThingList = OG_Util.RefreshThingList(this.outpostThingList); ChangeOutpostThingsFaction(null); ChangeOutpostTurretsFaction(turretsNewFaction, deactivateTurrets); ChangeOutpostDoorsFaction(doorsNewFaction, deactivateDoors); LaunchSecurityDropPods(dropPodsNumber, securityForcesDef, true); OG_Util.DestroyOutpostArea(); Find.LetterStack.ReceiveLetter(eventTitle, eventText, letterType, new TargetInfo(this.Position)); }
public async Task <List <LetterTemplate> > GetTemplate(LetterType type) { var param = new DynamicParameters(); param.Add("@Type", type); return((await SqlMapper.QueryAsync <LetterTemplate>(_unitOfWork.Connection, "GetLetterTemplate", param, commandType: CommandType.StoredProcedure, transaction: _unitOfWork.Transaction)).ToList()); }
public static bool IsLetter(char c, LetterType letterType) { bool isLetter = false; if (letterType != LetterType.upperCase && c >= 'a' && c <= 'z') { isLetter = true; } if (!isLetter && letterType != LetterType.lowerCase && c >= 'A' && c <= 'Z') { isLetter = true; } return(isLetter); }
private void SendLetterB_Click(object sender, EventArgs e) { LetterType selectedLetterType = ((ApplicationState)ServiceProvider.GetService(typeof(ApplicationState))).SelectedLetterType; ILetterPropertiesUIPlugin clientUIPlugin = ((PluginService)(ServiceProvider.GetService(typeof(PluginService)))).GetLetterPropetiesPlugin(selectedLetterType); global::Registration.SerializationService.LetterProperties letterProp = clientUIPlugin.GetLetterProperties(); LetterView letterView = clientUIPlugin.StandartLetter; if (SendLetter(letterView.Name, ((ApplicationState)ServiceProvider.GetService(typeof(ApplicationState))).Worker.Id, NamesAndLoginsReceivers, letterView.Text, letterProp.ToString(), selectedLetterType.Id)) { MessageService.InfoMessage(Message.MessageResource.SentLetter); Close(); } }
public void InitializeForm() { InitializeClientService(); InitializeMessageService(); InitializeBaseControls(); LetterView letterView = ((ApplicationState)ServiceProvider.GetService(typeof(ApplicationState))).SelectedLetterView; LetterType selectedLetterType = ClientRequests.GetLetterType(letterView.Type); ILetterPropertiesUIPlugin newControl = ((PluginService)(ServiceProvider.GetService(typeof(PluginService)))).GetLetterPropetiesPlugin(selectedLetterType); newControl.LetterView = letterView; newControl.ReadOnly = true; int tabIndex = 0; newControl.OnLoad(ServiceProvider); ((Control)newControl).TabIndex = tabIndex; int heightSize = 0; int locationY = 0; foreach (Control control in BaseControls) { if (control.Location.Y + control.Size.Height > locationY) { locationY = control.Location.Y + control.Size.Height; } heightSize += control.Size.Height; } this.Controls.Clear(); ((Control)newControl).Location = new Point(0, locationY); this.Size = new Size(((Control)newControl).Size.Width, ((Control)newControl).Size.Height + heightSize); this.Controls.Add(((Control)newControl)); foreach (Control control in BaseControls) { ++tabIndex; control.TabIndex = tabIndex; this.Controls.Add(control); } }
public void AddLetter(LetterType letterType) { if (acceptedTypes.Contains(letterType)) { if (letterType == LetterType.Gold) { current = capacity; } else { current += 1; } } CheckCapacity(); }
public void InitializeForm() { InitializeClientService(); InitializeMessageService(); InitializeBaseControls(); LetterView letterView = ((ApplicationState)ServiceProvider.GetService(typeof(ApplicationState))).SelectedLetterView; LetterType selectedLetterType = ClientRequests.GetLetterType(letterView.Type); ILetterPropertiesUIPlugin newControl = ((PluginService)(ServiceProvider.GetService(typeof(PluginService)))).GetLetterPropetiesPlugin(selectedLetterType); LetterProperties prop = new LetterProperties() { }; int minXLocation = int.MaxValue; int minYLocation = int.MaxValue; int sizeForMinYLocation = 0; foreach (Control control in BaseControls) { minXLocation = Math.Min(control.Location.X, minXLocation); if (control.Location.Y < minYLocation) { minYLocation = control.Location.Y; sizeForMinYLocation = control.Size.Height; } } ((Control)newControl).Location = new Point(minXLocation, minYLocation + sizeForMinYLocation); int width = Math.Max(BaseSizeHeight.X, ((Control)newControl).Width); this.Controls.Clear(); this.Size = new Size(width, BaseSizeHeight.Y + ((Control)newControl).Size.Height); this.Controls.Add(((Control)newControl)); foreach (Control control in BaseControls) { control.Location = new System.Drawing.Point(control.Location.X, control.Location.Y + ((Control)newControl).Size.Height); this.Controls.Add(control); } }
private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e) { LetterType letterType = ((ApplicationState)ServiceProvider.GetService(typeof(ApplicationState))).SelectedLetterType; if (toolStripComboBox1.SelectedIndex >= 0 && null != _comboLettersTypes[toolStripComboBox1.SelectedIndex]) { letterType.Id = _comboLettersTypes[toolStripComboBox1.SelectedIndex].Id; letterType.Name = _comboLettersTypes[toolStripComboBox1.SelectedIndex].Name; letterType.TypeClientUI = _comboLettersTypes[toolStripComboBox1.SelectedIndex].TypeClientUI; using (var makeLetterForm = new Forms.MakeLetterForm(ServiceProvider)) { makeLetterForm.ShowDialog(); } InitializeMainWorkerForm(); } }
public void RemoveWord(int length, int numberOfLetter, LetterType letterType) { foreach (ISentence sentence in this.GetSentences()) { List <Word> words = sentence.Items.OfType <Word>() .Where(item => item.Length == length && item.Length > numberOfLetter).ToList(); for (int i = 0; i < words.Count(); i++) { AlphabetItem alphabetItem = Alphabet.GetAlpabetItem(words[i].Items[numberOfLetter]); if (alphabetItem.Equals(default(AlphabetItem)) == false && alphabetItem.LetterType == letterType) { sentence.RemoveItem(words[i]); } } } }
public static IList <string> GetAlphabet(LetterType letterType) { var alphabet = new List <string>(); for (int i = 65; i <= 90; i++) { var letter = ((char)i).ToString(); switch (letterType) { case LetterType.Uppercase: letter = letter.ToUpper(); break; default: letter = letter.ToLower(); break; } alphabet.Add(letter); } return(alphabet); }
LetterType GetLetterType(List <FileData> p_files) { LetterType type = LetterType.File; if (p_files.All(p_file => FileFilter.UwpImage.Contains(p_file.Ext.ToLower()))) { type = LetterType.Image; } else if (p_files.All(p_file => FileFilter.UwpVideo.Contains(p_file.Ext.ToLower()))) { type = LetterType.Video; } else if (p_files.All(p_file => FileFilter.UwpAudio.Contains(p_file.Ext.ToLower()))) { type = LetterType.Voice; } return(type); }
//========================================================================================= /// <summary>Найти позицию последнего символа с указанным типом + 1.</summary> static int GetLastLetter(string line, int chr, LetterType letterType) { while (chr < line.Length && GetLetterType(line[chr]) == letterType) chr++; return chr; }
//========================================================================================= /// <summary>Найти позицию первого символа с указанным типом.</summary> static int GetFirstLetter(string line, int chr, LetterType letterType) { while (chr > 0 && GetLetterType(line[chr - 1]) == letterType) chr--; return chr; }
private Boolean IsOperator(LetterType letterType) { if (letterType == LetterType.LeftParentheses || letterType == LetterType.RightParentheses || letterType == LetterType.Operator) return true; return false; }
public void LaunchInvasion(string eventTitle, string eventText, float raidPointsFactor, int dropsNumber, LetterType letterType) { this.LaunchInvasion(eventTitle, eventText, raidPointsFactor, dropsNumber, letterType, IntVec3.Invalid); }
public void LaunchInvasion(string eventTitle, string eventText, float raidPointsFactor, int dropsNumber, LetterType letterType, IntVec3 spawnPosition) { this.invasionIsDone = true; // Get an indicative amount of points based on the colony wealth so it scales up well for late-game colonies. IncidentParms invasionParameters = IncidentMakerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig); invasionParameters.faction = Faction.OfMechanoids; invasionParameters.raidStrategy = RaidStrategyDefOf.ImmediateAttack; invasionParameters.raidArrivalMode = PawnsArriveMode.EdgeDrop; invasionParameters.raidNeverFleeIndividual = true; invasionParameters.raidPodOpenDelay = 800; if (dropsNumber > 0) { invasionParameters.points *= (raidPointsFactor / dropsNumber); if (invasionParameters.points < 320) { invasionParameters.points = 320; } for (int dropIndex = 0; dropIndex < dropsNumber; dropIndex++) { IntVec3 dropPodSpawningPosition; float squadPoint = invasionParameters.points; if (spawnPosition.IsValid) { invasionParameters.spawnCenter = spawnPosition; } else { RCellFinder.TryFindRandomPawnEntryCell(out invasionParameters.spawnCenter); } List<Pawn> mechanoidsList = new List<Pawn>(); while (squadPoint >= PawnKindDef.Named("Scyther").combatPower) { bool validDropPodCellIsFound = DropCellFinder.TryFindDropSpotNear(invasionParameters.spawnCenter, out dropPodSpawningPosition, false, true); if (validDropPodCellIsFound) { Faction faction = Faction.OfMechanoids; Pawn squadMember; if (Rand.Value < 0.6f) { squadMember = PawnGenerator.GeneratePawn(PawnKindDef.Named("Scyther"), faction); squadPoint -= PawnKindDef.Named("Scyther").combatPower; } else { squadMember = PawnGenerator.GeneratePawn(PawnKindDef.Named("Centipede"), faction); squadPoint -= (int)PawnKindDef.Named("Centipede").combatPower; } mechanoidsList.Add(squadMember); DropPodUtility.MakeDropPodAt(dropPodSpawningPosition, new DropPodInfo { SingleContainedThing = squadMember, openDelay = 800, leaveSlag = true }); } } StateGraph stateGraph = GraphMaker.AssaultColonyGraph(Faction.OfMechanoids, false, false); BrainMaker.MakeNewBrain(Faction.OfMechanoids, stateGraph, mechanoidsList); } } Find.LetterStack.ReceiveLetter(eventTitle, eventText, letterType, this.Position); }