Beispiel #1
0
        private void RunUntappd(string filePath)
        {
            FileStatus fileStatus = FileHelper.Check(filePath, Extensions.GetSupportExtensions());

            if (!EnumsHelper.IsValidFileStatus(fileStatus))
            {
                interactionRequestService.ShowMessage(Properties.Resources.Warning, CommunicationHelper.GetFileStatusMessage(fileStatus, filePath));
                return;
            }
            try
            {
                string untappdUserName = String.Empty;
                if (FileHelper.GetExtensionWihtoutPoint(filePath).Equals(Extensions.CSV))
                {
                    if (!interactionRequestService.AskReplaceText(Properties.Resources.UntappdUserNameCaption, ref untappdUserName))
                    {
                        return;
                    }
                }

                untappdService.Initialize(filePath, untappdUserName);
            }
            catch (ArgumentException ex)
            {
                interactionRequestService.ShowError(Properties.Resources.Error, StringHelper.GetFullExceptionMessage(ex));
                return;
            }

            settingService.SetRecentFilePaths(FileHelper.AddFilePath(settingService.GetRecentFilePaths(), filePath, settingService.GetMaxRecentFilePaths()));
            moduleManager.LoadModule(typeof(MainModule).Name);
            ActivateView(RegionNames.RootRegion, typeof(Main));
            interactionRequestService.ShowMessageOnStatusBar(filePath);
        }
        private void SaveAsProject()
        {
            string fileSavePath = interactionRequestService.SaveFile(String.IsNullOrEmpty(untappdService.FilePath) ? String.Empty : Path.GetDirectoryName(untappdService.FilePath), untappdService.GetUntappdProjectFileName(), Extensions.GetSaveExtensions());

            if (String.IsNullOrEmpty(fileSavePath))
            {
                return;
            }

            FileHelper.SaveFile(fileSavePath, untappdService.Untappd);
            untappdService.Initialize(fileSavePath);
            untappdService.ResetСhanges();
            FileHelper.CreateDirectory(untappdService.GetFileDataDirectory());
            interactionRequestService.ShowMessageOnStatusBar(untappdService.FilePath);
            settingService.SetRecentFilePaths(FileHelper.AddFilePath(settingService.GetRecentFilePaths(), fileSavePath, settingService.GetMaxRecentFilePaths()));
        }
        private void Activate()
        {
            Title = CommunicationHelper.GetTitle();
            bool   isUsedArgument = false;
            string filePath;

            if (argumentsProvider.Arguments.Count > 0)
            {
                filePath       = argumentsProvider.Arguments[0];
                isUsedArgument = true;
            }
            else
            {
                filePath = FileHelper.GetFirstFileItemPath(settingService.GetRecentFilePaths());
            }

            FileStatus fileStatus = FileHelper.Check(filePath, Extensions.GetSupportExtensions());

            if (EnumsHelper.IsValidFileStatus(fileStatus))
            {
                try
                {
                    untappdService.Initialize(filePath);
                    if (isUsedArgument)
                    {
                        settingService.SetRecentFilePaths(FileHelper.AddFilePath(settingService.GetRecentFilePaths(), filePath, settingService.GetMaxRecentFilePaths()));
                    }

                    moduleManager.LoadModule(typeof(MainModule).Name);
                }
                catch (ArgumentException ex)
                {
                    interactionRequestService.ShowError(Properties.Resources.Error, StringHelper.GetFullExceptionMessage(ex));
                    moduleManager.LoadModule(typeof(WelcomeModule).Name);
                }
            }
            else
            {
                if (fileStatus != FileStatus.IsEmptyPath)
                {
                    interactionRequestService.ShowMessage(Properties.Resources.Warning, CommunicationHelper.GetFileStatusMessage(fileStatus, filePath));
                }

                moduleManager.LoadModule(typeof(WelcomeModule).Name);
            }
        }