Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            HostedWindow        = null;
            MagicArrow          = new MagicArrow.MagicArrow();
            MagicArrow.MoveOut += (s, e) =>
            {
                HideEqualizer();
                HostedWindow.DisableWindow();
            };
            MagicArrow.MoveIn       += (s, e) => { HostedWindow.EnableWindow(); };
            MagicArrow.FilesDropped +=
                (s, e) => { MainViewModel.Instance.DragDropFiles((string[])e.Data.GetData(DataFormats.FileDrop)); };
            MagicArrow.Register(this);

            Closing      += MainWindow_Closing;
            Loaded       += MainWindow_Loaded;
            StateChanged += MainWindow_StateChanged;

            MagicArrow.DockManager.Docked      += (s, e) => { ApplyHostWindow(SmartWindowSkin); };
            MagicArrow.DockManager.Undocked    += (s, e) => { ApplyHostWindow(AdvancedWindowSkin); };
            MagicArrow.DockManager.DragStopped += DockManagerOnDragStopped;

            var appsettings = HurricaneSettings.Instance.CurrentState;

            if (appsettings.ApplicationState == null)
            {
                WindowStartupLocation        = WindowStartupLocation.CenterScreen;
                appsettings.ApplicationState = new DockingApplicationState
                {
                    CurrentSide = DockingSide.None,
                    Height      = 600,
                    Width       = 1000,
                    Left        = Left,
                    Top         = Top
                };
            }

            if (appsettings.ApplicationState.CurrentSide == DockingSide.None)
            {
                if (appsettings.ApplicationState.Left < WpfScreen.MostRightX)
                //To prevent that the window is out of view when the user unplugs a monitor
                {
                    Height      = appsettings.ApplicationState.Height;
                    Width       = appsettings.ApplicationState.Width;
                    Left        = appsettings.ApplicationState.Left;
                    Top         = appsettings.ApplicationState.Top;
                    WindowState = appsettings.ApplicationState.WindowState;
                }
                else
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen;
                }
            }

            MagicArrow.DockManager.CurrentSide = appsettings.ApplicationState.CurrentSide;
            WindowDialogService            = new WindowDialogService(this);
            SystemEvents.PowerModeChanged += SystemEventsOnPowerModeChanged;
        }
Example #2
0
        public AppViewModel()
        {
            var dataService   = new JsonContactDataService();
            var dialogService = new WindowDialogService();

            BookVM      = new BookViewModel(dataService, dialogService);
            CurrentView = BookVM;
        }
Example #3
0
        public AppViewModel()
        {
            var dataService   = new JsonDataService();
            var dialogService = new WindowDialogService();
            var mediaService  = new MusicService();

            _musicPlayerVM = new MusicPlayerViewModel(dataService, dialogService, mediaService);
        }
Example #4
0
        public static async void MoveToLocalFoler(WindowDialogService messageService)
        {
            var appDataDir     = AppDataDirectory;
            var localConfig    = new FileInfo("config.xml");
            var localPlaylists = new FileInfo("playlists.xml");
            var localCurrent   = new FileInfo("current.xml");

            bool replaceFiles = false;

            if (localConfig.Exists || localPlaylists.Exists)
            {
                replaceFiles = await
                               messageService.ShowMessage(
                    Application.Current.Resources["ReplaceFilesAtNewSaveLocation"].ToString(),
                    Application.Current.Resources["MoveSaveLocation"].ToString(), true, DialogMode.Single,
                    Application.Current.Resources["Yes"].ToString(), Application.Current.Resources["No"].ToString());
            }

            var configFile   = new FileInfo(Path.Combine(appDataDir.FullName, "config.xml"));
            var playlistFile = new FileInfo(Path.Combine(appDataDir.FullName, "playlists.xml"));
            var currentFile  = new FileInfo(Path.Combine(appDataDir.FullName, "current.xml"));

            if (!localConfig.Exists || replaceFiles)
            {
                configFile.CopyTo(localConfig.FullName, true);
            }

            if (!localPlaylists.Exists || replaceFiles)
            {
                playlistFile.CopyTo(localPlaylists.FullName, true);
            }

            if (!localCurrent.Exists || replaceFiles)
            {
                currentFile.CopyTo(localCurrent.FullName, true);
            }

            try
            {
                File.Move(Path.Combine(appDataDir.FullName, "youtube-dl.exe"), "youtube-dl.exe");
            }
            catch (IOException)
            {
                //file already exists
            }


            InstalledInfoFile.Delete();

            await
            messageService.ShowMessage(Application.Current.Resources["MoveSaveLocationSuccessful"].ToString(),
                                       Application.Current.Resources["MoveSaveLocation"].ToString(), false, DialogMode.Single);

            Process.Start(Application.ResourceAssembly.Location);
            Application.Current.Shutdown();
        }
