Esempio n. 1
0
        public void Grouping()
        {
            var targets = Libraries.Where(x => x.IsSelected).ToArray();
            if (CurrentLibrary == null || targets.Length == 0) return;
            var paramDic = new Dictionary<string, IInputFormParam>();

            var library = CurrentLibrary.Model;
            var gid = library.Gid;
            if (gid != 0)
            {
                // グループ登録済み
                paramDic.Add("GroupName",
                    new InputSelectParam("GroupName", library.GroupName, _groups.Select(x => x.Model.GroupName)));
                paramDic.Add("GroupKeyword",
                    new InputParam("GroupKeyword",
                        _groups.Where(x => x.Model.Gid == gid).Select(x => x.Model.Keyword).FirstOrDefault()));
            }
            else
            {
                // グループ未登録
                var keywordList = new List<string>();

                foreach (var title in Libraries.Where(x => x.IsSelected).Select(x => x.Model.Title))
                {
                    var words = MovselexUtils.CreateKeywords(title.Trim());
                    keywordList.AddRange(words);
                }

                // 対象のライブラリ中で一番多く出てくるキーワードを抽出
                var keyword = MovselexUtils.GetMaxCountMaxLengthKeyword(keywordList);


                paramDic.Add("GroupName", new InputSelectParam("GroupName", keyword, _groups.Select(x => x.Model.GroupName)));
                paramDic.Add("GroupKeyword", new InputParam("GroupKeyword", keyword));
            }
           
            paramDic.Add("Target", new InputListParam("Target", targets.Select(x=>x.Model.Title)));

            var inputTextContent = new InputFormContent(Resources.MessageRegistGroup, paramDic);
            var dlg = new ModernDialog
            {
                Title = "Grouping",
                Content = inputTextContent
            };
            dlg.Buttons = new[] {dlg.OkButton, dlg.CancelButton};
            var result = dlg.ShowDialog();


            if (result == false) return;

            var input = inputTextContent.InputParamDictionary;

            _client.Grouping(
                input["GroupName"].Value.ToString(),
                input["GroupKeyword"].Value.ToString(),
                targets.Select(x => x.Model));
        }
Esempio n. 2
0
        public void EditLibrary()
        {
            if (CurrentLibrary == null) return;

            var library = CurrentLibrary.Model;
            var paramDic = new Dictionary<string, IInputFormParam>();
            paramDic.Add("FilePath", new ReadOnlyParam("FilePath", library.FilePath));
            paramDic.Add("Title", new InputParam("Title", library.Title));
            paramDic.Add("No", new InputParam("No", library.No));
            paramDic.Add("Season", new InputParam("Season", library.Season));
            var inputTextContent = new InputFormContent(Resources.MessageEditLibrary, paramDic);
            var dlg = new ModernDialog
            {
                Title = Resources.EditLibrary,
                Content = inputTextContent
            };
            dlg.Buttons = new[] { dlg.OkButton, dlg.CancelButton };
            var result = dlg.ShowDialog();

            if (result == false || !inputTextContent.IsModify) return;

            var input = inputTextContent.InputParamDictionary;

            Client.ModifyLibrary(library, input.ToDictionary(pair => pair.Key, pair => pair.Value.Value));
        }
Esempio n. 3
0
        public void EditGroup()
        {
            if (CurrentGroup == null) return;
            _client.GetCandidateGroupName(CurrentGroup.Model.GroupName, candidateGroupNames =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var group = CurrentGroup.Model;
                    var paramDic = new Dictionary<string, IInputFormParam>();
                    paramDic.Add("GroupName", new InputSelectParam("GroupName", group.GroupName, candidateGroupNames));
                    paramDic.Add("GroupKeyword", new InputParam("GroupKeyword", group.Keyword));
                    var inputTextContent = new InputFormContent(Resources.MessageEditGroup, paramDic);
                    var dlg = new ModernDialog
                    {
                        Title = Resources.EditGroup,
                        Content = inputTextContent
                    };
                    dlg.Buttons = new[] {dlg.OkButton, dlg.CancelButton};
                    var result = dlg.ShowDialog();

                    if (result == false || !inputTextContent.IsModify) return;

                    var input = inputTextContent.InputParamDictionary;

                    _client.ModifyGroup(group, input["GroupName"].Value.ToString(),
                        input["GroupKeyword"].Value.ToString());
                });
            });
        }