Exemplo n.º 1
0
        public override void SetUp()
        {
            base.SetUp();

			var edit = new EditSection();// { Editors = new PermissionElement(), Administrators  };
			finder = new PluginFinder(typeFinder, new SecurityManager(new ThreadContext(), edit), TestSupport.SetupEngineSection());
        }
Exemplo n.º 2
0
        public new void SetUp()
        {
            _taxSettings = new TaxSettings();
            _taxSettings.DefaultTaxAddressId = 10;

            _workContext = null;

            _addressService = MockRepository.GenerateMock<IAddressService>();
            //default tax address
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address { Id = _taxSettings.DefaultTaxAddressId });

            var pluginFinder = new PluginFinder();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _geoLookupService = MockRepository.GenerateMock<IGeoLookupService>();
            _countryService = MockRepository.GenerateMock<ICountryService>();
            _logger = MockRepository.GenerateMock<ILogger>();
            _customerSettings = new CustomerSettings();
            _addressSettings = new AddressSettings();

            _taxService = new TaxService(_addressService, _workContext, _taxSettings,
                pluginFinder, _geoLookupService, _countryService, _logger
                , _customerSettings, _addressSettings);
        }
		public LibraryProviderSelector(Action<LibraryProvider> setCurrentLibraryProvider)
			: base(null)
		{
			this.Name = "Home".Localize();

			this.setCurrentLibraryProvider = setCurrentLibraryProvider;

			ApplicationController.Instance.CloudSyncStatusChanged.RegisterEvent(CloudSyncStatusChanged, ref unregisterEvents);

			if (false)
			{
				// This is test code for how to add these when we get to it
				// put in the queue provider
				libraryCreators.Add(new LibraryProviderQueueCreator());
				AddFolderImage("queue_folder.png");

				// put in the queue provider
				libraryCreators.Add(new LibraryProviderHistoryCreator());
				AddFolderImage("queue_folder.png");
			}

			// put in the sqlite provider
			libraryCreators.Add(new LibraryProviderSQLiteCreator());
			AddFolderImage("library_folder.png");

			// Check for LibraryProvider factories and put them in the list too.
			PluginFinder<LibraryProviderPlugin> libraryProviderPlugins = new PluginFinder<LibraryProviderPlugin>();
			foreach (LibraryProviderPlugin libraryProviderPlugin in libraryProviderPlugins.Plugins)
			{
				// This coupling is required to navigate to the Purchased folder after redemption or purchase updates
				libraryCreators.Add(libraryProviderPlugin);
				folderImagesForChildren.Add(libraryProviderPlugin.GetFolderImage());

				if (libraryProviderPlugin.ProviderKey == "LibraryProviderPurchasedKey")
				{
					this.PurchasedLibraryCreator = libraryProviderPlugin;
				}
			}

			// and any directory providers (sd card provider, etc...)
			// Add "Downloads" file system example
			string downloadsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
			if (Directory.Exists(downloadsDirectory))
			{
				libraryCreators.Add(new LibraryProviderFileSystemCreator(downloadsDirectory, "Downloads"));
				AddFolderImage("download_folder.png");
			}

			firstAddedDirectoryIndex = libraryCreators.Count;

#if !__ANDROID__
			MenuOptionFile.CurrentMenuOptionFile.AddLocalFolderToLibrary += (sender, e) =>
			{
				AddCollectionToLibrary(e.Data);
			};
#endif

			this.FilterProviders();
		}
Exemplo n.º 4
0
        private static void RegisterPlugins([NotNull] Container container)
        {
            DebugGuard.NotNull(container, nameof(container));

            var pluginAssemblies = PluginFinder.FindPluginAssemblies(Path.Combine(AppDomain.CurrentDomain.BaseDirectory));

            container.RegisterPackages(pluginAssemblies);
        }
Exemplo n.º 5
0
 private static IEnumerable <IPluginConfigurator> GetPluginConfigurators()
 {
     if (_pluginConfigurators == null)
     {
         _pluginConfigurators = PluginFinder.GetConfigurators(true);
     }
     return(_pluginConfigurators);
 }
Exemplo n.º 6
0
        public override void SetUp()
        {
            base.SetUp();

            var edit = new EditSection();            // { Editors = new PermissionElement(), Administrators  };

            finder = new PluginFinder(typeFinder, new SecurityManager(new ThreadContext(), edit), TestSupport.SetupEngineSection());
        }
Exemplo n.º 7
0
        public KolaNancyBootstrapper()
        {
            var plugins = new PluginFinder().FindPlugins().ToArray();

            this.ConfigureNamespaces(plugins);

            KolaConfigurationRegistry.RegisterPlugins(plugins);
        }
Exemplo n.º 8
0
        private static IEnumerable <IPluginConfigurator> GetPlugins(XmlNode section)
        {
            List <IPluginConfigurator>        plugins        = new List <IPluginConfigurator>();
            IEnumerable <IPluginConfigurator> dotlessPlugins = null; //lazy initiate incase of no plugins used
            List <string> assemblies = new List <string>();

            foreach (XmlNode node in section.SelectNodes("plugin"))
            {
                if (dotlessPlugins == null)
                {
                    dotlessPlugins = PluginFinder.GetConfigurators(false);
                }

                string assembly = GetStringValue(node, "assembly");

                if (assembly != null)
                {
                    if (!assemblies.Contains(assembly))
                    {
                        dotlessPlugins = dotlessPlugins.Union(PluginFinder.GetConfigurators(Assembly.Load(assembly)));
                        assemblies.Add(assembly);
                    }
                }

                string name   = GetStringValue(node, "name");
                var    plugin = dotlessPlugins.Where(p => p.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                                .FirstOrDefault();

                if (plugin == null)
                {
                    throw new Exception(
                              string.Format("Cannot find plugin called {0}. If it is an external plugin, make sure the assembly is referenced.", name));
                }
                var pluginParameters = plugin.GetParameters();

                foreach (XmlNode pluginParameter in node.SelectNodes("pluginParameter"))
                {
                    var pluginParameterName  = GetStringValue(pluginParameter, "name");
                    var pluginParameterValue = GetStringValue(pluginParameter, "value");

                    var actualParameter = pluginParameters
                                          .Where(p => p.Name.Equals(pluginParameterName, StringComparison.InvariantCultureIgnoreCase))
                                          .FirstOrDefault();

                    if (actualParameter == null)
                    {
                        throw new Exception(
                                  string.Format("Cannot find plugin argument {0} in plugin {1}", pluginParameterName, name));
                    }

                    actualParameter.SetValue(pluginParameterValue);
                }

                plugin.SetParameterValues(pluginParameters);
                plugins.Add(plugin);
            }
            return(plugins);
        }
Exemplo n.º 9
0
        public new void SetUp()
        {
            _discountRepo = MockRepository.GenerateMock <IRepository <Discount> >();
            var discount1 = new Discount
            {
                Id                 = 1,
                DiscountType       = DiscountType.AssignedToCategories,
                Name               = "Discount 1",
                UsePercentage      = true,
                DiscountPercentage = 10,
                DiscountAmount     = 0,
                DiscountLimitation = DiscountLimitationType.Unlimited,
                LimitationTimes    = 0,
            };
            var discount2 = new Discount
            {
                Id                 = 2,
                DiscountType       = DiscountType.AssignedToSkus,
                Name               = "Discount 2",
                UsePercentage      = false,
                DiscountPercentage = 0,
                DiscountAmount     = 5,
                RequiresCouponCode = true,
                CouponCode         = "SecretCode",
                DiscountLimitation = DiscountLimitationType.NTimesPerCustomer,
                LimitationTimes    = 3,
            };

            _discountRepo.Expect(x => x.Table).Return(new List <Discount>()
            {
                discount1, discount2
            }.AsQueryable());

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(new Store
            {
                Id   = 1,
                Name = "MyStore"
            });

            _settingService = MockRepository.GenerateMock <ISettingService>();

            var cacheManager = new NullCache();

            _discountRequirementRepo  = MockRepository.GenerateMock <IRepository <DiscountRequirement> >();
            _discountUsageHistoryRepo = MockRepository.GenerateMock <IRepository <DiscountUsageHistory> >();
            var pluginFinder = new PluginFinder();

            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();

            _discountService = new DiscountService(cacheManager, _discountRepo, _discountRequirementRepo,
                                                   _discountUsageHistoryRepo, _storeContext, _genericAttributeService, pluginFinder, _eventPublisher,
                                                   _settingService, base.ProviderManager);
        }
Exemplo n.º 10
0
        public void FixtureSetup()
        {
            _prev = CommonHelper.GetEntryAssembly;
            CommonHelper.GetEntryAssembly = () => typeof(TestBase).Assembly;
            var container = new TinyIoCContainer();

            container.Register <ISecurityManager, FakeSecurityManager>();
            _finder = new PluginFinder(new AppDomainTypeFinder(new AssemblyFinder()), container);
        }
Exemplo n.º 11
0
        public override void SetUp()
        {
            base.SetUp();

            //new[] { typeof(SeveralPlugins), typeof(PermittablePlugins) }

            var edit = new EditSection();            // { Editors = new PermissionElement(), Administrators  };

            finder = new PluginFinder(typeFinder, new SecurityManager(new ThreadContext(), edit), new EngineSection());
        }
Exemplo n.º 12
0
        private void VerifierGUI_Load(object sender, EventArgs e)
        {
            pfinder                    = new PluginFinder();
            pfinder.OnStart           += new EventHandler(pfinder_OnStart);
            pfinder.OnIsPluginTrusted += new PluginFinder.IsPluginTrustedEventHandler(pfinder_OnIsPluginTrusted);
            pfinder.OnPluginFound     += new PluginFinder.PluginFoundEventHandler(pfinder_OnPluginFound);
            pfinder.OnStop            += new EventHandler(pfinder_OnStop);
            plugins                    = new Dictionary <string, KeyValuePair <Type, IPlugin> >();

            pfinder.Start();
        }
Exemplo n.º 13
0
        public new void SetUp()
        {
            var cacheManager = new NasNullCache();

            _workContext = null;

            _currencySettings = new CurrencySettings();
            var currency1 = new Currency
            {
                Id               = 1,
                Name             = "Euro",
                CurrencyCode     = "EUR",
                DisplayLocale    = "",
                CustomFormatting = "€0.00",
                DisplayOrder     = 1,
                Published        = true,
                CreatedOnUtc     = DateTime.UtcNow,
                UpdatedOnUtc     = DateTime.UtcNow
            };
            var currency2 = new Currency
            {
                Id               = 1,
                Name             = "US Dollar",
                CurrencyCode     = "USD",
                DisplayLocale    = "en-US",
                CustomFormatting = "",
                DisplayOrder     = 2,
                Published        = true,
                CreatedOnUtc     = DateTime.UtcNow,
                UpdatedOnUtc     = DateTime.UtcNow
            };

            _currencyRepo = MockRepository.GenerateMock <IRepository <Currency> >();
            _currencyRepo.Expect(x => x.Table).Return(new List <Currency>()
            {
                currency1, currency2
            }.AsQueryable());

            _storeMappingRepo = MockRepository.GenerateMock <IRepository <StoreMapping> >();

            var pluginFinder = new PluginFinder();

            _currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingRepo,
                                                   _currencySettings, pluginFinder, null);

            _taxSettings = new TaxSettings();

            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax");
            _localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} excl tax");

            _priceFormatter = new PriceFormatter(_workContext, _currencyService, _localizationService,
                                                 _taxSettings, _currencySettings);
        }
