Ejemplo n.º 1
0
    private void UpdateGroupTypeInTable(TextBoxGroupType groupType)
    {
        var updateRow = m_groupTypesTable.Where(row => row.RowState !=
                                                DataRowState.Deleted && row.group_type_id == groupType.GroupTypeID).First();

        updateRow.group_type_name = groupType.TypeName;
    }
Ejemplo n.º 2
0
    private TextBoxGroupType AddGroupType()
    {
        var groupType = new TextBoxGroupType();

        m_listGroupTypes.Add(groupType);
        groupType.GroupTypeID = -1;
        groupType.IsChanged   = false;

        return(groupType);
    }
Ejemplo n.º 3
0
    private void InitList()
    {
        m_listGroupTypes = new ListContainer <TextBoxGroupType>();
        int height = new TextBoxGroupType().Height;

        Controls.Add(m_listGroupTypes);
        m_listGroupTypes.Init(height + 2, new Point(0, 25), "m_listOffices",
                              new Size(ClientSize.Width, ClientSize.Height - m_panelButtons.Height - 25), 3, 5);
        m_listGroupTypes.Anchor = AnchorStyles.Bottom | AnchorStyles.Left |
                                  AnchorStyles.Right | AnchorStyles.Top;
    }
        private bool GetValue(KeyValuePair <string, object> filterParameter,
                              FilterItem filterItem,
                              out string errorMessage)
        {
            bool success = true;

            errorMessage = "";
            Type valueType = filterParameter.Value.GetType();

            switch (valueType.Name.ToLower())
            {
            case "textbox":
                filterItem.Parameters.Add(filterParameter.Key, ((TextBox)filterParameter.Value).Text);
                break;

            case "checkbox":
                filterItem.Parameters.Add(filterParameter.Key, ((CheckBox)filterParameter.Value).IsChecked);
                break;

            case "list`1":
                TextBoxGroupType listType = (TextBoxGroupType)((List <object>)filterParameter.Value)[0];

                if (listType == TextBoxGroupType.RectType)
                {
                    int x = Convert.ToInt32(((TextBox)((List <object>)filterParameter.Value)[1]).Text);
                    int y = Convert.ToInt32(((TextBox)((List <object>)filterParameter.Value)[2]).Text);
                    int w = Convert.ToInt32(((TextBox)((List <object>)filterParameter.Value)[3]).Text);
                    int h = Convert.ToInt32(((TextBox)((List <object>)filterParameter.Value)[4]).Text);

                    if (x == InvalidValue && y == InvalidValue && w == InvalidValue && h == InvalidValue)
                    {
                        filterItem.Parameters.Add(filterParameter.Key, Rect.Empty);
                    }
                    else
                    {
                        var rect = new Rect(x, y, w, h);
                        filterItem.Parameters.Add(filterParameter.Key, rect);
                    }
                }
                else if (listType == TextBoxGroupType.ColorType)
                {
                    byte a     = Convert.ToByte(((TextBox)((List <object>)filterParameter.Value)[1]).Text);
                    byte r     = Convert.ToByte(((TextBox)((List <object>)filterParameter.Value)[2]).Text);
                    byte g     = Convert.ToByte(((TextBox)((List <object>)filterParameter.Value)[3]).Text);
                    byte b     = Convert.ToByte(((TextBox)((List <object>)filterParameter.Value)[4]).Text);
                    var  color = Color.FromArgb(a, r, g, b);
                    filterItem.Parameters.Add(filterParameter.Key, color);
                }
                else if (listType == TextBoxGroupType.PointType)
                {
                    double x     = Convert.ToDouble(((TextBox)((List <object>)filterParameter.Value)[1]).Text);
                    double y     = Convert.ToDouble(((TextBox)((List <object>)filterParameter.Value)[2]).Text);
                    var    point = new Point(x, y);
                    filterItem.Parameters.Add(filterParameter.Key, point);
                }
                else
                {
                    success = false;
                }

                break;

            case "stackpanel":     // Radio buttons for enumeration
                StackPanel container = (StackPanel)filterParameter.Value;

                foreach (var child in container.Children)
                {
                    if (child is RadioButton)
                    {
                        RadioButton radioButton = (RadioButton)child;

                        if ((bool)radioButton.IsChecked)
                        {
                            string typeString     = string.Format(Imaging.ImagingTypeStringStub, TypeOfImagingSDKEnumProperty(filterParameter.Key));
                            Type   type           = Type.GetType(typeString);
                            Array  enumValueArray = Enum.GetValues(type);

                            foreach (var enumValue in enumValueArray)
                            {
                                if (enumValue.ToString().Equals(radioButton.Content))
                                {
                                    filterItem.Parameters.Add(filterParameter.Key, enumValue);
                                    success = true;
                                    break;
                                }
                            }

                            break;
                        }
                    }
                }

                break;

            default:
                success = false;
                break;
            }

            if (!success)
            {
                errorMessage = "No implementation for handling property " + filterParameter.Key
                               + " (UI control is of type " + valueType.Name + ").";
                Debug.WriteLine(DebugTag + "GetValue(): " + errorMessage);
            }

            return(success);
        }
        /// <summary>
        /// Create the group of all required textbox next to each other within a grid.
        /// Type parameter defines if the values will present rect or color
        /// </summary>
        /// <param name="property"></param>
        /// <param name="header"></param>
        /// <param name="names"></param>
        /// <param name="values"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private List <object> CreateTextBoxGroup(PropertyInfo property, string header, List <string> names, object[] values, TextBoxGroupType type)
        {
            FilterPropertiesPanel.Children.Add(
                new TextBlock {
                Text     = header,
                FontSize = PropertyValueFontSize,
                Margin   = PropertyInnerMargin
            });

            var colGrid = new Grid();
            int i       = 0;
            var list    = new List <object> {
                type
            };
            bool valuesOk = (values != null && names.Count == values.Length);

            if (!valuesOk)
            {
                Debug.WriteLine(DebugTag + "CreateTextBoxGroup(): Values are not OK:" + (values == null ? " null" : ""));

                foreach (object valueObject in values)
                {
                    Debug.WriteLine("\t" + valueObject);
                }
            }

            foreach (var name in names)
            {
                colGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(TextBoxWidth + TextBoxMargin)
                });
                var item = CreateTextBox(property, name + "TextBox", (valuesOk ? values[i] : null));
                Grid.SetColumn(item, i);
                i++;
                colGrid.Children.Add(item);
                list.Add(item);
            }

            FilterPropertiesPanel.Children.Add(colGrid);

            return(list);
        }