protected AdvancedDropdownItem RebuildTree() { m_SearchableElements = new List <AdvancedDropdownItem>(); AdvancedDropdownItem root = new PresetTypeDropdownItem(L10n.Tr("Add Default Type")); var type = UnityType.FindTypeByName("AssetImporter"); var presetTypes = UnityType.GetTypes() .Where(t => t.IsDerivedFrom(type) && !t.isAbstract) .Select(t => new PresetType(t.persistentTypeID)) .Union( TypeCache.GetTypesDerivedFrom <ScriptedImporter>() .Where(t => !t.IsAbstract) .Select(t => new PresetType(t)) ) .Distinct() .Where(pt => pt.IsValidDefault()); // Add Importers var importersRoot = new PresetTypeDropdownItem(L10n.Tr("Importer")); root.AddChild(importersRoot); foreach (var presetType in presetTypes) { var menuPath = presetType.GetManagedTypeName(); var paths = menuPath.Split('.').Last(); var element = new PresetTypeDropdownItem(paths, presetType); importersRoot.AddChild(element); m_SearchableElements.Add(element); } // Add Components var menuDictionary = GetMenuDictionary(); menuDictionary.Sort(CompareItems); for (var i = 0; i < menuDictionary.Count; i++) { var menu = menuDictionary[i]; if (menu.Value == "ADD") { continue; } var menuPath = menu.Key; var paths = menuPath.Split('/'); var parent = root; for (var j = 0; j < paths.Length; j++) { var path = paths[j]; if (j == paths.Length - 1) { var element = new PresetTypeDropdownItem(path, menu.Value); parent.AddChild(element); m_SearchableElements.Add(element); continue; } var group = (PresetTypeDropdownItem)parent.children.SingleOrDefault(c => c.name == path); if (group == null) { group = new PresetTypeDropdownItem(path); parent.AddChild(group); } parent = group; } } // Add ScriptableObjects var scriptableObjectRoot = new PresetTypeDropdownItem(L10n.Tr("ScriptableObject")); root.AddChild(scriptableObjectRoot); foreach (var entry in GetScriptableObjectMenuItem()) { var menuPath = entry.Item2; var paths = menuPath.Split('/'); AdvancedDropdownItem parent = scriptableObjectRoot; for (var j = 0; j < paths.Length; j++) { var path = paths[j]; if (j == paths.Length - 1) { var presetType = new PresetType(entry.Item1); var element = new PresetTypeDropdownItem(path, presetType); parent.AddChild(element); m_SearchableElements.Add(element); continue; } var group = parent.children.SingleOrDefault(c => c.name == path); if (group == null) { group = new PresetTypeDropdownItem(path); parent.AddChild(group); } parent = group; } } return(root); }
void LoadWindow() { // Do not reenter if already in progress... if (m_LoadWindowInProgress) { return; } m_LoadWindowInProgress = true; rootVisualElement.Clear(); var mainTemplate = EditorGUIUtility.Load(k_ServicesWindowUxmlPath) as VisualTreeAsset; rootVisualElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesWindowCommon); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesWindowDark : ServicesUtils.StylesheetPath.servicesWindowLight); mainTemplate.CloneTree(rootVisualElement, new Dictionary <string, VisualElement>(), null); notificationSubscriber = new UIElementsNotificationSubscriber(rootVisualElement); notificationSubscriber.Subscribe( Notification.Topic.AdsService, Notification.Topic.AnalyticsService, Notification.Topic.BuildService, Notification.Topic.CollabService, Notification.Topic.CoppaCompliance, Notification.Topic.CrashService, Notification.Topic.ProjectBind, Notification.Topic.PurchasingService ); rootVisualElement.Q <Button>(k_ProjectSettingsBtnName).clicked += () => { ServicesUtils.OpenServicesProjectSettings(GeneralProjectSettings.generalProjectSettingsPath, typeof(GeneralProjectSettings).Name); }; var dashboardClickable = new Clickable(() => { if (UnityConnect.instance.projectInfo.projectBound) { ServicesConfiguration.instance.RequestBaseDashboardUrl(baseDashboardUrl => { EditorAnalytics.SendOpenDashboardForService(new ServicesProjectSettings.OpenDashboardForService() { serviceName = k_WindowTitle, url = baseDashboardUrl, organizationId = UnityConnect.instance.projectInfo.organizationId, projectId = UnityConnect.instance.projectInfo.projectId }); ServicesConfiguration.instance.RequestCurrentProjectDashboardUrl(Application.OpenURL); }); } else { NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Warning, L10n.Tr(k_ProjectNotBoundMessage)); ServicesUtils.OpenServicesProjectSettings(GeneralProjectSettings.generalProjectSettingsPath, typeof(GeneralProjectSettings).Name); } }); rootVisualElement.Q(k_DashboardLinkName).AddManipulator(dashboardClickable); m_SortedServices = new SortedList <string, SingleService>(); bool needProjectListOfPackage = false; foreach (var service in ServicesRepository.GetServices()) { m_SortedServices.Add(service.title, service); if (service.isPackage && service.packageName != null) { needProjectListOfPackage = true; } } // Only launch the listing if a service really needs the packages list... m_PackageCollection = null; if (needProjectListOfPackage) { m_ListRequestOfPackage = Client.List(); EditorApplication.update += ListingCurrentPackageProgress; } else { FinalizeServiceSetup(); m_LoadWindowInProgress = false; } }
void UnbindProject() { if (EditorUtility.DisplayDialog(L10n.Tr(k_UnlinkProjectDialogTitle), L10n.Tr(k_UnlinkProjectDialogMessage), L10n.Tr(k_Yes), L10n.Tr(k_No))) { string cachedProjectName = UnityConnect.instance.projectInfo.projectName; UnityConnect.instance.UnbindProject(); EditorAnalytics.SendProjectServiceBindingEvent(new ProjectBindManager.ProjectBindState() { bound = false, projectName = cachedProjectName }); NotificationManager.instance.Publish(Notification.Topic.ProjectBind, Notification.Severity.Info, L10n.Tr(k_ProjectUnlinkSuccessMessage)); ReinitializeSettings(); } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(".moduleList.Releases")); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = SplendidCRM.Security.IS_ADMIN; if (!this.Visible) { return; } try { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); // 09/03/2005 Paul. DataBind is required in order for the RequiredFieldValidators to work. // 07/02/2006 Paul. The required fields need to be bound manually. reqNAME.DataBind(); reqLIST_ORDER.DataBind(); gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { lstSTATUS.DataSource = SplendidCache.List("release_status_dom"); lstSTATUS.DataBind(); Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwRELEASES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { txtNAME.Text = Sql.ToString(rdr["NAME"]); ctlListHeader.Title = L10n.Term("Releases.LBL_RELEASE") + " " + txtNAME.Text; Utils.SetPageTitle(Page, L10n.Term("Releases.LBL_MODULE_NAME") + " - " + txtNAME.Text); txtLIST_ORDER.Text = Sql.ToString(rdr["LIST_ORDER"]); try { lstSTATUS.SelectedValue = Sql.ToString(rdr["STATUS"]); } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } } } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(".moduleList." + m_sMODULE)); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } try { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCASES_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "edit"); if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AppendParameter(cmd, gDuplicateID, "ID", false); gID = Guid.Empty; } else { Sql.AppendParameter(cmd, gID, "ID", false); } con.Open(); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); } else { // 11/25/2006 Paul. If item is not visible, then don't allow save ctlEditButtons.DisableAll(); ctlEditButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS"); } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); // 10/14/2006 Paul. Prepopulate the Account when created from Account or Contact. Guid gPARENT_ID = Sql.ToGuid(Request["PARENT_ID"]); if (!Sql.IsEmptyGuid(gPARENT_ID)) { string sMODULE = String.Empty; string sPARENT_TYPE = String.Empty; string sPARENT_NAME = String.Empty; SqlProcs.spPARENT_Get(ref gPARENT_ID, ref sMODULE, ref sPARENT_TYPE, ref sPARENT_NAME); if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Accounts") { new DynamicControl(this, "ACCOUNT_ID").ID = gPARENT_ID; new DynamicControl(this, "ACCOUNT_NAME").Text = sPARENT_NAME; } else if (!Sql.IsEmptyGuid(gPARENT_ID) && sMODULE == "Contacts") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwCONTACTS" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gPARENT_ID); con.Open(); using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { new DynamicControl(this, "ACCOUNT_ID").ID = Sql.ToGuid(rdr["ID"]); new DynamicControl(this, "ACCOUNT_NAME").Text = Sql.ToString(rdr["NAME"]); } } } } } } } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; } }
public void List(int offset, int limit, string searchText = "", bool fetchDetails = true) { m_ListOperation.Start(); onListOperation?.Invoke(m_ListOperation); if (!ApplicationUtil.instance.isUserLoggedIn) { m_ListOperation.TriggerOperationError(new Error(NativeErrorCode.Unknown, L10n.Tr("User not logged in"))); return; } RefreshLocalInfos(); if (offset == 0) { RefreshProductUpdateDetails(); } AssetStoreRestAPI.instance.GetProductIDList(offset, limit, searchText, productList => { if (!productList.isValid) { m_ListOperation.TriggerOperationError(new Error(NativeErrorCode.Unknown, productList.errorMessage)); return; } if (!ApplicationUtil.instance.isUserLoggedIn) { m_ListOperation.TriggerOperationError(new Error(NativeErrorCode.Unknown, L10n.Tr("User not logged in"))); return; } onProductListFetched?.Invoke(productList, fetchDetails); if (productList.list.Count == 0) { m_ListOperation.TriggeronOperationSuccess(); return; } var placeholderPackages = new List <IPackage>(); foreach (var productId in productList.list) { // create a placeholder before fetching data from the cloud for the first time if (!m_FetchedInfos.ContainsKey(productId.ToString())) { placeholderPackages.Add(new PlaceholderPackage(productId.ToString(), PackageType.AssetStore, PackageTag.None, PackageProgress.Refreshing)); } } if (placeholderPackages.Any()) { onPackagesChanged?.Invoke(placeholderPackages); } m_ListOperation.TriggeronOperationSuccess(); if (fetchDetails) { FetchDetails(productList.list); } }); }
public static string GetTooltipByProgress(PackageProgress progress) { return(L10n.Tr(k_TooltipsByProgress[(int)progress])); }
public string GetTranslationForText(string text) { return(L10n.Tr(text)); }
private void Page_Load(object sender, System.EventArgs e) { gID = Sql.ToGuid(Request["ID"]); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_ACTIVITIES" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/27/2006 Paul. Make sure to filter relationship data based on team access rights. // 12/07/2006 Paul. This view has an alternate assigned id. Security.Filter(cmd, m_sMODULE, "list", "ACTIVITY_ASSIGNED_USER_ID"); cmd.CommandText += " and ACCOUNT_ID = @ACCOUNT_ID " + ControlChars.CrLf; cmd.CommandText += " order by DATE_DUE desc " + ControlChars.CrLf; Sql.AddParameter(cmd, "@ACCOUNT_ID", gID); if (bDebug) { RegisterClientScriptBlock("vwACCOUNTS_ACTIVITIES", Sql.ClientScriptBlock(cmd)); } try { using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); // 11/26/2005 Paul. Convert the term here so that sorting will apply. foreach (DataRow row in dt.Rows) { // 11/26/2005 Paul. Status is translated differently for each type. switch (Sql.ToString(row["ACTIVITY_TYPE"])) { // 07/15/2006 Paul. Translation of Call status remains here because it is more complex than the standard list translation. case "Calls": row["STATUS"] = L10n.Term(".call_direction_dom.", row["DIRECTION"]) + " " + L10n.Term(".call_status_dom.", row["STATUS"]); break; //case "Meetings": row["STATUS"] = L10n.Term("Meeting") + " " + L10n.Term(".meeting_status_dom.", row["STATUS"]); break; //case "Tasks" : row["STATUS"] = L10n.Term("Task" ) + " " + L10n.Term(".task_status_dom." , row["STATUS"]); break; } } vwOpen = new DataView(dt); vwOpen.RowFilter = "IS_OPEN = 1"; grdOpen.DataSource = vwOpen; vwHistory = new DataView(dt); vwHistory.RowFilter = "IS_OPEN = 0"; grdHistory.DataSource = vwHistory; // 09/05/2005 Paul. LinkButton controls will not fire an event unless the the grid is bound. //if ( !IsPostBack ) { grdOpen.SortColumn = "DATE_DUE"; grdOpen.SortOrder = "desc"; grdOpen.ApplySort(); grdOpen.DataBind(); grdHistory.SortColumn = "DATE_MODIFIED"; grdHistory.SortOrder = "desc"; grdHistory.ApplySort(); grdHistory.DataBind(); } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
private void SetupAddMenu() { var dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package from disk..."); dropdownItem.userData = "AddFromDisk"; dropdownItem.action = () => { var path = m_Application.OpenFilePanelWithFilters(L10n.Tr("Select package on disk"), "", new[] { "package.json file", "json" }); if (string.IsNullOrEmpty(path)) { return; } try { if (m_IOProxy.GetFileName(path) != "package.json") { Debug.Log(L10n.Tr("[Package Manager] Please select a valid package.json file in a package folder.")); return; } if (!m_PackageDatabase.isInstallOrUninstallInProgress) { m_PackageDatabase.InstallFromPath(m_IOProxy.GetParentDirectory(path), out var tempPackageId); PackageManagerWindowAnalytics.SendEvent("addFromDisk"); var package = m_PackageDatabase.GetPackage(tempPackageId); if (package != null) { m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject; m_PageManager.SetSelected(package); } } } catch (System.IO.IOException e) { Debug.Log($"[Package Manager] Cannot add package from disk {path}: {e.Message}"); } }; dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package from tarball..."); dropdownItem.userData = "AddFromTarball"; dropdownItem.action = () => { var path = m_Application.OpenFilePanelWithFilters(L10n.Tr("Select package on disk"), "", new[] { "Package tarball", "tgz, tar.gz" }); if (!string.IsNullOrEmpty(path) && !m_PackageDatabase.isInstallOrUninstallInProgress) { m_PackageDatabase.InstallFromPath(path, out var tempPackageId); PackageManagerWindowAnalytics.SendEvent("addFromTarball"); var package = m_PackageDatabase.GetPackage(tempPackageId); if (package != null) { m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject; m_PageManager.SetSelected(package); } } }; dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package from git URL..."); dropdownItem.userData = "AddFromGit"; dropdownItem.action = () => { var args = new InputDropdownArgs { title = L10n.Tr("Add package from git URL"), iconUssClass = "git", placeholderText = L10n.Tr("URL"), submitButtonText = L10n.Tr("Add"), onInputSubmitted = url => { if (!m_PackageDatabase.isInstallOrUninstallInProgress) { m_PackageDatabase.InstallFromUrl(url); PackageManagerWindowAnalytics.SendEvent("addFromGitUrl", url); var package = m_PackageDatabase.GetPackage(url); if (package != null) { m_PackageFiltering.currentFilterTab = PackageFilterTab.InProject; m_PageManager.SetSelected(package); } } } }; addMenu.ShowInputDropdown(args); }; dropdownItem = addMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Add package by name..."); dropdownItem.userData = "AddByName"; dropdownItem.action = () => { // Same as above, the worldBound of the toolbar is used rather than the addMenu var rect = GUIUtility.GUIToScreenRect(worldBound); var dropdown = new AddPackageByNameDropdown(m_ResourceLoader, m_PackageFiltering, m_UpmClient, m_PackageDatabase, m_PageManager, PackageManagerWindow.instance) { position = rect }; DropdownContainer.ShowDropdown(dropdown); }; }
/// <summary>Get the data to display for this subject.</summary> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> public override IEnumerable <ICustomField> GetData(Metadata metadata) { // get data Item item = this.Target; SObject obj = item as SObject; bool isObject = obj != null; bool isCrop = this.FromCrop != null; bool isSeed = this.SeedForCrop != null; bool isDeadCrop = this.FromCrop?.dead.Value == true; bool canSell = obj?.canBeShipped() == true || metadata.Shops.Any(shop => shop.BuysCategories.Contains(item.Category)); // get overrides bool showInventoryFields = true; { ObjectData objData = metadata.GetObject(item, this.Context); if (objData != null) { this.Name = objData.NameKey != null?this.Translate(objData.NameKey) : this.Name; this.Description = objData.DescriptionKey != null?this.Translate(objData.DescriptionKey) : this.Description; this.Type = objData.TypeKey != null?this.Translate(objData.TypeKey) : this.Type; showInventoryFields = objData.ShowInventoryFields ?? true; } } // don't show data for dead crop if (isDeadCrop) { yield return(new GenericField(this.Translate(L10n.Crop.Summary), this.Translate(L10n.Crop.SummaryDead))); yield break; } // crop fields if (isCrop || isSeed) { // get crop Crop crop = this.FromCrop ?? this.SeedForCrop; // get harvest schedule int harvestablePhase = crop.phaseDays.Count - 1; bool canHarvestNow = (crop.currentPhase.Value >= harvestablePhase) && (!crop.fullyGrown.Value || crop.dayOfCurrentPhase.Value <= 0); int daysToFirstHarvest = crop.phaseDays.Take(crop.phaseDays.Count - 1).Sum(); // ignore harvestable phase // add next-harvest field if (isCrop) { // calculate next harvest int daysToNextHarvest = 0; SDate dayOfNextHarvest = null; if (!canHarvestNow) { // calculate days until next harvest int daysUntilLastPhase = daysToFirstHarvest - crop.dayOfCurrentPhase.Value - crop.phaseDays.Take(crop.currentPhase.Value).Sum(); { // growing: days until next harvest if (!crop.fullyGrown.Value) { daysToNextHarvest = daysUntilLastPhase; } // regrowable crop harvested today else if (crop.dayOfCurrentPhase.Value >= crop.regrowAfterHarvest.Value) { daysToNextHarvest = crop.regrowAfterHarvest.Value; } // regrowable crop else { daysToNextHarvest = crop.dayOfCurrentPhase.Value; // dayOfCurrentPhase decreases to 0 when fully grown, where <=0 is harvestable } } dayOfNextHarvest = SDate.Now().AddDays(daysToNextHarvest); } // generate field string summary; if (canHarvestNow) { summary = this.Translate(L10n.Crop.HarvestNow); } else if (Game1.currentLocation.Name != Constant.LocationNames.Greenhouse && !crop.seasonsToGrowIn.Contains(dayOfNextHarvest.Season)) { summary = this.Translate(L10n.Crop.HarvestTooLate, new { date = this.Stringify(dayOfNextHarvest) }); } else { summary = $"{this.Stringify(dayOfNextHarvest)} ({this.Text.GetPlural(daysToNextHarvest, L10n.Generic.Tomorrow, L10n.Generic.InXDays).Tokens(new { count = daysToNextHarvest })})"; } yield return(new GenericField(this.Translate(L10n.Crop.Harvest), summary)); } // crop summary { List <string> summary = new List <string>(); // harvest summary.Add(crop.regrowAfterHarvest.Value == -1 ? this.Translate(L10n.Crop.SummaryHarvestOnce, new { daysToFirstHarvest = daysToFirstHarvest }) : this.Translate(L10n.Crop.SummaryHarvestMulti, new { daysToFirstHarvest = daysToFirstHarvest, daysToNextHarvests = crop.regrowAfterHarvest }) ); // seasons summary.Add(this.Translate(L10n.Crop.SummarySeasons, new { seasons = string.Join(", ", this.Text.GetSeasonNames(crop.seasonsToGrowIn)) })); // drops if (crop.minHarvest != crop.maxHarvest && crop.chanceForExtraCrops.Value > 0) { summary.Add(this.Translate(L10n.Crop.SummaryDropsXToY, new { min = crop.minHarvest, max = crop.maxHarvest, percent = Math.Round(crop.chanceForExtraCrops.Value * 100, 2) })); } else if (crop.minHarvest.Value > 1) { summary.Add(this.Translate(L10n.Crop.SummaryDropsX, new { count = crop.minHarvest })); } // crop sale price Item drop = GameHelper.GetObjectBySpriteIndex(crop.indexOfHarvest.Value); summary.Add(this.Translate(L10n.Crop.SummarySellsFor, new { price = GenericField.GetSaleValueString(this.GetSaleValue(drop, false, metadata), 1, this.Text) })); // generate field yield return(new GenericField(this.Translate(L10n.Crop.Summary), "-" + string.Join($"{Environment.NewLine}-", summary))); } } // crafting if (obj?.heldObject?.Value != null) { if (obj is Cask cask) { // get cask data SObject agingObj = cask.heldObject.Value; ItemQuality curQuality = (ItemQuality)agingObj.Quality; string curQualityName = this.Translate(L10n.For(curQuality)); // calculate aging schedule float effectiveAge = metadata.Constants.CaskAgeSchedule.Values.Max() - cask.daysToMature.Value; var schedule = ( from entry in metadata.Constants.CaskAgeSchedule let quality = entry.Key let baseDays = entry.Value where baseDays > effectiveAge orderby baseDays ascending let daysLeft = (int)Math.Ceiling((baseDays - effectiveAge) / cask.agingRate.Value) select new { Quality = quality, DaysLeft = daysLeft, HarvestDate = SDate.Now().AddDays(daysLeft) } ) .ToArray(); // display fields yield return(new ItemIconField(this.Translate(L10n.Item.Contents), obj.heldObject.Value)); if (cask.MinutesUntilReady <= 0 || !schedule.Any()) { yield return(new GenericField(this.Translate(L10n.Item.CaskSchedule), this.Translate(L10n.Item.CaskScheduleNow, new { quality = curQualityName }))); } else { string scheduleStr = string.Join(Environment.NewLine, ( from entry in schedule let tokens = new { quality = this.Translate(L10n.For(entry.Quality)), count = entry.DaysLeft, date = entry.HarvestDate } let str = this.Text.GetPlural(entry.DaysLeft, L10n.Item.CaskScheduleTomorrow, L10n.Item.CaskScheduleInXDays).Tokens(tokens) select $"-{str}" )); yield return(new GenericField(this.Translate(L10n.Item.CaskSchedule), this.Translate(L10n.Item.CaskSchedulePartial, new { quality = curQualityName }) + Environment.NewLine + scheduleStr)); } } else if (obj is Furniture) { string summary = this.Translate(L10n.Item.ContentsPlaced, new { name = obj.heldObject.Value.DisplayName }); yield return(new ItemIconField(this.Translate(L10n.Item.Contents), obj.heldObject.Value, summary)); } else if (obj.ParentSheetIndex == Constant.ObjectIndexes.AutoGrabber) { string readyText = this.Text.Stringify(obj.heldObject.Value is Chest output && output.items.Any()); yield return(new GenericField(this.Translate(L10n.Item.Contents), readyText)); } else { string summary = obj.MinutesUntilReady <= 0 ? this.Translate(L10n.Item.ContentsReady, new { name = obj.heldObject.Value.DisplayName }) : this.Translate(L10n.Item.ContentsPartial, new { name = obj.heldObject.Value.DisplayName, time = this.Stringify(TimeSpan.FromMinutes(obj.MinutesUntilReady)) }); yield return(new ItemIconField(this.Translate(L10n.Item.Contents), obj.heldObject.Value, summary)); } } // item if (showInventoryFields) { // needed for { List <string> neededFor = new List <string>(); // bundles if (isObject) { string[] bundles = ( from bundle in this.GetUnfinishedBundles(obj) orderby bundle.Area, bundle.DisplayName let countNeeded = this.GetIngredientCountNeeded(bundle, obj) select countNeeded > 1 ? $"{this.GetTranslatedBundleArea(bundle)}: {bundle.DisplayName} x {countNeeded}" : $"{this.GetTranslatedBundleArea(bundle)}: {bundle.DisplayName}" ).ToArray(); if (bundles.Any()) { neededFor.Add(this.Translate(L10n.Item.NeededForCommunityCenter, new { bundles = string.Join(", ", bundles) })); } } // polyculture achievement if (isObject && metadata.Constants.PolycultureCrops.Contains(obj.ParentSheetIndex)) { int needed = metadata.Constants.PolycultureCount - GameHelper.GetShipped(obj.ParentSheetIndex); if (needed > 0) { neededFor.Add(this.Translate(L10n.Item.NeededForPolyculture, new { count = needed })); } } // full shipment achievement if (isObject && GameHelper.GetFullShipmentAchievementItems().Any(p => p.Key == obj.ParentSheetIndex && !p.Value)) { neededFor.Add(this.Translate(L10n.Item.NeededForFullShipment)); } // a full collection achievement LibraryMuseum museum = Game1.locations.OfType <LibraryMuseum>().FirstOrDefault(); if (museum != null && museum.isItemSuitableForDonation(obj)) { neededFor.Add(this.Translate(L10n.Item.NeededForFullCollection)); } // yield if (neededFor.Any()) { yield return(new GenericField(this.Translate(L10n.Item.NeededFor), string.Join(", ", neededFor))); } } // sale data if (canSell && !isCrop) { // sale price string saleValueSummary = GenericField.GetSaleValueString(this.GetSaleValue(item, this.KnownQuality, metadata), item.Stack, this.Text); yield return(new GenericField(this.Translate(L10n.Item.SellsFor), saleValueSummary)); // sell to List <string> buyers = new List <string>(); if (obj?.canBeShipped() == true) { buyers.Add(this.Translate(L10n.Item.SellsToShippingBox)); } buyers.AddRange( from shop in metadata.Shops where shop.BuysCategories.Contains(item.Category) let name = this.Translate(shop.DisplayKey).ToString() orderby name select name ); yield return(new GenericField(this.Translate(L10n.Item.SellsTo), string.Join(", ", buyers))); } // gift tastes var giftTastes = this.GetGiftTastes(item, metadata); yield return(new ItemGiftTastesField(this.Translate(L10n.Item.LovesThis), giftTastes, GiftTaste.Love)); yield return(new ItemGiftTastesField(this.Translate(L10n.Item.LikesThis), giftTastes, GiftTaste.Like)); } // fence if (item is Fence fence) { string healthLabel = this.Translate(L10n.Item.FenceHealth); // health if (Game1.getFarm().isBuildingConstructed(Constant.BuildingNames.GoldClock)) { yield return(new GenericField(healthLabel, this.Translate(L10n.Item.FenceHealthGoldClock))); } else { float maxHealth = fence.isGate.Value ? fence.maxHealth.Value * 2 : fence.maxHealth.Value; float health = fence.health.Value / maxHealth; double daysLeft = Math.Round(fence.health.Value * metadata.Constants.FenceDecayRate / 60 / 24); double percent = Math.Round(health * 100); yield return(new PercentageBarField(healthLabel, (int)fence.health.Value, (int)maxHealth, Color.Green, Color.Red, this.Translate(L10n.Item.FenceHealthSummary, new { percent = percent, count = daysLeft }))); } } // recipes if (item.GetSpriteType() == ItemSpriteType.Object) { RecipeModel[] recipes = GameHelper.GetRecipesForIngredient(this.DisplayItem).ToArray(); if (recipes.Any()) { yield return(new RecipesForIngredientField(this.Translate(L10n.Item.Recipes), item, recipes, this.Text)); } } // owned if (showInventoryFields && !isCrop && !(item is Tool)) { yield return(new GenericField(this.Translate(L10n.Item.Owned), this.Translate(L10n.Item.OwnedSummary, new { count = GameHelper.CountOwnedItems(item) }))); } // see also crop bool seeAlsoCrop = isSeed && item.ParentSheetIndex != this.SeedForCrop.indexOfHarvest.Value && // skip seeds which produce themselves (e.g. coffee beans) !(item.ParentSheetIndex >= 495 && item.ParentSheetIndex <= 497) && // skip random seasonal seeds item.ParentSheetIndex != 770; // skip mixed seeds if (seeAlsoCrop) { Item drop = GameHelper.GetObjectBySpriteIndex(this.SeedForCrop.indexOfHarvest.Value); yield return(new LinkField(this.Translate(L10n.Item.SeeAlso), drop.DisplayName, () => new ItemSubject(this.Text, drop, ObjectContext.Inventory, false, this.SeedForCrop))); } }
private void SetupAdvancedMenu() { toolbarSettingsMenu.tooltip = L10n.Tr("Advanced"); var dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Project Settings"); dropdownItem.action = () => { if (!m_SettingsProxy.advancedSettingsExpanded) { m_SettingsProxy.advancedSettingsExpanded = true; m_SettingsProxy.Save(); } SettingsWindow.Show(SettingsScope.Project, PackageManagerProjectSettingsProvider.k_PackageManagerSettingsPath); PackageManagerWindowAnalytics.SendEvent("advancedProjectSettings"); }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Preferences"); dropdownItem.action = () => { SettingsWindow.Show(SettingsScope.User, PackageManagerUserSettingsProvider.k_PackageManagerUserSettingsPath); PackageManagerWindowAnalytics.SendEvent("packageManagerUserSettings"); }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.insertSeparatorBefore = true; dropdownItem.text = L10n.Tr("Manual resolve"); dropdownItem.action = () => { if (!EditorApplication.isPlaying) { m_UpmClient.Resolve(); } }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.insertSeparatorBefore = true; dropdownItem.text = L10n.Tr("Reset Packages to defaults"); dropdownItem.action = () => { EditorApplication.ExecuteMenuItem(k_ResetPackagesMenuPath); m_PageManager.Refresh(RefreshOptions.UpmListOffline); PackageManagerWindowAnalytics.SendEvent("resetToDefaults"); }; if (Unsupported.IsDeveloperBuild()) { dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.insertSeparatorBefore = true; dropdownItem.text = L10n.Tr("Reset Package Database"); dropdownItem.action = () => { PackageManagerWindow.instance?.Close(); m_PageManager.Reload(); ServicesContainer.instance.Resolve <AssetStoreCallQueue>().ClearFetchDetails(); }; dropdownItem = toolbarSettingsMenu.AddBuiltInDropdownItem(); dropdownItem.text = L10n.Tr("Reset Stylesheets"); dropdownItem.action = () => { PackageManagerWindow.instance?.Close(); m_ResourceLoader.Reset(); }; } }
private void UpdateFiltersMenuText(PageFilters filters) { var filtersSet = new List <string>(); if (filters?.isFilterSet ?? false) { if (!string.IsNullOrEmpty(filters.status)) { filtersSet.Add(L10n.Tr("Status")); } if (filters.categories?.Any() ?? false) { filtersSet.Add(L10n.Tr("Category")); } if (filters.labels?.Any() ?? false) { filtersSet.Add(L10n.Tr("Label")); } } filtersMenu.text = filtersSet.Any() ? $"{L10n.Tr("Filters")} ({string.Join(",", filtersSet.ToArray())})" : L10n.Tr("Filters"); }
private void OnAssetStoreOperationError(Error error) { Debug.Log(string.Format(L10n.Tr("Error while fetching your assets: {0}"), error.message)); onRefreshOperationError?.Invoke(error); }
void ToggleGoogleKeyStateVisibility(VisualElement fieldBlock, GooglePlayKeyState importState) { if (fieldBlock != null) { var verifiedMode = fieldBlock.Q(k_VerifiedMode); if (verifiedMode != null) { var updateGooglePlayKeyBtn = m_IapOptionsBlock.Q <Button>(k_UpdateGooglePlayKeyBtn); if (importState == GooglePlayKeyState.Verified) { if (updateGooglePlayKeyBtn != null) { updateGooglePlayKeyBtn.text = L10n.Tr(k_GooglePlayKeyBtnUpdateLabel); } verifiedMode.style.display = DisplayStyle.Flex; } else { if (updateGooglePlayKeyBtn != null) { updateGooglePlayKeyBtn.text = L10n.Tr(k_GooglePlayKeyBtnVerifyLabel); } verifiedMode.style.display = DisplayStyle.None; } } var unVerifiedMode = fieldBlock.Q(k_UnverifiedMode); if (unVerifiedMode != null) { unVerifiedMode.style.display = (importState == GooglePlayKeyState.Verified) ? DisplayStyle.None : DisplayStyle.Flex; var badFormatError = fieldBlock.Q(k_ErrorKeyFormat); if (badFormatError != null) { badFormatError.style.display = (importState == GooglePlayKeyState.InvalidFormat) ? DisplayStyle.Flex : DisplayStyle.None; } var unauthUserError = fieldBlock.Q(k_ErrorUnauthorized); if (unauthUserError != null) { unauthUserError.style.display = (importState == GooglePlayKeyState.UnauthorizedUser) ? DisplayStyle.Flex : DisplayStyle.None; } var serverError = fieldBlock.Q(k_ErrorServer); if (serverError != null) { serverError.style.display = (importState == GooglePlayKeyState.ServerError) ? DisplayStyle.Flex : DisplayStyle.None; } var cantFetchError = fieldBlock.Q(k_ErrorFethcKey); if (cantFetchError != null) { cantFetchError.style.display = (importState == GooglePlayKeyState.CantFetch) ? DisplayStyle.Flex : DisplayStyle.None; } } } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE)); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); if (!IsPostBack) { Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwIFRAMES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AddParameter(cmd, "@ID", gDuplicateID); gID = Guid.Empty; } else { Sql.AddParameter(cmd, "@ID", gID); } con.Open(); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, rdr); } } } } } else { this.AppendEditViewFields(m_sMODULE + ".EditView", tblMain, null); new DynamicControl(this, "STATUS").Checked = true; try { // 12/04/2005 Paul. Default value is Personal. new DynamicControl(this, "TYPE").SelectedValue = "personal"; } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } try { // 12/04/2005 Paul. Default value is Tab Menu and Shortcut Menu. new DynamicControl(this, "PLACEMENT").SelectedValue = "all"; } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]); Utils.SetPageTitle(Page, L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); ctlEditButtons.ErrorText = ex.Message; } }
ServicesConfiguration() { m_UnityTeamUrl = L10n.Tr("https://unity3d.com/teams"); // Should be https://unity3d.com/fr/teams in French ! PrepareAdsEnvironment(ConvertStringToServerEnvironment(UnityConnect.instance.GetEnvironment())); }
public void Fetch(long productId) { if (!ApplicationUtil.instance.isUserLoggedIn) { onFetchDetailsError?.Invoke(new UIError(UIErrorCode.AssetStoreAuthorizationError, L10n.Tr("User not logged in"))); return; } RefreshLocalInfos(); var id = productId.ToString(); var localInfo = m_LocalInfos.Get(id); if (localInfo?.updateInfoFetched == false) { RefreshProductUpdateDetails(new[] { localInfo }); } // create a placeholder before fetching data from the cloud for the first time if (!m_ProductInfos.ContainsKey(productId.ToString())) { onPackagesChanged?.Invoke(new[] { new PlaceholderPackage(productId.ToString(), string.Empty, PackageType.AssetStore) }); } FetchDetails(new[] { productId }); onProductFetched?.Invoke(productId); }
public static string GetTooltipByState(PackageState state) { return(L10n.Tr(k_TooltipsByState[(int)state])); }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(".moduleList." + m_sMODULE)); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } try { gID = Sql.ToGuid(Request["ID"]); gCAMPAIGN_ID = Sql.ToGuid(Request["CAMPAIGN_ID"]); if (!IsPostBack) { lstVariableModule.Items.Add(new ListItem(L10n.Term(".LBL_ACCOUNT"), "Accounts")); lstVariableModule.Items.Add(new ListItem(L10n.Term("EmailTemplates.LBL_CONTACT_AND_OTHERS"), "Contacts")); lstVariableModule_Changed(null, null); if (!Sql.IsEmptyGuid(gCAMPAIGN_ID)) { lstTrackerName_Bind(); } Guid gDuplicateID = Sql.ToGuid(Request["DuplicateID"]); if (!Sql.IsEmptyGuid(gID) || !Sql.IsEmptyGuid(gDuplicateID)) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMAIL_TEMPLATES_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "edit"); if (!Sql.IsEmptyGuid(gDuplicateID)) { Sql.AppendParameter(cmd, gDuplicateID, "ID", false); gID = Guid.Empty; } else { Sql.AppendParameter(cmd, gID, "ID", false); } con.Open(); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (rdr.Read()) { ctlModuleHeader.Title = Sql.ToString(rdr["NAME"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); Utils.UpdateTracker(Page, m_sMODULE, gID, ctlModuleHeader.Title); ViewState["ctlModuleHeader.Title"] = ctlModuleHeader.Title; // 03/04/2006 Paul. Name was not being set. txtNAME.Text = Sql.ToString(rdr["NAME"]); txtDESCRIPTION.Text = Sql.ToString(rdr["DESCRIPTION"]); txtSUBJECT.Text = Sql.ToString(rdr["SUBJECT"]); // 04/21/2006 Paul. Change BODY to BODY_HTML. txtBODY.Value = Sql.ToString(rdr["BODY_HTML"]); // 12/19/2006 Paul. Add READ_ONLY field. chkREAD_ONLY.Checked = Sql.ToBoolean(rdr["READ_ONLY"]); // 12/21/2006 Paul. Add Team data. TEAM_ID.Value = Sql.ToString(rdr["TEAM_ID"]); TEAM_NAME.Text = Sql.ToString(rdr["TEAM_NAME"]); } else { // 11/25/2006 Paul. If item is not visible, then don't allow save ctlEditButtons.DisableAll(); ctlEditButtons.ErrorText = L10n.Term("ACL.LBL_NO_ACCESS"); } } } sSQL = "select * " + ControlChars.CrLf + " from vwEMAIL_TEMPLATES_Attachments " + ControlChars.CrLf + " where EMAIL_TEMPLATE_ID = @EMAIL_TEMPLATE_ID" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@EMAIL_TEMPLATE_ID", gID); if (bDebug) { RegisterClientScriptBlock("vwEMAIL_TEMPLATES_Attachments", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); ctlAttachments.DataSource = dt.DefaultView; ctlAttachments.DataBind(); } } } } } else { // 12/21/2006 Paul. The team name should always default to the current user's private team. TEAM_NAME.Text = Security.TEAM_NAME; TEAM_ID.Value = Security.TEAM_ID.ToString(); } } else { // 12/02/2005 Paul. When validation fails, the header title does not retain its value. Update manually. ctlModuleHeader.Title = Sql.ToString(ViewState["ctlModuleHeader.Title"]); SetPageTitle(L10n.Term(".moduleList." + m_sMODULE) + " - " + ctlModuleHeader.Title); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; } }
public static bool RunCustomLoader(IWin32Window owner) { CfgCustomLoader cfg = GlobalConfig.Instance.Settings.CustomLoader; bool bOk; using (CustomLoaderForm frm = new CustomLoaderForm()) { frm.Icon = Program.Icon; frm.ShowInTaskbar = false; frm.Program = cfg.ProgramPath; frm.CmdLine = cfg.CmdLine; foreach (CfgInjectDll dll in cfg.InjectDlls) { frm.HookDlls.Add(dll.Path); } DialogResult dr = frm.ShowDialog(owner); if (DialogResult.OK == dr) { List <Loader.GetHookPathDelegate> getHookPaths = new List <Loader.GetHookPathDelegate>(); cfg.InjectDlls.Clear(); foreach (object o in frm.HookDlls) { string path = o as string; if (null != path) { CfgInjectDll dll = new CfgInjectDll(); dll.Path = path; cfg.InjectDlls.Add(dll); getHookPaths.Add(isProcess64Bit => dll.FullPath); } } cfg.ProgramPath = frm.Program; cfg.CmdLine = frm.CmdLine; GlobalConfig.Instance.BackUp(); bOk = Loader.Load(getHookPaths, frm.Program, frm.CmdLine); if (!bOk) { MessageBox.Show(L10n._p("Custom Loader dialog", "CustomLoader failed"), L10n._("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { bOk = true; } } return(bOk); }
protected void Page_Command(Object sender, CommandEventArgs e) { if (e.CommandName == "Save") { if (Page.IsValid) { // 11/22/2006 Paul. Fix name of custom module. string sCUSTOM_MODULE = "EMAIL_TEMPLATES"; DataTable dtCustomFields = SplendidCache.FieldsMetaData_Validated(sCUSTOM_MODULE); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); // 11/18/2007 Paul. Use the current values for any that are not defined in the edit view. DataRow rowCurrent = null; DataTable dtCurrent = new DataTable(); if (!Sql.IsEmptyGuid(gID)) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwEMAIL_TEMPLATES_Edit" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Security.Filter(cmd, m_sMODULE, "edit"); Sql.AppendParameter(cmd, gID, "ID", false); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; da.Fill(dtCurrent); if (dtCurrent.Rows.Count > 0) { rowCurrent = dtCurrent.Rows[0]; } else { // 11/19/2007 Paul. If the record is not found, clear the ID so that the record cannot be updated. // It is possible that the record exists, but that ACL rules prevent it from being selected. gID = Guid.Empty; } } } } using (IDbTransaction trn = con.BeginTransaction()) { try { // 12/19/2006 Paul. Add READ_ONLY field. // 12/29/2007 Paul. TEAM_ID is now in the stored procedure. SqlProcs.spEMAIL_TEMPLATES_Update (ref gID , false // 11/17/2005 Paul. The PUBLISH flag is no longer used in SugarCRM 3.5.0B , chkREAD_ONLY.Checked , txtNAME.Text , txtDESCRIPTION.Text , txtSUBJECT.Text , String.Empty // BODY , txtBODY.Value // BODY_HTML , Sql.ToGuid(TEAM_ID.Value) , trn ); // 12/21/2007 Paul. There can be a maximum of 10 attachments, not including attachments that were previously saved. for (int i = 0; i < 10; i++) { HtmlInputFile fileATTACHMENT = FindControl("email_attachment" + i.ToString()) as HtmlInputFile; if (fileATTACHMENT != null) { HttpPostedFile pstATTACHMENT = fileATTACHMENT.PostedFile; if (pstATTACHMENT != null) { long lFileSize = pstATTACHMENT.ContentLength; long lUploadMaxSize = Sql.ToLong(Application["CONFIG.upload_maxsize"]); if ((lUploadMaxSize > 0) && (lFileSize > lUploadMaxSize)) { throw(new Exception("ERROR: uploaded file was too big: max filesize: " + lUploadMaxSize.ToString())); } // 08/20/2005 Paul. File may not have been provided. if (pstATTACHMENT.FileName.Length > 0) { string sFILENAME = Path.GetFileName(pstATTACHMENT.FileName); string sFILE_EXT = Path.GetExtension(sFILENAME); string sFILE_MIME_TYPE = pstATTACHMENT.ContentType; Guid gNOTE_ID = Guid.Empty; // 12/29/2007 Paul. TEAM_ID is now in the stored procedure. SqlProcs.spNOTES_Update (ref gNOTE_ID , L10n.Term("EmailTemplates.LBL_EMAIL_ATTACHMENT") + ": " + sFILENAME , "EmailTemplates" // Parent Type , gID // Parent ID , Guid.Empty , String.Empty , Sql.ToGuid(TEAM_ID.Value) , trn ); Guid gNOTE_ATTACHMENT_ID = Guid.Empty; // 01/20/2006 Paul. Must include in transaction SqlProcs.spNOTE_ATTACHMENTS_Insert(ref gNOTE_ATTACHMENT_ID, gNOTE_ID, pstATTACHMENT.FileName, sFILENAME, sFILE_EXT, sFILE_MIME_TYPE, trn); Notes.EditView.LoadFile(gNOTE_ATTACHMENT_ID, pstATTACHMENT.InputStream, trn); } } } } SplendidDynamic.UpdateCustomFields(this, trn, gID, sCUSTOM_MODULE, dtCustomFields); trn.Commit(); } catch (Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); ctlEditButtons.ErrorText = ex.Message; return; } } } if (Request.AppRelativeCurrentExecutionFilePath == "~/EmailTemplates/PopupEdit.aspx") { Response.Redirect("Popup.aspx?CAMPAIGN_ID=" + gCAMPAIGN_ID.ToString() + "&ID=" + gID.ToString()); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } } else if (e.CommandName == "Cancel") { if (Request.AppRelativeCurrentExecutionFilePath == "~/EmailTemplates/PopupEdit.aspx") { Response.Redirect("Popup.aspx?CAMPAIGN_ID=" + gCAMPAIGN_ID.ToString()); } else if (Sql.IsEmptyGuid(gID)) { Response.Redirect("default.aspx"); } else { Response.Redirect("view.aspx?ID=" + gID.ToString()); } } }
private void Page_Load(object sender, System.EventArgs e) { SetPageTitle(L10n.Term(m_sMODULE + ".LBL_LIST_FORM_TITLE")); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } try { if (this.IsMobile && grdMain.Columns.Count > 0) { grdMain.Columns[0].Visible = false; } DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwPROSPECTS_List" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; // 11/24/2006 Paul. Use new Security.Filter() function to apply Team and ACL security rules. Security.Filter(cmd, m_sMODULE, "list"); ctlSearchView.SqlSearchClause(cmd); if (bDebug) { RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); } using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { // 12/14/2007 Paul. Only set the default sort if it is not already set. It may have been set by SearchView. if (String.IsNullOrEmpty(grdMain.SortColumn)) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; } grdMain.ApplySort(); grdMain.DataBind(); } } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); lblError.Text = ex.Message; } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } }
static bool CanCreateNewPolyShape() { //If inspector is locked we cannot create new PolyShape. //First created inspector seems to hold a specific semantic where //if not unlocked no matter how many inspectors are present they will //not allow the creation of new PolyShape. #if UNITY_2019_1_OR_NEWER var inspWindows = InspectorWindow.GetInspectors(); if (inspWindows.Any(x => x.isLocked)) { if (UnityEditor.EditorUtility.DisplayDialog( L10n.Tr("Inspector Locked"), L10n.Tr("To create new Poly Shape you need access to all Inspectors, which are currently locked. Do you wish to unlock all Inpsectors?"), L10n.Tr("Unlock"), L10n.Tr("Cancel"))) { foreach (var insp in inspWindows) { insp.isLocked = false; } } else { return(false); } } #else var inspectorType = typeof(Editor).Assembly.GetType("UnityEditor.InspectorWindow"); var inspWindows = Resources.FindObjectsOfTypeAll(inspectorType); var isLocked = inspectorType.GetProperty("isLocked", BindingFlags.Instance | BindingFlags.Public); bool someInspectorLocked = false; foreach (var insp in inspWindows) { if ((bool)isLocked.GetGetMethod().Invoke(insp, null)) { someInspectorLocked = true; break; } } if (someInspectorLocked == true) { if (UnityEditor.EditorUtility.DisplayDialog( "Inspector Locked", "To create new Poly Shape you need access to all Inspectors, which are currently locked. Do you wish to unlock all Inpsectors?", "Unlock", "Cancel")) { foreach (var insp in inspWindows) { isLocked.GetSetMethod().Invoke(insp, new object[] { false }); } } else { return(false); } } #endif return(true); }
private void lst_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem)lst.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; ReportFilterGrid grd = objContainer.Parent.Parent as ReportFilterGrid; if (row != null) { // 04/25/2006 Paul. We always need to translate the items, even during postback. // This is because we always build the DropDownList. // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if (row[sDATA_FIELD] != DBNull.Value) { string sID = Sql.ToString(row["ID"]); string sMODULE = Sql.ToString(row["MODULE_NAME"]); lst.ID = sDATA_FIELD + "_" + sID; try { if (sDATA_FIELD == "MODULE_NAME") { XmlDocument xml = grd.Rdl; /* * // 06/20/2006 Paul. New RdlDocument handles custom properties. * string sRelationships = RdlUtil.GetCustomProperty(xml.DocumentElement, "Relationships"); * if ( !Sql.IsEmptyString(sRelationships) ) * { * XmlDocument xmlRelationship = new XmlDocument(); * xmlRelationship.LoadXml(sRelationships); * dt = XmlUtil.CreateDataTable(xmlRelationship.DocumentElement, "Relationship", new string[] {"MODULE_NAME", "DISPLAY_NAME"}); * lst.AutoPostBack = true; * foreach ( DataRow rowRelationship in dt.Rows ) * { * lst.Items.Add(new ListItem(Sql.ToString(rowRelationship["DISPLAY_NAME"]), Sql.ToString(rowRelationship["MODULE_NAME"]))); * } * } */ } else if (sDATA_FIELD == "DATA_FIELD") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select ColumnName as NAME " + ControlChars.CrLf + " , ColumnName as DISPLAY_NAME " + ControlChars.CrLf + " from vwSqlColumns " + ControlChars.CrLf + " where ObjectName = @ObjectName " + ControlChars.CrLf + " and ColumnName not in ('ID', 'ID_C')" + ControlChars.CrLf + " and ColumnName not like '%_ID' " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; DropDownList lstMODULE_NAME = null; // 05/28/2006 Paul. Not sure why, but grd.FindFilterControl() does not work. foreach (DataGridItem itm in objContainer.Parent.Controls) { lstMODULE_NAME = itm.FindControl("MODULE_NAME" + "_" + sID) as DropDownList; if (lstMODULE_NAME != null) { break; } } string sMODULE_NAME = lstMODULE_NAME.SelectedValue; string[] arrModule = sMODULE_NAME.Split(' '); string sModule = arrModule[0]; string sTableAlias = arrModule[0]; if (arrModule.Length > 1) { sTableAlias = arrModule[1].ToUpper(); } Sql.AddParameter(cmd, "@ObjectName", "vw" + sModule); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); foreach (DataRow rowColumn in dt.Rows) { rowColumn["NAME"] = sMODULE + "." + Sql.ToString(rowColumn["NAME"]); rowColumn["DISPLAY_NAME"] = L10n.Term(sModule + ".LBL_" + Sql.ToString(rowColumn["DISPLAY_NAME"])).Replace(":", ""); } DataView vwColumns = new DataView(dt); vwColumns.Sort = "DISPLAY_NAME"; foreach (DataRowView rowColumn in vwColumns) { lst.Items.Add(new ListItem(Sql.ToString(rowColumn["DISPLAY_NAME"]), Sql.ToString(rowColumn["NAME"]))); } } } } } } catch { } try { // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. if (!objContainer.Page.IsPostBack) { lst.SelectedValue = Sql.ToString(row[sDATA_FIELD]); } } catch { } } /* * // 04/25/2006 Paul. Make sure to translate the text. * // It cannot be translated in InstantiateIn() because the Page is not defined. * foreach(ListItem itm in lst.Items ) * { * itm.Text = L10n.Term(itm.Text); * } */ } }
/// <summary>Get the data to display for this subject.</summary> public override IEnumerable <ICustomField> GetData() { // get data Item item = this.Target; SObject obj = item as SObject; bool isCrop = this.FromCrop != null; bool isSeed = this.SeedForCrop != null; bool isDeadCrop = this.FromCrop?.dead.Value == true; bool canSell = obj?.canBeShipped() == true || this.Metadata.Shops.Any(shop => shop.BuysCategories.Contains(item.Category)); // get overrides bool showInventoryFields = true; { ObjectData objData = this.Metadata.GetObject(item, this.Context); if (objData != null) { this.Name = objData.NameKey != null?L10n.GetRaw(objData.NameKey) : this.Name; this.Description = objData.DescriptionKey != null?L10n.GetRaw(objData.DescriptionKey) : this.Description; this.Type = objData.TypeKey != null?L10n.GetRaw(objData.TypeKey) : this.Type; showInventoryFields = objData.ShowInventoryFields ?? true; } } // don't show data for dead crop if (isDeadCrop) { yield return(new GenericField(this.GameHelper, L10n.Crop.Summary(), L10n.Crop.SummaryDead())); yield break; } // crop fields foreach (ICustomField field in this.GetCropFields(this.FromCrop ?? this.SeedForCrop, isSeed)) { yield return(field); } // indoor pot crop if (obj is IndoorPot pot) { Crop potCrop = pot.hoeDirt.Value.crop; if (potCrop != null) { Item drop = this.GameHelper.GetObjectBySpriteIndex(potCrop.indexOfHarvest.Value); yield return(new LinkField(this.GameHelper, L10n.Item.Contents(), drop.DisplayName, () => this.Codex.GetCrop(potCrop, ObjectContext.World))); } } // machine output foreach (ICustomField field in this.GetMachineOutputFields(obj)) { yield return(field); } // item if (showInventoryFields) { // needed for foreach (ICustomField field in this.GetNeededForFields(obj)) { yield return(field); } // sale data if (canSell && !isCrop) { // sale price string saleValueSummary = GenericField.GetSaleValueString(this.GetSaleValue(item, this.KnownQuality), item.Stack, this.Text); yield return(new GenericField(this.GameHelper, L10n.Item.SellsFor(), saleValueSummary)); // sell to List <string> buyers = new List <string>(); if (obj?.canBeShipped() == true) { buyers.Add(L10n.Item.SellsToShippingBox()); } buyers.AddRange( from shop in this.Metadata.Shops where shop.BuysCategories.Contains(item.Category) let name = L10n.GetRaw(shop.DisplayKey).ToString() orderby name select name ); yield return(new GenericField(this.GameHelper, L10n.Item.SellsTo(), string.Join(", ", buyers))); } // clothing if (item is Clothing clothing) { yield return(new GenericField(this.GameHelper, L10n.Item.CanBeDyed(), this.Stringify(clothing.dyeable.Value))); } // gift tastes IDictionary <GiftTaste, GiftTasteModel[]> giftTastes = this.GetGiftTastes(item); yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.LovesThis(), giftTastes, GiftTaste.Love, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes)); yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.LikesThis(), giftTastes, GiftTaste.Like, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes)); if (this.ProgressionMode || this.HighlightUnrevealedGiftTastes) { yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.NeutralAboutThis(), giftTastes, GiftTaste.Neutral, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes)); yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.DislikesThis(), giftTastes, GiftTaste.Dislike, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes)); yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.HatesThis(), giftTastes, GiftTaste.Hate, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes)); } } // recipes switch (item.GetItemType()) { // for ingredient case ItemType.Object: { RecipeModel[] recipes = this.GameHelper.GetRecipesForIngredient(this.DisplayItem).ToArray(); if (recipes.Any()) { yield return(new RecipesForIngredientField(this.GameHelper, L10n.Item.Recipes(), item, recipes)); } } break; // for machine case ItemType.BigCraftable: { RecipeModel[] recipes = this.GameHelper.GetRecipesForMachine(this.DisplayItem as SObject).ToArray(); if (recipes.Any()) { yield return(new RecipesForMachineField(this.GameHelper, L10n.Item.Recipes(), recipes)); } } break; } // fish if (item.Category == SObject.FishCategory) { // spawn rules yield return(new FishSpawnRulesField(this.GameHelper, L10n.Item.FishSpawnRules(), item.ParentSheetIndex, this.Text)); // fish pond data foreach (FishPondData fishPondData in Game1.content.Load <List <FishPondData> >("Data\\FishPondData")) { if (!fishPondData.RequiredTags.All(item.HasContextTag)) { continue; } int minChanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, 1 / 10f) * 100); int maxChanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, FishPond.MAXIMUM_OCCUPANCY / 10f) * 100); string preface = L10n.Building.FishPondDropsPreface(chance: L10n.Generic.Range(min: minChanceOfAnyDrop, max: maxChanceOfAnyDrop)); yield return(new FishPondDropsField(this.GameHelper, L10n.Item.FishPondDrops(), -1, fishPondData, preface)); break; } } // fence if (item is Fence fence) { string healthLabel = L10n.Item.FenceHealth(); // health if (Game1.getFarm().isBuildingConstructed(Constant.BuildingNames.GoldClock)) { yield return(new GenericField(this.GameHelper, healthLabel, L10n.Item.FenceHealthGoldClock())); } else { float maxHealth = fence.isGate.Value ? fence.maxHealth.Value * 2 : fence.maxHealth.Value; float health = fence.health.Value / maxHealth; double daysLeft = Math.Round(fence.health.Value * this.Constants.FenceDecayRate / 60 / 24); double percent = Math.Round(health * 100); yield return(new PercentageBarField(this.GameHelper, healthLabel, (int)fence.health.Value, (int)maxHealth, Color.Green, Color.Red, L10n.Item.FenceHealthSummary(percent: (int)percent, count: (int)daysLeft))); } } // movie ticket if (obj?.ParentSheetIndex == 809 && !obj.bigCraftable.Value) { MovieData movie = MovieTheater.GetMovieForDate(Game1.Date); if (movie == null) { yield return(new GenericField(this.GameHelper, L10n.MovieTicket.MovieThisWeek(), L10n.MovieTicket.NoMovieThisWeek())); } else { // movie this week yield return(new GenericField(this.GameHelper, L10n.MovieTicket.MovieThisWeek(), new IFormattedText[] { new FormattedText(movie.Title, bold: true), new FormattedText(Environment.NewLine), new FormattedText(movie.Description) })); // movie tastes IDictionary <GiftTaste, string[]> tastes = this.GameHelper.GetMovieTastes() .GroupBy(entry => entry.Value) .ToDictionary(group => group.Key, group => group.Select(p => p.Key.Name).OrderBy(p => p).ToArray()); yield return(new MovieTastesField(this.GameHelper, L10n.MovieTicket.LovesMovie(), tastes, GiftTaste.Love)); yield return(new MovieTastesField(this.GameHelper, L10n.MovieTicket.LikesMovie(), tastes, GiftTaste.Like)); yield return(new MovieTastesField(this.GameHelper, L10n.MovieTicket.DislikesMovie(), tastes, GiftTaste.Dislike)); } } // dyes yield return(new ColorField(this.GameHelper, L10n.Item.ProducesDye(), item)); // owned and times cooked/crafted if (showInventoryFields && !isCrop) { // owned yield return(new GenericField(this.GameHelper, L10n.Item.Owned(), L10n.Item.OwnedSummary(count: this.GameHelper.CountOwnedItems(item)))); // times crafted RecipeModel[] recipes = this.GameHelper .GetRecipes() .Where(recipe => recipe.OutputItemIndex == this.Target.ParentSheetIndex) .ToArray(); if (recipes.Any()) { string label = recipes.First().Type == RecipeType.Cooking ? L10n.Item.Cooked() : L10n.Item.Crafted(); int timesCrafted = recipes.Sum(recipe => recipe.GetTimesCrafted(Game1.player)); if (timesCrafted >= 0) // negative value means not available for this recipe type { yield return(new GenericField(this.GameHelper, label, L10n.Item.CraftedSummary(count: timesCrafted))); } } } // see also crop bool seeAlsoCrop = isSeed && item.ParentSheetIndex != this.SeedForCrop.indexOfHarvest.Value && // skip seeds which produce themselves (e.g. coffee beans) !(item.ParentSheetIndex >= 495 && item.ParentSheetIndex <= 497) && // skip random seasonal seeds item.ParentSheetIndex != 770; // skip mixed seeds if (seeAlsoCrop) { Item drop = this.GameHelper.GetObjectBySpriteIndex(this.SeedForCrop.indexOfHarvest.Value); yield return(new LinkField(this.GameHelper, L10n.Item.SeeAlso(), drop.DisplayName, () => this.Codex.GetCrop(this.SeedForCrop, ObjectContext.Inventory))); } }
public void SetServiceStatusValue(string serviceName, bool active) { if (m_StatusLabelByServiceName.ContainsKey(serviceName)) { m_StatusLabelByServiceName[serviceName].text = active ? L10n.Tr("ON") : L10n.Tr("OFF"); if (active) { m_StatusLabelByServiceName[serviceName].AddToClassList(k_ServiceStatusCheckedClassName); } else { m_StatusLabelByServiceName[serviceName].RemoveFromClassList(k_ServiceStatusCheckedClassName); } } }
protected virtual void OnEnable() { const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy; var autoFields = GetType().GetFields(bindingFlags) .Where(f => Attribute.IsDefined(f, typeof(AutoPopulateAttribute))) .ToArray(); foreach (var field in autoFields) { var sp = serializedObject.FindProperty(field.Name); if (sp == null) { var message = string.Format(Content.UnableToLocateFormatString, field.Name); m_AutoFieldGUIControls.Add(() => EditorGUILayout.HelpBox(message, MessageType.Error)); Debug.LogError(message); continue; } if (field.FieldType == typeof(SerializedProperty)) { field.SetValue(this, sp); m_AutoFieldGUIControls.Add(() => EditorGUILayout.PropertyField(sp, true)); } else if (field.FieldType == typeof(ReorderableList)) { var list = new ReorderableList(serializedObject, sp); var label = EditorGUIUtility.TrTextContent(sp.displayName); list.drawHeaderCallback = rect => EditorGUI.LabelField(rect, label); list.elementHeightCallback = index => { var element = list.serializedProperty.GetArrayElementAtIndex(index); return(EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing); }; var attr = field.GetCustomAttributes(typeof(AutoPopulateAttribute)).Single() as AutoPopulateAttribute; var formatString = attr.ElementFormatString; if (formatString == null) { list.drawElementCallback = (rect, index, active, focused) => { var element = list.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField( new Rect(rect) { height = EditorGUI.GetPropertyHeight(element) }, element, true ); }; } else { var noLabel = formatString == string.Empty; if (!noLabel) { formatString = L10n.Tr(formatString); } var elementLabel = new GUIContent(); list.drawElementCallback = (rect, index, active, focused) => { var element = list.serializedProperty.GetArrayElementAtIndex(index); if (!noLabel) { elementLabel.text = string.Format(formatString, index); } EditorGUI.PropertyField( new Rect(rect) { height = EditorGUI.GetPropertyHeight(element) }, element, noLabel ? GUIContent.none : elementLabel, true ); }; } list.draggable = attr.Reorderable; list.displayAdd = list.displayRemove = attr.Resizable; field.SetValue(this, list); m_AutoFieldGUIControls.Add(() => list.DoLayoutList()); } } }
private void Page_Load(object sender, System.EventArgs e) { Utils.SetPageTitle(Page, L10n.Term(m_sMODULE + ".LBL_LIST_FORM_TITLE")); // 06/04/2006 Paul. Visibility is already controlled by the ASPX page, but it is probably a good idea to skip the load. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "list") >= 0); if (!this.Visible) { return; } try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; int nACLACCESS = Security.GetUserAccess(m_sMODULE, "list"); if (nACLACCESS == ACL_ACCESS.OWNER) { Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false); } ctlSearch.SqlSearchClause(cmd); #if DEBUG Page.RegisterClientScriptBlock("SQLCode", Sql.ClientScriptBlock(cmd)); #endif using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; using (DataTable dt = new DataTable()) { da.Fill(dt); vwMain = dt.DefaultView; grdMain.DataSource = vwMain; if (!IsPostBack) { grdMain.SortColumn = "NAME"; grdMain.SortOrder = "asc"; grdMain.ApplySort(); grdMain.DataBind(); } } } } } if (!IsPostBack) { // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //Page.DataBind(); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); lblError.Text = ex.Message; } }
private void Page_Load(object sender, System.EventArgs e) { // 06/04/2006 Paul. NewRecord should not be displayed if the user does not have edit rights. this.Visible = (SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit") >= 0); if (!this.Visible) { return; } // 06/09/2006 Paul. Remove data binding in the user controls. Binding is required, but only do so in the ASPX pages. //this.DataBind(); // Need to bind so that Text of the Button gets updated. reqLAST_NAME.ErrorMessage = L10n.Term(".ERR_MISSING_REQUIRED_FIELDS") + " " + L10n.Term("Contacts.LBL_LIST_LAST_NAME") + "<br>"; reqEMAIL1.ErrorMessage = L10n.Term("Contacts.LBL_INVALID_EMAIL") + "<br>"; }