Exemplo n.º 14
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings
            {
                UseCubeRootMethod = true,
                ConsiderAssociatedProductsDimensions = true,
                ShipSeparatelyOneItemEach            = false
            };

            _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >();
            _warehouseRepository      = new Mock <IRepository <Warehouse> >();
            _logger = new NullLogger();
            _productAttributeParser  = new Mock <IProductAttributeParser>();
            _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>();

            var cacheManager = new NopNullCache();

            _productService = new Mock <IProductService>();

            _eventPublisher = new Mock <IEventPublisher>();
            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            var pluginFinder = new PluginFinder(_eventPublisher.Object);

            _localizationService     = new Mock <ILocalizationService>();
            _addressService          = new Mock <IAddressService>();
            _genericAttributeService = new Mock <IGenericAttributeService>();
            _priceCalcService        = new Mock <IPriceCalculationService>();

            _store = new Store {
                Id = 1
            };
            _storeContext = new Mock <IStoreContext>();
            _storeContext.Setup(x => x.CurrentStore).Returns(_store);

            _shoppingCartSettings = new ShoppingCartSettings();

            _shippingService = new ShippingService(_addressService.Object,
                                                   cacheManager,
                                                   _checkoutAttributeParser.Object,
                                                   _eventPublisher.Object,
                                                   _genericAttributeService.Object,
                                                   _localizationService.Object,
                                                   _logger,
                                                   pluginFinder,
                                                   _priceCalcService.Object,
                                                   _productAttributeParser.Object,
                                                   _productService.Object,
                                                   _shippingMethodRepository.Object,
                                                   _warehouseRepository.Object,
                                                   _storeContext.Object,
                                                   _shippingSettings,
                                                   _shoppingCartSettings);
        }
Exemplo n.º 15
0
        public ActionResult Index()
        {
            PluginFinder pf   = new PluginFinder();
            var          list = pf.GetPluginDescriptors(LoadPluginsMode.All);

            ViewBag.Pager = new Paging()
            {
                PageIndex = 1, PageSize = 10
            };
            return(View(list));
        }
Exemplo n.º 16
0
        public PluginManager()
        {
            if (File.Exists(pluginStateFile))
            {
                try
                {
                    this.Disabled = JsonConvert.DeserializeObject <HashSet <string> >(File.ReadAllText(pluginStateFile));
                }
                catch
                {
                    this.Disabled = new HashSet <string>();
                }
            }
            else
            {
                this.Disabled = new HashSet <string>();
            }

            if (File.Exists(knownPluginsFile))
            {
                try
                {
                    this.KnownPlugins = JsonConvert.DeserializeObject <List <PluginState> >(File.ReadAllText(knownPluginsFile));
                }
                catch
                {
                }
            }

            var plugins = new List <IApplicationPlugin>();

            foreach (var containerType in PluginFinder.FindTypes <IApplicationPlugin>().Where(type => Disabled.Contains(type.FullName) == false))
            {
                try
                {
                    plugins.Add(Activator.CreateInstance(containerType) as IApplicationPlugin);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error constructing plugin: " + ex.Message);
                }
            }

            this.Plugins = plugins;

            /*
             * // Uncomment to generate new KnownPlugins.json file
             * KnownPlugins = plugins.Where(p => p.MetaData != null).Select(p => new PluginState { TypeName = p.GetType().FullName, Name = p.MetaData.Name }).ToList();
             *
             * File.WriteAllText(
             *      Path.Combine("..", "..", "knownPlugins.json"),
             *      JsonConvert.SerializeObject(KnownPlugins, Formatting.Indented)); */
        }
Exemplo n.º 17
0
        public void CanRemovePlugins_ThroughConfiguration()
        {
            int initialCount = finder.GetPlugins <NavigationPluginAttribute>().Count();

            finder = new PluginFinder(typeFinder, new SecurityManager(new ThreadContext(), new EditSection()), CreateEngineSection(new[] { new InterfacePluginElement {
                                                                                                                                               Name = "chill"
                                                                                                                                           } }));

            IEnumerable <NavigationPluginAttribute> plugins = finder.GetPlugins <NavigationPluginAttribute>();

            Assert.That(plugins.Count(), Is.EqualTo(initialCount - 1), "Found unexpected items, e.g.:" + plugins.FirstOrDefault());
        }
Exemplo n.º 18
0
        public new void SetUp()
        {
            _paymentSettings = new PaymentSettings();
            _paymentSettings.ActivePaymentMethodSystemNames = new List<string>();
            _paymentSettings.ActivePaymentMethodSystemNames.Add("Payments.TestMethod");

            var pluginFinder = new PluginFinder(new AppDomainTypeFinder());

            _shoppingCartSettings = new ShoppingCartSettings();

            _paymentService = new PaymentService(_paymentSettings, pluginFinder, _shoppingCartSettings);
        }
Exemplo n.º 19
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings
            {
                ActiveShippingRateComputationMethodSystemNames = new List <string>()
            };
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >();
            _warehouseRepository      = new Mock <IRepository <Warehouse> >();
            _logger = new NullLogger();
            _productAttributeParser  = new Mock <IProductAttributeParser>();
            _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>();

            var cacheManager = new NopNullCache();

            _productService = new Mock <IProductService>();

            _eventPublisher = new Mock <IEventPublisher>();
            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            var pluginFinder = new PluginFinder(_eventPublisher.Object);

            _localizationService     = new Mock <ILocalizationService>();
            _addressService          = new Mock <IAddressService>();
            _genericAttributeService = new Mock <IGenericAttributeService>();
            _priceCalcService        = new Mock <IPriceCalculationService>();

            _store = new Store {
                Id = 1
            };
            _storeContext = new Mock <IStoreContext>();
            _storeContext.Setup(x => x.CurrentStore).Returns(_store);

            _shoppingCartSettings = new ShoppingCartSettings();

            _shippingService = new ShippingService(_addressService.Object,
                                                   cacheManager,
                                                   _checkoutAttributeParser.Object,
                                                   _eventPublisher.Object,
                                                   _genericAttributeService.Object,
                                                   _localizationService.Object,
                                                   _logger,
                                                   pluginFinder,
                                                   _priceCalcService.Object,
                                                   _productAttributeParser.Object,
                                                   _productService.Object,
                                                   _shippingMethodRepository.Object,
                                                   _warehouseRepository.Object,
                                                   _storeContext.Object,
                                                   _shippingSettings,
                                                   _shoppingCartSettings);
        }
		public LibraryProviderSelector(Action<LibraryProvider> setCurrentLibraryProvider, bool includeQueueLibraryProvider)
			: base(null, setCurrentLibraryProvider)
		{
			this.includeQueueLibraryProvider = includeQueueLibraryProvider;
			this.Name = "Home".Localize();

			ApplicationController.Instance.CloudSyncStatusChanged.RegisterEvent(CloudSyncStatusChanged, ref unregisterEvents);

			libraryProviderPlugins = new PluginFinder<LibraryProviderPlugin>();

			ReloadData();
		}
Exemplo n.º 21
0
        public new void SetUp()
        {
            _paymentSettings = new PaymentSettings();
            _paymentSettings.ActivePaymentMethodSystemNames = new List <string>();
            _paymentSettings.ActivePaymentMethodSystemNames.Add("Payments.TestMethod");

            var pluginFinder = new PluginFinder(new AppDomainTypeFinder());

            _shoppingCartSettings = new ShoppingCartSettings();

            _paymentService = new PaymentService(_paymentSettings, pluginFinder, _shoppingCartSettings);
        }
        public new void SetUp()
        {
            _discountRepo = MockRepository.GenerateMock<IRepository<Discount>>();
            var discount1 = new Discount
            {
                Id = 1,
                DiscountType = DiscountType.AssignedToCategories,
                Name = "Discount 1",
                UsePercentage = true,
                DiscountPercentage = 10,
                DiscountAmount = 0,
                DiscountLimitation = DiscountLimitationType.Unlimited,
                LimitationTimes = 0,
            };
            var discount2 = new Discount
            {
                Id = 2,
                DiscountType = DiscountType.AssignedToSkus,
                Name = "Discount 2",
                UsePercentage = false,
                DiscountPercentage = 0,
                DiscountAmount = 5,
                RequiresCouponCode = true,
                CouponCode = "SecretCode",
                DiscountLimitation = DiscountLimitationType.NTimesPerCustomer,
                LimitationTimes = 3,
            };

            _discountRepo.Expect(x => x.Table).Return(new List<Discount>() { discount1, discount2 }.AsQueryable());

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

			_storeContext = MockRepository.GenerateMock<IStoreContext>();
			_storeContext.Expect(x => x.CurrentStore).Return(new Store 
			{ 
				Id = 1,
				Name = "MyStore"
			});

			_settingService = MockRepository.GenerateMock<ISettingService>();

            var cacheManager = new NullCache();
            _discountRequirementRepo = MockRepository.GenerateMock<IRepository<DiscountRequirement>>();
            _discountUsageHistoryRepo = MockRepository.GenerateMock<IRepository<DiscountUsageHistory>>();
            var pluginFinder = new PluginFinder();
			_genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();

			_discountService = new DiscountService(cacheManager, _discountRepo, _discountRequirementRepo,
				_discountUsageHistoryRepo, _storeContext, _genericAttributeService, pluginFinder, _eventPublisher,
				_settingService, base.ProviderManager);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            var pluginFinder = new PluginFinder();

            pluginFinder.ReloadPlugins();

            var pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName("BreadCrumb.GBS");

            if (pluginDescriptor != null)
            {
                builder.RegisterType <GBSProductModelFactory>().As <IProductModelFactory>().InstancePerLifetimeScope();
            }
        }
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            var pluginFinder = new PluginFinder();

            pluginFinder.ReloadPlugins();

            var pluginDescriptor = pluginFinder.GetPluginDescriptorBySystemName("PriceCalculation.GBS");

            if (pluginDescriptor != null)  // pluginDescriptor.Installed == true
            {
                builder.RegisterType <GBSPriceCalculationService>().As <IPriceCalculationService>().InstancePerLifetimeScope();
            }
        }
