public AppConfig()
        {
            InitializeComponent();

            // Region.
            _cultureInfos            = CultureInfo.GetCultures(CultureTypes.AllCultures).OrderBy(i => i.DisplayName).ToList();
            cbLocation.ItemsSource   = _cultureInfos.Select(c => c.DisplayName);
            cbLocation.SelectedIndex = _cultureInfos.FindIndex(c => c.Name == "ja-JP");

            //Timezone.
            _timezones               = TimeZoneInfo.GetSystemTimeZones().ToList();
            cbTimezone.ItemsSource   = _timezones.Select(t => t.DisplayName);
            cbTimezone.SelectedIndex = _timezones.FindIndex(tz => tz.Id == "Tokyo Standard Time");

            // Load exists config.
            var configs = LEConfig.GetProfiles(App.StandaloneFilePath);

            if (configs.Length > 0)
            {
                var conf = configs[0];

                if (!string.IsNullOrEmpty(conf.Parameter))
                {
                    tbAppParameter.FontStyle = FontStyles.Normal;
                    tbAppParameter.Text      = conf.Parameter;
                }
                cbTimezone.SelectedIndex = _timezones.FindIndex(tz => tz.Id == conf.Timezone);
                cbLocation.SelectedIndex = _cultureInfos.FindIndex(ci => ci.Name == conf.Location);

                cbStartAsAdmin.IsChecked     = conf.RunAsAdmin;
                cbRedirectRegistry.IsChecked = conf.RedirectRegistry;
                cbStartAsSuspend.IsChecked   = conf.RunWithSuspend;
            }
        }
        public FileContextMenuExt()
        {
            var is4K = SystemHelper.Is4KDisplay();

            //Load the bitmap for the menu item.
            _menuBmpPink   = is4K ? Resource.purple_200.GetHbitmap() : Resource.purple.GetHbitmap();
            _menuBmpGray   = is4K ? Resource.gray_200.GetHbitmap() : Resource.gray.GetHbitmap();
            _menuBmpBlue   = is4K ? Resource.blue_200.GetHbitmap() : Resource.blue.GetHbitmap();
            _menuBmpYellow = is4K ? Resource.yellow_200.GetHbitmap() : Resource.yellow.GetHbitmap();

            //Load default items.
            menuItems.Add(new LEMenuItem(I18n.GetString("Submenu"), true, null, _menuBmpYellow, ""));
            menuItems.Add(new LEMenuItem(I18n.GetString("RunDefault"), true, null, _menuBmpYellow, "-run \"%APP%\""));
            menuItems.Add(new LEMenuItem(I18n.GetString("ManageApp"), true, null, _menuBmpGray, "-manage \"%APP%\""));
            menuItems.Add(new LEMenuItem(I18n.GetString("ManageAll"), true, null, _menuBmpBlue, "-global"));

            //Load global profiles.
            Array.ForEach(LEConfig.GetProfiles(),
                          p =>
                          menuItems.Add(new LEMenuItem(p.Name,
                                                       true,
                                                       p.ShowInMainMenu,
                                                       _menuBmpPink,
                                                       $"-runas \"{p.Guid}\" \"%APP%\"")));

            //Config does not exist
            if (LEConfig.GetProfiles().Length == 0)
            {
                menuItems.Add(new LEMenuItem("No profile, please run LEGUI.exe.", false, false, _menuBmpPink, ""));
            }
        }
        private static void RunWithGlobalProfile(string guid, string path)
        {
            // We do not check whether the config exists because only when it exists can this method be called.

            var profile = LEConfig.GetProfiles().First(p => p.Guid == guid);

            DoRunWithLEProfile(path, profile);
        }
Exemple #4
0
        private static void RunWithIndependentProfile(string path)
        {
            string conf = path + ".le.config";

            if (!File.Exists(conf))
                Process.Start(
                    Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "LEGUI.exe"),
                    String.Format("\"{0}.le.config\"", path));
            else
            {
                LEProfile profile = LEConfig.GetProfiles(conf)[0];
                DoRunWithLEProfile(path, profile);
            }
        }
Exemple #5
0
        private static void RunWithDefaultProfile(string path)
        {
            path = SystemHelper.EnsureAbsolutePath(path);

            var conf = path + ".le.config";

            var appProfile     = LEConfig.GetProfiles(conf);
            var globalProfiles = LEConfig.GetProfiles();

            // app profile > first global profile > new profile(ja-JP)
            var profile = appProfile.Any()
                ? appProfile.First()
                : globalProfiles.Any() ? globalProfiles.First() : new LEProfile(true);

            DoRunWithLEProfile(path, 1, profile);
        }
        private static void RunWithIndependentProfile(string path)
        {
            var conf = path + ".le.config";

            if (!File.Exists(conf))
            {
                Process.Start(
                    Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "LEGUI.exe"),
                    $"\"{path}.le.config\"");
            }
            else
            {
                var profile = LEConfig.GetProfiles(conf)[0];
                DoRunWithLEProfile(path, 2, profile);
            }
        }
Exemple #7
0
        public GlobalConfig()
        {
            InitializeComponent();

            // Region.
            _cultureInfos          = CultureInfo.GetCultures(CultureTypes.AllCultures).OrderBy(i => i.DisplayName).ToList();
            cbLocation.ItemsSource = _cultureInfos.Select(c => c.DisplayName);

            //Timezone.
            _timezones             = TimeZoneInfo.GetSystemTimeZones().ToList();
            cbTimezone.ItemsSource = _timezones.Select(t => t.DisplayName);

            //Profiles.
            _profiles = LEConfig.GetProfiles().ToList();
            cbGlobalProfiles.ItemsSource = _profiles.Select(p => p.Name);
        }
        public FileContextMenuExt()
        {
            //Load the bitmap for the menu item.
            _menuBmpPink = Resource.Pink.GetHbitmap();
            _menuBmpGray = Resource.Gray.GetHbitmap();

            //Load default items.
            menuItems.Add(new LEMenuItem(I18n.GetString("RunDefault"), null, _menuBmpPink, "-run \"%APP%\""));
            menuItems.Add(new LEMenuItem(I18n.GetString("Submenu"), null, _menuBmpGray, ""));
            menuItems.Add(new LEMenuItem(I18n.GetString("ManageApp"), null, _menuBmpGray, "-manage \"%APP%\""));
            menuItems.Add(new LEMenuItem(I18n.GetString("ManageAll"), null, _menuBmpGray, "-global"));

            //Load global profiles.
            Array.ForEach(LEConfig.GetProfiles(),
                          p =>
                          menuItems.Add(new LEMenuItem(p.Name, p.ShowInMainMenu, _menuBmpGray,
                                                       string.Format("-runas \"{0}\" \"%APP%\"", p.Guid))));
        }