private ApplicationSettingsViewModel BuildViewModel()
        {
            // TODO extend tests based on Edition
            var licenseChecker   = Substitute.For <ILicenseChecker>();
            var offlineActivator = Substitute.For <IOfflineActivator>();

            var printerHelper = Substitute.For <IPrinterHelper>();

            printerHelper.GetApplicablePDFCreatorPrinter(Arg.Any <string>(), Arg.Any <string>()).Returns("PDFCreator");
            var settingsHelper  = Substitute.For <ISettingsProvider>();
            var settingsManager = Substitute.For <ISettingsManager>();

            settingsManager.GetSettingsProvider().Returns(settingsHelper);
            var updateAssistant = Substitute.For <IUpdateAssistant>();
            var uacAssistant    = Substitute.For <IUacAssistant>();
            var process         = Substitute.For <IProcessStarter>();

            var generalTabViewModel = new GeneralTabViewModel(Substitute.For <ILanguageProvider>(), null, updateAssistant, uacAssistant, Substitute.For <IInteractionInvoker>(),
                                                              Substitute.For <IOsHelper>(), Substitute.For <IProcessStarter>(), new GeneralTabTranslation());
            var printerTabViewModel = new PrinterTabViewModel(printerHelper, null, null, null, printerHelper, new PrinterTabTranslation());
            var titleTabViewModel   = new TitleTabViewModel(new TitleTabTranslation(), new TranslationFactory());

            var debugTabViewModel        = new DebugTabViewModel(settingsManager, Substitute.For <ITestPageHelper>(), Substitute.For <IFile>(), Substitute.For <IProcessStarter>(), Substitute.For <IInteractionInvoker>(), printerHelper, Substitute.For <IIniSettingsAssistant>(), new DebugTabTranslation());
            var licenseTabViewModel      = new LicenseTabViewModel(process, licenseChecker, offlineActivator, null, Substitute.For <IDispatcher>(), new LicenseTabTranslation());
            var pdfArchitectTabViewModel = new PdfArchitectTabViewModel(Substitute.For <IPdfArchitectCheck>(), Substitute.For <IProcessStarter>(), new PdfArchitectTabTranslation());

            var viewModelBundle = new ApplicationSettingsViewModelBundle(generalTabViewModel, printerTabViewModel, titleTabViewModel, debugTabViewModel, licenseTabViewModel, pdfArchitectTabViewModel);

            return(new ApplicationSettingsViewModel(viewModelBundle, new TranslationHelper(new DefaultSettingsProvider(), new AssemblyHelper(), new TranslationFactory()), new LicenseOptionProvider(false), new ApplicationSettingsWindowTranslation()));
        }