Exemplo n.º 25
0
        public new void SetUp()
        {
            _paymentSettings = new PaymentSettings();
            _paymentSettings.ActivePaymentMethodSystemNames = new List<string>();
            _paymentSettings.ActivePaymentMethodSystemNames.Add("Payments.TestMethod");

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _settingService = MockRepository.GenerateMock<ISettingService>();

            _paymentService = new PaymentService(_paymentSettings, pluginFinder, _settingService, _shoppingCartSettings);
        }
Exemplo n.º 26
0
        public new void SetUp()
        {
            _paymentSettings = new PaymentSettings();
            _paymentSettings.ActivePaymentMethodSystemNames = new List <string>();
            _paymentSettings.ActivePaymentMethodSystemNames.Add("Payments.TestMethod");

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _settingService       = MockRepository.GenerateMock <ISettingService>();

            _paymentService = new PaymentService(_paymentSettings, pluginFinder, _settingService, _shoppingCartSettings);
        }
Exemplo n.º 27
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _deliveryDateRepository   = MockRepository.GenerateMock <IRepository <DeliveryDate> >();
            _warehouseRepository      = MockRepository.GenerateMock <IRepository <Warehouse> >();
            _logger = new NullLogger();
            _productAttributeParser  = MockRepository.GenerateMock <IProductAttributeParser>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();

            var cacheManager = new NopNullCache();

            var pluginFinder = new PluginFinder();

            _productService = MockRepository.GenerateMock <IProductService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService     = MockRepository.GenerateMock <ILocalizationService>();
            _addressService          = MockRepository.GenerateMock <IAddressService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();

            _store = new Store()
            {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService      = new ShippingService(_shippingMethodRepository,
                                                        _deliveryDateRepository,
                                                        _warehouseRepository,
                                                        _logger,
                                                        _productService,
                                                        _productAttributeParser,
                                                        _checkoutAttributeParser,
                                                        _genericAttributeService,
                                                        _localizationService,
                                                        _addressService,
                                                        _shippingSettings,
                                                        pluginFinder,
                                                        _storeContext,
                                                        _eventPublisher,
                                                        _shoppingCartSettings,
                                                        cacheManager);
        }
Exemplo n.º 28
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings
            {
                UseCubeRootMethod = true,
                ConsiderAssociatedProductsDimensions = true
            };

            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _warehouseRepository      = MockRepository.GenerateMock <IRepository <Warehouse> >();
            _logger = new NullLogger();
            _productAttributeParser  = MockRepository.GenerateMock <IProductAttributeParser>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();

            var cacheManager = new NopNullCache();

            var pluginFinder = new PluginFinder();

            _productService = MockRepository.GenerateMock <IProductService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService     = MockRepository.GenerateMock <ILocalizationService>();
            _addressService          = MockRepository.GenerateMock <IAddressService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();

            _store = new Store {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService      = new ShippingService(_shippingMethodRepository,
                                                        _warehouseRepository,
                                                        _logger,
                                                        _productService,
                                                        _productAttributeParser,
                                                        _checkoutAttributeParser,
                                                        _genericAttributeService,
                                                        _localizationService,
                                                        _addressService,
                                                        _shippingSettings,
                                                        pluginFinder,
                                                        _storeContext,
                                                        _eventPublisher,
                                                        _shoppingCartSettings,
                                                        cacheManager);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Gets the plugin's registration key.
        /// </summary>
        public static Guid GetRegistrationKey(int pluginId)
        {
            PluginFinder finder = new PluginFinder {
                PluginId = pluginId
            };
            Plugin plugin = Plugin.FindOne(finder);

            if (!plugin.IsNull)
            {
                return(plugin.RegistrationKey);
            }

            return(Guid.Empty);
        }
Exemplo n.º 30
0
        public new void SetUp()
        {
            _taxSettings = new TaxSettings
            {
                DefaultTaxAddressId = 10
            };

            _workContext  = null;
            _storeContext = new Mock <IStoreContext>();
            _storeContext.Setup(x => x.CurrentStore).Returns(new Store {
                Id = 1
            });

            _addressService = new Mock <IAddressService>();
            //default tax address
            _addressService.Setup(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Returns(new Address {
                Id = _taxSettings.DefaultTaxAddressId
            });

            _eventPublisher = new Mock <IEventPublisher>();
            _eventPublisher.Setup(x => x.Publish(It.IsAny <object>()));

            var pluginFinder = new PluginFinder(_eventPublisher.Object);

            _geoLookupService     = new Mock <IGeoLookupService>();
            _countryService       = new Mock <ICountryService>();
            _stateProvinceService = new Mock <IStateProvinceService>();
            _logger    = new Mock <ILogger>();
            _webHelper = new Mock <IWebHelper>();
            _genericAttributeService = new Mock <IGenericAttributeService>();

            _customerSettings = new CustomerSettings();
            _shippingSettings = new ShippingSettings();
            _addressSettings  = new AddressSettings();

            _taxService = new TaxService(_addressSettings,
                                         _customerSettings,
                                         _addressService.Object,
                                         _countryService.Object,
                                         _genericAttributeService.Object,
                                         _geoLookupService.Object,
                                         _logger.Object,
                                         pluginFinder,
                                         _stateProvinceService.Object,
                                         _storeContext.Object,
                                         _webHelper.Object,
                                         _workContext,
                                         _shippingSettings,
                                         _taxSettings);
        }
Exemplo n.º 31
0
        /// <summary>
        /// Gets the plugin's Id.
        /// </summary>
        public static int GetPluginId(Guid registrationKey)
        {
            PluginFinder finder = new PluginFinder {
                RegistrationKey = registrationKey
            };
            Plugin plugin = Plugin.FindOne(finder);

            if (!plugin.IsNull)
            {
                return(plugin.PluginId.GetValueOrDefault());
            }

            return(0);
        }
Exemplo n.º 32
0
 public SystemWindow(double width, double height)
     : base(width, height, SizeLimitsToSet.None)
 {
     if (globalSystemWindowCreator == null)
     {
         string pluginPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
         PluginFinder <SystemWindowCreatorPlugin> systemWindowCreatorFinder = new PluginFinder <SystemWindowCreatorPlugin>(pluginPath);
         if (systemWindowCreatorFinder.Plugins.Count != 1)
         {
             throw new Exception(string.Format("Did not find any SystemWindowCreators in Plugin path ({0}.", pluginPath));
         }
         globalSystemWindowCreator = systemWindowCreatorFinder.Plugins[0];
     }
 }
Exemplo n.º 33
0
        private void SetMenuItems(DropDownMenu dropDownMenu)
        {
            menuItems = new List <PrintItemAction>();

            menuItems.Add(new PrintItemAction()
            {
                Title  = "Send".Localize(),
                Action = (items, queueDataView) => sendButton_Click(null, null)
            });

            menuItems.Add(new PrintItemAction()
            {
                Title  = "Add to Library".Localize(),
                Action = (items, queueDataView) => addToLibraryButton_Click(null, null)
            });

            // Extension point for plugins to hook into selected item actions
            var pluginFinder = new PluginFinder <PrintItemMenuExtension>();

            foreach (var menuExtensionPlugin in pluginFinder.Plugins)
            {
                foreach (var menuItem in menuExtensionPlugin.GetMenuItems())
                {
                    menuItems.Add(menuItem);
                }
            }

            BorderDouble padding = dropDownMenu.MenuItemsPadding;

            //Add the menu items to the menu itself
            foreach (PrintItemAction item in menuItems)
            {
                if (item.Action == null)
                {
                    dropDownMenu.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
                }
                else
                {
                    if (item.SingleItemOnly)
                    {
                        singleSelectionMenuItems.Add(item.Title);
                    }
                    dropDownMenu.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
                }

                dropDownMenu.AddItem(item.Title);
            }

            dropDownMenu.Padding = padding;
        }
Exemplo n.º 34
0
        public void TestInitialize()
        {
            //plugin initialization
            new Grand.Services.Tests.ServiceTest().PluginInitializator();

            _paymentSettings = new PaymentSettings();
            _paymentSettings.ActivePaymentMethodSystemNames = new List <string>();
            _paymentSettings.ActivePaymentMethodSystemNames.Add("Payments.TestMethod");
            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _settingService       = new Mock <ISettingService>().Object;
            _paymentService       = new PaymentService(_paymentSettings, pluginFinder, _settingService, _shoppingCartSettings);
        }
        public new void SetUp()
        {
            var cacheManager = new NopNullCache();

            _workContext = null;

            _currencySettings = new CurrencySettings();
            var currency1 = new Currency
            {
                Id = 1,
                Name = "Euro",
                CurrencyCode = "EUR",
                DisplayLocale =  "",
                CustomFormatting = "€0.00",
                DisplayOrder = 1,
                Published = true,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc= DateTime.UtcNow
            };
            var currency2 = new Currency
            {
                Id = 1,
                Name = "US Dollar",
                CurrencyCode = "USD",
                DisplayLocale = "en-US",
                CustomFormatting = "",
                DisplayOrder = 2,
                Published = true,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc= DateTime.UtcNow
            };            
            _currencyRepo = MockRepository.GenerateMock<IRepository<Currency>>();
            _currencyRepo.Expect(x => x.Table).Return(new List<Currency>() { currency1, currency2 }.AsQueryable());

            _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>();

            var pluginFinder = new PluginFinder();
            _currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService,
                _currencySettings, pluginFinder, null);

            _taxSettings = new TaxSettings();

            _localizationService = MockRepository.GenerateMock<ILocalizationService>();
            _localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax");
            _localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} excl tax");
            
            _priceFormatter = new PriceFormatter(_workContext, _currencyService,_localizationService, 
                _taxSettings, _currencySettings);
        }
        public void TestInitialize()
        {
            //plugin initialization
            new Grand.Services.Tests.ServiceTest().PluginInitializator();

            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >().Object;
            _deliveryDateRepository   = new Mock <IRepository <DeliveryDate> >().Object;
            _warehouseRepository      = new Mock <IRepository <Warehouse> >().Object;
            _logger = new NullLogger();
            _productAttributeParser  = new Mock <IProductAttributeParser>().Object;
            _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>().Object;
            _serviceProvider         = new Mock <IServiceProvider>().Object;

            var tempEventPublisher = new Mock <IMediator>();
            {
                //tempEventPublisher.Setup(x => x.Publish(It.IsAny<object>()));
                _eventPublisher = tempEventPublisher.Object;
            }

            var cacheManager = new TestMemoryCacheManager(new Mock <IMemoryCache>().Object, _eventPublisher);

            var pluginFinder = new PluginFinder(_serviceProvider);

            _countryService       = new Mock <ICountryService>().Object;
            _stateProvinceService = new Mock <IStateProvinceService>().Object;
            _currencyService      = new Mock <ICurrencyService>().Object;
            _productService       = new Mock <IProductService>().Object;



            _localizationService = new Mock <ILocalizationService>().Object;
            _addressService      = new Mock <IAddressService>().Object;

            _store = new Store {
                Id = "1"
            };
            var tempStoreContext = new Mock <IStoreContext>();

            {
                tempStoreContext.Setup(x => x.CurrentStore).Returns(_store);
                _storeContext = tempStoreContext.Object;
            }

            _shoppingCartSettings = new ShoppingCartSettings();
        }
		public LibraryProviderSelector(Action<LibraryProvider> setCurrentLibraryProvider)
			: base(null)
		{
			this.setCurrentLibraryProvider = setCurrentLibraryProvider;

			ApplicationController.Instance.CloudSyncStatusChanged.RegisterEvent(CloudSyncStatusChanged, ref unregisterEvents);

			if (false)
			{
				// This is test code for how to add these when we get to it
				// put in the queue provider
				libraryProviders.Add(new LibraryProviderQueue(null, this));
				AddFolderImage("queue_folder.png");

				// put in the queue provider
				libraryProviders.Add(new LibraryProviderHistory(null, this));
				AddFolderImage("queue_folder.png");
			}

			// put in the sqlite provider
			libraryProviders.Add(new LibraryProviderSQLite(null, this));
			AddFolderImage("library_folder.png");

			// Check for LibraryProvider factories and put them in the list too.
			PluginFinder<LibraryProviderPlugin> libraryProviderPlugins = new PluginFinder<LibraryProviderPlugin>();
			foreach (LibraryProviderPlugin libraryProviderPlugin in libraryProviderPlugins.Plugins)
			{
				// This coupling is required to navigate to the Purchased folder after redemption or purchase updates
				var pluginProvider = libraryProviderPlugin.CreateLibraryProvider(this);
				if (pluginProvider.ProviderKey == "LibraryProviderPurchasedKey")
				{
					this.PurchasedLibrary = pluginProvider;
				}

				libraryProviders.Add(pluginProvider);
				folderImagesForChildren.Add(libraryProviderPlugin.GetFolderImage());
			}

			// and any directory providers (sd card provider, etc...)
			// Add "Downloads" file system example
			string downloadsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
			if (Directory.Exists(downloadsDirectory))
			{
				libraryProviders.Add(new LibraryProviderFileSystem(downloadsDirectory, "Downloads", this));
				AddFolderImage("download_folder.png");
			}

			this.FilterProviders();
		}
