async void deletefile(JSONFile jfile) { HttpClient c = new HttpClient(HAPSettings.certfilter); c.DefaultRequestHeaders.Cookie.Add(new HttpCookiePairHeaderValue("token", HAPSettings.CurrentToken[0])); c.DefaultRequestHeaders.Cookie.Add(new HttpCookiePairHeaderValue(HAPSettings.CurrentToken[2], HAPSettings.CurrentToken[1])); c.DefaultRequestHeaders.Accept.Add(new Windows.Web.Http.Headers.HttpMediaTypeWithQualityHeaderValue("application/json")); HttpStringContent sc = new HttpStringContent("[ \"" + jfile.Path.Replace("../Download/", "").Replace("\\", "/") + "\" ]", Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json"); string sc1 = null; MessageDialog mes = new MessageDialog("Are you sure you want to delete?\n\n" + jfile.Name); mes.Commands.Add(new UICommand("Yes")); mes.Commands.Add(new UICommand("No")); mes.DefaultCommandIndex = 0; IUICommand x = await mes.ShowAsync(); try { var cr = await c.PostAsync(new Uri(HAPSettings.CurrentSite.Address, "./api/myfiles/delete" + "?" + DateTime.Now.Ticks), sc); sc1 = await cr.Content.ReadAsStringAsync(); } catch (Exception ex) { MessageDialog mes2 = new MessageDialog("Error Deleting file\n\n" + ex.ToString()); mes2.Commands.Add(new UICommand("OK")); mes2.DefaultCommandIndex = 0; mes2.ShowAsync(); } var ignored2 = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, reload); }
static async Task Main(string[] args) { Console.WriteLine("Hello World!"); CancellationTokenSource cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, a) => { a.Cancel = true; cts.Cancel(); }; string configurationFilePath; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { configurationFilePath = @"/share/JAVS.Hypnos.Pi.HDMIController/PiSettings.json"; } else { configurationFilePath = @"./PiSettings.json"; } _piSettings = await JSONFile.LoadAsync <PiSettings>(configurationFilePath); FaceDetectionService faceDetectionService = new FaceDetectionService(_piSettings); await faceDetectionService.Init(); faceDetectionService.ListenFor <FaceDetectionStats>((stats) => { Console.WriteLine("Face Change."); string output = ""; if (stats.IsZeroFaceAlert) { output = @"vcgencmd display_power 0".Bash(); } else if (stats.FaceRectangles?.Count > 0) { output = @"xset s reset"; output += @"vcgencmd display_power 1".Bash(); } Console.WriteLine(output); //if (stats.IsZeroFaceAlert) // output = @"echo 'standby 0' | cec-client -s -d 1".Bash(); //else if(stats.FaceRectangles?.Count > 0) // output = @"echo 'standby 1' | cec-client -s -d 1".Bash(); }); await faceDetectionService.Join(new JoinGroupRequest() { IsHDMIController = true, Password = "******" }); while (!cts.IsCancellationRequested) { } }
void Loaded() { //Dont create empty config files if (typeof(ConfigData).GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic).Length > 0) { _settingsFile = new JSONFile <ConfigData>($"{Name}", ConfigLocation.Config, extension: ".cfg"); } }
public void TestMethod1() { var jsonFile = new JSONFile(); jsonFile.ImportJSONFile(@"C:\projects\sample-yaml-convert-to-json\sampl-yaml-to-json\Test-sampl-yaml-to-json\test-savetofile-input.json"); jsonFile.SaveToFile(@"C:\projects\sample-yaml-convert-to-json\sampl-yaml-to-json\Test-sampl-yaml-to-json\test-savetofile-result.json"); return; }
static async Task Main(string[] args) { _faceDetectionConfiguration = new FaceDetectionConfiguration() { ScaleFactor = 1.2, MinimumNeighbors = 5, MinimumFaceWidth = 20, MinimumFaceHeight = 20, FaceTimeoutInSeconds = 5 }; Console.WriteLine("Hello World!"); CancellationTokenSource cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, a) => { a.Cancel = true; cts.Cancel(); }; string configurationFilePath; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { configurationFilePath = @"/share/JAVS.Hypnos.Pi.Detector/PiSettings.json"; } else { configurationFilePath = @"./PiSettings.json"; } _piSettings = await JSONFile.LoadAsync <PiSettings>(configurationFilePath); FaceDetectionService faceDetectionService = new FaceDetectionService(_piSettings); await faceDetectionService.Init(); faceDetectionService.ListenFor <ClientGroupStats>((stats) => { foreach (var group in stats.ConnectedClientGroupCounts) { Console.WriteLine($"{group.Key}: {group.Value} Clients Connected."); _clientGroupStats = stats; } }); faceDetectionService.ListenFor <FaceDetectionConfiguration>((config) => { _faceDetectionConfiguration = config; }); await faceDetectionService.Join(new JoinGroupRequest() { IsDetector = true, Password = "******" }); RunFacialDetection(cts, faceDetectionService); }
void Loaded() { _settingsFile = new JSONFile <ConfigData>($"{Name}", ConfigLocation.Config, extension: ".cfg"); PlayerData = new PlayerDataController <SlotPlayerData>(); if (lang_en.Count > 0) { lang.RegisterMessages(lang_en, this); //Setup lang now by default in case it is needed } }
private void Button_Click(object sender, RoutedEventArgs e) { JSONFile file = ((JSONFile)fileGridView.SelectedItem); pro.Visibility = Windows.UI.Xaml.Visibility.Visible; pro.Value = 0; loading.IsIndeterminate = true; downloadfile(file); }
void Init() { _plugin = this; _settingsFile = new JSONFile <ConfigData>("RespawnBalance", ConfigLocation.Config); BagField = typeof(SleepingBag).GetField("unlockTime", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); if (BagField == null) { PrintError("Warning! Didnt find bag field!"); } }
public void CanReadJSONReader() { var jsonFile = new JSONFile(FullFilePath); var testDataKey = "Animals"; var testDataIndex = 0; var jsonReader = CreateJSONReader(jsonFile, testDataKey, testDataIndex); Assert.Equals(jsonReader, "Dog"); }
// ================================================================================= // Import // --------------------------------------------------------------------------------- public static bool Import(iCS_VisualScriptData storage, string path) { // -- Decode JSON string. -- JObject root = JSONFile.Read(path); if (root == null || root.isNull) { Debug.LogWarning("iCanScript: Import failure: JSON file corrupted."); return(false); } // -- Extract version information. -- var cache = new iCS_VisualScriptData(); JNumber majorVersion = root.GetValueFor("Storage.MajorVersion") as JNumber; JNumber minorVersion = root.GetValueFor("Storage.MinorVersion") as JNumber; JNumber bugFixVersion = root.GetValueFor("Storage.BugFixVersion") as JNumber; cache.MajorVersion = (int)majorVersion.value; cache.MinorVersion = (int)minorVersion.value; cache.BugFixVersion = (int)bugFixVersion.value; // -- Extract visual script attributes. -- JBool isEditorScript = root.GetValueFor("Storage.IsEditorScript") as JBool; JString csharpFileName = root.GetValueFor("Storage.CSharpFileName") as JString; JBool baseTypeOverride = root.GetValueFor("Storage.BaseTypeOverride") as JBool; JString baseType = root.GetValueFor("Storage.BaseType") as JString; JString sourceFileGUID = root.GetValueFor("Storage.SourceFileGUID") as JString; cache.IsEditorScript = isEditorScript.value; cache.CSharpFileName = csharpFileName.value; cache.BaseTypeOverride = baseTypeOverride.value; cache.BaseType = baseType.value; cache.SourceFileGUID = sourceFileGUID.value; // -- Extract engine objects. -- JArray engineObjects = root.GetValueFor("Storage.EngineObjects") as JArray; if (engineObjects == null) { Debug.LogWarning("iCanScript: Import failure: Unable to locate engine array."); return(false); } cache.EngineObjects.Capacity = engineObjects.value.Length; foreach (var eobj in engineObjects.value) { var newObj = ReadEngineObject(eobj as JObject); if (newObj != null) { cache.EngineObjects.Add(newObj); } else { Debug.LogWarning("iCanScript: Unable to create instance of iCS_EngineObject"); } } cache.CopyTo(storage); return(true); }
// Use this for initialization void Start() { scriptScreenShot = gameObject.GetComponent <ScreenShot>(); scriptJsonFile = gameObject.GetComponent <JSONFile>(); scriptBB = new List <BoundingBox>(); objets = GameObject.FindGameObjectsWithTag("BoundingObject"); for (int i = 0; i < objets.Length; ++i) { scriptBB.Add(objets[i].GetComponent <BoundingBox>()); } }
public PlayerDataController(string filename = null) { if (filename == null) { return; } _file = new JSONFile <Dictionary <string, T> >(filename); _timer = _plugin.timer.Every(120f, () => { _file.Save(); }); }
// ======================================================================== /// Save and Update the package information. public void Save() { // -- Create the project folders (if not existing). -- var projectPath = GetRelativePackageFolder(true); var separator = string.IsNullOrEmpty(projectPath) ? "" : "/"; // -- Update version information. -- myVersion = Version.Current.ToString(); // -- Save the project information. -- var fileName = GetFileName(); var filePath = Folder.AssetToAbsolutePath(projectPath + separator + fileName); JSONFile.PrettyWrite(filePath, this); }
// ================================================================================= /// Load the package file from disk. /// /// @param absolutePath The absolute path of the project file. /// @info The active project set to the newly loaded project. /// public static PackageInfo Load(string absolutePath, bool declareError = false) { var jsonRoot = JSONFile.Read(absolutePath); if (jsonRoot == null || jsonRoot.isNull) { if (declareError) { Debug.LogError("iCanScript: Unable to load package at=> " + absolutePath); } return(null); } return(Load(jsonRoot)); }
async void makefile(MemoryStream ms, JSONFile jfile) { if (EnsureUnsnapped()) { FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; // Dropdown of file types the user can save the file as savePicker.FileTypeChoices.Add(string.IsNullOrEmpty(jfile.Type) ? jfile.Extension : jfile.Type, new List <string>() { jfile.Extension }); // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = jfile.Name; StorageFile file = await savePicker.PickSaveFileAsync(); if (file != null) { // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync. CachedFileManager.DeferUpdates(file); // write to file await FileIO.WriteBytesAsync(file, ms.ToArray()); // Let Windows know that we're finished changing the file so the other app can update the remote version of the file. // Completing updates may require Windows to ask for user input. FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file); XmlDocument toastXML = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); XmlNodeList texts = toastXML.GetElementsByTagName("text"); if (status == FileUpdateStatus.Complete) { texts[0].AppendChild(toastXML.CreateTextNode("HAP+ - Download Complete")); texts[1].AppendChild(toastXML.CreateTextNode(file.Name + " has been downloaded and is ready to use.")); } else { texts[0].AppendChild(toastXML.CreateTextNode("HAP+ - Download Canceled")); texts[1].AppendChild(toastXML.CreateTextNode("You have canceled this download")); } ((XmlElement)toastXML.SelectSingleNode("/toast")).SetAttribute("launch", "{\"type\":\"toast\"}"); ToastNotification toast = new ToastNotification(toastXML); ToastNotificationManager.CreateToastNotifier().Show(toast); var ignored2 = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { pro.Visibility = Windows.UI.Xaml.Visibility.Collapsed; loading.IsIndeterminate = false; }); } else { var ignored2 = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { pro.Visibility = Windows.UI.Xaml.Visibility.Collapsed; loading.IsIndeterminate = false; }); } } }
void Loaded() { //Dont create empty config files if (typeof(ConfigData).GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic).Length > 0) { _settingsFile = new JSONFile <ConfigData>($"{Name}", ConfigLocation.Config, extension: ".cfg"); } PlayerData = new PlayerDataController <CorpsePlayerData>(); //Don't create empty lang files if (lang_en.Count > 0) { lang.RegisterMessages(lang_en, this); } }
private void fileGridView_ItemClick(object sender, ItemClickEventArgs e) { JSONFile file = ((JSONFile)e.ClickedItem); if (file.Type != null && file.Type == "Directory") { Frame.Navigate(typeof(Browser), ((JSONFile)e.ClickedItem).Path); } else { Frame.Navigate(typeof(Details), ((JSONFile)e.ClickedItem).Path); //pro.Visibility = Windows.UI.Xaml.Visibility.Visible; //pro.Value = 0; //downloadfile(file); } }
public static JSONFile loadScores() { if (!File.Exists($"{filePath}\\SavedScore.json")) { return(null); } while (saving) { } // spin lock to prevent loading whilst saving jsonString = File.ReadAllText($"{filePath}\\SavedScore.json"); data = JsonConvert.DeserializeObject <JSONFile>(jsonString); return(data); }
// Handle selection changed on ListBox private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { // If selected index is -1 (no selection) do nothing if (MainListBox.SelectedIndex == -1) { return; } JSONFile jfile = ((JSONFile)MainListBox.SelectedValue); if (jfile.Type != null && jfile.Type == "Directory") { path = jfile.Path; NavigationService.Navigate(new Uri("/Browser.xaml?Path=" + jfile.Path, UriKind.Relative)); } else { NavigationService.Navigate(new Uri("/DetailsPage.xaml?Path=" + jfile.Path, UriKind.Relative)); } }
private void loadSavedValues(JSONFile d) { if (d == null) { return; } var oldScore = d.getOldestScore(currentRound); var oldShots = d.getOldestArrowCount(); checkAndCreateSerises(oldScore > oldShots ? oldShots : oldScore); foreach (var score in d.getRoundRoundScores(currentRound)) { addScore(score.date, score.scores); } foreach (var s in d.shots) { addShot(s.date, s.shots); } }
private void fileGridView_SelectionChanged(object sender, SelectionChangedEventArgs e) { //try //{ if (fileGridView.SelectedItem != null && fileGridView.SelectedItem is JSONFile) { JSONFile file = ((JSONFile)fileGridView.SelectedItem); if (file.Type != null && file.Type == "Directory") { downloadbutton.IsEnabled = deletebutton.IsEnabled = false; uploadbutton.IsEnabled = bottomAppBar.IsOpen = file.Permissions.Modify; } else { downloadbutton.IsEnabled = bottomAppBar.IsOpen = true; deletebutton.IsEnabled = file.Permissions.Delete; uploadbutton.IsEnabled = false; } } else { downloadbutton.IsEnabled = deletebutton.IsEnabled = bottomAppBar.IsOpen = false; uploadbutton.IsEnabled = Params == null ? false : Params.Properties.Permissions.Modify; } //} //catch { downloadbutton.IsEnabled = bottomAppBar.IsOpen = uploadbutton.IsEnabled = false; } }
public async void DownloadHistoricalData() { var controller = new IBController(); Assert.True(controller.Connect(), "Connection setup failed!"); var taskHandler = new IBDTaskHandler(controller); taskHandler.AddTask(new IBDTaskInstruction("DownloadHistoricalData") { contract = new IBApi.Contract() { Symbol = "VIX", SecType = "IND", Exchange = "CBOE" } }); var storage = new JSONFile(); taskHandler.OnTaskResult += storage.ProcessTaskResult; await taskHandler.BeginAsync(); await storage.FlushAsync(); }
void OnServerInitialized() { settings = new JSONFile <Settings>("DespawnConfig", ConfigLocation.Config); settings.Instance.Initialize(); settings.Save(); if (Manager.GetPlugins().Any(x => x.Name == "NoDespawning")) { rust.RunServerCommand("oxide.unload NoDespawing"); PrintError("NoDespawning Detected! Please delete NoDespawning, it is obsolete!"); } serverInitialized = true; foreach (var item in GameObject.FindObjectsOfType <DroppedItem>()) { SetDespawnTime(item); } foreach (var container in GameObject.FindObjectsOfType <DroppedItemContainer>()) { SetDespawnTime(container); } }
public async void GenerateOptionHistoricalDataTasks() { var controller = new IBController(); Assert.True(controller.Connect(), "Connection setup failed!"); var taskHandler = new IBDTaskHandler(controller); var instruction = new IBDTaskInstruction("BuildOptionDownloadTasks") { Symbol = "VIX", SecType = "OPT" }; instruction.parameters["filter.expirytype"] = OptionChain.Expiration.Type.any.ToString(); taskHandler.AddTask(instruction); var storage = new JSONFile(); taskHandler.OnTaskResult += storage.ProcessTaskResult; await taskHandler.BeginAsync(); await storage.FlushAsync(); }
internal static void SaveAsset(Scene scene) { string path = ""; Dispatcher.CurrentDispatcher.Invoke(() => { var dlg = new Ookii.Dialogs.Wpf.VistaSaveFileDialog(); dlg.Filter = "xml|*.xml"; if (dlg.ShowDialog() == true) { path = dlg.FileName; if (path.Contains("}") || path.Contains("{")) { DefaultScene.Actions.Add(() => { new MessageBox(DefaultScene.scene.Context, "File name must not contain { or }.", "File Name Mismatch"); }); path = ""; return; } } }); if (string.IsNullOrEmpty(path)) { return; } #if false Urho3DNet.File file = new Urho3DNet.File(scene.Context, path, Urho3DNet.FileMode.FileWrite); file.sa if (!scene.Save(file)) { new MessageBox(scene.Context, "Couldn't Save File", "Save Error"); return; } #endif #if false var jsonFile = new JSONFile(scene.Context); var rootElem = jsonFile.GetRoot(); if (!scene.SaveJSON(rootElem)) { new MessageBox(scene.Context, "Couldn't Save File", "Save Error"); return; } jsonFile.SaveFile(path); #endif #if true var xmlFile = new XMLFile(scene.Context); XMLElement rootElem = xmlFile.CreateRoot("Root"); if (!scene.SaveXML(rootElem)) { new MessageBox(scene.Context, "Couldn't Save File", "Save Error"); return; } xmlFile.SaveFile(path); #endif //Task.Run(async () => await cam.MoveToSelected(max, modelnode.Position, 50)); }
private static JSONReader CreateJSONReader(JSONFile jsonFile, string testDataKey, int testDataIndex) { return(new JSONReader(jsonFile, testDataKey, testDataIndex)); }
void Loaded() { _settingsFile = new JSONFile <ConfigData>("ChestStacks", ConfigLocation.Config); }
void Loaded() { _settingsFile = new JSONFile <ConfigData>("QuickSmelt", ConfigLocation.Config, extension: ".json"); ConsumeFuelMethod = typeof(BaseOven).GetMethod("ConsumeFuel", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); }
private void reloadChart(JSONFile d) { chart.Series.Clear(); loadSavedValues(d); }
void Loaded() { _settingsFile = new JSONFile <ConfigData>($"{Name}", ConfigLocation.Config, extension: ".cfg"); PlayerData = new PlayerDataController <TemplatePlayerData>(); lang.RegisterMessages(lang_en, this); }