Esempio n. 1
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnExport_Click(object sender, RoutedEventArgs e)
        {
            if (watchElements == null || watchElements.Count == 0)
            {
                MessageBox.Show("没有要导出的表盘元素");
                return;
            }

            System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string       folder = folderBrowserDialog.SelectedPath;
                ExportWindow export = new ExportWindow();
                export.WatchDescription = new WatchDescription
                {
                    Screen  = resolution == 0 ? "HWHD02" : "HWHD01",
                    Version = resolution == 0 ? "2.1.1" : "3.1.1"
                };
                if (export.ShowDialog() ?? false)
                {
                    ConfigWriter writer = new ConfigWriter(folder, watchElements, export.WatchDescription);
                    writer.Write();
                    string res = folder + "/watchface/res/";
                    SaveToImage(res + "A100_001.png");

                    SaveToPreviewImage(folder + "/preview/");
                    Process.Start(folder);
                }
            }
        }
Esempio n. 2
0
        public void UserConfigWriteTest()
        {
            UserConfigWriter.m_TestUserConfigName = Path.GetTempPath() + "user.config";
            AppConfigWriter.m_TestAppConfigName   = Path.GetTempPath() + "app.config";
            if (File.Exists(UserConfigWriter.m_TestUserConfigName))
            {
                File.Delete(UserConfigWriter.m_TestUserConfigName);
            }
            ConfigWriter config = new ConfigWriter();

            config.Read(UserConfigWriter.m_TestUserConfigName);
            Assert.AreEqual("", config.GetItem("PromtReasonForChange"));
            //UserConfigWriter.Instance.SetItem("PromtReasonForChange", "true");
            //UserConfigWriter.Instance.SetItem("SomeItem", "true");
            //UserConfigWriter.Instance.Save();
            //config.Read(UserConfigWriter.m_TestUserConfigName);
            //Assert.AreEqual("true", config.GetItem("PromtReasonForChange"));
            //Assert.AreEqual("", config.GetItem("SomeItem"));
            var target = UserConfigWriter.CreateConfigWriter();

            target.SetItem("PromtReasonForChange", "false");
            target.SetItem("SomeItem", "false");
            target.Save();
            config.Read(UserConfigWriter.m_TestUserConfigName);
            Assert.AreEqual("false", config.GetItem("PromtReasonForChange"));
            Assert.AreEqual("", config.GetItem("SomeItem"));
        }
Esempio n. 3
0
        /// <summary>
        /// Writes the test into <paramref name="directory" />.
        /// </summary>
        /// <param name="directory">Directory for writing the test.</param>
        /// <param name="cleanExistingDirectory">Clean existing directory if set to true.</param>
        public void Write(string directory, bool cleanExistingDirectory = true)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(directory));
            Contract.Requires(PathTable != null);

            // If the root path is specified, it overrides the given directory
            if (RootPath != null)
            {
                directory = RootPath;
            }

            if (cleanExistingDirectory && FileSystem.Exists(AbsolutePath.Create(PathTable, directory)))
            {
                // TODO: delete the directory.
                // TODO: Add this to interface
                //global::BuildXL.Native.IO.FileUtilities.DeleteDirectoryContents(directory);
            }
            FileSystem.CreateDirectory(AbsolutePath.Create(PathTable, directory));
            ConfigWriter.Write(directory, this);

            foreach (var extraFile in ExtraFiles)
            {
                WriteFile(Path.Combine(directory, extraFile.Key), extraFile.Value);
            }
        }