Exemplo n.º 38
0
        public static IDiscountService Init()
        {
            var _cacheManager            = new TestMemoryCacheManager(new Mock <IMemoryCache>().Object);
            var _discountRepo            = new Mock <IRepository <Discount> >();
            var _complexDiscountRepo     = new Mock <IRepository <ComplexDiscount> >();
            var _discountRequirementRepo = new Mock <IRepository <DiscountRequirement> >();

            _discountRequirementRepo.Setup(x => x.Table).Returns(new List <DiscountRequirement>().AsQueryable());
            var _discountUsageHistoryRepo = new Mock <IRepository <DiscountUsageHistory> >();
            var _categoryRepo             = new Mock <IRepository <Category> >();

            _categoryRepo.Setup(x => x.Table).Returns(new List <Category>().AsQueryable());
            var _manufacturerRepo = new Mock <IRepository <Manufacturer> >();

            _manufacturerRepo.Setup(x => x.Table).Returns(new List <Manufacturer>().AsQueryable());
            var _productRepo = new Mock <IRepository <Product> >();

            _productRepo.Setup(x => x.Table).Returns(new List <Product>().AsQueryable());
            var _customerService     = new Mock <ICustomerService>();
            var _localizationService = new Mock <ILocalizationService>();
            var _eventPublisher      = new Mock <IEventPublisher>();
            var pluginFinder         = new PluginFinder(_eventPublisher.Object);
            var _categoryService     = new Mock <ICategoryService>();

            var _store = new Store {
                Id = 1
            };
            var _storeContext = new Mock <IStoreContext>();

            _storeContext.Setup(x => x.CurrentStore).Returns(_store);

            var discountService = new TestDiscountService(_categoryService.Object,
                                                          _customerService.Object,
                                                          _eventPublisher.Object,
                                                          _localizationService.Object,
                                                          pluginFinder,
                                                          _categoryRepo.Object,
                                                          _discountRepo.Object,
                                                          _complexDiscountRepo.Object,
                                                          _discountRequirementRepo.Object,
                                                          _discountUsageHistoryRepo.Object,
                                                          _manufacturerRepo.Object,
                                                          _productRepo.Object,
                                                          _cacheManager,
                                                          _storeContext.Object);

            return(discountService);
        }
        public new void SetUp()
        {
            _paymentSettings = new PaymentSettings();
            _paymentSettings.ActivePaymentMethodSystemNames = new List<string>();
            _paymentSettings.ActivePaymentMethodSystemNames.Add("Payments.TestMethod");

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
			_settingService = MockRepository.GenerateMock<ISettingService>();

			var localizationService = MockRepository.GenerateMock<ILocalizationService>();
			localizationService.Expect(ls => ls.GetResource(null)).IgnoreArguments().Return("NotSupported").Repeat.Any();

			_paymentService = new PaymentService(_paymentSettings, pluginFinder, _shoppingCartSettings, _settingService, localizationService, this.ProviderManager);
        }
Exemplo n.º 40
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>();
            _deliveryDateRepository = MockRepository.GenerateMock<IRepository<DeliveryDate>>();
            _warehouseRepository = MockRepository.GenerateMock<IRepository<Warehouse>>();
            _logger = new NullLogger();
            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();
            _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>();

            var cacheManager = new NopNullCache();

            var pluginFinder = new PluginFinder();
            _productService = MockRepository.GenerateMock<IProductService>();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _localizationService = MockRepository.GenerateMock<ILocalizationService>();
            _addressService = MockRepository.GenerateMock<IAddressService>();
            _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();

            _store = new Store { Id = 1 };
            _storeContext = MockRepository.GenerateMock<IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService = new ShippingService(_shippingMethodRepository,
                _deliveryDateRepository,
                _warehouseRepository,
                _logger,
                _productService,
                _productAttributeParser,
                _checkoutAttributeParser,
                _genericAttributeService,
                _localizationService,
                _addressService,
                _shippingSettings, 
                pluginFinder,
                _storeContext,
                _eventPublisher,
                _shoppingCartSettings,
                cacheManager);
        }
Exemplo n.º 41
0
        internal List <Plugin> GetRegisteredPlugins()
        {
            List <Plugin> registered = new List <Plugin>();

            //check the plugins path is valid
            if (Directory.Exists(PluginsPath))
            {
                PluginFinder        pluginFinder      = new PluginFinder();
                EntityList <Plugin> registeredPlugins = Plugin.FindMany(pluginFinder);

                foreach (Plugin plugin in registeredPlugins)
                {
                    //get the plugins path info
                    string pluginFolder = Path.Combine(PluginsPath, plugin.RelativePath);
                    string filePath     = Path.Combine(pluginFolder, plugin.Filename);

                    //try and load the plugin's xml config file
                    IPlugin pluginFile = null;
                    if (File.Exists(filePath))
                    {
                        //try and deserialize the plugin
                        try
                        {
                            pluginFile = PluginHelper.ReadPlugin(filePath);
                        }
                        catch (Exception e)
                        {
                            //an error occurred so assume the config xml
                            //is invalid and does not validate correctly
                            plugin.FormatErrorMessage = String.Format("{0} {1}", e.Message, (e.InnerException != null ? ":- " + e.InnerException.Message : String.Empty));
                        }
                    }

                    //add the plugin file and sets the status flags
                    AddPluginFile(plugin, pluginFile, filePath);

                    //add to the list
                    registered.Add(plugin);
                }
            }
            else
            {
                m_Logger.Error(string.Format("The plugins path is not set to a valid folder - {0}", PluginsPath));
            }
            return(registered);
        }
Exemplo n.º 42
0
 public ActionResult Index()
 {
     //加载插件
     PluginFinder _pluginFinder = new PluginFinder();
     List<IShippingMethod> shippingMethodList = _pluginFinder.GetPlugins<IShippingMethod>().ToList();
     ViewData["ShippingMethods"] = shippingMethodList;
     _indexService.GetTestName();
     var TestTable = _indexService.GetTestTable();
     var categoryModelList =
        TestTable.Select(p =>
        {
            var categoryModel = new CategoryModel();
            categoryModel.Id = p.Id;
            categoryModel.Name = p.Name;
            return categoryModel;
        });
     IEnumerable<CategoryModel> CategoryModel = categoryModelList;
     return View(categoryModelList);
 }
