예제 #1
0
 public void FileDialogCallback(OpeningFileSelectionMessage message)
 {
     if (message.Response != null && message.Response.Length > 0)
     {
         this.Plugin.ImagePath = message.Response[0];
     }
 }
예제 #2
0
 private void SelectSoundPath(OpeningFileSelectionMessage parameter)
 {
     if (parameter.Response != null)
     {
         this.NotifySoundPath = parameter.Response;
     }
 }
 public void SetScreenshotPath(OpeningFileSelectionMessage parameter)
 {
     if (parameter.Response != null && parameter.Response.Count() > 0)
     {
         ScreenshotPath = parameter.Response[0];
     }
 }
 public void SetExecutablePath(OpeningFileSelectionMessage parameter)
 {
     if (parameter.Response != null && parameter.Response.Count() > 0)
     {
         ExecutablePath = parameter.Response[0];
     }
 }
예제 #5
0
    public async Task LoadSetting_InvalidLang()
    {
        const string invalidLangCode = "xx";
        const string validLangCode = "en";

        string settingContent = @"{""AppLanguageCode"": """ + invalidLangCode + @"""}";
        string settingContentOther = @"{""AppLanguageCode"": """ + validLangCode + @"""}";

        var mockFileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
        {
            [defaultSettingFilePath] = new MockFileData(settingContent),
            [otherSettingFilePath] = new MockFileData(settingContentOther),
        });

        var model = new MainModel(mockFileSystem, Scheduler.Immediate);
        var mainVM = new MainWindowViewModel(model);
        mainVM.Initialize();
        await model.WaitIdleUI().Timeout(3000d);
        await Task.Delay(100);

        //設定VMは設定読込時にリセットされるので、MainVMの設定プロパティからアクセスする
        //settingVM...

        //ステージ1 初期状態
        mainVM.SettingVM.Value.SelectedLanguage.Value
                .Should().Be(CultureInfo.InvariantCulture, because: "無効な言語コードが指定された場合は自動カルチャになるはず");

        //ステージ2 読込後
        var fileMessage = new OpeningFileSelectionMessage() { Response = new[] { otherSettingFilePath } };
        mainVM.SettingVM.Value.LoadSettingFileDialogCommand.Execute(fileMessage);

        mainVM.SettingVM.Value.SelectedLanguage.Value.Name
                .Should().Be(validLangCode, because: "有効な言語コードが指定された場合はそのカルチャになるはず");
    }
예제 #6
0
        public void AttachImage()
        {
            var dir = Setting.LastImageOpenDir.Value;

            if (!Directory.Exists(dir))
            {
                dir = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            }
            var msg = new OpeningFileSelectionMessage
            {
                Filter =
                    InputAreaResources.AttachImageDlgFilterImg + "|*.jpg;*.jpeg;*.jpe;*.png;*.gif;*.bmp;*.dib|" +
                    InputAreaResources.AttachImageDlgFilterAll + "|*.*",
                InitialDirectory = dir,
                MultiSelect      = false,
                Title            = InputAreaResources.AttachImageDlgTitle
            };
            var m = _parent.Messenger.GetResponse(msg);

            if (m.Response == null || m.Response.Length <= 0 ||
                String.IsNullOrEmpty(m.Response[0]) || !File.Exists(m.Response[0]))
            {
                return;
            }

            Setting.LastImageOpenDir.Value = Path.GetDirectoryName(m.Response[0]);
            this.AttachImageFromPath(m.Response[0]);
        }
예제 #7
0
        private void SetBackUpData(OpeningFileSelectionMessage parameter)
        {
            if (parameter.Response == null || parameter.Response.Length == 0)
                return;

            File.Copy(parameter.Response[0], AppDomain.CurrentDomain.BaseDirectory + @"\Resources\MyData.sdf", true);
            Messenger.Raise(new InformationMessage("復元しました。再起動すると復元データを利用できます。", "お知らせ", "Info"));
        }
예제 #8
0
        public void OpenFile(OpeningFileSelectionMessage m)
        {
            if (m.Response == null)
            {
                Messenger.Raise(new InformationMessage("Cancel", "Error", MessageBoxImage.Error, "Info"));
                return;
            }

            m.Response.Select(f => { FileUris.Add(f); return(f); }).ToList();
        }
예제 #9
0
        public async void OpenFileDialogCallback(OpeningFileSelectionMessage message)
        {
            if (Util.IsNull(message.Response))
            {
                return;
            }

            var slnFile = message.Response.FirstOrDefault();
            await SolutionExplorerVM.ShowDataAsync(slnFile);
        }
예제 #10
0
        protected String[] OpenDialog(String title, String filter, bool multiSelect)
        {
            var message = new OpeningFileSelectionMessage("Open")
            {
                Title       = title,
                Filter      = filter,
                MultiSelect = multiSelect,
            };

            Messenger.Raise(message);
            return(message.Response);
        }
예제 #11
0
 public void Open(OpeningFileSelectionMessage m)
 {
     if (m.Response == null)
     {
         return;
     }
     if (!_model.LoadFile(m.Response[0]))
     {
         Messenger.Raise(new InformationMessage("無効なファイル", "Error",
                                                MessageBoxImage.Error, "Information"));
     }
 }
예제 #12
0
        public void OpenFileDialog()
        {
            var msg = new OpeningFileSelectionMessage("OpenFile");

            msg.Filter = "画像ファイル|*.jpg;*.jpeg;*.jpe;*.gif;*.png;*.bmp";
            msg.Title  = "背景画像を選択";
            string resp;

            if ((resp = this.Messenger.GetResponse(msg).Response) != null)
            {
                this.BackgroundImage = resp;
            }
        }
예제 #13
0
        public void FileSelected([NotNull] OpeningFileSelectionMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }


            string selectedPaths = message.Response == null
                ? "未選択"
                : String.Join(";", message.Response);

            OutputMessage = $"{DateTime.Now}: FileSelected: {selectedPaths}";
        }
예제 #14
0
 public async void AddMedia(OpeningFileSelectionMessage parameter)
 {
     await Task.Run(() =>
     {
         if (parameter.Response.Length == 0)
         {
             return;
         }
         Media     = File.Open(parameter.Response[0], FileMode.Open);
         MediaPath = parameter.Response[0];
         RaisePropertyChanged(() => HasMedia);
         RemoveMediaCommand.RaiseCanExecuteChanged();
     });
 }
예제 #15
0
        /// <summary>
        /// パラメータファイル読込
        /// </summary>
        /// <param name="parameter">パラメータ</param>
        public void OpenParamFile(OpeningFileSelectionMessage parameter)
        {
            if (parameter.Response == null || parameter.Response.Length < 1)
            {
                return;
            }

            try
            {
                _parameterFileManager.load(parameter.Response[0]);
            }
            catch (Exception e)
            {
                StatusBarMessage = e.Message;
            }
        }
예제 #16
0
        /// <summary>
        /// JSONファイルのインポート
        /// </summary>
        private async void ImportJson()
        {
            var message = new OpeningFileSelectionMessage("ImportJsonFileDialog")
            {
                Title  = Resources.ImportJsonFileDialogTitle,
                Filter = Resources.FileDialogJsonFilter,
            };

            var result = Messenger.GetResponse(message);

            var path = result?.Response?.FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(path))
            {
                await ConfigJsonService.ImportJsonAsync(path);
            }
        }
예제 #17
0
        private void SetImportData(OpeningFileSelectionMessage parameter)
        {
            if (parameter.Response == null || parameter.Response.Length == 0)
                return;

            bool ExistsError = this.CustomerListViewModel.SetImportData(parameter.Response[0]);

            if (ExistsError)
            {
                Messenger.Raise(new InformationMessage("インポートが完了しましたが、エラーが発生したためインポートできなかった行があります。\nOKをクリックすると詳細情報を表示します。",
                    "お知らせ", "Info"));
                System.Diagnostics.Process.Start("notepad.exe", "ErrorList.txt");
            }
            else
            {
                Messenger.Raise(new InformationMessage("インポート完了。", "お知らせ", "Info"));
            }
            //customerListViewModel.Initialize(orderController);
        }
예제 #18
0
        public void SelectBackgroundImage()
        {
            var msg = new OpeningFileSelectionMessage
            {
                Filter = "画像ファイル|*.png;*.jpg;*.jpeg;*.gif;*.bmp",
                Title  = "背景画像を選択"
            };

            if (!String.IsNullOrEmpty(BackgroundImagePath))
            {
                msg.FileName = BackgroundImagePath;
            }
            var resp = this.Messenger.GetResponse(msg);

            if (resp.Response != null && resp.Response.Length > 0)
            {
                BackgroundImagePath = resp.Response[0];
            }
        }
예제 #19
0
    public async Task LoadSetting_NullFilePath()
    {
        const string firstIgnoreExt = "firstignoreext";
        const string otherIgnoreExt = "otherignoreext";

        string settingContent = @"{""IgnoreExtensions"":[{""Value"":""" + firstIgnoreExt + @"""}]}";
        string settingContentOther = @"{""IgnoreExtensions"":[{""Value"":""" + otherIgnoreExt + @"""}]}";

        var mockFileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
        {
            [defaultSettingFilePath] = new MockFileData(settingContent),
            [otherSettingFilePath] = new MockFileData(settingContentOther),
        });

        var model = new MainModel(mockFileSystem, Scheduler.Immediate);
        var mainVM = new MainWindowViewModel(model);
        mainVM.Initialize();
        await model.WaitIdleUI().Timeout(3000d);
        await Task.Delay(100);

        //設定VMは設定読込時にリセットされるので、MainVMの設定プロパティからアクセスする
        //settingVM...

        //ステージ1 初期状態
        mainVM.SettingVM.Value.IgnoreExtensions.Select(x => x.Value)
                .Should().Contain(firstIgnoreExt, because: "起動時にファイルから設定値が読み込まれたはず");

        //ステージ2 読込後
        var fileMessage = new OpeningFileSelectionMessage() { Response = null };
        mainVM.SettingVM.Value.LoadSettingFileDialogCommand.Execute(fileMessage);

        mainVM.SettingVM.Value.IgnoreExtensions.Select(x => x.Value)
            .Should().Contain(firstIgnoreExt, because: "設定を読み込めていないので、元の設定値のままのはず");

        mainVM.SettingVM.Value.IgnoreExtensions.Select(x => x.Value)
            .Should().NotContain(otherIgnoreExt, because: "設定を読み込めていないので、ファイルから設定値が読み込まれていないはず");

        mainVM.SettingVM.Value.PreviousSettingFileDirectory.Value
            .Should().Be(Path.GetDirectoryName(defaultSettingFilePath), "設定を読み込めていないので、デフォルトファイルのディレクトリパスになっているはず");

        mainVM.SettingVM.Value.PreviousSettingFileName.Value
            .Should().Be(Path.GetFileName(defaultSettingFilePath), "設定を読み込めていないので、デフォルトファイル名前になっているはず");
    }
예제 #20
0
        /// <summary>
        /// 画像ファイルをシステムに登録します
        /// </summary>
        /// <param name="message"></param>
        public async void ImportRegisterImageFile(OpeningFileSelectionMessage message)
        {
            if (message.Response != null && message.Response.Count() > 0)
            {
                foreach (var filepath in message.Response)
                {
                    LOG.DebugFormat("選択したファイル情報 {0}", filepath);

                    /*
                     * using (var proxy = new HalcyonService.AlcedinesApiServiceClient())
                     * {
                     *      var artifacts = await proxy.AttachFileAsync(filepath, 1L);
                     *      foreach (var artifact in artifacts)
                     *      {
                     *              LOG.InfoFormat("登録したArtifact: ID={0}", artifact.Artifact.Id);
                     *      }
                     * }
                     */
                }
            }
        }
예제 #21
0
        public void FileImport()
        {
            var ofm = new OpeningFileSelectionMessage("OpenFile");

            ofm.Title  = "色設定ファイルを選択";
            ofm.Filter = "色設定ファイル|*.kcx";
            this.Messenger.Raise(ofm);
            if (ofm.Response != null)
            {
                try
                {
                    var data = XMLSerializer.LoadXML <ColoringProperty>(ofm.Response, true);
                    ApplyColoringProperty(data);
                }
                catch
                {
                    this.Messenger.Raise(new InformationMessage("ファイルを読み込めません。",
                                                                "色設定ファイルのロードエラー", System.Windows.MessageBoxImage.Error, "Message"));
                }
            }
        }
예제 #22
0
        /// <summary>
        /// OpenFileダイアログの表示
        /// </summary>
        private string[] ShowOpenFileDialog()
        {
            OpeningFileSelectionMessage msg = new OpeningFileSelectionMessage()
            {
                MessageKey = "OpenFile",
                // ダイアログのタイトル
                Title = "タイトル",
                // 複数選択の設定
                MultiSelect = true,
                // デフォルトで表示するファイル名
                FileName = "*.*",
                // デフォルトで表示するフォルダ
                InitialDirectory = @"C:\",
                // ファイル種類
                Filter = "全てのファイル(*.*)|*.*|テキストファイル(*.txt)|*.txt"
            };

            // 結果が必要な場合はGetResponse(非同期はGetResponseAsync)
            // 選択されたファイルはresult.Responseに文字列の配列で入る(キャンセル時はnull)
            return(Messenger.GetResponse(msg).Response);
        }
 public void FileSelected(OpeningFileSelectionMessage message)
 {
     OutputMessage.Value = $"{DateTime.Now}: FileSelected: {message.Response[0]}";
 }