Esempio n. 4
0
        void WritePlainText(TextWriter writer, string clientVersion)
        {
            writer.WriteLine($"Client Version: v{clientVersion}");
            writer.WriteLine();

            foreach (var job in cache.Jobs.OrderBy(i => i.JobType.FullName))
            {
                writer.WriteLine(ConsoleFormat.DoubleLine);
                writer.WriteLine($"Job:\t{job.JobType.FullName} [{job.JobType.Assembly.GetName().Name}]");
                writer.WriteLine($"Config:\t{job.ConfigType.FullName} [{job.ConfigType.Assembly.GetName().Name}]");
                writer.WriteLine(ConsoleFormat.DoubleLine);
                writer.WriteLine();

                if (job.IsValid)
                {
                    writer.WriteLine(verbose ? ConfigWriter.ToJson(cache.GetDefaultConfig(job)) : ConfigWriter.ToReducedJson(cache.GetDefaultConfig(job)));
                    writer.WriteLine();
                }
                else
                {
                    writer.WriteLine($"Error Loading Job: {job.Errors.ToString()}");
                    writer.WriteLine();
                }
            }
        }
        private void ButtonDo_Click(object sender, RoutedEventArgs e)
        {
            if (AppInfo.State.TokenExpireTime < DateTime.Now)
            {
                this.ButtonDo.Content = "spotify token expired!";
                return;
            }

            var trackResp = _spotify.GetCurrentTrack(AppInfo.State.SpotifyAccessToken);

            if (trackResp == null)
            {
                return;
            }

            this.UpdateInterfaceTrackInfo(trackResp);

            if (AccountsList.SelectedItem == null)
            {
                return;
            }

            var cfgWriter = new ConfigWriter(
                $@"{SteamIdLooker.UserdataPath}\{this.GetSelectedAccountId().ToString()}\730\local\cfg\audio.cfg",
                this.NowPlayingConfig.Config.CfgText);

            cfgWriter.RewriteKeyBinding(trackResp);
        }
Esempio n. 6
0
        IEnumerable GetJobJson()
        {
            if (verbose)
            {
                return(cache.Jobs.OrderBy(i => i.JobType.FullName).Select(p => new
                {
                    JobType = p.JobType.FullName,
                    ConfigType = p.ConfigType.FullName,
                    DefaultConfig = cache.GetDefaultConfig(p.JobType.FullName),
                    Assembly = p.JobType.Assembly.GetName().Name,
                    CanRun = p.IsValid,
                    Errors = p.Errors.ToString(),
                    Schema = schema.Generate(p.ConfigType)
                }));
            }

            // Include the reduced config
            return(cache.Jobs.OrderBy(i => i.JobType.FullName).Select(p => new
            {
                JobType = p.JobType.FullName,
                ConfigType = p.ConfigType.FullName,
                DefaultConfig = ConfigWriter.ToReducedJObject(cache.GetDefaultConfig(p.JobType.FullName)),
                Assembly = p.JobType.Assembly.GetName().Name,
                CanRun = p.IsValid,
                Errors = p.Errors.ToString()
            }));
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                SimpleModel           simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject    tmesh       = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                ForwardXNABasicShader shader      = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
                ForwardMaterial       fmaterial   = new ForwardMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }

            ConfigWriter cw = new ConfigWriter("teste.properties");

            cw.AddKeyValue("teste", "value");
            cw.Write();

            ConfigReader cr = new ConfigReader("teste.properties");

            cr.Read();
            String v = cr.ReadValue("teste");

            System.Diagnostics.Debug.Assert(v == "value");

            this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));

            this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
        }
Esempio n. 8
0
        /// <summary>
        /// Click event handler for saving the new config file. Validates prior to saving.  Displays the error/save message box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveFile_Click(object sender, EventArgs e)
        {
            try
            {
                var formProcessor = new FormProcessor(ContentFlow);

                var cv = new ConfigValidator(ConfigPath, SchemaPath);
                if (cv.Validate(true) != 0)
                {
                    throw new InvalidDataException("XSD-based Validation Failed.  Check for errors.");
                }

                var cf = new ConfigWriter(ConfigPath);
                cf.Write();
                Saved.Text      = "Saved newrelic.config successfully";
                Saved.BackColor = Color.FromArgb(244, 144, 0);
                Saved.Visible   = true;
                _savedTimer.Start();
            }
            catch (Exception ex)
            {
                log.Error("01 - " + ex.Message);
                Saved.Text      = ex.Message;
                Saved.BackColor = Color.DarkRed;
                Saved.Visible   = true;
                _savedTimer.Start();
            }
        }
