예제 #1
0
        public void AppRegistry_InvokeTests()
        {
            var module = new AppRegistry();

            var name = default(string);
            var args = default(object[]);

            module.InvocationHandler = new MockInvocationHandler((n, a) =>
            {
                name = n;
                args = a;
            });

            var appKey        = "foo";
            var appParameters = new Dictionary <string, object>();

            module.runApplication(appKey, appParameters);
            Assert.AreEqual(nameof(AppRegistry.runApplication), name);
            Assert.AreEqual(2, args.Length);
            Assert.AreSame(appKey, args[0]);
            Assert.AreSame(appParameters, args[1]);

            module.unmountApplicationComponentAtRootTag(42);
            Assert.AreEqual(nameof(AppRegistry.unmountApplicationComponentAtRootTag), name);
            Assert.AreEqual(1, args.Length);
            Assert.AreEqual(42, args[0]);
        }
예제 #2
0
        public void AppRegistryTest()
        {
            var regs = new AppRegistry[]
            {
                new AppRegistry {
                    Item = "Person1", Key = "Name", Value = "zmjack"
                },
                new AppRegistry {
                    Item = "Person1", Key = "Age", Value = "28"
                },
                new AppRegistry {
                    Item = "Person1", Key = "Enable", Value = "unknown"
                },
                new AppRegistry {
                    Item = "Person2", Key = "Name", Value = "ashe"
                },
                new AppRegistry {
                    Item = "Person2", Key = "Age", Value = "27"
                },
            };

            var zmjack = AppRegistryAgent.Connect(regs, "Person1");

            zmjack.Age = 999;

            Assert.Equal("Person1", zmjack.GetItemString());
            Assert.Equal(999, zmjack.Age);
            Assert.Equal("haha", zmjack.NickName);
            Assert.False(zmjack.Enable);
            Assert.Null(zmjack.Address);

            Assert.Throws <KeyNotFoundException>(() => zmjack.NickName = "new");
            Assert.Equal("999", regs.FirstOrDefault(x => x.Key == nameof(AppRegistryAgent.Age))?.Value);
        }
예제 #3
0
        /// <summary>
        /// Scan for all dicitionaries (default resx files, without culture identification)
        /// </summary>
        private void ScanForDefaultDictionaries()
        {
            Dictionaries.Clear();

            var culturInfoList = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => c.Name.Length > 0);

            _resourceDirectory = SelectedProjectDirectory.GetDirectories("Resources").Single();
            var resxFiles = _resourceDirectory.GetFiles("*.resx");

            foreach (FileInfo resxFile in resxFiles)
            {
                if (culturInfoList.Any(ci => resxFile.Name.EndsWith(ci.Name + ".resx")))
                {
                    continue;
                }

                Dictionaries.Add(resxFile.Name.Replace(".resx", String.Empty));
            }

            if (Dictionaries.Any())
            {
                string lastUsedDictionary = AppRegistry.GetValue(RegistryKeys.SelectedDictionary);
                if (String.IsNullOrEmpty(lastUsedDictionary))
                {
                    SelectedDictionary = Dictionaries.First();
                }
                else
                {
                    SelectedDictionary = Dictionaries.First(dict => dict == lastUsedDictionary);
                }
            }
        }
예제 #4
0
 private void btnResult1_Click(object sender, EventArgs e)
 {
     if (btnResult.Text == "")
     {
         return;
     }
     AppRegistry.loadApp(btnResult.Text);
     txtSearch.Clear();
     btnResult.Text = "";
 }
예제 #5
0
 private static AppMetadataChangedEvent ConvertToAppRegistryChangedEvent(AppRegistry registry)
 {
     return new AppMetadataChangedEvent
     {
         Apps = { registry.Apps.Select(appInfo => new AppMetadataInfo
         {
             Id = appInfo.Id,
             DisplayName = appInfo.DisplayName,
             LauncherId = appInfo.LauncherId,
             LauncherParams = { appInfo.LauncherParams.Select(pair => new OptionParameter {Key = pair.Key, Value = pair.Value.ToString() })}
         })}
     };
 }
