Esempio n. 1
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);
            }
Esempio n. 2
0
            public void ShowChordLayouts(WebView webView, NameValueCollection parameters)
            {
                var model = new ShowChordLayoutsModel
                {
                    Root          = _currentRoot,
                    ChordType     = _currentChordType.ToDescription(),
                    conv          = _currentSettings.conv,
                    AllowPartial  = _allowPartial,
                    AllowSpecial  = _currentSettings.AllowSpecial,
                    AllRoots      = _allRoots,
                    AllChordTypes = _allChordTypes,
                    ShowTips      = _currentSettings.ShowTips,
                };

                model.Populate(parameters);

                var   id = string.Format("{0}{1}", model.Root, model.ChordType);
                Chord chord;

                if (!Chord.TryParse(id, NamingConvention.English, out chord))
                {
                    model.Error = $"{id} is not a valid chord";
                }
                else
                {
                    model.ChordDecorator = new ChordDecorator(chord, _currentSettings.conv);
                    model.Layouts        = model.ChordDecorator
                                           .GenerateLayouts(_currentSettings.AllowBarre, _currentSettings.AllowSpecial, model.AllowPartial, _currentSettings.maxFret)
                                           .OrderBy(i => i.Favorite ? 0 : 1)
                                           .ToArray();
                }
                var template = new ShowChordLayoutsView {
                    Model = model
                };
                var page = template.GenerateString();

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