Beispiel #1
0
        public MainWindow(MainViewModel mainViewModel, TaskbarPanel taskbarPanel)
        {
            try
            {
                DataContext = mainViewModel;
                ViewModel = mainViewModel;
            }
            catch (Exception e)
            {
                _log.ErrorException("Error setting context", e);

                MessageBox.Show(e.Message);
            }

            InitializeComponent();

            SetPosition();

            WindowPanels.Add(LoginViewControl);
            WindowPanels.Add(RegistrationViewControl);

            RegisterTaskbarCallbacks(taskbarPanel);

            LoginViewControl.RegistrationClick += Login_OnRegistrationClick;
            LoginViewControl.CloseLogin += Login_Close;
            LoginViewControl.LoginSuccessfulNotifier += ViewModel.LoginSuccessful;

            LoginViewControl.DataContext = ViewModel.LoginViewModel;

            RegistrationViewControl.ClosePanel += Registration_Close;
        }
Beispiel #2
0
        public TaskbarPanel(ILatch latch, ILogger logger, MainViewModel mainViewModel, IUiHelper uiHelper)
        {
            _log = logger;
            _mainViewModel = mainViewModel;
            _uiHelper = uiHelper;

            InitializeComponent();
            InitializeMainWindowLatch = latch;

            ViewModel = new TaskbarPanelViewModel(_mainViewModel.MyApplications.Where(a => a.Application.PinnedToTaskbar && !a.IsUnsupported).ToList());
            DataContext = ViewModel;
        }
 private void InitializeTests()
 {
     ServiceLocator.LocalStorage.ClearAllStoredData();
     ServiceLocator.CachedAppDirectApi.SuggestedApps.Returns(_suggestedApplications);
     _mainViewModel = new MainViewModel();
     _mainViewModel.InitializeAppsLists();
     _mainViewModel.SyncMyApplications(true, true);
     _mainViewModel.GetSuggestedApplicationsWithApiCall();
     _mainViewModel.LogoutNotifier += LogoutNotifier;
 }
        public void ResetUpdateTextUpdateAvailableTest()
        {
            ServiceLocator.LocalStorage.UpdateDownloaded = true;

            _mainViewModel = new MainViewModel();
            _mainViewModel.ResetUpdateText();

            Assert.AreEqual("Install updates now", _mainViewModel.UpdateString);
        }
        public void ResetUpdateTextNoUpdateTest()
        {
            ServiceLocator.LocalStorage.UpdateDownloaded = false;

            _mainViewModel = new MainViewModel();
            _mainViewModel.ResetUpdateText();
            Assert.AreEqual("Check for updates", _mainViewModel.UpdateString);
        }
Beispiel #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // Make sure that Current Directory is the same which contains all the binaries
            Environment.CurrentDirectory = (
                from assembly in AppDomain.CurrentDomain.GetAssemblies()
                where assembly.CodeBase.EndsWith(".exe")
                select System.IO.Path.GetDirectoryName(assembly.CodeBase.Replace("file:///", ""))
            ).FirstOrDefault();

            var startTicks = Environment.TickCount;

            bool createdNew;
            _instanceMutex = new Mutex(true, @"AppDirect.WindowsClient Application Manager Mutex", out createdNew);

            if (!createdNew)
            {
                _log.Info("Instance already exists, exit.");
                _instanceMutex = null;
                Current.Shutdown();
                Environment.Exit(0);
            }

            try
            {
                ServiceLocator.Initialize();
            }
            catch (Exception ex)
            {
                _log.ErrorException("Failed to initialize", ex);
                ServiceLocator.UiHelper.IgnoreException(_instanceMutex.ReleaseMutex);
                _instanceMutex = null;
                Current.Shutdown();
                Environment.Exit(0);
            }

            var helper = ServiceLocator.UiHelper;

            ServiceLocator.LocalStorage.LoadStorage();
            helper.StartAsynchronously(ServiceLocator.IpcCommunicator.Start);

            _mainViewModel = new MainViewModel();
            _mainViewModel.InitializeAppsLists();

            helper.StartAsynchronously(() => ServiceLocator.UiHelper.IgnoreException(ServiceLocator.BrowserWindowsCommunicator.Start));

            _explorerWatcher = new ExplorerWatcher(_log, helper, OnExplorerStartup, OnExplorerShutdown);
            _explorerWatcher.Start();

            base.OnStartup(e);

            var timeElapsed = Environment.TickCount - startTicks;
            helper.StartAsynchronously(() => {
                _log.Warn("Application startup completed in " + timeElapsed + "ms.");
                ServiceLocator.Analytics.Notify("ClientStarted", "StartedIn", timeElapsed);
            });
        }
Beispiel #7
0
        private TaskbarPanel CreateTaskbarPanel(MainViewModel mainViewModel, IUiHelper uiHelper)
        {
            try
            {
                var taskbarPanel = new TaskbarPanel(_mainWindowReadyLatch, new NLogLogger("TaskbarPanel"), mainViewModel, uiHelper);
                taskbarPanel.InitializeButtons();

                return taskbarPanel;
            }
            catch (Exception ex)
            {
                _log.ErrorException("Failed to initialize taskbar module", ex);
                uiHelper.ShowMessage(ex.ToString());
                uiHelper.IgnoreException(_instanceMutex.ReleaseMutex);
                _instanceMutex = null;
                Current.Shutdown();
                Environment.Exit(0);
            }

            return null;
        }