Esempio n. 1
0
        public static void PickFile(ModelItem modelItem, string filter, string modelItemPropertyName, bool convertToRelativePath = true)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Filter = filter;
            var result = openFileDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                var newExpression = new Microsoft.VisualBasic.Activities.VisualBasicValue <string>("\"" + openFileDialog.FileName + "\"");
                if (convertToRelativePath)
                {
                    newExpression.ExpressionText = DesignerHelper.ConvertFullPathToRelativePathExpressionText(newExpression.ExpressionText);
                }
                var newValue = new InArgument <string>(newExpression);
                modelItem.Properties[modelItemPropertyName].SetValue(newValue);
            }
        }
Esempio n. 2
0
        public static void PickFolder(ModelItem modelItem, string modelItemPropertyName, bool convertToRelativePath = true)
        {
            FolderBrowserDialog browseFolderDialog = new FolderBrowserDialog();

            browseFolderDialog.ShowNewFolderButton = false;
            var result = browseFolderDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                var newExpression = new Microsoft.VisualBasic.Activities.VisualBasicValue <string>("\"" + browseFolderDialog.SelectedPath + "\"");
                if (convertToRelativePath)
                {
                    newExpression.ExpressionText = DesignerHelper.ConvertFullPathToRelativePathExpressionText(newExpression.ExpressionText);
                }
                var newValue = new InArgument <string>(newExpression);
                modelItem.Properties[modelItemPropertyName].SetValue(newValue);
            }
        }