Exemplo n.º 43
0
        public ActionResult ShippingMethod(string method)
        {
            PluginFinder _pluginFinder = new PluginFinder();
            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName<IShippingMethod>(method);
            var plugin = pluginDescriptor.Instance() as IShippingMethod;

            string actionName = "";
            string controllerName = "";
            RouteValueDictionary configurationRouteValues = null;
            plugin.GetConfigurationRoute(out actionName, out controllerName, out configurationRouteValues);

            ShippingMethodModel model = new ShippingMethodModel()
            {
                ActionName = actionName,
                ConfigurationRouteValues = configurationRouteValues,
                ControllerName = controllerName
            };

            return View(model);
        }
		public static FrostedSerialPortFactory GetAppropriateFactory(string driverType)
		{
            lock(availableFactories)
            {
                try
                {
                    if (availableFactories.Count == 0)
                    {
                        // always add a serial port this is a raw port
                        availableFactories.Add("Raw", new FrostedSerialPortFactory());

                        // add in any plugins that we find with other factories.
                        PluginFinder<FrostedSerialPortFactory> pluginFinder = new PluginFinder<FrostedSerialPortFactory>();

                        foreach (FrostedSerialPortFactory plugin in pluginFinder.Plugins)
                        {
                            availableFactories.Add(plugin.GetDriverType(), plugin);
                        }

                        // If we did not finde a RepRap driver add the default.
                        if (!availableFactories.ContainsKey("RepRap"))
                        {
                            availableFactories.Add("RepRap", new FrostedSerialPortFactory());
                        }
                    }

                    if (!string.IsNullOrEmpty(driverType)
                        && availableFactories.ContainsKey(driverType))
                    {
                        return availableFactories[driverType];
                    }

                    return availableFactories["RepRap"];
                }
                catch
                {
                    return new FrostedSerialPortFactory();
                }
            }
		}
        public new void SetUp()
        {
            _taxSettings = new TaxSettings();
            _taxSettings.DefaultTaxAddressId = 10;

            _workContext = null;

			_cartSettings = new ShoppingCartSettings();

            _addressService = MockRepository.GenerateMock<IAddressService>();
            //default tax address
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address() { Id = _taxSettings.DefaultTaxAddressId });

            var pluginFinder = new PluginFinder();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

			_settingService = MockRepository.GenerateMock<ISettingService>();
			_geoCountryLookup = MockRepository.GenerateMock<IGeoCountryLookup>();

			_taxService = new TaxService(_addressService, _workContext, _taxSettings, _cartSettings, pluginFinder, _settingService, _geoCountryLookup, this.ProviderManager);
        }
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>();
            _logger = new NullLogger();
            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();
			_productService = MockRepository.GenerateMock<IProductService>();
            _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>();

            var cacheManager = new NullCache();

            var pluginFinder = new PluginFinder();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _localizationService = MockRepository.GenerateMock<ILocalizationService>();
			_genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();
			_settingService = MockRepository.GenerateMock<ISettingService>();

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService = new ShippingService(cacheManager, 
                _shippingMethodRepository, 
                _logger,
                _productAttributeParser,
				_productService,
                _checkoutAttributeParser,
				_genericAttributeService,
                _localizationService,
                _shippingSettings, pluginFinder, _eventPublisher,
                _shoppingCartSettings,
				_settingService, 
				this.ProviderManager);
        }
		private LibraryProviderSelector()
			: base(null)
		{
			// put in the sqlite provider
			libraryProviders.Add(new LibraryProviderSQLite(null, this));

			//#if __ANDROID__
			//libraryProviders.Add(new LibraryProviderFileSystem(ApplicationDataStorage.Instance.PublicDataStoragePath, "Downloads", this.ProviderKey));

			// Check for LibraryProvider factories and put them in the list too.
			PluginFinder<LibraryProviderPlugin> libraryProviderPlugins = new PluginFinder<LibraryProviderPlugin>();
			foreach (LibraryProviderPlugin libraryProviderPlugin in libraryProviderPlugins.Plugins)
			{
				libraryProviders.Add(libraryProviderPlugin.CreateLibraryProvider(this));
			}

			// and any directory providers (sd card provider, etc...)
			// Add "Downloads" file system example
			string downloadsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
			if (Directory.Exists(downloadsDirectory))
			{
				libraryProviders.Add(new LibraryProviderFileSystem(downloadsDirectory, "Downloads", this));
			}
		}
Exemplo n.º 48
0
		private FlowLayoutWidget CreateRightButtonPanel(double buildHeight)
		{
			FlowLayoutWidget buttonRightPanel = new FlowLayoutWidget(FlowDirection.TopToBottom);
			buttonRightPanel.Width = 200;

			// put in undo redo
			if(true) // this will not be enabled until the new scene_bundle gets merged
			{
				FlowLayoutWidget undoRedoButtons = new FlowLayoutWidget()
				{
					VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop,
					HAnchor = HAnchor.FitToChildren | HAnchor.ParentCenter,
				};
				double oldWidth = WhiteButtonFactory.FixedWidth;
				WhiteButtonFactory.FixedWidth = WhiteButtonFactory.FixedWidth / 2;
                Button undoButton = WhiteButtonFactory.Generate("Undo".Localize(), centerText: true);
				undoButton.Name = "3D View Undo";
				undoButton.Enabled = false;
				undoButton.Click += (sender, e) =>
				{
					UndoBuffer.Undo();
				};
				undoRedoButtons.AddChild(undoButton);

				Button redoButton = WhiteButtonFactory.Generate("Redo".Localize(), centerText: true);
				redoButton.Name = "3D View Redo";
				redoButton.Enabled = false;
				redoButton.Click += (sender, e) =>
				{
					UndoBuffer.Redo();
				};
				undoRedoButtons.AddChild(redoButton);
				buttonRightPanel.AddChild(undoRedoButtons);

				UndoBuffer.Changed += (sender, e) =>
				{
					undoButton.Enabled = UndoBuffer.UndoCount > 0;
					redoButton.Enabled = UndoBuffer.RedoCount > 0;
				};
				WhiteButtonFactory.FixedWidth = oldWidth;
			}

			{
				BorderDouble buttonMargin = new BorderDouble(top: 3);

				expandRotateOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton(
					"Rotate".Localize().ToUpper(),
					View3DWidget.ArrowRight,
					View3DWidget.ArrowDown);
				expandRotateOptions.Margin = new BorderDouble(bottom: 2);
				buttonRightPanel.AddChild(expandRotateOptions);
				expandRotateOptions.CheckedStateChanged += expandRotateOptions_CheckedStateChanged;

				rotateOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
				rotateOptionContainer.HAnchor = HAnchor.ParentLeftRight;
				rotateOptionContainer.Visible = false;
				buttonRightPanel.AddChild(rotateOptionContainer);

				buttonRightPanel.AddChild(new ScaleControls(this));

				buttonRightPanel.AddChild(new MirrorControls(this));

				PluginFinder<SideBarPlugin> SideBarPlugins = new PluginFinder<SideBarPlugin>();
				foreach (SideBarPlugin plugin in SideBarPlugins.Plugins)
				{
					buttonRightPanel.AddChild(plugin.CreateSideBarTool(this));
				}

				// put in the material options
				int numberOfExtruders = ActiveSliceSettings.Instance.GetValue<int>(SettingsKey.extruder_count);

				expandMaterialOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton("Materials".Localize().ToUpper(),
					View3DWidget.ArrowRight,
					View3DWidget.ArrowDown);
				expandMaterialOptions.Margin = new BorderDouble(bottom: 2);
				expandMaterialOptions.CheckedStateChanged += expandMaterialOptions_CheckedStateChanged;

				if (numberOfExtruders > 1)
				{
					buttonRightPanel.AddChild(expandMaterialOptions);

					materialOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
					materialOptionContainer.HAnchor = HAnchor.ParentLeftRight;
					materialOptionContainer.Visible = false;

					buttonRightPanel.AddChild(materialOptionContainer);
					AddMaterialControls(materialOptionContainer);
				}

				// put in the view options
				{
					expandViewOptions = ExpandMenuOptionFactory.GenerateCheckBoxButton("Display".Localize().ToUpper(),
					View3DWidget.ArrowRight,
					View3DWidget.ArrowDown);
					expandViewOptions.Margin = new BorderDouble(bottom: 2);
					buttonRightPanel.AddChild(expandViewOptions);
					expandViewOptions.CheckedStateChanged += expandViewOptions_CheckedStateChanged;

					viewOptionContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
					viewOptionContainer.HAnchor = HAnchor.ParentLeftRight;
					viewOptionContainer.Padding = new BorderDouble(left: 4);
					viewOptionContainer.Visible = false;
					{
						CheckBox showBedCheckBox = new CheckBox("Show Print Bed".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
						showBedCheckBox.Checked = true;
						showBedCheckBox.CheckedStateChanged += (sender, e) =>
						{
							meshViewerWidget.RenderBed = showBedCheckBox.Checked;
						};
						viewOptionContainer.AddChild(showBedCheckBox);

						if (buildHeight > 0)
						{
							CheckBox showBuildVolumeCheckBox = new CheckBox("Show Print Area".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor);
							showBuildVolumeCheckBox.Checked = false;
							showBuildVolumeCheckBox.Margin = new BorderDouble(bottom: 5);
							showBuildVolumeCheckBox.CheckedStateChanged += (sender, e) =>
							{
								meshViewerWidget.RenderBuildVolume = showBuildVolumeCheckBox.Checked;
							};
							viewOptionContainer.AddChild(showBuildVolumeCheckBox);
						}

						if (UserSettings.Instance.IsTouchScreen)
						{
							UserSettings.Instance.set(UserSettingsKey.defaultRenderSetting, RenderTypes.Shaded.ToString());
						}
						else
						{
							CreateRenderTypeRadioButtons(viewOptionContainer);
						}
					}
					buttonRightPanel.AddChild(viewOptionContainer);
				}

				GuiWidget verticalSpacer = new GuiWidget();
				verticalSpacer.VAnchor = VAnchor.ParentBottomTop;
				buttonRightPanel.AddChild(verticalSpacer);

				AddGridSnapSettings(buttonRightPanel);
			}

			buttonRightPanel.Padding = new BorderDouble(6, 6);
			buttonRightPanel.Margin = new BorderDouble(0, 1);
			buttonRightPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
			buttonRightPanel.VAnchor = VAnchor.ParentBottomTop;

			return buttonRightPanel;
		}
        public new void SetUp()
        {
            _workContext = null;

            _store = new Store() { Id = 1 };
            _storeContext = MockRepository.GenerateMock<IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings = new CatalogSettings();

            var cacheManager = new NopNullCache();

            _productService = MockRepository.GenerateMock<IProductService>();

            //price calculation service
            _discountService = MockRepository.GenerateMock<IDiscountService>();
            _categoryService = MockRepository.GenerateMock<ICategoryService>();
            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();
            _priceCalcService = new PriceCalculationService(_workContext, _storeContext,
                _discountService, _categoryService,
                _productAttributeParser, _productService,
                cacheManager, _shoppingCartSettings, _catalogSettings);

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _localizationService = MockRepository.GenerateMock<ILocalizationService>();

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>();
            _deliveryDateRepository = MockRepository.GenerateMock<IRepository<DeliveryDate>>();
            _warehouseRepository = MockRepository.GenerateMock<IRepository<Warehouse>>();
            _logger = new NullLogger();
            _shippingService = new ShippingService(_shippingMethodRepository,
                _deliveryDateRepository,
                _warehouseRepository,
                _logger,
                _productService,
                _productAttributeParser,
                _checkoutAttributeParser,
                _genericAttributeService,
                _localizationService,
                _addressService,
                _shippingSettings,
                pluginFinder,
                _storeContext,
                _eventPublisher,
                _shoppingCartSettings,
                cacheManager);
            _shipmentService = MockRepository.GenerateMock<IShipmentService>();

            _paymentService = MockRepository.GenerateMock<IPaymentService>();
            _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>();
            _giftCardService = MockRepository.GenerateMock<IGiftCardService>();
            _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = 10;
            _addressService = MockRepository.GenerateMock<IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address() { Id = _taxSettings.DefaultTaxAddressId });
            _taxService = new TaxService(_addressService, _workContext, _taxSettings, pluginFinder);

            _rewardPointsSettings = new RewardPointsSettings();

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                _priceCalcService, _taxService, _shippingService, _paymentService,
                _checkoutAttributeParser, _discountService, _giftCardService,
                _genericAttributeService,
                _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);

            _orderService = MockRepository.GenerateMock<IOrderService>();
            _webHelper = MockRepository.GenerateMock<IWebHelper>();
            _languageService = MockRepository.GenerateMock<ILanguageService>();
            _priceFormatter= MockRepository.GenerateMock<IPriceFormatter>();
            _productAttributeFormatter= MockRepository.GenerateMock<IProductAttributeFormatter>();
            _shoppingCartService= MockRepository.GenerateMock<IShoppingCartService>();
            _checkoutAttributeFormatter= MockRepository.GenerateMock<ICheckoutAttributeFormatter>();
            _customerService= MockRepository.GenerateMock<ICustomerService>();
            _encryptionService = MockRepository.GenerateMock<IEncryptionService>();
            _workflowMessageService = MockRepository.GenerateMock<IWorkflowMessageService>();
            _customerActivityService = MockRepository.GenerateMock<ICustomerActivityService>();
            _currencyService = MockRepository.GenerateMock<ICurrencyService>();
            _affiliateService = MockRepository.GenerateMock<IAffiliateService>();
            _vendorService = MockRepository.GenerateMock<IVendorService>();
            _pdfService = MockRepository.GenerateMock<IPdfService>();

            _paymentSettings = new PaymentSettings()
            {
                ActivePaymentMethodSystemNames = new List<string>()
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings = new OrderSettings();

            _localizationSettings = new LocalizationSettings();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _currencySettings = new CurrencySettings();

            _orderProcessingService = new OrderProcessingService(_orderService, _webHelper,
                _localizationService, _languageService,
                _productService, _paymentService, _logger,
                _orderTotalCalcService, _priceCalcService, _priceFormatter,
                _productAttributeParser, _productAttributeFormatter,
                _giftCardService, _shoppingCartService, _checkoutAttributeFormatter,
                _shippingService, _shipmentService, _taxService,
                _customerService, _discountService,
                _encryptionService, _workContext,
                _workflowMessageService, _vendorService,
                _customerActivityService, _currencyService, _affiliateService,
                _eventPublisher,_pdfService, _paymentSettings, _rewardPointsSettings,
                _orderSettings, _taxSettings, _localizationSettings,
                _currencySettings);
        }
