private void ZipDesigner_Loaded(object sender, System.Windows.RoutedEventArgs e) { var encoding = ModelItem.Properties[nameof(Zip.TextEncoding)]; if (encoding.Value == null) { encoding.SetValue(new InArgument <Encoding>(ExpressionServiceLanguage.CreateExpression <Encoding>(ModelItem, $"{typeof(Encoding).FullName}.{nameof(Encoding.UTF8)}"))); } }
private void LoadButton_Click(object sender, RoutedEventArgs e) { var ofd = new OpenFileDialog { Multiselect = Multiselect }; if (string.IsNullOrEmpty(Filter)) { ofd.Filter = "All files (*.*)|*.*"; } else { ofd.Filter = Filter; } if (string.IsNullOrWhiteSpace(Title)) { Title = "Select file(s)"; } ofd.Title = Title; ofd.InitialDirectory = Directory.GetCurrentDirectory(); if (CheckFileExists.HasValue) { ofd.CheckFileExists = CheckFileExists.Value; } if (CheckPathExists.HasValue) { ofd.CheckPathExists = CheckPathExists.Value; } if (ValidateNames.HasValue) { ofd.ValidateNames = ValidateNames.Value; } if (ofd.ShowDialog() == true) { var baseUri = new Uri(ofd.InitialDirectory); var files = ofd.FileNames; if (files.Length == 1) { ModelItem.Properties[PropertyName].SetValue(InArgument <string> .FromValue(IOUtil.GetRelativePath(ofd.InitialDirectory, files[0]))); return; } var paths = string.Join(", ", files.Select(path => $"\"{IOUtil.GetRelativePath(ofd.InitialDirectory, path)}\"")); var code = ExpressionServiceLanguage.CreateExpression <IEnumerable <string> >(ModelItem, $"{{{paths}}}", $"new [] {{{paths}}}"); ModelItem.Properties[PropertyName].SetValue(new InArgument <IEnumerable <string> >(code)); } }