예제 #6
0
 private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)13)
     {
         if (btnResult.Text == "")
         {
             return;
         }
         AppRegistry.loadApp(btnResult.Text);
         txtSearch.Text = "Search Here";
         btnResult.Text = "";
         e.Handled      = true;
     }
 }
예제 #7
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (UserRegistry.checkPassword(txtUsername.Text, txtPassword.Text))
     {
         this.pnlLoadingContainer.Visible = true;
         Desktop desktop = new Desktop();
         desktop.Shown += new System.EventHandler(handleLoad);
         desktop.Show();
     }
     else
     {
         AppRegistry.loadMessageDialog("Error", "The Username/Password combination has not been recognized. Please try again.");
     }
 }
예제 #8
0
        /// <summary>
        /// Called, when the solution directory changes
        /// </summary>
        private void SolutionDirectoryChangedCallback()
        {
            AppRegistry.SetValue(RegistryKeys.SolutionPath, SolutionPath);

            ProjectDirectories = new ObservableCollection <DirectoryInfo>(
                SolutionDirectory.GetFiles("*.csproj", SearchOption.AllDirectories)
                .Select(f => f.Directory)
                .ToList()
                );

            string lastProjectUsed = AppRegistry.GetValue(RegistryKeys.SelectedProject);

            if (String.IsNullOrEmpty(lastProjectUsed))
            {
                return;
            }

            SelectedProjectDirectory = ProjectDirectories.FirstOrDefault(dir => dir.FullName == lastProjectUsed);
        }
예제 #9
0
        public MainPage()
        {
            var registry = new AppRegistry();

            registry.For <ISettingsDictionary>().Use <SettingsDictionary>().Singleton();
            Func <INavigation> navigationFactory = NavigationFactory;

            registry.For <Func <INavigation> >().Use(navigationFactory);
            _container = new Container(registry);

            this.InitializeComponent();
            var          mainPage     = _container.GetInstance <Forms.MainPage>();
            SettingsPage settingsPage = _container.GetInstance <SettingsPage>();

            var navigationService = _container.GetInstance <NavigationService>();

            navigationService.SettingsPage = settingsPage;
            _navigationPage = new NavigationPage(mainPage);
            LoadApplication(new Forms.App(_navigationPage));
        }
예제 #10
0
 public static void registerapps()
 {
     AppRegistry.registerApp(typeof(SettingsAppMain), "Settings");
     AppRegistry.registerApp(typeof(HybridModeAppMain), "Hybrid Mode");
 }
예제 #11
0
        /// <summary>
        /// Called, when the selected dictionary changes
        /// </summary>
        private void SelectedDictionaryChangedCallback()
        {
            AppRegistry.SetValue(RegistryKeys.SelectedDictionary, SelectedDictionary);

            ScanForLocalizations();
        }
예제 #12
0
 public MainViewModel()
 {
     IsScanInactive = true;
     SolutionPath   = AppRegistry.GetValue(RegistryKeys.SolutionPath);
 }
예제 #13
0
 private void Desktop_Load(object sender, EventArgs e)
 {
     RegisterApps.registerapps();
     apps = AppRegistry.listApps();
 }
예제 #14
0
 private void btnHybrid_Click(object sender, EventArgs e)
 {
     AppRegistry.loadApp("Hybrid Mode");
 }
예제 #15
0
 private void btnSettings_Click(object sender, EventArgs e)
 {
     AppRegistry.loadApp("Settings");
 }
예제 #16
0
 public virtual bool OnAppInitializing(AppRegistry appRegistry)
 {
     return true;
 }
예제 #17
0
 /// <summary>
 /// Called, when the selected localization project changes
 /// </summary>
 private void SelectedProjectDirectoryChangedCallback()
 {
     AppRegistry.SetValue(RegistryKeys.SelectedProject, SelectedProjectDirectory.FullName);
     ScanForDefaultDictionaries();
 }