Esempio n. 9
0
 internal static void SaveSettings()
 {
     if (Program.settings != null)
     {
         ConfigWriter.Write(Program.settings, Program.GetSettingsFilename(), true);
     }
 }
Esempio n. 10
0
        public void AppConfigWriteTest()
        {
            UserConfigWriter.m_TestUserConfigName = Path.GetTempPath() + "user_v6.config";
            AppConfigWriter.m_TestAppConfigName   = Path.GetTempPath() + "app_v6.config";
            if (File.Exists(AppConfigWriter.m_TestAppConfigName))
            {
                File.Delete(AppConfigWriter.m_TestAppConfigName);
            }
            var config = new ConfigWriter();

            config.Read(AppConfigWriter.m_TestAppConfigName);
            Assert.AreEqual("", config.GetItem("DocumentPrinter"));
            string expected = "test printer";
            //Assert.AreEqual(AppConfigWriter.Instance.FileName, AppConfigWriter.m_TestAppConfigName);
            //AppConfigWriter.Instance.SetItem("DocumentPrinter", expected);
            //AppConfigWriter.Instance.SetItem("SomeItem", "true");
            //AppConfigWriter.Instance.Save();
            //config.Read(AppConfigWriter.m_TestAppConfigName);
            //Assert.AreEqual(expected, config.GetItem("DocumentPrinter"));
            //Assert.AreEqual("", config.GetItem("SomeItem"));
            ConfigWriter target = AppConfigWriter.CreateConfigWriter();

            target.SetItem("DocumentPrinter", expected);
            target.SetItem("SomeItem", "false");
            target.Save();
            config.Read(AppConfigWriter.m_TestAppConfigName);
            Assert.AreEqual(expected, config.GetItem("DocumentPrinter"));
            Assert.AreEqual("", config.GetItem("SomeItem"));
        }
Esempio n. 11
0
        protected override void CustomSetConfig(DeviceConfig config)
        {
            PropertiesConfig.Presets = NearEndPresets;

            Config.Properties = JToken.FromObject(PropertiesConfig);

            ConfigWriter.UpdateDeviceConfig(config);
        }
Esempio n. 12
0
        /// <summary>
        /// Gets all files known by this test writer.
        /// </summary>
        /// <returns>All files known by this test writer.</returns>
        public IEnumerable <Tuple <string, string> > GetAllFiles()
        {
            var files = new List <Tuple <string, string> >();

            files.AddRange(ConfigWriter.GetAllFiles());
            files.AddRange(ExtraFiles.Select(kvp => Tuple.Create(kvp.Key, kvp.Value)));

            return(files);
        }
Esempio n. 13
0
 /// <summary>
 /// 保存
 /// </summary>
 public void SaveProject(string dir, ConfigWriter write)
 {
     using (WorkModelScope.CreateScope(WorkModel.Saving))
     {
         dir = write.SaveProject(this, dir);
         SaveTypedefs(dir, write);
         SaveNotifies(dir, write);
     }
 }
Esempio n. 14
0
        public void SaveTypedefs(string dir, ConfigWriter write)
        {
            var path = GlobalConfig.CheckPath(dir, "Typedef");

            foreach (var type in TypedefItems.ToArray())
            {
                SaveTypedef(write, type, path);
            }
        }
Esempio n. 15
0
        private void save(ConfigurationFormWriter formWriter, bool isLocal)
        {
            var writer  = new ConfigWriter();
            var file    = formWriter.Configuration.ConfigurationFullpath;
            var content = writer.Transform(formWriter.Configuration);

            saveConfiguration(file, content);
            notifyVM(file, content, isLocal);
        }
