示例#1
0
 protected void OnControlChange(ValueControl control, Direction direction)
 {
     if (ControlChange != null)
     {
         ControlChange(control, direction);
     }
 }
        private void                spinEdit_Length_EditValueChanged(object aSender, EventArgs aEventArgs)
        {
            int lNewLength  = (int)spinEdit_Length.Value;
            int lCurrLength = tabControl_Value.TabCount;

            if (lNewLength != lCurrLength)
            {
                TabPage lTabPage;
                if (lNewLength > lCurrLength)
                {
                    ValueControl lValueControl;
                    Type         lType = Type;
                    int          lAdd  = lNewLength - lCurrLength;
                    for (int i = 0; i < lAdd; i++)
                    {
                        lValueControl = new ValueControl();
                        lValueControl.setType(lType);
                        lValueControl.Left = tabControl_Value.Width / 2 - lValueControl.Width / 2;
                        lTabPage           = new TabPage(StringUtils.ObjectToString(lCurrLength + i));
                        lTabPage.Controls.Add(lValueControl);
                        tabControl_Value.TabPages.Add(lTabPage);
                    }
                }
                else
                {
                    while (tabControl_Value.TabCount != lNewLength)
                    {
                        lTabPage = tabControl_Value.TabPages[tabControl_Value.TabCount - 1];
                        tabControl_Value.TabPages.Remove(lTabPage);
                        lTabPage.Controls[0].Dispose();
                        lTabPage.Dispose();
                    }
                }
            }
        }
示例#3
0
 public void ShowControlValue(ValueControl control)
 {
     if (_outputDevice != null)
     {
         var value = GetControlValue(control);
         _outputDevice.SendControlChange(_deviceChannel, (Control)control, value);
     }
 }
        public ValueControlVisualizer(IVoxelHandle handle, Func <int> getValue, Action <int> setValue, Matrix local)
        {
            this.getValue = getValue;
            this.setValue = setValue;
            this.local    = local;
            ValueControl  = new ValueControl();

            voxel = handle.GetInternalVoxel();
        }
示例#5
0
    //public bool multiply = false;
    //private int m;

    void Start()
    {
        v                     = GetComponent <ValueControl> ();
        activepulse           = new bool[_pulselength];
        pulse                 = new float[_pulselength];
        origin                = new Vector4[_pulselength];
        travel                = new float[_pulselength];
        width                 = new float[_pulselength];
        _cam.depthTextureMode = DepthTextureMode.Depth;
    }
示例#6
0
        /// <summary>
        /// The QuickRead static method is used to read values from the console.
        /// </summary>
        private static void RunExample()
        {
            string firstName = ValueControl <string> .QuickRead("First Name:");

            string lastName = ValueControl <string> .QuickRead("Last Name:");

            // Display the read values.
            CustomConsole.WriteLine();
            CustomConsole.WriteLine("Hi, {0} {1}!", firstName, lastName);
        }
示例#7
0
 public int GetControlValue(ValueControl control)
 {
     if (_controlValues.ContainsKey(control))
     {
         return(_controlValues[control]);
     }
     else
     {
         return(0);
     }
 }
示例#8
0
        private void AddValueControl(CalibrItem calibr)
        {
            var value = new ValueControl();

            value.SetValue(calibr);
            valueControls.Add(calibr.Name, value);
            value.Dock = DockStyle.Top;
            valuesPanel.Controls.Add(value);
            value.BringToFront();
            PlaceValueControl();
        }
示例#9
0
 private void tracker_ValueChanged(ValueControl sender, ValueChangedEventArgs e)
 {
     _zoom            = ScaleFactor.CommonZooms[sender.Value];
     this.ToolTipText = _zoom.ToString();
     this.Invalidate();
     //
     if (ZoomChanged != null)
     {
         ZoomChanged(this, new EventArgs());
     }
 }
示例#10
0
 public void SetControlValue(ValueControl control, int value)
 {
     if (value < 0)
     {
         value = 0;
     }
     if (value > 15)
     {
         value = 15;
     }
     _controlValues[control] = value;
 }
