public async Task <bool> Start(ConfigViewModel config, Sensors mcuSensors)
        {
            _serialPort.PortName = config.PortName;
            _config  = config;
            _command = Command.Proceed;

            try
            {
                _serialPort.Open();

                _runningCollector = Task.Factory.StartNew(ReceiveProtobuf,
                                                          CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default)
                                    .Unwrap();

                // Send configuration to MCU and begin
                _serialPort.Write(mcuSensors.ToByteArray(), 0, mcuSensors.CalculateSize());
            }
            catch (Exception)
            {
                _serialPort.Close();
                return(false);
            }

            while (!SensorsDTO.Data.Any())
            {
                await Task.Delay(8);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Load configuration from persistence on startup of application
        /// </summary>
        public void LoadConfigOnAppStartup()
        {
            ConfigViewModel retOpts = null;

            try
            {
                // Re/Load program options to control global behaviour of program
                if ((retOpts = ConfigViewModel.LoadOptions(App.DirFileAppSessionData)) == null)
                {
                    retOpts = new ConfigViewModel();
                }
            }
            catch
            {
            }
            finally
            {
                if (retOpts == null)
                {
                    retOpts = new ConfigViewModel();
                }
            }

            this.Config = retOpts;

            this.Skins = new Themes.ThemesVM(this.Config.CurrentTheme);
            this.ResetTheme(null, null);
            this.Config.ThemeChanged += new EventHandler(this.ResetTheme);
        }
Example #3
0
 public ConfigJumpMenuItem(
     IContextMenuTranslations contextMenuTranslations,
     IWindowManager windowManager,
     ConfigViewModel configViewModel,
     LanguageConfigViewModel languageConfigViewModel
     )
 {
     // automatically update the DisplayName
     contextMenuTranslations.CreateDisplayNameBinding(this, nameof(IContextMenuTranslations.JumpToConfigure));
     Id   = "G_ConfigJump";
     Icon = new PackIconMaterial
     {
         Kind = PackIconMaterialKind.Settings,
         HorizontalAlignment        = HorizontalAlignment.Stretch,
         VerticalAlignment          = VerticalAlignment.Stretch,
         HorizontalContentAlignment = HorizontalAlignment.Stretch,
         VerticalContentAlignment   = VerticalAlignment.Stretch
     };
     ClickAction = clickedItem =>
     {
         configViewModel.CurrentConfigScreen = languageConfigViewModel;
         if (!configViewModel.IsActive)
         {
             windowManager.ShowDialog(configViewModel);
         }
     };
     this.ApplyIconForegroundColor(Brushes.Gray);
 }
Example #4
0
 private void InitializeApplication()
 {
     if (ConfigVM == null)
     {
         ConfigVM = new ConfigViewModel();
     }
 }
        public async Task <ActionResult> Edit(ConfigViewModel configViewModel, params string[] selectedRole)
        {
            if (ModelState.IsValid)
            {
                var config = _appEntities.GetConfigById(configViewModel.Id);
                if (config == null)
                {
                    return(new StatusCodeResult(StatusCodes.Status404NotFound));
                }


                config = new Config()
                {
                    Id           = configViewModel.Id,
                    SettingName  = configViewModel.SettingName,
                    SettingValue = configViewModel.SettingValue,
                    SettingType  = configViewModel.SettingType,
                    Timestamp    = configViewModel.Timestamp,
                    Username     = configViewModel.Username,
                    IsActive     = configViewModel.IsActive
                };

                _appEntities.UpsertConfig(config);
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Something failed.");
            return(View());
        }
Example #6
0
        public static void PackageProject(ProjectListing project, ConfigViewModel config)
        {
            string output = Path.Combine(project.OutputPath, "Staging");

            if (Directory.Exists(output))
            {
                Directory.Delete(output, true);
            }
            Directory.CreateDirectory(output);

            foreach (var file in project.IncludedFiles)
            {
                if (file.EndsWith(".uexp"))
                {
                    var patched    = PatchFile(file, config, project.OutputPath.Length + 2);
                    var subdirName = file.Substring(project.InputPath.Length);
                    var outpath    = output + subdirName;
                    Directory.CreateDirectory(Path.GetDirectoryName(outpath));
                    using (var fo = File.Create(outpath, (int)patched.Length, FileOptions.Asynchronous | FileOptions.SequentialScan))
                    {
                        patched.Position = 0;
                        patched.CopyTo(fo);
                    }
                }
                else
                {
                    var subdirName = file.Substring(project.InputPath.Length);
                    var outpath    = output + subdirName;
                    var outdir     = Path.GetDirectoryName(outpath);
                    Directory.CreateDirectory(outdir);
                    File.Copy(file, outpath);
                }
            }
        }
        //
        // GET: /Users/Edit/1
        public async Task <ActionResult> Edit(string id)
        {
            int configId;

            if (id == null || !int.TryParse(id, out configId))
            {
                return(new StatusCodeResult(StatusCodes.Status400BadRequest));
            }
            var config = _appEntities.GetConfigById(configId);

            if (config == null)
            {
                return(new StatusCodeResult(StatusCodes.Status404NotFound));
            }

            ConfigViewModel model = new ConfigViewModel()
            {
                Id           = config.Id,
                SettingName  = config.SettingName,
                SettingValue = config.SettingValue,
                SettingType  = config.SettingType,
                Timestamp    = config.Timestamp,
                Username     = config.Username,
                IsActive     = config.IsActive
            };

            return(View(model));
        }
Example #8
0
        public void CreateConfig(string name, string category, string author)
        {
            // Build the base config structure
            var settings = new ConfigSettings();

            settings.Name   = name;
            settings.Author = author;

            var newConfig = new ConfigViewModel(name, category, new Config(settings, string.Empty));

            // Add it to the collection and persistent storage
            vm.Add(newConfig);

            vm.CurrentConfig = newConfig;
            var newStackerVM = new StackerViewModel(vm.CurrentConfig);

            if (OB.MainWindow.ConfigsPage.StackerPage != null) // Maintain the previous stacker settings
            {
                newStackerVM.TestData  = OB.Stacker.TestData;
                newStackerVM.TestProxy = OB.Stacker.TestProxy;
                newStackerVM.ProxyType = OB.Stacker.ProxyType;
            }
            OB.Stacker = newStackerVM;
            OB.MainWindow.ConfigsPage.StackerPage = new Stacker();                 // Create a Stacker instance
            OB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Stacker instance");
            OB.MainWindow.ConfigsPage.OtherOptionsPage = new ConfigOtherOptions(); // Create an Other Options instance
            OB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Other Options instance");
            OB.MainWindow.ConfigsPage.menuOptionStacker_MouseDown(this, null);     // Switch to Stacker
        }
        public ActionResult Index()
        {
            var             config          = ConfigManager.GetConfig();
            ConfigViewModel configViewModel = mapper.GetViewModel <ConfigViewModel>(config);

            return(View(configViewModel));
        }
Example #10
0
        public ConfigPage(AppSetting appSetting, ConfigViewModel dataService, PaletteSelectorViewModel paletteSelector)
        {
            InitializeComponent();
            DataContext = dataService;

            panel1.DataContext = paletteSelector;
        }
Example #11
0
        public ConfigView(ToDo selectedToDo, User user)
        {
            InitializeComponent();

            DataContext  = new ConfigViewModel(selectedToDo, user);
            SelectedToDo = selectedToDo;
        }
Example #12
0
 public ConfigPage()
 {
     InitializeComponent();
     ViewModel            = new ConfigViewModel();
     ViewModel.Navigation = Navigation;
     BindingContext       = ViewModel;
 }
        public virtual ActionResult Index()
        {
            var settings = (from p in typeof(IAppConfiguration).GetProperties(BindingFlags.Public | BindingFlags.Instance)
                            where p.CanRead
                            select p)
                           .ToDictionary(p => p.Name, p =>
            {
                var propertyType  = p.PropertyType;
                var propertyValue = p.GetValue(_config.Current);

                if (propertyValue != null && p.Name.ToLowerInvariant().Contains("connectionstring"))
                {
                    propertyValue = new string('*', 10);
                }

                return(Tuple.Create(propertyType, propertyValue));
            });

            var features = (from p in typeof(FeatureConfiguration).GetProperties(BindingFlags.Public | BindingFlags.Instance)
                            where p.CanRead
                            select new FeatureConfigViewModel(p, _config.Features))
                           .ToList();


            var configModel = new ConfigViewModel(settings, features, _auth.Authenticators.Values);

            return(View(configModel));
        }
Example #14
0
        private void ShowConfigDialog(MainViewModel mainViewModel)
        {
            var win = new Window();

            win.Title = "Configure";
            win.Owner = App.Current.MainWindow;

            var configViewModel = new ConfigViewModel(mainViewModel.AgentConfig);

            configViewModel.Removed += mainViewModel.OnNodeRemoved;
            configViewModel.Updated += mainViewModel.OnNodeUpdated;
            configViewModel.Added   += mainViewModel.OnNodeAdded;

            win.Content = new ConfigPanel()
            {
                DataContext = configViewModel
            };

            win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            win.WindowStyle           = WindowStyle.SingleBorderWindow;
            win.ResizeMode            = ResizeMode.NoResize;
            win.Width  = 600;
            win.Height = 300;
            win.ShowDialog();
        }
Example #15
0
        public MainWindow()
        {
            var config = Serialization.LoadMain(ConfigPath);

            if (config == null)
            {
                config          = new MainConfig();
                config.Projects = new List <ProjectListing>();
                config.Guids    = new List <GuidEntry>();
                int xl = Serialization.BaseGuids.Length;
                for (int i = 0; i < xl; i++)
                {
                    var set = Serialization.BaseGuids[i];
                    config.Guids.Add(new GuidEntry()
                    {
                        Modified = set[0], Retail = set[1], Name = set[2]
                    });
                }

                Serialization.SaveMain(ConfigPath, config);
            }

            //GuidGrid.DataContext = Config.Guids;

            Config           = new ConfigViewModel(config);
            this.DataContext = Config;

            InitializeComponent();

            ProjectList.ItemsSource       = Config.Projects;
            ProjectList.SelectionChanged += ProjectList_SelectionChanged;

            var d = config.Guids[0];
        }
Example #16
0
        public IActionResult Index()
        {
            SetCoreViewData();
            ConfigViewModel model = ConfigViewModel.From(service);

            return(View("Index", model));
        }
Example #17
0
        public async Task <IActionResult> Index([FromQuery] string substitutionBindingMethod, [FromQuery] string slackId)
        {
            var config = new ConfigViewModel
            {
                ConfigValues = new List <string>()
            };

            if (!string.IsNullOrWhiteSpace(slackId))
            {
                var response = await _slackService.AddUserToChannel(slackId);

                config.ConfigValues.Add($"Response Content: {await response.Content.ReadAsStringAsync()}");
            }

            if (!string.IsNullOrWhiteSpace(substitutionBindingMethod))
            {
                var substitutionBinder = Type.GetType("ExerciseDaemon.SubstitutionBinder");
                var method             = substitutionBinder.GetMethod(substitutionBindingMethod);
                var result             = method.Invoke(_substitutionBinder, new object[0]);

                config.ConfigValues.Add(JsonConvert.SerializeObject(result));
            }

            _logger.LogInformation("Config page visited.");

            return(View(config));
        }
Example #18
0
        public void ShowConfig()
        {
            Configuration   configuration = new Configuration();
            ConfigViewModel model         = new ConfigViewModel(configuration);

            configuration.DataContext = model;
            configuration.ShowDialog();
        }
Example #19
0
        public FrmConfig(ConfigViewModel configViewModel, List <Config> configs, int index)
        {
            InitializeComponent();

            this.configs = configs;
            this.index   = index;
            Init(configViewModel);
        }
 public void Setup()
 {
     _session = MockRepository.GenerateStub <ISession>();
     _session.Stub(x => x.Get <List <Uri> >(Session.CombatantImages)).Return(new List <Uri> {
         new Uri("ftp://foo"), new Uri("http://bar"), new Uri("http://foobar")
     });
     _target = new ConfigViewModel(_session, new EventAggregator());
 }
        public ConfigWindow()
        {
            InitializeComponent();

            configViewModel = new ConfigViewModel();

            this.DataContext = configViewModel;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigWindow"/> class.
        /// </summary>
        /// <param name="settingsFilename">Path to file containing settings for this.</param>
        public ConfigWindow(string settingsFilename)
        {
            InitializeComponent();

            _vm = new ConfigViewModel(settingsFilename);

            DataContext = _vm;
        }
Example #23
0
 public MainForm(ICoreConfiguration coreConfiguration, IWindowManager windowManager, ConfigViewModel configViewModel, SettingsForm settingsForm, [ImportMany] IEnumerable <IDestination> destinations)
 {
     _coreConfiguration = coreConfiguration;
     _windowManager     = windowManager;
     _configViewModel   = configViewModel;
     _settingsForm      = settingsForm;
     _destinations      = destinations;
     Instance           = this;
 }
Example #24
0
        public void LoadConfig(ConfigViewModel config)
        {
            if (config == null)
            {
                SB.Logger.LogError(Components.ConfigManager, "The config to load cannot be null", true);
                return;
            }

            try
            {
                SBIOManager.CheckRequiredPlugins(SB.BlockPlugins.Select(b => b.Name), config.Config);
            }
            catch (Exception ex)
            {
                SB.Logger.LogError(Components.ConfigManager, ex.Message, true);
                return;
            }

            // Set the config as current
            vm.CurrentConfig = config;

            if (vm.CurrentConfig.Remote)
            {
                SB.Logger.LogError(Components.ConfigManager, "The config was pulled from a remote source and cannot be edited!", true);
                vm.CurrentConfig = null;
                return;
            }

            SB.Logger.LogInfo(Components.ConfigManager, "Loading config: " + vm.CurrentConfig.Name);

            SB.MainWindow.ConfigsPage.menuOptionStacker.IsEnabled      = true;
            SB.MainWindow.ConfigsPage.menuOptionOtherOptions.IsEnabled = true;

            var newStackerVM = new StackerViewModel(vm.CurrentConfig);

            // Preserve the old stacker test data and proxy
            if (SB.MainWindow.ConfigsPage.StackerPage != null)
            {
                newStackerVM.TestData  = SB.Stacker.TestData;
                newStackerVM.TestProxy = SB.Stacker.TestProxy;
                newStackerVM.ProxyType = SB.Stacker.ProxyType;
            }

            SB.Stacker = newStackerVM;
            SB.MainWindow.ConfigsPage.StackerPage = new Stacker();                 // Create a Stacker instance
            SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Stacker instance");
            SB.MainWindow.ConfigsPage.OtherOptionsPage = new ConfigOtherOptions(); // Create an Other Options instance
            SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Other Options instance");
            SB.MainWindow.ConfigsPage.ConfigOcrSettings = new ConfigOcrSettings(); // Create an Ocr Testing instance
            SB.Logger.LogInfo(Components.ConfigManager, "Created and assigned a new Ocr Testing instance");
            SB.MainWindow.ConfigsPage.menuOptionStacker_MouseDown(this, null);     // Switch to Stacker

            // Save the last state of the config
            SB.MainWindow.ConfigsPage.StackerPage.SetScript();
            SaveState();
        }
        public async Task <ConfigVariableDTO> ChangeConfigAsync(ConfigViewModel newConfig)
        {
            var config = await _сonfigRepository.GetByIdAsync(newConfig.Id);

            config.Value = newConfig.Value;

            await _сonfigRepository.SaveChangesAsync();

            return(_mapper.Map <ConfigVariableDTO>(config));
        }
Example #26
0
        public async Task <IActionResult> Details(string id)
        {
            var model = new ConfigViewModel
            {
                Id         = id,
                ConfigInfo = await ConfigProvider.LoadConfigWithoutSecrets(id, true)
            };

            return(Ok(model));
        }
Example #27
0
        public ActionResult Index()
        {
            var model = new ConfigViewModel();
            int totalItem;
            var allCategory = _configService.GetData(model.PageIndex, model.PageSize, out totalItem).ToList();

            model.TotalItem = totalItem;
            model.ListData  = allCategory;
            return(View(model));
        }
Example #28
0
        public ConfigView()
        {
            InitializeComponent();

            var configViewModel = new ConfigViewModel();

            configViewModel.RequestClose += (s, e) => this.Close();

            DataContext = configViewModel;
        }
Example #29
0
 private void Init(ConfigViewModel configViewModel)
 {
     if (configViewModel != null)
     {
         ConfigViewModel      = configViewModel;
         this.ConfigViewModel = configViewModel;
         txtName.Text         = this.ConfigViewModel.Name;
         txtKeyword.Text      = this.ConfigViewModel.Keyword;
     }
 }
        public async Task <IActionResult> Details(string id)
        {
            var model = new ConfigViewModel
            {
                Id         = id,
                ConfigInfo = await ConfigProvider.LoadOverride(id)
            };

            return(Ok(model));
        }
Example #31
0
 private static void OpenConfig()
 {
     var viewModel = new ConfigViewModel();
     var element = FloatingHelpers.CreateFloatingElement("Application Status", new Point(600, 400), new Size(800, 600),
         viewModel);
     AppStateSettings.Instance.FloatingItems.AddFloatingElement(element);
 }
        private void OnEditConfiguration()
        {
            var window = new ConfigWindow();
            var configVM = new ConfigViewModel();

            window.DataContext = configVM;
            configVM.OnSaved += window.Close;
            window.ShowDialog();
            ListenToReceiversCommand.RaiseCanExecuteChanged();
        }
        private void ShowConfigDialog()
        {
            ConfigViewModel viewModel = new ConfigViewModel();
            IModalDialog configDialog = ServiceProvider.Instance.Get<IConfigModalDialog>();
            viewModel.CloseAction = new Action(configDialog.Close);
            configDialog.BindViewModel(viewModel);
            configDialog.ShowDialog();

            OnPropertyChanged(nameof(SwSettings));
            OnPropertyChanged(nameof(SelectedSetting));
        }