Esempio n. 16
0
        /// <summary>
        /// 保存通知对象
        /// </summary>
        public void SaveNotifies(string dir, ConfigWriter write)
        {
            string path = GlobalConfig.CheckPath(dir, "Notify");

            foreach (var notify in NotifyItems.ToArray())
            {
                write.SaveConfig(notify, path, true);
            }
        }
    public void SaveConfigValues()
    {
        ConfigWriter configWriter = new ConfigWriter(SETTINGS_FILE_NAME);

        configWriter.SetInt(RESOLUTION_VALUE, resolutionIndexSave);
        configWriter.SetInt(QUALITY_VALUE, qualityIndexSave);
        configWriter.SetString(FULLSCREEN_VALUE, isFullscreenSave ? TRUE_VALUE : FALSE_VALUE);
        configWriter.SetFloat(MUSIC_VOLUME_VALUE, masterVolumeSave);
        configWriter.SetFloat(SFX_VOLUME_VALUE, gameSfxSave);
    }
Esempio n. 18
0
 private void LoadConfig(string configName)
 {
     m_config = ConfigWriter.Instance;
     if (string.IsNullOrEmpty(configName))
     {
         configName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Config.GeneralConfigName);
     }
     m_config.Read(File.Exists(configName) ? configName : Config.DefaultGeneralConfigPath);
     lbConfigFileName.Text = m_config.FileName;
 }
Esempio n. 19
0
        public void Should_deserialize_reduced_config()
        {
            var expected = new DiagnosticConfig();

            expected.Job.Type = typeof(DiagnosticJob).FullName;

            var actual = reader.FromJson(ConfigWriter.ToReducedJson(expected));

            actual.Should().NotBeNull();
            actual.Job.Type.Should().Be(typeof(DiagnosticJob).FullName);
        }
Esempio n. 20
0
        protected override void CustomSetConfig(DeviceConfig config)
        {
            var newPropertiesConfig = JsonConvert.DeserializeObject <EssentialsHuddleRoomPropertiesConfig>(config.Properties.ToString());

            if (newPropertiesConfig != null)
            {
                PropertiesConfig = newPropertiesConfig;
            }

            ConfigWriter.UpdateRoomConfig(config);
        }
Esempio n. 21
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ConfigWriter writer = new ConfigWriter(saveFileDialog1.FileName);
                Config       config = BuildConfigFromDataGridView();
                writer.Write(config);

                Geo.Utils.FormUtil.ShowOkAndOpenDirectory(Path.GetDirectoryName(saveFileDialog1.FileName));
            }
        }
Esempio n. 22
0
        private void write(string text)
        {
            var config = new ConfigurationFormWriter(false, new ConfigParser("").Parse(), new MSBuildLocator());

            config.SetIgnoreThisUpgrade(text);

            var writer  = new ConfigWriter();
            var file    = config.Configuration.ConfigurationFullpath;
            var content = writer.Transform(config.Configuration);

            saveConfiguration(file, content);
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            saveDisableAll();
            saveDisableAnonFeedback();
            var writer  = new ConfigWriter();
            var file    = _writer.Configuration.ConfigurationFullpath;
            var content = writer.Transform(_writer.Configuration);

            saveConfiguration(file, content);
            notifyVM(file, content);
            Close();
        }
Esempio n. 24
0
        public void Should_serialize_reduced_config()
        {
            var config = new Config()
            {
                Job = new JobConfig()
                {
                    Type = "SomeType"
                }
            };

            ConfigWriter.ToReducedJson(config).Replace("\r", "").Replace("\n", "").Should().Be("{  \"job\": \"SomeType\"}");
        }
Esempio n. 25
0
        protected override void CustomSetConfig(DeviceConfig config)
        {
            var newPropertiesConfig = JsonConvert.DeserializeObject <RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());

            if (newPropertiesConfig != null)
            {
                PropertiesConfig = newPropertiesConfig;
            }

            ConfigWriter.UpdateDeviceConfig(config);

            SetUpDevice();
        }