示例#11
0
        /// <summary>
        /// Releases all resource used by the FormField object.
        /// <para xml:lang="es">Libera todos los recursos utilizados por el objeto de campo de formulario.</para>
        /// </summary>
        /// <remarks>Call Dispose when you are finished using the FormField.
        /// The Dispose method leaves the FormField in an unusable
        /// state. After calling Dispose, you must release all references to the
        /// FormField so the garbage collector can reclaim the memory that the
        /// FormField was occupying.
        /// <para xml:lang="es">
        /// Llame a Dispose cuando termine de usar el FormField.
        /// El método Dispose deja el FormField en un estado inutilizable.
        /// Después de llamar a Dispose, debe liberar todas las referencias al
        /// FormField por lo que el recolector de basura puede reclamar la memoria que el
        /// FormField ocupaba.
        /// </para>
        /// </remarks>
        public void Dispose()
        {
            if (CaptionControl != null)
            {
                CaptionControl.Dispose();
            }

            if (ValueControl != null)
            {
                ValueControl.Dispose();
            }
        }
        /// <summary>
        /// This example creates instances for each input value and sets different label colors.
        /// Each instance reads a different type of value (string, int, DateTime, float)
        /// </summary>
        private static void RunExample()
        {
            // Create the input controls
            ValueControl <int> ageControl = new ValueControl <int>("Age:");

            ageControl.Label.ForegroundColor = ConsoleColor.DarkGreen;

            // Read values using the input controls
            int age = ageControl.Read();

            // Display th read values.
            CustomConsole.WriteLine();
            CustomConsole.WriteLine("You are {0} years old.", age);
        }
示例#13
0
        private void dataTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Check
            if (dataTypeComboBox.SelectedItem is DataType)
            {
                //Get Data Type
                dataType = (DataType)dataTypeComboBox.SelectedItem;

                //Get Bit Count
                int bitCount   = data.Length * 8;
                int dataLength = dataType.Length * 8;

                //Begin
                containerPanel.SuspendLayout();

                //Clear Panel
                containerPanel.Controls.Clear();

                //Clear Dictionary
                foreach (var control in controls)
                {
                    control.Value.Dispose();
                }
                controls.Clear();

                //Create
                using (MemoryStream ms = new MemoryStream(data))
                    using (BinaryReader reader = new BinaryReader(ms))
                        for (int i = 0; i < bitCount; i += dataLength)
                        {
                            //Get Offset
                            int offset = i / 8;

                            //Prepare
                            ValueControl valueControl = new ValueControl();
                            valueControl.Address      = offset;
                            valueControl.Type         = dataType.Name;
                            valueControl.ControlName  = $"{dataType.Name} 0x{offset:X}";
                            valueControl.Value        = dataType.Read(reader).ToString();
                            valueControl.ValueChanged = valueControl_ValueChanged;

                            //Add
                            controls.Add(offset, valueControl);
                            containerPanel.Controls.Add(valueControl);
                        }

                //End
                containerPanel.ResumeLayout();
            }
        }
        public void Execute()
        {
            StringValue.QuickWrite("First Name:", "John");
            StringValue.QuickWrite("Last Name:", "Doe");
            Int32Value.QuickWrite("Age:", 25);

            // or

            ValueControl <string> .QuickWrite("First Name:", "John");

            ValueControl <string> .QuickWrite("Last Name:", "Doe");

            ValueControl <int> .QuickWrite("Age:", 25);
        }
示例#15
0
 protected override void DataValidating(object sender, CancelEventArgs e)
 {
     if (Validation(sender) < 1)
     {
         IsValidation = false;
         ValueControl.CancelPopup();
         ValueControl.ClosePopup();
         e.Cancel = false;  //焦点不能离开
     }
     else
     {
         IsValidation = true;
         e.Cancel     = false;
     }
 }
        private static void RunExample()
        {
            ValueControl <int> numberControl = new ValueControl <int>("Number ({0}):");

            numberControl.AcceptDefaultValue = true;
            numberControl.DefaultValue       = 42;

            CustomConsole.WriteLine("Just hit enter. The default value, 42, is returned by the ValueControl control.");
            CustomConsole.WriteLine();

            int number = numberControl.Read();

            CustomConsole.WriteLine();
            CustomConsole.WriteLine("You selected {0}.", number);
        }
        /// <summary>
        /// This example creates instances for each input value and sets different label colors.
        /// Each instance reads a different type of value (string, int, DateTime, float)
        /// </summary>
        private static void RunExample()
        {
            // Create the input controls

            ValueControl <string> firstNameControl = new ValueControl <string>("First Name:");

            firstNameControl.Label.ForegroundColor = ConsoleColor.Cyan;

            ValueControl <string> lastNameControl = new ValueControl <string>("Last Name:");

            lastNameControl.Label.ForegroundColor = ConsoleColor.Cyan;

            // Read values using the input controls
            string firstName = firstNameControl.Read();
            string lastName  = lastNameControl.Read();

            // Display the read values.
            CustomConsole.WriteLine();
            CustomConsole.WriteLine("Hi, {0} {1}!", firstName, lastName);
        }
        //active color point location
        private void vColorLoc_ValueChanged(ValueControl sender, ValueChangedEventArgs e)
        {
            if (edit.Gradient == null)
            {
                return;
            }
            ColorPoint pt = edit.Selection as ColorPoint;

            if (pt == null)
            {
                return;
            }
            if (edit.FocusSelection)
            {
                pt.Focus = (double)vColorLoc.Value / 100.0;
            }
            else
            {
                pt.Position = (double)vColorLoc.Value / 100.0;
            }
        }
