protected override async Task <List <FileDataValue> > ComputeFileDataValuesAsync(string filePath, CancellationToken cancellationToken) { Debug.Assert(await this.IsValidFileAsync(filePath), $"{filePath} should be a tsconfig.json file."); var tsconfig = await TsConfigJsonFactory.CreateAsync(filePath); Debug.Assert(!string.IsNullOrEmpty(tsconfig?.OutFile), "Should have an outfile specified."); var tsconfigFolder = Path.GetDirectoryName(filePath); var outFile = Path.Combine(tsconfigFolder, tsconfig.OutFile); var launchSettings = new PropertySettings { [LaunchConfigurationConstants.NameKey] = $"node {outFile} {NodejsConstants.TsConfigJsonFile}", [LaunchConfigurationConstants.TypeKey] = "default" }; var fileDataValues = new List <FileDataValue> { new FileDataValue( DebugLaunchActionContext.ContextTypeGuid, DebugLaunchActionContext.IsDefaultStartupProjectEntry, launchSettings, target: outFile), new FileDataValue(BuildConfigurationContext.ContextTypeGuid, outFile, null, context: "Debug", target: outFile), new FileDataValue(BuildConfigurationContext.ContextTypeGuid, outFile, null, context: "Debug", target: null) }; return(fileDataValues); }
public BehaviorParameterInfoEditor(BehaviorParamsInfo info) { // Components InitializeComponent(); UpdateAmbientColors(); // Make B. Params expandable for (int i = 1; i <= 4; i++) { var propset = new PropertySettings(); propset.DisplayName = "Param " + Conversions.ToString(i); propset.PropertyName = "Param" + Conversions.ToString(i); propset.TypeConverter = new ExpandableObjectConverter(); advPropertyGrid1.PropertySettings.Add(propset); } // Add handler for Node created advPropertyGrid1.PropertyTree.NodeMouseUp += (_, __) => SetBParamValueText(); advPropertyGrid1.PropertyTree.AfterNodeSelect += (_, __) => SetBParamValueText(); advPropertyGrid1.PropertiesLoaded += (_, __) => SetBParamValueText(); // Set Object advPropertyGrid1.SelectedObject = info; // Expand everything advPropertyGrid1.PropertyTree.ExpandAll(); }
public PropertyDefinition(string name, string typename, PropertySettings propertySettings, PropertyReadSettings readSettings) { this.name = name; this.typename = typename; this.propertySettings = propertySettings; this.readSettings = readSettings; }
public virtual IActionResult ResetProperty() { var model = new PropertySettings(); Engine.Settings.Set(model); return(RedirectWithResetMessage("Property")); }
private void FormPropertyValuesTranslationMethod2_Load(object sender, EventArgs e) { // Initialize the value mapping collection _Values.Add(ImageLayout.Center, "Center Image"); _Values.Add(ImageLayout.None, "As is"); _Values.Add(ImageLayout.Stretch, "Stretch Image"); _Values.Add(ImageLayout.Tile, "Tile Image"); _Values.Add(ImageLayout.Zoom, "Zoom Image"); // Initialize property setting object _BackImageLayoutPropertySetting = new PropertySettings("BackgroundImageLayout"); // Handling these 3 events is needed for proper value mapping _BackImageLayoutPropertySetting.ConvertFromStringToPropertyValue += new ConvertValueEventHandler(BackImageLayoutConvertFromStringToPropertyValue); _BackImageLayoutPropertySetting.ConvertPropertyValueToString += new ConvertValueEventHandler(BackImageLayoutConvertPropertyValueToString); _BackImageLayoutPropertySetting.ProvidePropertyValueList += new PropertyValueListEventHandler(BackImageLayoutProvidePropertyValueList); // Create new visual style for property node so we can see it better _BackImageLayoutPropertySetting.Style = new ElementStyle(); _BackImageLayoutPropertySetting.Style.TextColor = Color.DarkRed; // Add property setting to the grid advPropertyGrid1.PropertySettings.Add(_BackImageLayoutPropertySetting); // Set object to display properties for advPropertyGrid1.SelectedObject = buttonX1; }
public async Task <IResponseModel> AddPropertyTermsAsync(IPropertyTermsModel model) { try { var settings = new PropertySettings { Id = Guid.NewGuid(), MonthDeposit = model.MonthDeposit, MonthAdvance = model.MonthAdvance, PropertyId = model.PropertyId }; _db.Settings.Add(settings); var result = await _db.SaveChangesAsync(); _response.Status = true; _response.Message = "Property Terms added successfully."; return(_response); } catch (Exception ex) { _loggerService.Log("Add Property Terms", ex.InnerException.Message, ex.Message, ex.StackTrace); _response.Status = false; _response.Message = "Error adding property terms."; return(_response); } }
protected override Task <List <FileDataValue> > ComputeFileDataValuesAsync(string filePath, CancellationToken cancellationToken) { Debug.Assert(PackageJsonFactory.IsPackageJsonFile(filePath), $"{filePath} should be a package.json file"); var packageJson = PackageJsonFactory.Create(this.EnsureRooted(filePath)); var main = packageJson.Main; var fileDataValues = new List <FileDataValue>(); if (!string.IsNullOrEmpty(main)) { var launchSettings = new PropertySettings { [LaunchConfigurationConstants.NameKey] = $"node {main} (package.json)", [LaunchConfigurationConstants.TypeKey] = "default" }; fileDataValues.Add(new FileDataValue( DebugLaunchActionContext.ContextTypeGuid, DebugLaunchActionContext.IsDefaultStartupProjectEntry, launchSettings, target: main)); // Target has to match the name used in the debug action context so it can be found during project configuration fileDataValues.Add(new FileDataValue(DebugLaunchActionContext.ContextTypeGuid, main, null, target: main)); // Also need a null target so that can be found for the context menu when querying for build configurations. // (See Microsoft.VisualStudio.Workspace.VSIntegration.UI.FileContextActionsCommandHandlersProvider.Provider.GetActionProviderForProjectConfiguration) fileDataValues.Add(new FileDataValue(DebugLaunchActionContext.ContextTypeGuid, main, null, target: null)); } return(Task.FromResult(fileDataValues)); }
public RoomInfoController(IMediator mediator, IRoomInfoRepository roomRepository, PropertySettings settings, IIdentityService identityService) { _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); _roomRepository = roomRepository; _settings = settings; _identityService = identityService; }
public void LoadComboBoxObjComboEntries(ObjectComboList objComboList) { myObjectCombos = objComboList; // Remove old property settings foreach (var ps in AdvPropertyGrid1.PropertySettings.ToArray()) { if (ps.PropertyName == nameof(Managed3DObject.ObjectCombo) || ps.PropertyName == nameof(Managed3DObject.ObjectComboID)) { AdvPropertyGrid1.PropertySettings.Remove(ps); } } // Set property settings for ObjectCombo AdvPropertyGrid1.PropertySettings.Add(new PropertySettings(nameof(Managed3DObject.ObjectCombo)) { Visible = false }); // Set property settings for ObjectComboIndex var propSet = new PropertySettings(nameof(Managed3DObject.ObjectComboID)); var items = objComboList.Select(n => new ComboItem { Text = n.Name, Tag = n.ID.ID }).ToArray(); var editor = new ComboBoxPropertyEditor(items); editor.DropDownWidth = 300; editor.SelectedType = SelectedTypes.SelectedComboItem; propSet.ValueEditor = editor; AdvPropertyGrid1.PropertySettings.Add(propSet); }
public AdvPropGrid_ObjectPropertiesHelper(AdvPropertyGrid advPropGrid, ObjectComboList objComboList, BehaviorInfoList behaviors, string behaviorPropName, string bParamPropName) { CbEditorBParam1 = null; CbEditorBParam2 = null; CbEditorBParam3 = null; CbEditorBParam4 = null; CbEditorBehavAddr = null; AdvPropertyGrid1 = advPropGrid; myObjectCombos = objComboList; myBehaviors = behaviors; this.behaviorPropName = behaviorPropName; this.bParamPropName = bParamPropName; General.LoadBehaviorInfosIfEmpty(); General.LoadObjectCombosIfEmpty(); LoadComboBoxObjComboEntries(objComboList); // Add B. Param Editors to Property Grid var bpeditor = new ContentSelectorEditor(); bpeditor.EditorCreated += ContentSelectorEditor_EditorCreated; bpeditor.EditorCreating += ContentSelectorEditor_EditorCreating; var bp1PropSet = new PropertySettings(bParamPropName + Conversions.ToString(1)); var bp2PropSet = new PropertySettings(bParamPropName + Conversions.ToString(2)); var bp3PropSet = new PropertySettings(bParamPropName + Conversions.ToString(3)); var bp4PropSet = new PropertySettings(bParamPropName + Conversions.ToString(4)); bp1PropSet.ValueEditor = bpeditor; bp2PropSet.ValueEditor = bpeditor; bp3PropSet.ValueEditor = bpeditor; bp4PropSet.ValueEditor = bpeditor; AdvPropertyGrid1.PropertySettings.Add(bp1PropSet); AdvPropertyGrid1.PropertySettings.Add(bp2PropSet); AdvPropertyGrid1.PropertySettings.Add(bp3PropSet); AdvPropertyGrid1.PropertySettings.Add(bp4PropSet); // Add Behavior Address Editor to Property Grid var behavaddreditor = new ContentSelectorEditor(); behavaddreditor.EditorCreating += ContentSelectorEditor_EditorCreating; behavaddreditor.EditorCreated += ContentSelectorEditor_EditorCreated; var behavaddrPropSet = new PropertySettings(behaviorPropName); behavaddrPropSet.ValueEditor = behavaddreditor; AdvPropertyGrid1.PropertySettings.Add(behavaddrPropSet); // Add Position/Rotation Editors (NumberInputEditor for Increment/Decrement) foreach (string l in new[] { "X", "Y", "Z" }) { foreach (string e in new[] { "Position", "Rotation" }) { var xyzeditor = new PropertyIntegerEditorX() { ShowUpDownButton = true, MinValue = short.MinValue, MaxValue = short.MaxValue }; var xyzPropSet = new PropertySettings(e + l); xyzPropSet.ValueEditor = xyzeditor; AdvPropertyGrid1.PropertySettings.Add(xyzPropSet); } } }
protected override async Task <List <FileDataValue> > ComputeFileDataValuesAsync(string filePath, CancellationToken cancellationToken) { var outFile = await DetermineOutFileAsync(filePath); if (string.IsNullOrEmpty(outFile)) { return(new List <FileDataValue>(0)); } var fileDataValues = new List <FileDataValue>(); if (!string.IsNullOrEmpty(outFile)) { var launchSettings = new PropertySettings { [LaunchConfigurationConstants.NameKey] = $"node {outFile}", [LaunchConfigurationConstants.TypeKey] = "default" }; fileDataValues.Add(new FileDataValue( DebugLaunchActionContext.ContextTypeGuid, DebugLaunchActionContext.IsDefaultStartupProjectEntry, launchSettings, target: outFile)); fileDataValues.Add( new FileDataValue(BuildConfigurationContext.ContextTypeGuid, outFile, null, context: "Debug", target: outFile)); fileDataValues.Add( new FileDataValue(BuildConfigurationContext.ContextTypeGuid, outFile, null, context: "Debug", target: null)); } return(fileDataValues); }
public async Task PropertyService_AddPropertyTermsAsync_Test() { try { using (db = new DatabaseContext(dbContextOpt.Options)) { Guid PropertyId = Guid.Parse("D95FF806-C50A-4A54-A476-02D350B2C6FA"); var propertyTerms = new PropertyTermsModel { PropertyId = PropertyId, MonthDeposit = 2, MonthAdvance = 1 }; var settings = new PropertySettings { Id = Guid.NewGuid(), MonthDeposit = propertyTerms.MonthDeposit, MonthAdvance = propertyTerms.MonthAdvance, PropertyId = propertyTerms.PropertyId }; db.Settings.Add(settings); var result = await db.SaveChangesAsync(); Assert.IsTrue(result == 1); } } catch (Exception ex) { logService.Log("Add Property Terms", ex.InnerException.Message, ex.Message, ex.StackTrace); Assert.Fail(); } }
internal void AssertProperty( Property property, PropertySettings expectedPropertySettings) { property.Should().NotBeNull(); expectedPropertySettings.Should().NotBeNull(); property.Name.Should().Be(expectedPropertySettings.Name); property.Element.Should().NotBeNull(); }
public MainFrm() { InitializeComponent(); #region add properitygrid // Customize AntiAlias property appearance _AntiAliasPropertySetting = new PropertySettings("AntiAlias"); // Specifies that this setting is attached to AntiAlias property _AntiAliasPropertySetting.Description = "This is custom description, help text, for the AntiAlias property"; _AntiAliasPropertySetting.DisplayName = "AntiAliasCustomName"; // Change property name that is displayed in property grid // Create new visual style for property ElementStyle style = new ElementStyle(); style.BackColor = Color.WhiteSmoke; style.BackColor2 = Color.LightGoldenrodYellow; style.BackColorGradientAngle = 90; style.TextColor = Color.Brown; _AntiAliasPropertySetting.Style = style; // Adds property setting to the grid advPropertyGrid1.PropertySettings.Add(_AntiAliasPropertySetting); // Set object to display properties for //advPropertyGrid1.SelectedObject = buttonItem29; // Create new button item //ButtonItem button = new ButtonItem("helpPanel", "帮助"); //button.ButtonStyle = eButtonStyle.TextOnlyAlways; //button.OptionGroup = "helpPanel"; // This will automatically manage the Check property so only one button in group is checked //button.OptionGroupChanging += new OptionGroupChangingEventHandler(ButtonOptionGroupChanging); //// This is how to access the Property Grid toolbar and add new button to it //advPropertyGrid1.Toolbar.Items.Add(button); advPropertyGrid1.HelpType = ePropertyGridHelpType.Panel; // Create save button item ButtonItem btnSave = new ButtonItem("btnSave", "保 存"); btnSave.ButtonStyle = eButtonStyle.TextOnlyAlways; //btnSave.Image = ((System.Drawing.Image)(resources.GetObject("SaveButton.png"))); btnSave.OptionGroup = "helpPanel"; // This will automatically manage the Check property so only one button in group is checked btnSave.OptionGroupChanging += new OptionGroupChangingEventHandler(ButtonOptionGroupChanging); btnSave.Click += new EventHandler(btnSave_Click); // This is how to access the Property Grid toolbar and add new button to it advPropertyGrid1.Toolbar.Items.Add(btnSave); // Create second button //button = new ButtonItem("helpTooltip", "SuperTooltip Help"); //button.ButtonStyle = eButtonStyle.TextOnlyAlways; //button.OptionGroup = "helpPanel"; //button.Checked = true; // This is default value //button.OptionGroupChanging += new OptionGroupChangingEventHandler(ButtonOptionGroupChanging); //advPropertyGrid1.Toolbar.Items.Add(button); // Apply layout changes so items become visible advPropertyGrid1.Toolbar.RecalcLayout(); #endregion }
private void LoadPropertiesToEdit(object obj) { AdvPropertyGrid1.SelectedObject = null; AdvPropertyGrid1.PropertySettings.Clear(); if (obj is TextGroupInfo) { var piEncodingString = new PropertySettings(nameof(TextGroupInfo.EncodingString)) { DisplayName = "Encoding", ValueEditor = new PropertyValueEditors.TextEncodingEditor(new[] { TextGroupInfo.ENCODING_STRING_M64, TextGroupInfo.ENCODING_STRING_ASCII }) }; AdvPropertyGrid1.PropertySettings.Add(piEncodingString); var piEncoding = new PropertySettings(nameof(TextTableGroupInfo.Encoding)) { Visible = false }; AdvPropertyGrid1.PropertySettings.Add(piEncoding); if (obj is TextTableGroupInfo) { var piData = new PropertySettings(nameof(TextTableGroupInfo.Data)) { TypeConverter = new ExpandableObjectConverter() }; AdvPropertyGrid1.PropertySettings.Add(piData); var piDialogData = new PropertySettings(nameof(TextTableGroupInfo.DialogData)) { TypeConverter = new ExpandableObjectConverter() }; AdvPropertyGrid1.PropertySettings.Add(piDialogData); var piSegmented = new PropertySettings(nameof(TextTableGroupInfo.Segmented)) { TypeConverter = new ExpandableObjectConverter() }; AdvPropertyGrid1.PropertySettings.Add(piSegmented); var piTableType = new PropertySettings(nameof(TextTableGroupInfo.TableType)) { Visible = false }; AdvPropertyGrid1.PropertySettings.Add(piTableType); } else if (obj is TextArrayGroupInfo) { var piTexts = new PropertySettings(nameof(TextArrayGroupInfo.Texts)) { Visible = false }; AdvPropertyGrid1.PropertySettings.Add(piTexts); } LoadTextArrayItems((TextGroupInfo)obj); } AdvPropertyGrid1.SelectedObject = obj; AdvPropertyGrid1.ExpandAllGridItems(); }
public UIObjectPropertyGrid() { InitializeComponent(); foreach (var prop in m_resProperties) { PropertySettings propertySetting = new PropertySettings(prop); propertySetting.UITypeEditor = new ImageResourceEditor(); m_propertyGrid.PropertySettings.Add(propertySetting); } }
public virtual IActionResult Property() { _cache.Remove(typeof(PropertySettings).ToString()); PropertySettings model = Engine.Settings.Property; if (model == null) { model = new PropertySettings(); } return(View(model)); }
public virtual async Task <IActionResult> List(PropertyListModel model, string viewName = "_List_Property") { PropertySettings propertySettings = Engine.Settings.Property; if (!propertySettings.Enabled || !propertySettings.ShowList) { return(NotFound()); } model = await _property.GetPropertiesAsync(model); return(View(viewName, model)); }
private void FormPropertyValueEditors_Load(object sender, EventArgs e) { // Property setting applies to property name: TrackBarDynamic PropertySettings propertySetting = new PropertySettings("TrackBarDynamic"); // Assign our custom property value editor propertySetting.ValueEditor = new TrackBarPropertyEditor(0, 100); advPropertyGrid1.PropertySettings.Add(propertySetting); CustomClass custom = new CustomClass(); custom.PropertyChanged += new PropertyChangedEventHandler(CustomClassPropertyChanged); advPropertyGrid1.SelectedObject = custom; }
/// <summary> /// creating and displaying the properties of car. /// </summary> private void DisplayProperties() { var propertyName = "Max Speed"; var propertyValue = Car.MaxSpeed.ToString(); CarMaxSpeedProperties = new PropertySettings(propertyName, propertyValue, true); PropertyPanel.Children.Add(CarMaxSpeedProperties); var propertyName2 = "Model"; var propertyValue2 = Car.Model.Name; CarModelProperties = new PropertySettings(propertyName2, propertyValue2, false); CarModelProperties.PreviewTextInput -= CarModelProperties.NumberValidationTextBox; PropertyPanel.Children.Add(CarModelProperties); }
private void displayProperties() { var propertyName = "Available Cars"; var propertyValue = Building.AvailableCars.ToString(); AvailableCarsProperty = new PropertySettings(propertyName, propertyValue, true); PropertyPanel.Children.Add(AvailableCarsProperty); var propertyName2 = "Model"; var propertyValue2 = Building.Model.Name; CarModelProperties = new PropertySettings(propertyName2, propertyValue2, false); CarModelProperties.PreviewTextInput -= CarModelProperties.NumberValidationTextBox; PropertyPanel.Children.Add(CarModelProperties); }
public virtual IActionResult Property(PropertySettings model) { try { Engine.Settings.Set(model); SaveMessage = "Settings saved!"; MessageType = AlertType.Success; } catch (Exception ex) { SaveMessage = "Error saving: " + ex.Message; MessageType = AlertType.Danger; } return(View(model)); }
public override void LoadPages() { //SSITOPCServer.Instance.RefreshDatas(true); //SSITOPCGroup.Instance.RefreshDatas(true); //SSITOPCTag.Instance.RefreshDatas(true); this.Text = "系统OPC关联配置"; PropertySettings ps = Settings; base.LoadPages(ps, ""); this.WindowState = System.Windows.Forms.FormWindowState.Maximized; //判断权限 //this.AllowEdit = SSIT.UserManager.Security.CheckLoginAndRight(UserManager.RoleSettings.MyRoleRight.OPCSetting_Edit); this.AllowEdit = true; }
public void PropertyService_AddPropertyTermsADO_Test() { try { using (SqlConnection con = new SqlConnection(connectionString)) { Guid PropertyId = Guid.Parse("1897C7A7-EB70-4A11-9EF1-C6714DF34D5A"); var propertyTerms = new PropertyTermsModel { PropertyId = PropertyId, MonthDeposit = 2, MonthAdvance = 1 }; var settings = new PropertySettings { Id = Guid.NewGuid(), MonthDeposit = propertyTerms.MonthDeposit, MonthAdvance = propertyTerms.MonthAdvance, PropertyId = propertyTerms.PropertyId }; SqlCommand cmd = new SqlCommand("sp_AddPropertyTerms", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", settings.Id); cmd.Parameters.AddWithValue("@PropertyId", settings.PropertyId); cmd.Parameters.AddWithValue("@MonthAdv", settings.MonthAdvance); cmd.Parameters.AddWithValue("@MonthDep", settings.MonthDeposit); con.Open(); cmd.ExecuteNonQuery(); con.Close(); //Assert.IsTrue(rows > 1); } } catch (Exception ex) { logService.Log("Add Property Terms", ex.InnerException.Message, ex.Message, ex.StackTrace); Assert.Fail(); } }
private void FormPropertyAppearance_Load(object sender, EventArgs e) { // Customize AntiAlias property appearance _AntiAliasPropertySetting = new PropertySettings("AntiAlias"); // Specifies that this setting is attached to AntiAlias property _AntiAliasPropertySetting.Description = "This is custom description, help text, for the AntiAlias property"; _AntiAliasPropertySetting.DisplayName = "AntiAliasCustomName"; // Change property name that is displayed in property grid // Create new visual style for property ElementStyle style = new ElementStyle(); style.BackColor = Color.WhiteSmoke; style.BackColor2 = Color.LightGoldenrodYellow; style.BackColorGradientAngle = 90; style.TextColor = Color.Brown; _AntiAliasPropertySetting.Style = style; // Adds property setting to the grid advPropertyGrid1.PropertySettings.Add(_AntiAliasPropertySetting); // Set object to display properties for advPropertyGrid1.SelectedObject = buttonX1; }
public virtual async Task <IActionResult> List(PropertyListModel model, string viewName = "_List_Property") { var propertySettings = Engine.Settings.Property; if (!propertySettings.Enabled || !propertySettings.ShowList) { return(NotFound()); } model.PublishStatus = ContentStatus.Published; model = await _property.GetPropertiesAsync(model); model.Locations = await _property.GetLocationsAsync(model); model.CentrePoint = GeoCalculations.GetCentralGeoCoordinate(model.Locations.Select(p => new GeoCoordinate(p.Latitude, p.Longitude))); PropertySettings settings = Engine.Settings.Property; model.AvailableTypes = settings.GetListingTypes(); model.PlanningTypes = settings.GetPlanningTypes(); return(View(viewName, model)); }
internal void ValidatePropertySettings( PropertySettings propertySettings, int index) { if (propertySettings == null) { this.Logger.LogError("Null property settings on index {0}", index); throw new ArgumentNullException($"The argument PropertySettings with index {index} is null!"); } if (string.IsNullOrEmpty(propertySettings.Name)) { this.Logger.LogError("Null or empty property settings name on index {0}", index); throw new ArgumentNullException($"The Name property of argument PropertySettings with index {index} is null!"); } if (string.IsNullOrEmpty(propertySettings.Selector)) { this.Logger.LogError("Null or empty property settings selector on index {0}", index); throw new ArgumentNullException($"The Selector property of argument PropertySettings with index {index} is null!"); } }
public virtual Property ScrapeProperty( IElement element, PropertySettings propertySettings) { this.Logger.LogInformation( "Scraping property {0} with selector {1}...", propertySettings.Name, propertySettings.Selector); var property = new Property { Name = propertySettings.Name, Element = element.QuerySelector(propertySettings.Selector) }; this.Logger.LogInformation("Sending event property scraped..."); var e = new PropertyScrapedEventArgs { Settings = propertySettings, ScrapedProperty = property }; this.PropertyScraped?.Invoke(this, e); return(property); }
public BasePropertyController() : base() { _propertySettings = Engine.Settings.Property; }
public static void Main(string[] args) { System.Net.ServicePointManager.ServerCertificateValidationCallback = (s, ce, ch, p) => true; // Load services var initialSettingsProvider = new PropertySettings(); initialSettingsProvider.Load(); // Default settings provider is the Windows application settings implementation ServiceLocator.Settings = initialSettingsProvider; // DEBUG SETTINGS - Force first run //ServiceLocator.Settings["Analytics"] = false; //ServiceLocator.Settings["FirstRun"] = true; string PiwikURL = AESEncryption.Decrypt((string)ServiceLocator.Settings["Piwik"]); string SentryURL = AESEncryption.Decrypt((string)ServiceLocator.Settings["Sentry"]); #if DEBUG string sentryEnvironment = "debug"; #else string sentryEnvironment = "release"; #endif Version version = Assembly.GetExecutingAssembly().GetName().Version; string gameVersion = $"{version.Major}.{version.Minor}.{version.Build}"; var userID = (string)ServiceLocator.Settings["UserID"]; // Generate or load user ID for Piwik Guid userGUID; if (!Guid.TryParse(userID, out userGUID)) { userGUID = Guid.NewGuid(); } // Save user GUID ServiceLocator.Settings["UserID"] = userGUID.ToString(); Platform runningPlatform = PlatformDetection.RunningPlatform(); string platformVersion = PlatformDetection.GetVersionName(); // Load Sentry service if ((bool)ServiceLocator.Settings["Analytics"] || (bool)ServiceLocator.Settings["FirstRun"]) { ServiceLocator.ErrorReporting = new SentryErrorReporting( SentryURL, sentryEnvironment, gameVersion, userGUID.ToString(), runningPlatform, platformVersion); } int PiwikAppID = 3; // Load Piwik service if ((bool)ServiceLocator.Settings["Analytics"] || (bool)ServiceLocator.Settings["FirstRun"]) { ServiceLocator.Analytics = new PiwikAnalytics( PiwikAppID, PiwikURL, runningPlatform, platformVersion, DisplayDevice.Default.Width, DisplayDevice.Default.Height, gameVersion, userGUID.ToString(), "http://turntninja"); } ServiceLocator.Directories = new DirectoryHandler(); var directoryHandler = ServiceLocator.Directories; //set application path directoryHandler.AddPath("Application", AppDomain.CurrentDomain.BaseDirectory); //set base path if (Directory.Exists(directoryHandler.Locate("Application", "Content"))) { directoryHandler.AddPath("Base", directoryHandler["Application"].FullName); } else if (Directory.Exists(directoryHandler.Locate("Application", @"../../src/TurntNinja/Content"))) { directoryHandler.AddPath("Base", directoryHandler.Locate("Application", @"../../src/TurntNinja")); } else { throw new Exception("Couldn't find resource folder location"); } directoryHandler.AddPath("AppData", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), (string)ServiceLocator.Settings["AppDataFolderName"])); directoryHandler.AddPath("Resources", Path.Combine(directoryHandler["Base"].FullName, "Content")); directoryHandler.AddPath("Fonts", Path.Combine(directoryHandler["Resources"].FullName, @"Fonts")); directoryHandler.AddPath("Shaders", Path.Combine(directoryHandler["Resources"].FullName, @"Shaders")); directoryHandler.AddPath("Images", Path.Combine(directoryHandler["Resources"].FullName, @"Images")); directoryHandler.AddPath("Crash", Path.Combine(directoryHandler["AppData"].FullName, "CrashLogs")); directoryHandler.AddPath("BundledSongs", Path.Combine(directoryHandler["Resources"].FullName, @"Songs")); directoryHandler.AddPath("ProcessedSongs", Path.Combine(directoryHandler["AppData"].FullName, @"Processed Songs")); if (!Directory.Exists(directoryHandler["AppData"].FullName)) { Directory.CreateDirectory(directoryHandler["AppData"].FullName); } if (!Debugger.IsAttached) { //initialise crash reporter _crashReporter = new CrashReporter(directoryHandler["Crash"].FullName); //attach exception handlers AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; } // If we are not running on a windows platform, use the JsonSettings backend if (PlatformDetection.RunningPlatform() != Platform.Windows) { ServiceLocator.Settings = new JsonSettings(initialSettingsProvider, directoryHandler.Locate("AppData", "settings.json")); ServiceLocator.Settings.Load(); } //init logging Splat.DependencyResolverMixins.RegisterConstant(Splat.Locator.CurrentMutable, new SimpleLogger(directoryHandler["Application"].FullName, Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location) + ".log") { Level = Splat.LogLevel.Debug }, typeof(Splat.ILogger)); int rX = (int)ServiceLocator.Settings["ResolutionX"]; int rY = (int)ServiceLocator.Settings["ResolutionY"]; int FSAASamples = (int)ServiceLocator.Settings["AntiAliasingSamples"]; GraphicsMode graphicsMode = new GraphicsMode(32, 32, 8, FSAASamples, GraphicsMode.Default.AccumulatorFormat, 3); // Choose right OpenGL version for mac int major = 3; int minor = 0; if (PlatformDetection.RunningPlatform() == Platform.MacOSX) { major = 4; } if ((bool)ServiceLocator.Settings["Analytics"]) { ServiceLocator.Analytics.TrackApplicationStartup(); } using (GameController game = new GameController(ServiceLocator.Settings, rX, rY, graphicsMode, "Turnt Ninja", major, minor, directoryHandler)) { game.Title = "Turnt Ninja"; // Only set icon if we're on Windows or Linux if (runningPlatform != Platform.MacOSX) { game.Icon = new System.Drawing.Icon(directoryHandler.Locate("Images", "icon.ico")); } game.Run(); } }