Exemplo n.º 50
0
		private void SetMenuItems(DropDownMenu dropDownMenu)
		{
			menuItems = new List<PrintItemAction>();

			if (ActiveTheme.Instance.IsTouchScreen)
			{
				menuItems.Add(new PrintItemAction()
				{
					Title = "Remove All".Localize(),
					Action = (items, queueDataView) => clearAllButton_Click(null, null)
				});
			}

			menuItems.Add(new PrintItemAction()
			{
				Title = "Send".Localize(),
				Action = (items, queueDataView) => sendButton_Click(null, null)
			});

			menuItems.Add(new PrintItemAction()
			{
				Title = "Add To Library".Localize(),
				Action = (items, queueDataView) => addToLibraryButton_Click(null, null)
			});

			// Extension point for plugins to hook into selected item actions
			var pluginFinder = new PluginFinder<PrintItemMenuExtension>();
			foreach (var menuExtensionPlugin in pluginFinder.Plugins)
			{
				foreach(var menuItem in menuExtensionPlugin.GetMenuItems())
				{
					menuItems.Add(menuItem);
				}
			}

			BorderDouble padding = dropDownMenu.MenuItemsPadding;

			//Add the menu items to the menu itself
			foreach (PrintItemAction item in menuItems)
			{
				if (item.Action == null)
				{
					dropDownMenu.MenuItemsPadding = new BorderDouble(5, 0, padding.Right, 3);
				}
				else
				{
					if(item.SingleItemOnly)
					{
						singleSelectionMenuItems.Add(item.Title);
					}
					dropDownMenu.MenuItemsPadding = new BorderDouble(10, 5, padding.Right, 5);
				}

				dropDownMenu.AddItem(item.Title);
			}

			dropDownMenu.Padding = padding;
		}
Exemplo n.º 51
0
		public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing)
		{
			this.openMode = openMode;
			this.windowType = windowType;
			allowAutoRotate = (autoRotate == AutoRotate.Enabled);
			autoRotating = allowAutoRotate;
			MeshGroupExtraData = new List<PlatingMeshGroupData>();
			MeshGroupExtraData.Add(new PlatingMeshGroupData());

			this.printItemWrapper = printItemWrapper;
			this.Name = "View3DWidget";

			FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
			mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

			FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
			centerPartPreviewAndControls.Name = "centerPartPreviewAndControls";
			centerPartPreviewAndControls.AnchorAll();

			GuiWidget viewArea = new GuiWidget();
			viewArea.AnchorAll();
			{
				meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize());

				PutOemImageOnBed();

				meshViewerWidget.AnchorAll();
			}
			viewArea.AddChild(meshViewerWidget);

			centerPartPreviewAndControls.AddChild(viewArea);
			mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

			FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
			buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.Padding = new BorderDouble(3, 3);
			buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);
			buttonRightPanel.Name = "buttonRightPanel";
			buttonRightPanel.Visible = false;

			CreateOptionsContent();

			// add in the plater tools
			{
				FlowLayoutWidget editToolBar = new FlowLayoutWidget();

				string progressFindPartsLabel = "Entering Editor".Localize();
				string progressFindPartsLabelFull = "{0}:".FormatWith(progressFindPartsLabel);

				processingProgressControl = new ProgressControl(progressFindPartsLabelFull, ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
				processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
				editToolBar.AddChild(processingProgressControl);
				editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				processingProgressControl.Visible = false;

				// If the window is embedded (in the center panel) and there is no item loaded then don't show the add button
				enterEditButtonsContainer = new FlowLayoutWidget();
				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize();
					addButton.Margin = new BorderDouble(right: 0);
					enterEditButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							DoAddFileAfterCreatingEditData = true;
							EnterEditAndCreateSelectionData();
						});
					};
					if (printItemWrapper != null
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						addButton.Enabled = false;
					}

					ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit.png", 14, 14);

					Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), normalImage);
					enterEdittingButton.Name = "3D View Edit";
					enterEdittingButton.Margin = new BorderDouble(right: 4);
					enterEdittingButton.Click += (sender, e) =>
					{
						EnterEditAndCreateSelectionData();
					};

					if (printItemWrapper != null
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						enterEdittingButton.Enabled = false;
					}

					Button exportButton = textImageButtonFactory.Generate("Export...".Localize());
					if (printItemWrapper != null &&
						(printItemWrapper.PrintItem.Protected || printItemWrapper.PrintItem.ReadOnly))
					{
						exportButton.Enabled = false;
					}

					exportButton.Margin = new BorderDouble(right: 10);
					exportButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							OpenExportWindow();
						});
					};

					enterEditButtonsContainer.AddChild(enterEdittingButton);
					enterEditButtonsContainer.AddChild(exportButton);
				}
				editToolBar.AddChild(enterEditButtonsContainer);

				doEdittingButtonsContainer = new FlowLayoutWidget();
				doEdittingButtonsContainer.Visible = false;

				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.Margin = new BorderDouble(right: 10);
					doEdittingButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							FileDialog.OpenFileDialog(
								new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true),
								(openParams) =>
								{
									LoadAndAddPartsToPlate(openParams.FileNames);
								});
						});
					};

					GuiWidget separator = new GuiWidget(1, 2);
					separator.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separator.Margin = new BorderDouble(4, 2);
					separator.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separator);

					Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize());
					ungroupButton.Name = "3D View Ungroup";
					doEdittingButtonsContainer.AddChild(ungroupButton);
					ungroupButton.Click += (sender, e) =>
					{
						UngroupSelectedMeshGroup();
						UndoBuffer.ClearHistory();
					};

					Button groupButton = textImageButtonFactory.Generate("Group".Localize());
					groupButton.Name = "3D View Group";
					doEdittingButtonsContainer.AddChild(groupButton);
					groupButton.Click += (sender, e) =>
					{
						GroupSelectedMeshs();
						UndoBuffer.ClearHistory();
					};

					Button alignButton = textImageButtonFactory.Generate("Align".Localize());
					doEdittingButtonsContainer.AddChild(alignButton);
					alignButton.Click += (sender, e) =>
					{
						AlignToSelectedMeshGroup();
						UndoBuffer.ClearHistory();
					};

					Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize());
					doEdittingButtonsContainer.AddChild(arrangeButton);
					arrangeButton.Click += (sender, e) =>
					{
						AutoArrangePartsInBackground();
					};

					GuiWidget separatorTwo = new GuiWidget(1, 2);
					separatorTwo.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorTwo.Margin = new BorderDouble(4, 2);
					separatorTwo.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorTwo);

					Button copyButton = textImageButtonFactory.Generate("Copy".Localize());
					copyButton.Name = "3D View Copy";
					doEdittingButtonsContainer.AddChild(copyButton);
					copyButton.Click += (sender, e) =>
					{
						MakeCopyOfGroup();
					};

					Button deleteButton = textImageButtonFactory.Generate("Remove".Localize());
					deleteButton.Name = "3D View Remove";
					doEdittingButtonsContainer.AddChild(deleteButton);
					deleteButton.Click += (sender, e) =>
					{
						DeleteSelectedMesh();
					};

					GuiWidget separatorThree = new GuiWidget(1, 2);
					separatorThree.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorThree.Margin = new BorderDouble(4, 1);
					separatorThree.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorThree);

					Button cancelEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true);
					cancelEditModeButton.Name = "3D View Cancel";
					cancelEditModeButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							if (saveButtons.Visible)
							{
								StyledMessageBox.ShowMessageBox(ExitEditingAndSaveIfRequired, "Would you like to save your changes before exiting the editor?".Localize(), "Save Changes".Localize(), StyledMessageBox.MessageType.YES_NO);
							}
							else
							{
								if (partHasBeenEdited)
								{
									ExitEditingAndSaveIfRequired(false);
								}
								else
								{
									SwitchStateToNotEditing();
								}
							}
						});
					};

					doEdittingButtonsContainer.AddChild(cancelEditModeButton);

					// put in the save button
					AddSaveAndSaveAs(doEdittingButtonsContainer);
				}

				editToolBar.AddChild(doEdittingButtonsContainer);
				buttonBottomPanel.AddChild(editToolBar);
			}

			GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);
			buttonRightPanelHolder.Name = "buttonRightPanelHolder";
			centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
			buttonRightPanelHolder.AddChild(buttonRightPanel);
			buttonRightPanel.VisibleChanged += (sender, e) =>
			{
				buttonRightPanelHolder.Visible = buttonRightPanel.Visible;
			};

			viewControls3D = new ViewControls3D(meshViewerWidget);

			viewControls3D.ResetView += (sender, e) =>
			{
				meshViewerWidget.ResetView();
			};

			buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
			buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
			buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);

			viewControls3D.PartSelectVisible = false;
			LockEditControls();

			GuiWidget leftRightSpacer = new GuiWidget();
			leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.AddChild(leftRightSpacer);

			if (windowType == WindowMode.StandAlone)
			{
				Button closeButton = textImageButtonFactory.Generate("Close".Localize());
				buttonBottomPanel.AddChild(closeButton);
				closeButton.Click += (sender, e) =>
				{
					CloseOnIdle();
				};
			}

			mainContainerTopToBottom.AddChild(buttonBottomPanel);

			this.AddChild(mainContainerTopToBottom);
			this.AnchorAll();

			meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
			AddChild(viewControls3D);

			UiThread.RunOnIdle(AutoSpin);

			if (printItemWrapper == null && windowType == WindowMode.Embeded)
			{
				enterEditButtonsContainer.Visible = false;
			}

			if (windowType == WindowMode.Embeded)
			{
				PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents);
				if (windowType == WindowMode.Embeded)
				{
					// make sure we lock the controls if we are printing or paused
					switch (PrinterConnectionAndCommunication.Instance.CommunicationState)
					{
						case PrinterConnectionAndCommunication.CommunicationStates.Printing:
						case PrinterConnectionAndCommunication.CommunicationStates.Paused:
							LockEditControls();
							break;
					}
				}
			}

			ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);

			meshViewerWidget.interactionVolumes.Add(new UpArrow3D(this));
			meshViewerWidget.interactionVolumes.Add(new SelectionShadow(this));
			meshViewerWidget.interactionVolumes.Add(new SnappingIndicators(this));

			PluginFinder<InteractionVolumePlugin> InteractionVolumePlugins = new PluginFinder<InteractionVolumePlugin>();
			foreach (InteractionVolumePlugin plugin in InteractionVolumePlugins.Plugins)
			{
				meshViewerWidget.interactionVolumes.Add(plugin.CreateInteractionVolume(this));
			}

			// make sure the colors are set correct
			ThemeChanged(this, null);

			saveButtons.VisibleChanged += (sender, e) =>
			{
				partHasBeenEdited = true;
			};

			meshViewerWidget.ResetView();