示例#19
0
 /// <summary>
 ///
 /// </summary>
 public override void Compute()
 {
     if (Convert.ToDouble(powerlever.Value) > (Convert.ToDouble(powerlever.Min) + (Convert.ToDouble(powerlever.Max) - Convert.ToDouble(powerlever.Min)) / 2))
     {
         //Wenn über der Mittelstellung
         brakes.Value = ValueControl.TransformToRange(powerlever, brakes);
         if (Convert.ToDouble(throttle.Value) != 0)
         {
             throttle.Value = 0;
         }
     }
     else
     {
         //Wenn unter der Mittelstellung
         throttle.Value = ValueControl.TransformToRange(powerlever, throttle);
         if (Convert.ToDouble(brakes.Value) != 0)
         {
             brakes.Value = 0;
         }
     }
 }
示例#20
0
        public void TestValueControl()
        {
            var engine  = EngineFactory.CreateEngine();
            var control = new ValueControl();

            engine.AddSimulator(new BasicSimulator(() =>
            {
                if (TW.Graphics.Mouse.LeftMouseJustPressed)
                {
                    control.TryLeftClick(TW.Data.Get <CameraInfo>().GetCenterScreenRay());
                }
                else if (TW.Graphics.Mouse.RightMouseJustPressed)
                {
                    control.TryRightClick(TW.Data.Get <CameraInfo>().GetCenterScreenRay());
                }

                control.Update();
            }));
            engine.AddSimulator(new WorldRenderingSimulator());

            control.Show();
        }
示例#21
0
 public MessSendControl(ActionType action, MarketType market, Order order = null, string api_guid = null) : base(MessType.UserControl, ProcType.SendControl)
 {
     Value = new ValueControl(action, market, order, api_guid);
 }
示例#22
0
 // Start is called before the first frame update
 public void GameStart()
 {
     gameOver         = false;
     callLoopInterval = resetCallLoopInterval;
     valueControl     = quilt.GetComponent <ValueControl>();
 }
