Пример #1
0
        public void CommandViewModelTo(AddMaterialDataToFile msg)
        {
            //FIXME:ここもなんだかif文が多い。
            //いや、if文があることは悪いことではないが、ここに書くべきではない気がする。
            //どこか別のところに書いたほうがいいだろう。


            //MaterialListFileAdapter FileInstance = new MaterialListFileAdapter();
            //MaterialSiteListFileAdapter LicenseTextInstance = new MaterialSiteListFileAdapter();

            //bool MaterialSiteExists = LicenseTextInstance.MaterialSiteExists(msg.MaterialSiteName);

            //if (msg.MaterialName.Equals("") || msg.MaterialFilePath.Equals("") || msg.MaterialSiteName.Equals(""))
            //{
            //    msg.ProcessingResult = AddMaterialDataToFile.NOT_INPUT_ITEM_EXISTS;
            //    return;
            //}

            //FIXME:将来的に例外処理も実装すること。
            //現状は、コンポボックスで素材配布サイトを指定しており、この例外が発生する可能性は少ないと
            //見られるため処理の実装を省略する。

            /*
             * if (!MaterialSiteExists)
             * {
             *  msg.ProcessingResult = AddMaterialDataToFile.MATERIALSITE_NOT_FOUND;
             *  return;
             * }
             */

            ActiveProjectData.GetInstance().MateiralListLogicalData.AddMaterialData(msg.AddedMaterialData);

            //msg.ProcessingResult = AddMaterialDataToFile.PROCESS_SUCCESSFUL;
        }
        private void ClickedOKButton(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(MaterialName.Text))
            {
                MessageBox.Show("素材名を入力してください", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(MaterialSiteList.Text))
            {
                MessageBox.Show("素材配布サイトを選択してください。", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(MaterialType.Text))
            {
                MessageBox.Show("ファイルの種類を選択してください。", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            MaterialLicenseChecker.Models.MaterialData AddedMaterialData = new MaterialLicenseChecker.Models.MaterialData();
            AddedMaterialData.MaterialCreationSiteName = MaterialSiteList.Text;
            AddedMaterialData.MaterialType             = MaterialType.Text;
            AddedMaterialData.MaterialName             = MaterialName.Text;
            AddedMaterialData.MaterialFileAbsolutePath = MaterialFileLocation.Text;

            MaterialAdditional.AddMaterialDataToFile cmd = new MaterialAdditional.AddMaterialDataToFile();

            cmd.AddedMaterialData = AddedMaterialData;

            //FIXME:本当はこれではまずい。なぜなら、ViewからViewへダイレクトに呼び出しているからだ。
            //ただ時間が無い。これで許してくれ……
            ReceiverOfViewModel.CommandViewModelTo(cmd);
            MainView MainViewInstance = (MainView)this.Owner;

            MainViewInstance.UpdateMaterialDataGrid();
            Close();
        }