Esempio n. 2
0
        static void Main(string[] arguments)
        {
            string solutionDirectory = @"D:\GitHub\entitas-vs\Entitas-vs.View\bin\Debug";

            string[]   uniqueProjectNames = { "adwd/awda.csproj", "awidjqqwe.csproj" };
            ConfigData configData         = Config.Load(solutionDirectory);
            var        settingsViewModel  = new SettingsViewModel(configData, solutionDirectory);
            var        generalTab         = new GeneralTabViewModel(settingsViewModel, solutionDirectory);
            var        triggersTab        = new TriggersTabViewModel(settingsViewModel, solutionDirectory, uniqueProjectNames);

            settingsViewModel.AddChild(generalTab);
            settingsViewModel.AddChild(triggersTab);
            settingsViewModel.CurrentTabViewModel = generalTab;

            var settingsView = new SettingsView {
                DataContext = settingsViewModel, Title = "Entitas VS Settings"
            };

            settingsViewModel.PropertyChanged += (self, args) => { if ((self as SettingsViewModel).WindowClosed)
                                                                   {
                                                                       settingsView.Close();
                                                                   }
            };
            settingsView.ShowDialog();
        }
        /// <summary>
        /// Shows the tool window when the menu item is clicked.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        private void ShowWindow(object sender, EventArgs e)
        {
            if (!EntitasVsPackage.IsSolutionLoaded)
            {
                MessageBox.Show("Solution not loaded. Load a solution to see settings.");
                return;
            }

            string solutionDirectory = DTE.Solution.GetDirectory();

            string[]   uniqueProjectNames = DTE.Solution.GetAllProjects().UniqueNames().ToArray();
            ConfigData configData         = Config.Load(solutionDirectory);
            var        settingsViewModel  = new SettingsViewModel(configData, solutionDirectory);
            var        generalTab         = new GeneralTabViewModel(settingsViewModel, solutionDirectory);
            var        triggersTab        = new TriggersTabViewModel(settingsViewModel, solutionDirectory, uniqueProjectNames);

            settingsViewModel.AddChild(generalTab);
            settingsViewModel.AddChild(triggersTab);
            settingsViewModel.CurrentTabViewModel = generalTab;

            var settingsView = new SettingsView {
                DataContext = settingsViewModel, Title = "Entitas VS Settings"
            };

            settingsViewModel.PropertyChanged += (self, args) => { if ((self as SettingsViewModel).WindowClosed)
                                                                   {
                                                                       settingsView.Close();
                                                                   }
            };
            settingsView.ShowDialog();
        }
        private async void View_LoadView(object sender, EventArgs e)
        {
            view.Loading(true);
            try
            {
                if (product.ID > 0)
                {
                    product = await Task.Run(() => api.GetProduct(product));
                }

                await Task.Run(async() =>
                {
                    GeneralTabVM        = new GeneralTabViewModel(product as ProductData, api.GetLanguages());
                    DataTabVM           = new DataTabViewModel(product as ProductData, api.GetLengthClasses(), api.GetWeightClasses(), api.GetStockStatuses(), api.GetTaxClasses());
                    LinksTabVM          = new LinksTabViewModel(product as ProductData, api.GetStores(), api.GetManufacturers(), await Task.Run(() => api.GetProducts(null)), api.GetCategories());
                    var customer_groups = api.GetCustomerGroups();
                    DiscountTabVM       = new DiscountTabViewModel(product as ProductData, customer_groups);
                    SpecialTabVM        = new SpecialTabViewModel(product as ProductData, customer_groups);
                    ImagesTabVM         = new ImagesTabViewModel(product as ProductData, api.GetServerData().URL_img);
                });
            }
            catch (InvalidOperationException ex)
            {
                view.Message(ex.Message);
            }
            finally
            {
                view.Loading(false);
            }
        }
        private GeneralTabViewModel BuildGeneralTabViewModel()
        {
            var generalTabViewModel = new GeneralTabViewModel(null);

            generalTabViewModel.ApplicationSettings = new ApplicationSettings();

            return(generalTabViewModel);
        }
        public void UpdateCheckControlVisibility_EditionHideAndDisableUpdatesIsEnabled_ReturnsCollapsed()
        {
            var edition = new Edition();

            edition.HideAndDisableUpdates = true;
            var generalTabViewModel = new GeneralTabViewModel(edition);

            Assert.AreEqual(Visibility.Collapsed, generalTabViewModel.UpdateCheckControlVisibility);
        }
        public void UpdateCheckControlVisibility_EditionHideAndDisableUpdatesIsDisabled_ReturnsVisibile()
        {
            var edition = new Edition();

            edition.HideAndDisableUpdates = false;
            var generalTabViewModel = new GeneralTabViewModel(edition);

            Assert.AreEqual(Visibility.Visible, generalTabViewModel.UpdateCheckControlVisibility);
        }
 public ApplicationSettingsViewModelBundle(GeneralTabViewModel generalTabViewModel,
                                           PrinterTabViewModel printerTabViewModel, TitleTabViewModel titleTabViewModel,
                                           DebugTabViewModel debugTabViewModel, LicenseTabViewModel licenseTabViewModel, PdfArchitectTabViewModel pdfArchitectTabViewModel)
 {
     GeneralTabViewModel      = generalTabViewModel;
     PrinterTabViewModel      = printerTabViewModel;
     TitleTabViewModel        = titleTabViewModel;
     DebugTabViewModel        = debugTabViewModel;
     LicenseTabViewModel      = licenseTabViewModel;
     PdfArchitectTabViewModel = pdfArchitectTabViewModel;
 }
Esempio n. 9
0
        private GeneralTabViewModel BuildGeneralTabViewModelWithoutUpdate()
        {
            var updateAssistant = Substitute.For <IUpdateAssistant>();

            updateAssistant.UpdatesEnabled.Returns(false);

            var generalTabViewModel = new GeneralTabViewModel(Substitute.For <ILanguageProvider>(), null, updateAssistant, Substitute.For <IUacAssistant>(), Substitute.For <IInteractionInvoker>(), Substitute.For <IOsHelper>(), Substitute.For <IProcessStarter>(), new GeneralTabTranslation());

            generalTabViewModel.SetSettingsAndRaiseNotifications(new PdfCreatorSettings(null), null);

            return(generalTabViewModel);
        }
Esempio n. 10
0
        public void UpdateCheckControlVisibility_EditionIsNull_ReturnsVisibile()
        {
            var generalTabViewModel = new GeneralTabViewModel(null);

            Assert.AreEqual(Visibility.Visible, generalTabViewModel.UpdateCheckControlVisibility);
        }