コード例 #1
0
 public MainWindowController(ChocolateyService chocolateyService, WindowsTaskService windowsTaskService, ShortcutService shortcutService, CandyShopContext candyShopContext)
 {
     ChocolateyService  = chocolateyService;
     WindowsTaskService = windowsTaskService;
     ShortcutService    = shortcutService;
     CandyShopContext   = candyShopContext;
 }
コード例 #2
0
        public TestChocolateyService()
        {
            m_commandServiceMock    = new Mock <ICommandService>();
            m_fileSystemServiceMock = new Mock <IFileSystemService>();

            m_cut = new ChocolateyService(m_commandServiceMock.Object, m_fileSystemServiceMock.Object);
        }
コード例 #3
0
        public TestChocolateyService()
        {
            m_commandServiceMock    = new Mock <ICommandService>();
            m_fileSystemServiceMock = new Mock <IFileSystemService>();
            m_consoleLoggerFactory  = new NLogConsoleFactory();

            m_cut = new ChocolateyService(m_commandServiceMock.Object, m_fileSystemServiceMock.Object, m_consoleLoggerFactory);
        }
コード例 #4
0
 private async void LoadOutdatedPackagesAsync(ChocolateyService service)
 {
     try
     {
         await service.GetOutdatedPackagesAsync();
     }
     catch (ChocolateyException e)
     {
         Log.Error(LocaleEN.ERROR_RETRIEVING_OUTDATED_PACKAGES, e.Message);
     }
 }
コード例 #5
0
        private async void RunInBackground(MainWindowController controller, ChocolateyService service)
        {
            List <ChocolateyPackage> packages = null;

            // create tray icon
            NotifyIcon icon = InitTrayIcon();

            // obtain outdated packages
            try
            {
                packages = await service.GetOutdatedPackagesAsync();
            }
            catch (ChocolateyException e)
            {
                icon.BalloonTipIcon  = ToolTipIcon.Error;
                icon.Text            = Application.ProductName;
                icon.BalloonTipTitle = String.Format(LocaleEN.TEXT_APP_TITLE, Application.ProductName, Application.ProductVersion);
                icon.BalloonTipText  = String.Format(LocaleEN.ERROR_RETRIEVING_OUTDATED_PACKAGES, e.Message);
                icon.ShowBalloonTip(2000);
                Program.Exit();
            }

            // create click handlers
            icon.BalloonTipClicked += new EventHandler((sender, e) =>
            {
                controller.InitView();
            });

            icon.MouseClick += new MouseEventHandler((sender, e) =>
            {
                controller.InitView();
            });


            if (packages.Count > 0)
            {
                ShowNotification(packages.Count, icon);
            }
            else
            {
                Program.Exit();
            }
        }
コード例 #6
0
        public CandyShopApplicationContext(CandyShopContext context)
        {
            Log.Debug("Launched CandyShop.");

            // init services
            ChocolateyService  chocolateyService  = new ChocolateyService();
            WindowsTaskService windowsTaskService = new WindowsTaskService();
            ShortcutService    shortcutService    = new ShortcutService();

            //
            LoadOutdatedPackagesAsync(chocolateyService);

            // init controller
            MainWindowController    candyShopController     = new MainWindowController(chocolateyService, windowsTaskService, shortcutService, context);
            InstalledPageController installedPageController = new InstalledPageController(chocolateyService);

            // init views
            IMainWindowView    mainView = new MainWindow(candyShopController);
            IInstalledPageView pageView = mainView.InstalledPackagesPage;

            installedPageController.InjectView(pageView);
            candyShopController.InjectView(mainView);

            // launch with form or in tray
            if (context.LaunchedMinimized)
            {
                // creates a tray icon, displays a notification if outdated packages
                // are found and opens the upgrade UI on click
                RunInBackground(candyShopController, chocolateyService);
            }
            else
            {
                // launch window
                candyShopController.InitView();
                installedPageController.InitView();
            }
        }
コード例 #7
0
 public void Setup()
 {
     _mocks   = new RhinoAutoMocker <ChocolateyService>();
     _service = _mocks.ClassUnderTest;
 }
コード例 #8
0
 public InstalledPageController(ChocolateyService chocolateyService)
 {
     ChocolateyService = chocolateyService;
 }