Example #5
0
        public void ConfigureContainer()
        {
            Locator.SetLocator <UnityLocator>();

            var navigationService = new ViewModelNavigationService(Application.Current.MainWindow);

            navigationService.Configure <MainViewModel, MainPage>();
            navigationService.Configure <CategoryViewModel, CategoryPage>();
            navigationService.Configure <ItemViewModel, ItemPage>();

            var dialogService = new WindowDialogService(Application.Current.MainWindow);

            Locator.Current.Register <INavigationService>(navigationService);
            Locator.Current.Register <IDialogService>(dialogService);
            Locator.Current.Register <ICrudService <Category>, CategoryService>();
            Locator.Current.Register <ICrudService <Item>, ItemService>();
        }
Example #6
0
        public static async void MoveToAppData(WindowDialogService messageService)
        {
            var appDataDir = AppDataDirectory;

            var configFile   = new FileInfo(Path.Combine(appDataDir.FullName, "config.xml"));
            var playlistFile = new FileInfo(Path.Combine(appDataDir.FullName, "playlists.xml"));
            var currentFile  = new FileInfo(Path.Combine(appDataDir.FullName, "current.xml"));

            bool replaceFiles = true;

            if (appDataDir.Exists && (configFile.Exists || playlistFile.Exists))
            {
                replaceFiles = await
                               messageService.ShowMessage(
                    Application.Current.Resources["ReplaceFilesAtNewSaveLocation"].ToString(),
                    Application.Current.Resources["MoveSaveLocation"].ToString(), true, DialogMode.Single,
                    Application.Current.Resources["Yes"].ToString(), Application.Current.Resources["No"].ToString());
            }

            if (!appDataDir.Exists)
            {
                appDataDir.Create();
            }

            var localConfig    = new FileInfo("config.xml");
            var localPlaylists = new FileInfo("playlists.xml");
            var localCurrent   = new FileInfo("current.xml");

            if (!configFile.Exists || replaceFiles)
            {
                localConfig.CopyTo(configFile.FullName, true);
            }

            if (!playlistFile.Exists || replaceFiles)
            {
                localPlaylists.CopyTo(playlistFile.FullName, true);
            }

            if (!currentFile.Exists || replaceFiles)
            {
                localCurrent.CopyTo(currentFile.FullName, true);
            }

            try
            {
                File.Move("youtube-dl.exe", Path.Combine(appDataDir.FullName, "youtube-dl.exe"));
            }
            catch (IOException)
            {
                //file already exists
            }

            // ReSharper disable once LocalizableElement because le garcon n'est pas absent de croissant bonbon
            File.WriteAllText(InstalledInfoFile.FullName, "garcon?");

            await
            messageService.ShowMessage(Application.Current.Resources["MoveSaveLocationSuccessful"].ToString(),
                                       Application.Current.Resources["MoveSaveLocation"].ToString(), false, DialogMode.Single);

            Process.Start(Application.ResourceAssembly.Location);
            Application.Current.Shutdown();
        }