Exemplo n.º 1
0
        public ArgsEditor(BaseTaskArgs args)
        {
            InitializeComponent();

            bool firstRow = true;
            int  row      = 0;

            tpnlControls.SuspendLayout();

            var properties = TypeDescriptor.GetProperties(args);

            foreach (PropertyDescriptor prop in properties)
            {
                if (!firstRow)
                {
                    tpnlControls.RowCount++;
                    tpnlControls.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));
                }

                var editor = FactoryHelper.Create(args, prop);
                if (editor != null)
                {
                    editor.Dock   = DockStyle.Fill;
                    editor.Margin = new Padding(3);

                    tpnlControls.Controls.Add(CreateLabel(prop), 0, row);
                    tpnlControls.Controls.Add(editor, 1, row);

                    firstRow = false;
                    ++row;
                }
            }

            tpnlControls.ResumeLayout();
        }
Exemplo n.º 2
0
        public override bool CreateControl(BaseTaskArgs args, PropertyDescriptor property, out Control control)
        {
            control = null;

            var type = property.PropertyType;

            if (type.IsEnum)
            {
                var converter = TypeDescriptor.GetConverter(type);
                var comboBox  = new ComboBox();

                comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
                comboBox.DataSource    = Enum.GetValues(type)
                                         .Cast <object>()
                                         .Select(v => new { Display = converter.ConvertToString(v), Value = v })
                                         .ToList();
                comboBox.DisplayMember = "Display";
                comboBox.ValueMember   = "Value";
                comboBox.DataBindings.Add("SelectedValue", args, property.Name, true, DataSourceUpdateMode.OnPropertyChanged);

                control = comboBox;
            }

            return(control != null);
        }
Exemplo n.º 3
0
        public override bool CreateControl(BaseTaskArgs args, PropertyDescriptor property, out Control control)
        {
            control = null;

            var type = property.PropertyType;

            if (sNumericTypes.Contains(type))
            {
                var numValue = new NumericUpDown();
                numValue.DataBindings.Add("Value", args, property.Name);

                var range = property.Attributes
                            .Cast <Attribute>()
                            .OfType <RangeAttribute>()
                            .SingleOrDefault();

                if (range != null)
                {
                    numValue.Minimum = range.Minimum;
                    numValue.Maximum = range.Maximum;
                }

                control = numValue;
            }

            return(control != null);
        }
Exemplo n.º 4
0
 public BaseFFmpegTask()
 {
     mRunCommand            = new DelegateCommand(DoRun, CanRun);
     mDisplayName           = GetType().Name;
     mArgs                  = CreateArgs();
     mArgs.PropertyChanged += mArgs_PropertyChanged;
 }
Exemplo n.º 5
0
        public override bool CreateControl(BaseTaskArgs args, PropertyDescriptor property, out Control control)
        {
            control = null;

            if (property.PropertyType == typeof(FileInfo))
            {
                control = new FileInfoEditor(args, property);
            }

            return(control != null);
        }
Exemplo n.º 6
0
        public static Control Create(BaseTaskArgs args, PropertyDescriptor property)
        {
            Control control = null;

            foreach (var factory in mFactories)
            {
                if (factory.CreateControl(args, property, out control))
                {
                    break;
                }
            }

            return(control);
        }
Exemplo n.º 7
0
        public FileInfoEditor(BaseTaskArgs args, PropertyDescriptor property)
        {
            mArgs     = args;
            mProperty = property;

            InitializeComponent();
            mArgs.PropertyChanged += mArgs_PropertyChanged;

            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFileDialog1.Filter           = string.Format("Supported formats | {0}", ffmpeg.GetFormatFilter());

            ReadPropertyValue();

            btnBrowse.Click     += btnBrowse_Click;
            txtPath.TextChanged += txtPath_TextChanged;
        }
Exemplo n.º 8
0
 public abstract bool CreateControl(BaseTaskArgs args, PropertyDescriptor property, out Control control);