示例#1
0
            public void ShowChord(WebView webView, NameValueCollection parameters)
            {
                string page;
                var    model = new ShowChordModel
                {
                    Root                = _currentRoot,
                    ChordType           = _currentChordType,
                    conv                = _currentSettings.conv,
                    ShowBasicChordTypes = _currentSettings.ShowBasicChordTypes
                };

                model.Populate(parameters);

                _allRoots      = null;
                _allChordTypes = null;

                var template = new ShowChordView {
                    Model = model
                };

                page = template.GenerateString();
                // Load the rendered HTML into the view with a base URL
                // that points to the root of the bundled Assets folder
                webView.LoadDataWithBaseURL("file:///android_asset/?page=ShowChord", page, "text/html", "UTF-8", null);
            }
示例#2
0
            public void ShowChordResults(WebView webView, NameValueCollection parameters)
            {
                string page;
                var    model = new ShowChordModel
                {
                    Root                = _currentRoot,
                    ChordType           = _currentChordType,
                    conv                = _currentSettings.conv,
                    ShowBasicChordTypes = _currentSettings.ShowBasicChordTypes
                };

                model.Populate(parameters);

                Chord chord;
                var   id          = string.Format("{0}{1}", model.Root, model.ChordType.ToDescription());
                var   resultModel = new ShowChordResultModel
                {
                    conv          = _currentSettings.conv,
                    AllowPartial  = _allowPartial,
                    AllRoots      = _allRoots,
                    AllChordTypes = _allChordTypes
                };

                if (!string.IsNullOrEmpty(id))
                {
                    resultModel.Populate(parameters);

                    if (!Chord.TryParse(id, NamingConvention.English, out chord))
                    {
                        resultModel.Error = $"{id} is not a valid chord in {_currentSettings.conv} naming convention";
                    }
                    else
                    {
                        _currentRoot               = chord.Root;
                        _currentChordType          = chord.ChordType;
                        _allowPartial              = resultModel.AllowPartial;
                        resultModel.Root           = _currentRoot;
                        resultModel.ChordType      = _currentChordType.ToDescription();
                        resultModel.ChordDecorator = new ChordDecorator(chord, _currentSettings.conv);
                    }
                    var template = new ShowChordResultView {
                        Model = resultModel
                    };

                    page = template.GenerateString();
                }
                else
                {
                    var template = new ShowChordView {
                        Model = model
                    };

                    page = template.GenerateString();
                }

                webView.LoadDataWithBaseURL("file:///android_asset/?page=ShowChordResults", page, "text/html", "UTF-8", null);
            }