Exemplo n.º 1
0
 public ActionResult MultipleSelect(Multiselect model)
 {
     try
     {
         return(View(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            var isSaveAs         = IsSaveAs.Get(context);
            var initialDirectory = InitialDirectory.Get(context);
            var title            = Title.Get(context);
            var defaultExt       = DefaultExt.Get(context);
            var filter           = Filter.Get(context);
            var filterIndex      = FilterIndex.Get(context);
            var checkFileExists  = CheckFileExists.Get(context);
            var checkPathExists  = CheckPathExists.Get(context);
            var multiselect      = Multiselect.Get(context);

            System.Windows.Forms.FileDialog dialog;
            if (isSaveAs)
            {
                dialog = new System.Windows.Forms.SaveFileDialog();
            }
            else
            {
                dialog = new System.Windows.Forms.OpenFileDialog();
                ((System.Windows.Forms.OpenFileDialog)dialog).Multiselect = multiselect;
            }
            if (!string.IsNullOrEmpty(title))
            {
                dialog.Title = title;
            }
            if (!string.IsNullOrEmpty(defaultExt))
            {
                dialog.DefaultExt = defaultExt;
            }
            if (!string.IsNullOrEmpty(filter))
            {
                dialog.Filter      = filter;
                dialog.FilterIndex = filterIndex;
            }
            dialog.CheckFileExists = checkFileExists;
            dialog.CheckPathExists = checkPathExists;


            System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.Cancel;
            GenericTools.RunUI(() =>
            {
                result = dialog.ShowDialog();
            });
            if (result != System.Windows.Forms.DialogResult.OK)
            {
                context.SetValue(FileName, null);
                context.SetValue(FileNames, null);
                return;
            }
            context.SetValue(FileName, dialog.FileName);
            context.SetValue(FileNames, dialog.FileNames);
        }
Exemplo n.º 3
0
        protected override void Execute(CodeActivityContext context)
        {
            var isSaveAs         = IsSaveAs.Get(context);
            var initialDirectory = InitialDirectory.Get(context);
            var title            = Title.Get(context);
            var defaultExt       = DefaultExt.Get(context);
            var filter           = Filter.Get(context);
            var filterIndex      = FilterIndex.Get(context);
            var checkFileExists  = CheckFileExists.Get(context);
            var checkPathExists  = CheckPathExists.Get(context);
            var multiselect      = Multiselect.Get(context);

            System.Windows.Forms.FileDialog dialog;
            if (isSaveAs)
            {
                dialog = new System.Windows.Forms.SaveFileDialog();
            }
            else
            {
                dialog = new System.Windows.Forms.OpenFileDialog();
                ((System.Windows.Forms.OpenFileDialog)dialog).Multiselect = multiselect;
            }
            if (!string.IsNullOrEmpty(title))
            {
                dialog.Title = title;
            }
            if (!string.IsNullOrEmpty(defaultExt))
            {
                dialog.DefaultExt = defaultExt;
            }
            if (!string.IsNullOrEmpty(filter))
            {
                dialog.Filter      = filter;
                dialog.FilterIndex = filterIndex;
            }
            try
            {
                if (!string.IsNullOrEmpty(initialDirectory) && !initialDirectory.Contains("\\"))
                {
                    Enum.TryParse(initialDirectory, out Environment.SpecialFolder specialfolder);
                    initialDirectory = Environment.GetFolderPath(specialfolder);
                }
            }
            catch (Exception)
            {
                throw;
            }
            if (!string.IsNullOrEmpty(initialDirectory))
            {
                dialog.InitialDirectory = initialDirectory;
            }
            dialog.CheckFileExists = checkFileExists;
            dialog.CheckPathExists = checkPathExists;


            System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.Cancel;
            GenericTools.RunUI(() =>
            {
                result = dialog.ShowDialog();
            });
            if (result != System.Windows.Forms.DialogResult.OK)
            {
                context.SetValue(FileName, null);
                context.SetValue(FileNames, null);
                return;
            }
            context.SetValue(FileName, dialog.FileName);
            context.SetValue(FileNames, dialog.FileNames);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Determines the appropriate form field class to use and then
        /// returns that to the caller.
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public IFormField GetFormField(String content)
        {
            IFormField field = null;
            String[] lines = content.Split(new String [] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

            StringBuilder markup = new StringBuilder();
            for (int i = 2; i < lines.Length; i++)
                markup.AppendLine(lines[i].Trim());

            //There will always be at least two lines, otherwise, the markup is invalid
            if (lines.Length >= 2)
            {
                String id = lines[0].Trim();
                String description = lines[1].Trim();

                //Determine if the field is required or not
                bool required = id.Contains("*");
                bool hidden = id.Contains("hidden");
                id = id.Replace("hidden", "");

                if (required)
                {
                    id = id.Replace("*", "");
                    description = description + " *";
                }
                id = id.Trim();

                if (id.Equals("::markup"))
                {
                    field = new GenericText(this.engine);
                }
                else
                {
                    if (lines.Length == 2)
                    {
                        if (lines[1].StartsWith("^"))
                            field = new Checkbox();
                        else
                            field = new Textbox();
                    }
                    else
                    {
                        if (lines[2].StartsWith("("))
                            field = new Textarea();
                        else if (lines[2].StartsWith("^"))
                            field = new Checkbox();
                        else if (lines[2].StartsWith("+"))
                            field = new Dropdown();
                        else if (lines[2].StartsWith("##"))
                            field = new Multiselect();
                        else if (lines[2].StartsWith("#"))
                            field = new Radiolist();
                    }
                }

                if (field != null)
                {
                    field.Id = String.Format("{0}_{1}", this.formId, id);
                    field.IsRequired = required;
                    field.IsHidden = hidden;
                    field.Description = description.Trim();
                    field.Markup = markup.ToString().Trim();
                }
            }

            return field;
        }