#if DoBooleanTest
            DrawBefore += CreateBooleanTestGeometry;
            DrawAfter += RemoveBooleanTestGeometry;
#endif
			meshViewerWidget.TrackballTumbleWidget.DrawGlContent += trackballTumbleWidget_DrawGlContent;

		}
        public new void SetUp()
        {
            _workContext = MockRepository.GenerateMock<IWorkContext>();

            _store = new Store { Id = 1 };
            _storeContext = MockRepository.GenerateMock<IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings = new CatalogSettings();

            //price calculation service
            _discountService = MockRepository.GenerateMock<IDiscountService>();
            _categoryService = MockRepository.GenerateMock<ICategoryService>();
            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();
            _productService = MockRepository.GenerateMock<IProductService>();
            _productAttributeService = MockRepository.GenerateMock<IProductAttributeService>();
            _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();
            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _settingService = MockRepository.GenerateMock<ISettingService>();
            _typeFinder = MockRepository.GenerateMock<ITypeFinder>();

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>();
            _logger = new NullLogger();

            _shippingService = new ShippingService(
                _shippingMethodRepository,
                _logger,
                _productAttributeParser,
                _productService,
                _checkoutAttributeParser,
                _genericAttributeService,
                _shippingSettings,
                _eventPublisher,
                _shoppingCartSettings,
                _settingService,
                this.ProviderManager,
                _typeFinder);

            _providerManager = MockRepository.GenerateMock<IProviderManager>();
            _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>();
            _giftCardService = MockRepository.GenerateMock<IGiftCardService>();

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.PricesIncludeTax = false;
            _taxSettings.TaxDisplayType = TaxDisplayType.IncludingTax;
            _taxSettings.DefaultTaxAddressId = 10;

            _addressService = MockRepository.GenerateMock<IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address { Id = _taxSettings.DefaultTaxAddressId });
            _downloadService = MockRepository.GenerateMock<IDownloadService>();
            _services = MockRepository.GenerateMock<ICommonServices>();
            _httpRequestBase = MockRepository.GenerateMock<HttpRequestBase>();
            _geoCountryLookup = MockRepository.GenerateMock<IGeoCountryLookup>();

            _taxService = new TaxService(_addressService, _workContext, _taxSettings, _shoppingCartSettings, pluginFinder, _geoCountryLookup, this.ProviderManager);

            _rewardPointsSettings = new RewardPointsSettings();

            _priceCalcService = new PriceCalculationService(_discountService, _categoryService, _productAttributeParser, _productService, _shoppingCartSettings, _catalogSettings,
                _productAttributeService, _downloadService, _services, _httpRequestBase, _taxService);

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                _priceCalcService, _taxService, _shippingService, _providerManager,
                _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService, _productAttributeParser,
                _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);
        }
        private static void LoadPlugin(PluginInfo pi, IForwardDestinationHandler ifdh)
        {
            try
            {
                // load if not already loaded
                if (ifdh == null)
                {
                    PluginFinder pf = new PluginFinder();
                    ifdh = pf.Load<IForwardDestinationHandler>(pi, ignoreList);
                }

                if (ifdh != null)
                {
                    // for the 'path' value, we still want to use the userprofile directory no matter where the plugin was loaded from
                    // the reason is that the 'path' is where plugin settings will be saved, so it needs to be user writable and user-specific
                    string path = Path.Combine(userForwarderDirectory, Growl.CoreLibrary.PathUtility.GetSafeFolderName(ifdh.Name));

                    // check to make sure this plugin was not loaded from another directory already
                    if (!loadedPlugins.ContainsKey(path))
                    {
                        loadedPlugins.Add(pi.FolderPath, pi);
                        if (!loadedPlugins.ContainsKey(path)) loadedPlugins.Add(path, pi); // link by the settings path as well so we can detect duplicate plugins in other folders
                        loadedPluginsList.Add(pi);

                        LoadInternal(ifdh, pi.FolderPath, path);
                    }
                    else
                    {
                        // plugin was not valid
                        Utility.WriteDebugInfo(String.Format("Forwarder not loaded: '{0}' - Duplicate plugin was already loaded from another folder", pi.FolderPath));
                    }
                }
                else
                {
                    // plugin was not valid
                    Utility.WriteDebugInfo(String.Format("Forwarder not loaded: '{0}' - Does not implement IForwardDestinationHandler interface", pi.FolderPath));
                }
            }
            catch (Exception ex)
            {
                // suppress any per-plugin loading exceptions
                Utility.WriteDebugInfo(String.Format("Forwarder failed to load: '{0}' - {1} - {2}", pi.FolderPath, ex.Message, ex.StackTrace));
            }
        }
		private void FindAndInstantiatePlugins()
		{
#if false
			string pluginDirectory = Path.Combine("..", "..", "..", "MatterControlPlugins", "bin");
#if DEBUG
			pluginDirectory = Path.Combine(pluginDirectory, "Debug");
#else
			pluginDirectory = Path.Combine(pluginDirectory, "Release");
#endif
			if (!Directory.Exists(pluginDirectory))
			{
				string dataPath = DataStorage.ApplicationDataStorage.Instance.ApplicationUserDataPath;
				pluginDirectory = Path.Combine(dataPath, "Plugins");
			}
			// TODO: this should look in a plugin folder rather than just the application directory (we probably want it in the user folder).
			PluginFinder<MatterControlPlugin> pluginFinder = new PluginFinder<MatterControlPlugin>(pluginDirectory);
#else
			PluginFinder<MatterControlPlugin> pluginFinder = new PluginFinder<MatterControlPlugin>();
#endif

			string oemName = ApplicationSettings.Instance.GetOEMName();
			foreach (MatterControlPlugin plugin in pluginFinder.Plugins)
			{
				string pluginInfo = plugin.GetPluginInfoJSon();
				Dictionary<string, string> nameValuePairs = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(pluginInfo);

				if (nameValuePairs != null && nameValuePairs.ContainsKey("OEM"))
				{
					if (nameValuePairs["OEM"] == oemName)
					{
						plugin.Initialize(this);
					}
				}
				else
				{
					plugin.Initialize(this);
				}
			}
		}
Exemplo n.º 55
0
		public SystemWindow(double width, double height)
			: base(width, height, SizeLimitsToSet.None)
		{
            ToolTipManager = new ToolTipManager(this);
			if (globalSystemWindowCreator == null)
			{
				string pluginPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
				PluginFinder<SystemWindowCreatorPlugin> systemWindowCreatorFinder = new PluginFinder<SystemWindowCreatorPlugin>(pluginPath);
				if (systemWindowCreatorFinder.Plugins.Count != 1)
				{
					throw new Exception(string.Format("Did not find any SystemWindowCreators in Plugin path ({0}.", pluginPath));
				}
				globalSystemWindowCreator = systemWindowCreatorFinder.Plugins[0];
			}

            openWindows.Add(this);
		}
Exemplo n.º 56
0
		public void CanRemovePlugins_ThroughConfiguration()
		{
			int initialCount = finder.GetPlugins<NavigationPluginAttribute>().Count();
			finder = new PluginFinder(typeFinder, new SecurityManager(new ThreadContext(), new EditSection()), CreateEngineSection(new[] { new InterfacePluginElement { Name = "chill" } }));
			
			IEnumerable<NavigationPluginAttribute> plugins = finder.GetPlugins<NavigationPluginAttribute>();
			
			Assert.That(plugins.Count(), Is.EqualTo(initialCount - 1), "Found unexpected items, e.g.:" + plugins.FirstOrDefault());
		}
        private static void LoadFolder(string folder)
        {
            try
            {
                if (!loadedPlugins.ContainsKey(folder))
                {
                    PluginFinder pf = new PluginFinder();
                    IForwardDestinationHandler plugin = pf.Search<IForwardDestinationHandler>(folder, CheckType, ignoreList);
                    if (plugin != null)
                    {
                        Type type = plugin.GetType();
                        PluginInfo pi = new PluginInfo(folder, type);

                        LoadPlugin(pi, plugin);
                    }
                }
            }
            catch (Exception ex)
            {
                // suppress any per-plugin loading exceptions
                Utility.WriteDebugInfo(String.Format("Plugin failed to load: '{0}' - {1} - {2}", folder, ex.Message, ex.StackTrace));
            }
        }