Esempio n. 26
0
        private static void CreateNewConfigFromInventor(string output)
        {
            ShowReadBanner();

            try
            {
                ConfigWriter configWriter = new ConfigWriter(output);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }
Esempio n. 27
0
        public async Task RunAsync(CancellationToken cancel)
        {
            TextWriter writer = null;
            JobInfo    job;

            try
            {
                job = cache.Get(jobType);
            }
            catch (TypeNotFoundException)
            {
                Console.WriteLine($"Could not find the job type '{jobType}'.");
                return;
            }

            var config = cache.GetDefaultConfig(job);

            try
            {
                if (filePath == null)
                {
                    writer = Console.Out;
                }
                else
                {
                    // If path is an existing directory, such as ".", add a file name
                    if (Directory.Exists(filePath))
                    {
                        filePath = Path.Combine(filePath, job.JobType.Name + ".json");
                    }

                    writer = new StreamWriter(File.Open(filePath, FileMode.Create));
                }

                await writer.WriteAsync(verbose?ConfigWriter.ToJson(config) : ConfigWriter.ToReducedJson(config));
            }
            finally
            {
                if (filePath != null && writer != null)
                {
                    await writer.FlushAsync();

                    writer.Dispose();
                }
            }

            if (filePath != null)
            {
                Console.WriteLine($"Default config for {job.JobType.FullName} saved to {Path.GetFullPath(filePath)}");
            }
        }
Esempio n. 28
0
        public void AssertNewFileIsSameAsOldFile()
        {
            var p      = new Parser("ConfigFilesForTest/telldus.conf");
            var config = p.Parse();

            var w = new ConfigWriter("ConfigFilesForTest/test.conf");

            w.Write(config);

            var p2      = new Parser("ConfigFilesForTest/test.conf");
            var config2 = p2.Parse();

            Assert.Equal(config.Devices.Count, config2.Devices.Count);
        }
Esempio n. 29
0
        static async Task Main()
        {
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(onClose);

            steamService = OperatingSystem.IsWindows() ? new SteamServiceWindows() : new SteamServiceLinux();
            string redirectUrl = @"http://localhost:8888/";

            keySender    = new InputSenderWindows();
            keyFormatter = new KeyFormatterWindows();
            pathResolver = new PathResolver();

            requestsManager = new SpotifyRequestsManager("7633771350404368ac3e05c9cf73d187",
                                                         "29bd9ec2676c4bf593f3cc2858099838", redirectUrl);

            process = new GameProcess();
            process.Start();

            steamContext = steamService.GetSteamContext();
            var accounts = steamContext.GetAccounts();

            Console.WriteLine("Awaiting user authorization...");
            var server = new AuthServer(redirectUrl);

            string authUrl = requestsManager.GetAuthUrl().Replace("&", "^&");

            Process.Start(new ProcessStartInfo("cmd", $"/c start {authUrl}")
            {
                CreateNoWindow = true
            });
            string code = await server.GetAuthCode();

            await requestsManager.StartTokenRequests(code);

            int accSteamId3 = accounts.FirstOrDefault((x) => x.Name == steamContext.LastAccount).SteamId3;

            string writePath = pathResolver.GetWritePath(process.CurrentProcess, steamContext.UserdataPath, accSteamId3.ToString());

            configWriter = new ConfigWriter(writePath);

            Console.WriteLine("Press the bind key");
            var consoleInput = Console.ReadKey(true);

            currentKeyVirtual = (ushort)consoleInput.Key;
            currentKey        = keyFormatter.GetSourceKey(currentKeyVirtual);

            trackInfoUpdater = new SpotifyTrackUpdater(requestsManager);
            trackInfoUpdater.OnPlaybackStateUpdate += onPlaybackStateUpdate;
            trackInfoUpdater.StartPlaybackUpdate();
        }
Esempio n. 30
0
 public void SaveTypedef(ConfigWriter write, TypedefItem type, string path, bool checkState = true)
 {
     if (type.IsDelete)
     {
         Remove(type);
     }
     else
     {
         foreach (var field in type.Items.Where(p => p.Value.IsDelete).ToArray())
         {
             type.Items.Remove(field.Key);
         }
     }
     write.SaveConfig(type, path, true);
 }