예제 #1
0
        public void OpenFileRequested()
        {
            FileInfo[] files = view.SelectProfileFiles();
            if (files == null)
            {
                return;
            }

            string invalidFiles = null;
            LinkedList <string> validationMessages = new LinkedList <string>();

            foreach (FileInfo file in files)
            {
                if (file.Extension.ToUpperInvariant() != PR0_FILE_EXTENSION)
                {
                    if (invalidFiles == null)
                    {
                        invalidFiles = file.Name;
                    }
                    else
                    {
                        invalidFiles += "\n" + file.Name;
                    }
                    continue;
                }

                var  report  = new ClawValidationReport();
                bool success = model.LoadProfile(file, report);

                if (report.SomethingHappened)
                {
                    validationMessages.AddLast((string)App.Current.FindResource(VALIDATION_MSG_STH_HAPPENED) + "\n" + report.Message);
                }

                if (!success)
                {
                    continue;
                }

                MadCatzProfile profile = model.Profiles.Last.Value;
                view.AddProfile(profile);
            }

            if (invalidFiles != null)
            {
                view.ShowErrorMessage((string)App.Current.FindResource(ERROR_MSG_INVALID_PROFILES) + "\n" + invalidFiles);
            }

            foreach (string msg in validationMessages)
            {
                view.ShowMessage(msg);
            }
        }