示例#23
0
        private Dictionary <string, bool> IsValid()
        {
            if (!(FindForm() is FBase))
            {
                return(new Dictionary <string, bool>());
            }
            if (!(GetSForm().StateForm == StateForm.Inserting || GetSForm().StateForm == StateForm.Editing))
            {
                return(new Dictionary <string, bool>());
            }
            try
            {
                if (Name == string.Empty)
                {
                    return(new Dictionary <string, bool>());
                }
                Validations = new Dictionary <string, bool>();

                if (GetSForm() == null)
                {
                    RemoveErrorProvider();
                    return(new Dictionary <string, bool>());
                }
                if (PropertyControl == null)
                {
                    return(new Dictionary <string, bool>());
                }
                var validationAttributes = GetAttribute();
                var reflection           = new SReflection();
                foreach (var attribute in validationAttributes)
                {
                    try
                    {
                        var validationAttribute = attribute as ValidationAttribute;
                        if (validationAttribute == null)
                        {
                            continue;
                        }
                        bool isValid;

                        var operatorValue = GetAttribute <OperationValue>(PropertyControl);
                        if (operatorValue != null)
                        {
                            decimal result     = 0;
                            var     component1 =
                                GetSForm()
                                .GetListControls()
                                .FirstOrDefault(c => c.Name == operatorValue.PropertyOperationName);
                            var componentTotal =
                                GetSForm()
                                .GetListControls()
                                .FirstOrDefault(c => c.Name == operatorValue.PropertyResultName);
                            if (component1 != null)
                            {
                                if (componentTotal != null)
                                {
                                    switch (operatorValue.TypeOperation)
                                    {
                                    case TypeOperation.Division:
                                        if ((decimal)ValueControl != 0)
                                        {
                                            result = (decimal)component1.ValueControl / (decimal)ValueControl;
                                        }
                                        break;

                                    case TypeOperation.Multiplication:
                                        result = (decimal)ValueControl * (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.Sum:
                                        result = (decimal)ValueControl + (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.Subtraction:
                                        result = (decimal)component1.ValueControl - (decimal)ValueControl;
                                        break;

                                    case TypeOperation.SubtractionInversion:
                                        result = (decimal)ValueControl - (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.SubtractionPorcent:
                                        result = (decimal)component1.ValueControl - (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    case TypeOperation.AditionalPorcent:
                                        result = (decimal)component1.ValueControl + (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    case TypeOperation.PorcentValue:
                                        result = (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    default:
                                        result = 0;
                                        break;
                                    }
                                }
                            }
                            componentTotal.Disable      = false;
                            componentTotal.ValueControl = result;
                        }

                        if (validationAttribute is LockedTrueValue)
                        {
                            var lockedTrueValue = validationAttribute as LockedTrueValue;
                            var valid           = false;
                            if (lockedTrueValue.UniqueValue)
                            {
                                valid = lockedTrueValue.Value[0].ToString() != ValueControl.ToString();
                            }
                            for (var i = 0; i < lockedTrueValue.PropertyName.Count(); i++)
                            {
                                if (!lockedTrueValue.UniqueValue)
                                {
                                    valid = lockedTrueValue.Value[i]?.ToString() != PropertyControl?.GetValue(GetSForm()?.CurrentControl)?.ToString();
                                }

                                var component = GetSForm().GetListControls().FirstOrDefault(c => c.Name == lockedTrueValue.PropertyName[i]);
                                component.Disable = valid;
                                if (!valid)
                                {
                                    component.Clear();
                                }
                            }
                        }

                        if (validationAttribute is CompareAttribute)
                        {
                            var otherName     = validationAttribute.GetType().GetProperty("OtherProperty").GetValue(validationAttribute).ToString();
                            var otherProperty = CurrentControl.GetType().GetProperty(otherName);
                            var otherValue    = otherProperty.GetValue(CurrentControl);
                            isValid = otherValue?.ToString() == ValueControl.ToString();
                        }
                        else
                        {
                            if (this is SComboBox)
                            {
                                isValid = !ValueControl.ToString().Equals("0");
                            }
                            else
                            {
                                isValid = validationAttribute.IsValid(ValueControl);
                            }
                        }
                        var key = validationAttribute.FormatErrorMessage(DisplayName(PropertyControl));
                        if (!isValid && !Validations.ContainsKey(key))
                        {
                            Validations.Add(key, false);
                        }

                        var compoundIndex = GetSForm().GetAttribute <CompoundIndex>();
                        var unique        = attribute as Unique;

                        if ((compoundIndex != null && compoundIndex.Properties.Contains(Name)) || unique != null)
                        {
                            var typeValue = ValueControl as string;
                            if (!(typeValue != null && ReferenceEquals(ValueControl, string.Empty)))
                            {
                                // Pego o tipo do contexto.
                                var typeDataSource = GetSForm().InvokeMethod.TypeModel;

                                // Para garantia de Lista anonima (generica), pesquisa pela propriedade Id,
                                // chave primária do objeto.
                                var property = PropertyControl;

                                // Pego o valor da propriedade do objeto atual.
                                var value = ValueControl;

                                // se o tipo do objeto já foi informado para mesmo contexto, não é passado mais.
                                var parameterType = Expression.Parameter(typeDataSource);

                                // passa o tipo da propriedade
                                var prop = Expression.Property(parameterType, property);
                                // converte o tipo do dado, para garantir a identidade do mesmo.
                                var convertedValue = reflection.ChangeType(value, property.PropertyType);
                                // cria expressao do valor que será passada na expressão.
                                var soap = Expression.Constant(convertedValue);
                                // relaciona a propriedade com o dado. Exemplo: param0 => param0 == 1
                                var equal = Expression.Equal(prop, soap);

                                Expression expressionCompound = null;
                                // Se acaso for index composto adiciona mais uma expressão
                                if (compoundIndex != null && compoundIndex.Properties.Contains(Name))
                                {
                                    // Pesquiso  as outras propriedades que fazem parte da composição.
                                    var properties = compoundIndex.Properties.Where(c => c != Name);

                                    expressionCompound = (from index in properties select typeDataSource.GetProperty(index) into propertyCompoundId let propCompoundId = Expression.Property(parameterType, propertyCompoundId) let convertedValueCompoundId = reflection.ChangeType(propertyCompoundId.GetValue(GetSForm().CurrentControl), propertyCompoundId.PropertyType) let soapCompoundId = Expression.Constant(convertedValueCompoundId) select Expression.Equal(propCompoundId, soapCompoundId)).Aggregate(expressionCompound, (current, equalCompoundId) => current == null ? equalCompoundId : Expression.And(equalCompoundId, current));
                                }

                                if (expressionCompound != null)
                                {
                                    equal = Expression.And(equal, expressionCompound);
                                }

                                var propertyId = typeDataSource.GetProperty("Id");
                                // passa o tipo da propriedade
                                var propId = Expression.Property(parameterType, propertyId);
                                // converte o tipo do dado, para garantir a identidade do mesmo.
                                var convertedValueId = Convert.ChangeType(propertyId.GetValue(GetSForm().CurrentControl), propertyId.PropertyType);
                                // cria expressao do valor que será passada na expressão.
                                var soapId = Expression.Constant(convertedValueId);
                                // relaciona a propriedade com o dado. Exemplo: param0 => param0 == 1
                                var equalId = Expression.NotEqual(propId, soapId);

                                var yourExpression = Expression.And(equal, equalId);

                                var delegateType = typeof(Func <,>).MakeGenericType(typeDataSource, typeof(bool));
                                var expression   = Expression.Lambda(delegateType, yourExpression, true, parameterType);
                                var objetoApp    = GetSForm().InvokeMethod;
                                var method       = objetoApp.Methods.FirstOrDefault(c => c.Key == TypeExecute.Search).Value;
                                if (string.IsNullOrEmpty(method))
                                {
                                    MessageBox.Show("Método Search não configurado\nController: " + objetoApp.TypeController.Name,
                                                    "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                }
                                var result = reflection.GetListContext(objetoApp.TypeController, method, expression);

                                var components = GetSForm().GetListControls().Where(c =>
                                {
                                    if (compoundIndex == null)
                                    {
                                        return(false);
                                    }
                                    foreach (var s in compoundIndex.Properties)
                                    {
                                        if (Equals(s, c.Name))
                                        {
                                            break;
                                        }
                                    }
                                    return(false);
                                });

                                if (result.Any())
                                {
                                    if (compoundIndex != null && compoundIndex.Properties.Contains(Name))
                                    {
                                        var enumerable      = components as IList <IComponent> ?? components.ToList();
                                        var componentValues = enumerable.Aggregate("", (current, component) => current + component.Caption + " = " + component.ValueControl + " ");
                                        foreach (var component in enumerable)
                                        {
                                            component.SetError("Já existem dados com " + componentValues);
                                            component.ComponentBackColor = Color.FromArgb(255, 255, 173, 178);
                                        }
                                        Validations.Add("Já existem dados com " + (componentValues == "" ? " este registro" : componentValues), false);
                                    }
                                    else
                                    {
                                        Validations.Add("Este " + GetTextLabel() + " já existe, considere em informar outro", false);
                                    }
                                }
                                else
                                {
                                    foreach (var component in components)
                                    {
                                        if (!component.Validations.Values.Contains(false))
                                        {
                                            component.RemoveErrorProvider();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    SComponent.BackColor = Validations.Values.Contains(false) ? Color.FromArgb(255, 255, 173, 178) : Color.White;
                }
                return(Validations);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
示例#24
0
        /// <summary>
        /// 布局Group内的控件
        /// </summary>
        private void LayoutOwnControl()
        {
            List <KeyValuePair <int, ValueControl> > ctrList = new List <KeyValuePair <int, ValueControl> >();

            ///将PropertyInfo属性,属性的定制特性(Attribute)传递给ValueControl,
            ///创建好控件后,按照定制属性中的SubControlIndex存储入List
            foreach (AutoAttributeData autoAttData in _itemList.AutoAttributeDatas)
            {
                ValueControl ctr = OwnerAutoPanel.CreateValueControl(autoAttData, this);
                ctrList.Add(new KeyValuePair <int, ValueControl>(autoAttData.Attribute.MainControlIndex, ctr));
            }

            ///使用List.Sort方法对List中的Item进行排序
            ctrList.Sort(AutoLayoutPanelCtrPairComparer.CreateComparer());

            int height = 1;
            int width  = 0;
            int beginX = 1;

            ///如果使用系统自带的GroupBox样式
            ///1. 计算宽度与高度,2. 无论用户如何设IsGroupPaintBorder,都不画边框
            if (_autoAttribute.GroupBoxUseWinStyle)
            {
                height       = 13;
                width        = 2;
                beginX       = 2;
                _PaintBorder = false;
            }

            ///如果Group有标志图片
            #region
            if (_autoAttribute.GroupBoxMainImage != null)
            {
                width  = 6 + 36 + 6;
                beginX = 6 + 36 + 6;
                PictureBox picBox = new PictureBox();
                picBox.Size     = new Size(36, 36);
                picBox.Location = new Point(6, 6);
                picBox.Image    = Image.FromFile(//TODO:路径需调用软件Service
                    Path.Combine(Application.StartupPath, _autoAttribute.GroupBoxMainImage));
                this.Controls.Add(picBox);
            }
            #endregion

            foreach (KeyValuePair <int, ValueControl> pair in ctrList)
            {
                ValueControl ctr = pair.Value;
                OwnerAutoPanel.ValueControls.Add(ctr);

                ctr.Location = new Point(beginX, height);
                height       = height + ctr.Height;

                ///根据是否用GroupBox样式的需求:
                ///true使用System.GroupBox再封装一层
                if (_isGroupBox)
                {
                    _innerGroupBox.Controls.Add(ctr);
                }
                else
                {
                    this.Controls.Add(ctr);
                }

                ///如果控件的索引是List的第1个时,给width赋值
                if (ctrList.IndexOf(pair) == 0)
                {
                    width = width + ctr.Width;
                }

                ///如果当前控件的宽度比width大时
                if (ctr.Width > width)
                {
                    width = ctr.Width;
                }
            }//foreach

            ///判断是否使用GroupBox样式,来生成this的大小
            if (_autoAttribute.GroupBoxUseWinStyle && _innerGroupBox != null)
            {
                if (_autoAttribute.ColumnCountOfGroupControl != 1)
                {
                    ReLayOutControl(width);
                    this.Controls.Add(_innerGroupBox);
                    this.Size = new Size(_innerGroupBox.Width + 4, _innerGroupBox.Height);
                }
                else
                {
                    _innerGroupBox.Size = new Size(width + 2, height + 8);
                    this.Controls.Add(_innerGroupBox);
                    this.Size = new Size(width + 4, height + 10);
                }
            }
            else
            {
                this.Size = new Size(width + 2, height + 5);
            }
        }
示例#25
0
        public static void GenerateControls(FlowLayoutPanel panel, Block block)
        {
            //Suspend
            panel.SuspendLayout();

            //Loop
            foreach (Field field in block.Fields)
            {
                //Prepare
                Control control = null;

                //Handle
                switch (field.Type)
                {
                case FieldType.FieldExplanation: control = new ExplanationControl((ExplanationField)field); break;

                case FieldType.FieldBlock: control = new BlockControl((BlockField)field); break;

                case FieldType.FieldStruct: control = new StructControl((StructField)field); break;

                case FieldType.FieldString:
                case FieldType.FieldLongString:
                    control = new StringControl(field);
                    break;

                case FieldType.FieldTagReference:
                    control = new TagReferenceControl(field);
                    break;

                case FieldType.FieldStringId:
                case FieldType.FieldOldStringId:
                    control = new StringIdControl(field);
                    break;

                case FieldType.FieldCharInteger:
                case FieldType.FieldShortInteger:
                case FieldType.FieldLongInteger:
                case FieldType.FieldAngle:
                case FieldType.FieldTag:
                case FieldType.FieldReal:
                case FieldType.FieldRealFraction:
                    control = new ValueControl(field);
                    break;

                case FieldType.FieldCharEnum:
                case FieldType.FieldEnum:
                case FieldType.FieldLongEnum:
                    control = new EnumControl(field);
                    break;

                case FieldType.FieldLongFlags:
                    control = new FlagsControl()
                    {
                        Field        = field,
                        Title        = field.Name,
                        Information  = field.Information,
                        Options      = ((LongFlagsField)field).Options.Select(o => o.Name).ToArray(),
                        Details      = field.Details,
                        Value        = field.Value,
                        ValueChanged = FlagsControl_ValueChanged
                    };
                    break;

                case FieldType.FieldWordFlags:
                    control = new FlagsControl()
                    {
                        Field        = field,
                        Title        = field.Name,
                        Information  = field.Information,
                        Options      = ((WordFlagsField)field).Options.Select(o => o.Name).ToArray(),
                        Details      = field.Details,
                        Value        = field.Value,
                        ValueChanged = FlagsControl_ValueChanged
                    };
                    break;

                case FieldType.FieldByteFlags:
                    control = new FlagsControl()
                    {
                        Field        = field,
                        Title        = field.Name,
                        Information  = field.Information,
                        Options      = ((ByteFlagsField)field).Options.Select(o => o.Name).ToArray(),
                        Details      = field.Details,
                        Value        = field.Value,
                        ValueChanged = FlagsControl_ValueChanged
                    };
                    break;

                case FieldType.FieldShortBounds:
                    control = new RangeControl()
                    {
                        Field      = field,
                        Title      = field.Name,
                        RangeValue = new string[] { ((ShortBounds)field.Value).Min.ToString(), ((ShortBounds)field.Value).Max.ToString() }
                    };
                    break;

                case FieldType.FieldAngleBounds:
                case FieldType.FieldRealBounds:
                case FieldType.FieldRealFractionBounds:
                    control = new RangeControl()
                    {
                        Field      = field,
                        Title      = field.Name,
                        RangeValue = new string[] { ((FloatBounds)field.Value).Min.ToString(), ((FloatBounds)field.Value).Max.ToString() }
                    };
                    break;

                case FieldType.FieldPoint2D:
                    control = new TwoTupleControl()
                    {
                        LabelA     = "x",
                        LabelB     = "y",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Point2)field.Value).X.ToString(), ((Point2)field.Value).Y.ToString() }
                    };
                    break;

                case FieldType.FieldRealPoint2D:
                    control = new TwoTupleControl()
                    {
                        LabelA     = "x",
                        LabelB     = "y",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Point2F)field.Value).X.ToString(), ((Point2F)field.Value).Y.ToString() }
                    };
                    break;

                case FieldType.FieldRealPoint3D:
                    control = new ThreeTupleControl()
                    {
                        LabelA     = "x",
                        LabelB     = "y",
                        LabelC     = "z",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Point3F)field.Value).X.ToString(), ((Point3F)field.Value).Y.ToString(), ((Point3F)field.Value).Z.ToString() }
                    };
                    break;

                case FieldType.FieldRealVector2D:
                    control = new TwoTupleControl()
                    {
                        LabelA     = "i",
                        LabelB     = "j",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Vector2)field.Value).I.ToString(), ((Vector2)field.Value).J.ToString() }
                    };
                    break;

                case FieldType.FieldRealVector3D:
                    control = new ThreeTupleControl()
                    {
                        LabelA     = "i",
                        LabelB     = "j",
                        LabelC     = "k",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Vector3)field.Value).I.ToString(), ((Vector3)field.Value).J.ToString(), ((Vector3)field.Value).K.ToString() }
                    };
                    break;


                case FieldType.FieldRectangle2D:
                    control = new FourTupleControl()
                    {
                        LabelA     = "t",
                        LabelB     = "l",
                        LabelC     = "r",
                        LabelD     = "b",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Rectangle2)field.Value).Top.ToString(), ((Rectangle2)field.Value).Left.ToString(),
                                                    ((Rectangle2)field.Value).Right.ToString(), ((Rectangle2)field.Value).Bottom.ToString() }
                    };
                    break;

                case FieldType.FieldRgbColor:
                    control = new ThreeTupleControl()
                    {
                        LabelA = "r",
                        LabelB = "g",
                        LabelC = "b",
                        Field  = field,
                        Title  = field.Name,
                    };
                    break;

                case FieldType.FieldArgbColor:
                    control = new FourTupleControl()
                    {
                        LabelA = "a",
                        LabelB = "r",
                        LabelC = "g",
                        LabelD = "b",
                        Field  = field,
                        Title  = field.Name,
                    };
                    break;

                case FieldType.FieldRealRgbColor:
                    control = new ThreeTupleControl()
                    {
                        LabelA = "r",
                        LabelB = "g",
                        LabelC = "b",
                        Field  = field,
                        Title  = field.Name,
                    };
                    break;

                case FieldType.FieldRealArgbColor:
                    control = new FourTupleControl()
                    {
                        LabelA = "a",
                        LabelB = "r",
                        LabelC = "g",
                        LabelD = "b",
                        Field  = field,
                        Title  = field.Name,
                    };
                    break;

                case FieldType.FieldRealHsvColor:
                    control = new ThreeTupleControl()
                    {
                        LabelA = "h",
                        LabelB = "s",
                        LabelC = "v",
                        Field  = field,
                        Title  = field.Name,
                    };
                    break;

                case FieldType.FieldRealAhsvColor:
                    control = new FourTupleControl()
                    {
                        LabelA = "a",
                        LabelB = "h",
                        LabelC = "s",
                        LabelD = "v",
                        Field  = field,
                        Title  = field.Name,
                    };
                    break;

                case FieldType.FieldQuaternion:
                    control = new FourTupleControl()
                    {
                        LabelA     = "w",
                        LabelB     = "i",
                        LabelC     = "j",
                        LabelD     = "k",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Quaternion)field.Value).W.ToString(), ((Quaternion)field.Value).I.ToString(),
                                                    ((Quaternion)field.Value).J.ToString(), ((Quaternion)field.Value).K.ToString() }
                    };
                    break;

                case FieldType.FieldEulerAngles2D:
                    control = new TwoTupleControl()
                    {
                        LabelA     = "i",
                        LabelB     = "j",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Vector2)field.Value).I.ToString(), ((Vector2)field.Value).J.ToString() }
                    };
                    break;

                case FieldType.FieldEulerAngles3D:
                    control = new ThreeTupleControl()
                    {
                        LabelA     = "i",
                        LabelB     = "j",
                        LabelC     = "k",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Vector3)field.Value).I.ToString(), ((Vector3)field.Value).J.ToString(), ((Vector3)field.Value).K.ToString() }
                    };
                    break;

                case FieldType.FieldRealPlane2D:
                    control = new ThreeTupleControl()
                    {
                        LabelA     = "i",
                        LabelB     = "j",
                        LabelC     = "d",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Vector3)field.Value).I.ToString(), ((Vector3)field.Value).J.ToString(), ((Vector3)field.Value).K.ToString() }
                    };
                    break;

                case FieldType.FieldRealPlane3D:
                    control = new FourTupleControl()
                    {
                        LabelA     = "i",
                        LabelB     = "j",
                        LabelC     = "k",
                        LabelD     = "d",
                        Field      = field,
                        Title      = field.Name,
                        TupleValue = new string[] { ((Vector4)field.Value).I.ToString(), ((Vector4)field.Value).J.ToString(), ((Vector4)field.Value).K.ToString(), ((Vector4)field.Value).W.ToString() }
                    };
                    break;


                default: control = new GuerillaControl()
                {
                        Visible = false
                }; break;
                }

                //Check
                if (control != null)
                {
                    panel.Controls.Add(control);
                }
            }

            //Resume
            panel.ResumeLayout();
        }
