Example #1
0
        private void OpenHelp(string pathToYaml, bool isAbsPath = false)
        {
            string absPath = isAbsPath
                ? pathToYaml
                : Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) +
                             $"/{pathToYaml}";

            if (!File.Exists(absPath))
            {
                Logger.Error("Help file {h} not found", absPath);
                MessageBox.Show(
                    parent: this,
                    caption: "Error",
                    text: $"Could not find help file '{absPath}'",
                    type: MessageBoxType.Error
                    );
                return;
            }

            if (string.IsNullOrWhiteSpace(File.ReadAllText(absPath)))
            {
                Logger.Error("Could not load help", absPath);
                MessageBox.Show(
                    parent: this,
                    caption: "Error",
                    text: $"Help file '{absPath}' is empty",
                    type: MessageBoxType.Error
                    );
                return;
            }

            // todo error catching
            new HelpDialog(YamlParser.ParseHelpFile(absPath)).ShowModal(this);
        }