private async Task <string> GetParent(Guid parent) { var par = Regions.FirstOrDefault(x => x.Guid == parent); if (par != null) { return($"{par.Name} {par.Prefix} "); } var cachedParent = await TryGetFromCache(parent); var stout = $"{cachedParent.OffName} {cachedParent.ShortName}."; if (cachedParent.ParentGuid.HasValue) { var p1 = await TryGetFromCache(cachedParent.ParentGuid.Value); stout = $"{p1.OffName} {p1.ShortName}., {stout}"; if (p1.ParentGuid.HasValue) { var p2 = await TryGetFromCache(p1.ParentGuid.Value); stout = $"{p2.OffName} {p2.ShortName}., {stout}"; } } return(stout); }
private void changeRegionColor() { var selectedIndex = m_RegionListing.SelectedIndex; if (selectedIndex == -1) { return; } var region = Regions.FirstOrDefault(p => p.RegionName == m_RegionListing.Items[selectedIndex].ToString()); if (region != null) { var originalRegionName = region.RegionName; RegionSettings frm = new RegionSettings(region, Regions); if (frm.ShowDialog() == DialogResult.OK) { region.RColor = frm.RegionToChange.RColor; region.TextColor = frm.RegionToChange.TextColor; region.RegionName = frm.RegionToChange.RegionName; updateExistingRoomRegions(frm.RegionToChange.RegionName, originalRegionName); addRegionsToListbox(); m_RegionListing.Invalidate(); m_RegionListing.SelectedIndex = selectedIndex; } } }
private string GetParent(Guid parent) { var par = Regions.FirstOrDefault(x => x.Guid == parent); if (par != null) { return($"{par.Name} {par.Prefix} "); } else { var p0 = TryGetFromCache(parent); var stout = $"{p0.OffName} {p0.ShortName}."; if (!p0.ParentGuid.HasValue) { return(stout); } var p1 = TryGetFromCache(p0.ParentGuid.Value); stout = $"{p1.OffName} {p1.ShortName}., {stout}"; if (!p1.ParentGuid.HasValue) { return(stout); } var p2 = TryGetFromCache(p1.ParentGuid.Value); stout = $"{p2.OffName} {p2.ShortName}., {stout}"; return(stout); } }
////TODO: If is tell me action hide back button(first page) we need to show only the settings page //public ProviderControlViewModel(IMtTranslationOptions options,bool isTellMeAction) //{ // _options = options; // _isTellMeAction = isTellMeAction; // InitializeComponent(); //} private void InitializeComponent() { TranslationOptions = new List <TranslationOption> { new TranslationOption { Name = PluginResources.Microsoft, ProviderType = MtTranslationOptions.ProviderType.MicrosoftTranslator }, new TranslationOption { Name = PluginResources.Google, ProviderType = MtTranslationOptions.ProviderType.GoogleTranslate } }; GoogleApiVersions = new List <GoogleApiVersion> { new GoogleApiVersion { Name = PluginResources.GoogleApiVersionV2Description, Version = Enums.GoogleApiVersion.V2 }, new GoogleApiVersion { Name = PluginResources.GoogleApiVersionV3Description, Version = Enums.GoogleApiVersion.V3 } }; // set the default region Region = Regions.FirstOrDefault(a => a.Key == ""); if (_options != null) { ClientId = _options.ClientId; PersistMicrosoftKey = _options.PersistMicrosoftCreds; UseCatId = _options.UseCatID; CatId = _options.CatId; ApiKey = _options.ApiKey; PersistGoogleKey = _options.PersistGoogleKey; JsonFilePath = _options.JsonFilePath; ProjectName = _options.ProjectName; GoogleEngineModel = _options.GoogleEngineModel; ProjectLocation = _options.ProjectLocation; GlossaryPath = _options.GlossaryPath; BasicCsvGlossary = _options.BasicCsv; RegionChecked = string.IsNullOrEmpty(Region?.Key) && _options.RegionChecked; Region = Regions.FirstOrDefault(a => a.Key == (RegionChecked ? _options.Region ?? string.Empty : "")); } SetTranslationOption(); SetGoogleApiVersion(); }
public Sprite CreateSpriteFromRegion(string regionName) { var region = Regions.FirstOrDefault(x => x.Name.Equals(regionName, StringComparison.OrdinalIgnoreCase)); if (region == null) { throw new RegionNotFoundException(); } return(new Sprite(Image, region.Keys.First().Bounds.ToRectangle())); }
private async Task Delete(int id) { var region = Regions.FirstOrDefault(p => p.Id.Equals(id)); var confirmed = await Js.InvokeAsync <bool>("confirm", $"Are you sure you want to delete the region with name: {region.Name}?"); if (confirmed) { await OnDeleted.InvokeAsync(id); } }
} //End method /// <summary> This method returns the Region object that matches the one passed into the function. </summary> /// <param name="Region"> A Container Region object. </param> /// <returns> The matched object if found, otherwise adds it to the DB and return the object. </returns> public void GetRegion(Cont.Region Region) { var info = Regions.FirstOrDefault(x => x.Equals(Region)); if (info == null) { Region.ID = Handler.Region.Add(Region); Regions.Add(Region); } else { Region.ID = info.ID; } } //End method
public void Apply(object entity) { if (entity is Region region) { var match = Regions.FirstOrDefault(each => each.Id == region.Id); if (match != null) { Regions.Remove(match); } Regions.Add(region); } }
protected override async Task FetchDataAsync() { var regions = await base.Api.GetAsync <List <RegionModel> >( $"{Constants.Endpoints.Regions}?{Constants.ApiOptions.IncludeDeleted}"); var casted = regions.Select(r => new RegionViewModel(r, Save, Cancel)); this.Regions.AddRange(casted); var selectedRegionId = Navigator.GetNavigationData <Guid>(); if (selectedRegionId != null && selectedRegionId != Guid.Empty) { this.Selected = Regions.FirstOrDefault(s => s.Id == selectedRegionId); } }
public TargetObj Get <T>(string id) where T : TargetObj { Type type = typeof(T); switch (type.Name) { case nameof(Bridge): return(Bridges.FirstOrDefault(_ => _.ID == id)); case nameof(GateInfo): return(Gates.FirstOrDefault(_ => _.ID == id)); case nameof(FenceRegionsInfo): return(Regions.FirstOrDefault(_ => _.ID == id)); } return(null); }
/// <summary> /// 得到价格 /// </summary> /// <param name="calculator"></param> /// <returns></returns> public virtual void SetRegionPrice(FreightCalculatorEntity calculator) { var region = Regions?.FirstOrDefault(it => it.GetRegionArray() != null && (it.GetRegionArray().Contains(calculator.Province) || it.GetRegionArray().Contains(calculator.City) || it.GetRegionArray().Contains(calculator.County))); var defaultPrice = region == null ? DefaultPrice : region.DefaultPrice; var defaultCount = region == null ? DefaultCount : region.DefaultCount; if (FullFreePrice > 0 && FullFreePrice <= calculator.PayAmount) { Price = 0; Cost = GetRegionPrice(calculator, region, defaultPrice, defaultCount); } Price = Cost = GetRegionPrice(calculator, region, defaultPrice, defaultCount); }
public FenceRegionsInfo[] GetBridgeFromGate(string id) { var regions = Bridges?.FirstOrDefault(_ => _.ID == id); List <FenceRegionsInfo> list = new List <FenceRegionsInfo>(); if (regions != null && regions.Links != null) { foreach (var r in regions.Links) { var reg = Regions?.FirstOrDefault(_ => _.ID == r); if (reg != null) { list.Add(reg); } } } return(list.ToArray()); }
public void InitRegion(int id, int tid) { var ls = new ObservableCollection <IRegionVM>(); var region = AppHelper.Regions.FirstOrDefault(x => x.tid == id); ls.Add(new RegionDetailHomeVM(region)); Regions = ls; foreach (var item in region.children) { ls.Add(new RegionDetailChildVM(item)); } if (tid == 0) { SelectRegion = Regions[0]; } else { SelectRegion = Regions.FirstOrDefault(x => x.ID == tid); } }
/// <summary> /// 得到续重价格 /// </summary> /// <returns></returns> public virtual decimal GetContinuePrice(FreightCalculatorEntity calculator) { if (Type == FreightType.Take) { return(0); } if (Type == FreightType.Distribution) { return(GetDistribution(calculator, 0, 0)); } if (Type == FreightType.Express) { var region = Regions?.FirstOrDefault(it => it.GetRegionArray() != null && (it.GetRegionArray().Contains(calculator.Province) || it.GetRegionArray().Contains(calculator.City) || it.GetRegionArray().Contains(calculator.County))); return(GetRegionPrice(calculator, region, 0, 0)); } return(0); }
private void CheckAndClean() { // Cities with empty regions var cityWithEmptyRegion = Cities.FirstOrDefault(city => string.IsNullOrWhiteSpace(city.RegionId) || city.RegionId.All(ch => ch == '0')); if (cityWithEmptyRegion != null) { throw new Exception($"There is '{cityWithEmptyRegion}' city with empty Region"); } // Countries with no regions for (int i = Countries.Count - 1; i >= 0; i--) { Country country = Countries[i]; var region = Regions.FirstOrDefault(r => country.Id.Equals(r.CountryId)); if (region == null) { Countries.RemoveAt(i); Console.WriteLine($"'{country.Name}' has no regions and was deleted"); } } }
private void RegionListBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } Font txtColorFont = new Font("Arial", 6); using (var palette = new Palette()) { e.DrawBackground(); var colorBounds = new Rectangle(e.Bounds.Left + HORIZONTAL_MARGIN, e.Bounds.Top + VERTICAL_MARGIN, WIDTH, e.Bounds.Height - VERTICAL_MARGIN * 2); var textBounds = new Rectangle(colorBounds.Right + HORIZONTAL_MARGIN, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - HORIZONTAL_MARGIN * 2, e.Bounds.Height); var foundRegion = Regions.FirstOrDefault(p => p.RegionName == m_RegionListing.Items[e.Index].ToString()); if (foundRegion != null) { e.Graphics.FillRectangle(palette.Brush(foundRegion.RColor), colorBounds); e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds); e.Graphics.DrawString(m_RegionListing.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left); e.Graphics.DrawString("123", txtColorFont, palette.Brush(foundRegion.TextColor), colorBounds, StringFormats.Center); } } }
private RegionInfo GetCurrentDisplayRegion() { return(Regions.FirstOrDefault(r => r.Index == SelectedIndex)); }
public CreateServerModel() { Region = Regions?.FirstOrDefault(r => r.IsOptimal); }
/// <summary> /// Returns the region the provided position is in /// </summary> /// <param name="position">Position in world</param> /// <returns></returns> public Region GetRegion(Vector2 position) { return(Regions.FirstOrDefault(region => region.Contains(position))); }
public Region GetRegionAt(Vector3 pos) => Regions.FirstOrDefault(region => IsInRegion(pos, region));