示例#26
0
 public void ShowControlValue(ValueControl control)
 {
     if (_outputDevice != null)
     {
         var value = GetControlValue(control);
         _outputDevice.SendControlChange(_deviceChannel, (Control) control, value);
     }
 }
示例#27
0
 public void SetControlValue(ValueControl control, int value)
 {
     if (value < 0) value = 0;
     if (value > 15) value = 15;
     _controlValues[control] = value;
 }
示例#28
0
 public int GetControlValue(ValueControl control)
 {
     if ( _controlValues.ContainsKey(control))
     {
         return _controlValues[control];
     }
     else
     {
         return 0;
     }
 }
示例#29
0
 protected void OnControlChange(ValueControl control, Direction direction)
 {
     if (ControlChange != null)
     {
         ControlChange(control, direction);
     }
 }
示例#30
0
        private void ChangePrompter()
        {
            ValueControl <string> valueControl = new ValueControl <string>("New Prompter Text:");

            prompter.Text = valueControl.Read();
        }
示例#31
0
 private void SComponent_LostFocus(object sender, EventArgs e)
 {
     ValueControl = SComponent.Text;
     SComponent.SelectionStart = ValueControl.ToString().Length;
 }
示例#32
0
 public ValueProvider(ValueControl valueControl) : base(valueControl.Control, ValuePattern.Pattern)
 {
     _valueControl = valueControl;
 }