Exemplo n.º 58
0
        public new void SetUp()
        {
            currencyUSD = new Currency()
            {
                Id = 1,
                Name = "US Dollar",
                CurrencyCode = "USD",
                Rate = 1.2M,
                DisplayLocale = "en-US",
                CustomFormatting = "",
                Published = true,
                DisplayOrder = 1,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow,
            };
            currencyEUR = new Currency()
            {
                Id = 2,
                Name = "Euro",
                CurrencyCode = "EUR",
                Rate = 1,
                DisplayLocale = "",
                CustomFormatting = "€0.00",
                Published = true,
                DisplayOrder = 2,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow,
            };
            currencyRUR = new Currency()
            {
                Id = 3,
                Name = "Russian Rouble",
                CurrencyCode = "RUB",
                Rate = 34.5M,
                DisplayLocale = "ru-RU",
                CustomFormatting = "",
                Published = true,
                DisplayOrder = 3,
                CreatedOnUtc = DateTime.UtcNow,
                UpdatedOnUtc = DateTime.UtcNow,
            };
            _currencyRepository = MockRepository.GenerateMock<IRepository<Currency>>();
            _currencyRepository.Expect(x => x.Table).Return(new List<Currency>() { currencyUSD, currencyEUR, currencyRUR }.AsQueryable());
            _currencyRepository.Expect(x => x.GetById(currencyUSD.Id)).Return(currencyUSD);
            _currencyRepository.Expect(x => x.GetById(currencyEUR.Id)).Return(currencyEUR);
            _currencyRepository.Expect(x => x.GetById(currencyRUR.Id)).Return(currencyRUR);

            var cacheManager = new NopNullCache();

            _customerService = MockRepository.GenerateMock<ICustomerService>();

            _currencySettings = new CurrencySettings();
            _currencySettings.PrimaryStoreCurrencyId = currencyUSD.Id;
            _currencySettings.PrimaryExchangeRateCurrencyId = currencyEUR.Id;

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            var pluginFinder = new PluginFinder();
            _currencyService = new CurrencyService(cacheManager,
                _currencyRepository, _customerService,
                _currencySettings, pluginFinder, _eventPublisher);
        }
        public new void SetUp()
        {
            _workContext = MockRepository.GenerateMock<IWorkContext>();

            _store = new Store() { Id = 1 };
            _storeContext = MockRepository.GenerateMock<IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            var pluginFinder = new PluginFinder();
            var cacheManager = new NopNullCache();

            //price calculation service
            _discountService = MockRepository.GenerateMock<IDiscountService>();
            _categoryService = MockRepository.GenerateMock<ICategoryService>();
            _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings = new CatalogSettings();

            _priceCalcService = new PriceCalculationService(_workContext, _discountService,
                _categoryService, _productAttributeParser, _shoppingCartSettings, _catalogSettings);

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            _localizationService = MockRepository.GenerateMock<ILocalizationService>();

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>();
            _logger = new NullLogger();
            _shippingService = new ShippingService(cacheManager,
                _shippingMethodRepository,
                _logger,
                _productAttributeParser,
                _checkoutAttributeParser,
                _genericAttributeService,
                _localizationService,
                _shippingSettings, pluginFinder,
                _eventPublisher, _shoppingCartSettings);

            _paymentService = MockRepository.GenerateMock<IPaymentService>();
            _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>();
            _giftCardService = MockRepository.GenerateMock<IGiftCardService>();
            _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>();

            _eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = 10;
            _addressService = MockRepository.GenerateMock<IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address() { Id = _taxSettings.DefaultTaxAddressId });
            _taxService = new TaxService(_addressService, _workContext, _taxSettings, pluginFinder);

            _rewardPointsSettings = new RewardPointsSettings();

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                _priceCalcService, _taxService, _shippingService, _paymentService,
                _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService,
                _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);
        }
Exemplo n.º 60
0
		public void CreateWindowContent()
		{
			this.RemoveAllChildren();
			TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
			FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
			topToBottom.AnchorAll();

			// Creates Header
			FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
			headerRow.HAnchor = HAnchor.ParentLeftRight;
			headerRow.Margin = new BorderDouble(0, 3, 0, 0);
			headerRow.Padding = new BorderDouble(0, 3, 0, 3);
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			//Creates Text and adds into header
			{
				TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14);
				elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				elementHeader.HAnchor = HAnchor.ParentLeftRight;
				elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

				headerRow.AddChild(elementHeader);
				topToBottom.AddChild(headerRow);
			}

			// Creates container in the middle of window
			FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			{
				middleRowContainer.HAnchor = HAnchor.ParentLeftRight;
				middleRowContainer.VAnchor = VAnchor.ParentBottomTop;
				middleRowContainer.Padding = new BorderDouble(5);
				middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			if (!partIsGCode)
			{
				string exportStlText = LocalizedString.Get("Export as");
				string exportStlTextFull = string.Format("{0} STL", exportStlText);

				Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull);
				exportAsStlButton.HAnchor = HAnchor.ParentLeft;
				exportAsStlButton.Cursor = Cursors.Hand;
				exportAsStlButton.Click += new EventHandler(exportSTL_Click);
				middleRowContainer.AddChild(exportAsStlButton);
			}

			if (!partIsGCode)
			{
				string exportAmfText = LocalizedString.Get("Export as");
				string exportAmfTextFull = string.Format("{0} AMF", exportAmfText);

				Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull);
				exportAsAmfButton.HAnchor = HAnchor.ParentLeft;
				exportAsAmfButton.Cursor = Cursors.Hand;
				exportAsAmfButton.Click += new EventHandler(exportAMF_Click);
				middleRowContainer.AddChild(exportAsAmfButton);
			}

			bool showExportGCodeButton = ActiveSliceSettings.Instance != null || partIsGCode;
			if (showExportGCodeButton)
			{
				string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize());
				Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);
				exportGCode.Name = "Export as GCode Button";
				exportGCode.HAnchor = HAnchor.ParentLeft;
				exportGCode.Cursor = Cursors.Hand;
				exportGCode.Click += new EventHandler((object sender, EventArgs e) =>
				{
					UiThread.RunOnIdle(ExportGCode_Click);
				});
				middleRowContainer.AddChild(exportGCode);

				PluginFinder<ExportGcodePlugin> exportPluginFinder = new PluginFinder<ExportGcodePlugin>();

				foreach (ExportGcodePlugin plugin in exportPluginFinder.Plugins)
				{
					//Create export button for each Plugin found

					string exportButtonText = plugin.GetButtonText().Localize();

					Button exportButton = textImageButtonFactory.Generate(exportButtonText);
					exportButton.HAnchor = HAnchor.ParentLeft;
					exportButton.Cursor = Cursors.Hand;
					exportButton.Click += (object sender, EventArgs e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							// Close the export window
							Close();

							// Open a SaveFileDialog. If Save is clicked, slice the part if needed and pass the plugin the 
							// path to the gcode file and the target save path
							FileDialog.SaveFileDialog(
								new SaveFileDialogParams(plugin.GetExtensionFilter())
								{
									Title = "MatterControl: Export File",
									FileName = printItemWrapper.Name,
									ActionButtonLabel = "Export"
								},
								(SaveFileDialogParams saveParam) =>
								{
									string extension = Path.GetExtension(saveParam.FileName);
									if (extension == "")
									{
										saveParam.FileName += plugin.GetFileExtension();
									}

									if (partIsGCode)
									{
										plugin.Generate(printItemWrapper.FileLocation, saveParam.FileName);
									}
									else
									{
										SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);

										printItemWrapper.SlicingDone += (printItem, eventArgs) =>
										{
											PrintItemWrapper sliceItem = (PrintItemWrapper)printItem;
											if (File.Exists(sliceItem.GetGCodePathAndFileName()))
											{
												plugin.Generate(sliceItem.GetGCodePathAndFileName(), saveParam.FileName);
											}
										};
									}
								});
						});
					}; // End exportButton Click handler

					middleRowContainer.AddChild(exportButton);
				}
			}

			middleRowContainer.AddChild(new VerticalSpacer());

			// If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
			if (showExportGCodeButton && ActiveSliceSettings.Instance.DoPrintLeveling)
			{
				applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
				applyLeveling.Checked = true;
				applyLeveling.HAnchor = HAnchor.ParentLeft;
				applyLeveling.Cursor = Cursors.Hand;
				//applyLeveling.Margin = new BorderDouble(top: 10);
				middleRowContainer.AddChild(applyLeveling);
			}

			// TODO: make this work on the mac and then delete this if
			if (OsInformation.OperatingSystem == OSType.Windows
				|| OsInformation.OperatingSystem == OSType.X11)
			{
				showInFolderAfterSave = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10);
				showInFolderAfterSave.HAnchor = HAnchor.ParentLeft;
				showInFolderAfterSave.Cursor = Cursors.Hand;
				//showInFolderAfterSave.Margin = new BorderDouble(top: 10);
				middleRowContainer.AddChild(showInFolderAfterSave);
			}

			if (!showExportGCodeButton)
			{
				string noGCodeMessageTextBeg = LocalizedString.Get("Note");
				string noGCodeMessageTextEnd = LocalizedString.Get("To enable GCode export, select a printer profile.");
				string noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd);
				TextWidget noGCodeMessage = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
				noGCodeMessage.HAnchor = HAnchor.ParentLeft;
				middleRowContainer.AddChild(noGCodeMessage);
			}

			//Creates button container on the bottom of window
			FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
			{
				BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
				buttonRow.HAnchor = HAnchor.ParentLeftRight;
				buttonRow.Padding = new BorderDouble(0, 3);
			}

			Button cancelButton = textImageButtonFactory.Generate("Cancel");
			cancelButton.Name = "Export Item Window Cancel Button";
			cancelButton.Cursor = Cursors.Hand;
			cancelButton.Click += (sender, e) =>
			{
				CloseOnIdle();
			};

			buttonRow.AddChild(new HorizontalSpacer());
			buttonRow.AddChild(cancelButton);
			topToBottom.AddChild(middleRowContainer);
			topToBottom.AddChild(buttonRow);

			this.AddChild(topToBottom);
		}