コード例 #1
0
        public MakeViewModel()
        {
            PackageName = _("Enter-Package-Name-Placeholder");

            Languages = new ObservableCollection <CultureInfo>(
                CultureInfo.GetCultures(CultureTypes.AllCultures));

            SelectedLanguage = CultureInfo.CurrentCulture;

            MakeBackup      = true;
            ForceOverride   = false;
            WithTranslation = true;

            ExportCommand = new RelayCommand(Export);
            PackUpCommand = new RelayCommand(PackUp);

            packageManageService            = Localizer.Localizer.Kernel.Get <IPackageManageService>();
            packageExportService            = Localizer.Localizer.Kernel.Get <IPackageExportService>();
            packagePackService              = Localizer.Localizer.Kernel.Get <IPackagePackService>();
            packageSaveService              = Localizer.Localizer.Kernel.Get <IPackageSaveService>();
            packageUpdateService            = Localizer.Localizer.Kernel.Get <IPackageUpdateService>();
            fileSaveService                 = Localizer.Localizer.Kernel.Get <IFileSaveService>();
            sourcePackageLoadServiceService = Localizer.Localizer.Kernel.Get <SourcePackageLoadService <Package> >();
            fileLoadService                 = Localizer.Localizer.Kernel.Get <IFileLoadService>();
        }
コード例 #2
0
        public ManagerViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                packageManageService            = Localizer.Localizer.Kernel.Get <IPackageManageService>();
                sourcePackageLoadServiceService = Localizer.Localizer.Kernel.Get <SourcePackageLoadService <Package> >();
                packedPackageLoadServiceService = Localizer.Localizer.Kernel.Get <PackedPackageLoadService <Package> >();
                packageImportService            = Localizer.Localizer.Kernel.Get <IPackageImportService>();
                fileLoadService = Localizer.Localizer.Kernel.Get <IFileLoadService>();

                packageManageService.PackageGroups = new ObservableCollection <IPackageGroup>();
            }

            ReloadCommand    = new RelayCommand(Reload, () => !loading && !importing);
            SaveStateCommand = new RelayCommand(SaveState, () => !loading && !importing);
            ImportAllCommand = new RelayCommand(ImportAll, () => !loading && !importing);
            RevertCommand    = new RelayCommand(Revert);

            Application.Current.Dispatcher.InvokeAsync(() =>
            {
                LoadPackages();
                if (Localizer.Localizer.Config.AutoImport)
                {
                    ImportAll();
                }
            });
        }
コード例 #3
0
        public ManagerViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                packageManageDisposable         = Plugin.Kernel.Get <IPackageManageService>();
                sourcePackageLoadServiceService = Plugin.Kernel.Get <SourcePackageLoad <Package> >();
                packedPackageLoadServiceService = Plugin.Kernel.Get <PackedPackageLoad <Package> >();
                packageImportService            = Plugin.Kernel.Get <IPackageImportService>();
                fileLoadService = Plugin.Kernel.Get <IFileLoadService>();
                packageManageDisposable.PackageGroups = new ObservableCollection <IPackageGroup>();
            }

            ReloadCommand    = new RelayCommand(Reload, () => !loading && !importing);
            SaveStateCommand = new RelayCommand(SaveState, () => !loading && !importing);
            ImportAllCommand = new RelayCommand(ImportAll, () => !loading && !importing);

            packageManageDisposable.PackageGroups.Clear();
            LoadPackages();
        }
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: ziyuejun/Localizer
        public MainWindow()
        {
            Button AddButton(string text, string tooltip, MouseEvent action)
            {
                var button = new Button
                {
                    Text    = text,
                    Tooltip = tooltip,
                    Dock    = DockStyle.Left
                };

                button.MouseClick += action;
                _menuBar.Content.Controls.Add(button);
                return(button);
            }

            loading    = true;
            pkgManager = Localizer.Kernel.Get <IPackageManageService>();
            sourcePackageLoadServiceService = Localizer.Kernel.Get <SourcePackageLoad <DataModel.Default.Package> >();
            packedPackageLoadServiceService = Localizer.Kernel.Get <PackedPackageLoad <DataModel.Default.Package> >();
            packageExportService            = Localizer.Kernel.Get <IPackageExportService>();
            packageSaveService       = Localizer.Kernel.Get <IPackageSaveService>();
            packageUpdateService     = Localizer.Kernel.Get <IPackageUpdateService>();
            fileLoadService          = Localizer.Kernel.Get <IFileLoadService>();
            fileSaveService          = Localizer.Kernel.Get <IFileSaveService>();
            packageBrowserService    = Localizer.Kernel.Get <IPackageBrowserService>();
            downloadManagerService   = Localizer.Kernel.Get <IDownloadManagerService>();
            pkgManager.PackageGroups = new ObservableCollection <IPackageGroup>();
            Size          = new Point(800, 340);
            Position      = new Point(40, 200);
            Titlebar.Text = _("PackageManage");
            Titlebar.Button.MouseClick += (sender, args) => Visible = false;
            Resizable = true;

            _menuBar = new Panel
            {
                Dock = DockStyle.Top,
                Size = new Point(0, 30)
            };
            Controls.Add(_menuBar);

            AddButton(_("Reload"), _("ReloadDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    LoadPackages();
                }
            });

            var refreshBtn = AddButton(_("RefreshOnline"), _("RefreshOnlineDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    RefreshOnlinePackages(sender);
                }
            });

            AddButton(_("OpenFolder"), _("OpenFolderDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    Process.Start($"file://{Path.Combine(Environment.CurrentDirectory, "Localizer")}");
                }
            });

            AddButton(_("Export"), _("ExportDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    Export(false);
                }
            });

            AddButton(_("ExportWithTranslation"), _("ExportWithTranslationDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    Export(true);
                }
            });

            _split = new SplitContainer
            {
                Margin = new Margin(0, 10, 0, 0),
                Dock   = DockStyle.Fill
            };
            _split.SplitButton.Style    = "button";
            _split.SplitFrame1.AutoSize = AutoSize.Horizontal;
            _split.SplitFrame2.AutoSize = AutoSize.Horizontal;
            Controls.Add(_split);
            _split.SplitFrame1.Controls.Add(_modList);
            _modList.SelectedItemChanged += (sender, value) => RefreshPkgList();
            _split.SplitFrame2.Controls.Add(_pkgList);
            RefreshModList();
            LoadPackages().ContinueWith(_ => RefreshOnlinePackages(refreshBtn));
        }