Beispiel #1
0
 private void _QueryData_RowChanged(object sender, DataRowChangeEventArgs e)
 {
     try
     {
         if ((e.Action == DataRowAction.Add || e.Action == DataRowAction.Change) && e.Row["Type"].ToString() == "Color" && !FeatureClassProperties.isUpdating && e.Row["Value"].GetType() != typeof(short))
         {
             short num = DXFCode.TranslateColorString(e.Row["Value"].ToString());
             FeatureClassProperties.isUpdating = true;
             e.Row["Value"] = num;
             FeatureClassProperties.isUpdating = false;
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #2
0
        private void BuildColorRow(string selectedValue)
        {
            string value = "";

            if (selectedValue == AfaStrings.AnyValue)
            {
                value = "";
            }
            else if (selectedValue == "Select Color...")
            {
                var          colorDialog  = new Autodesk.AutoCAD.Windows.ColorDialog();
                DialogResult dialogResult = colorDialog.ShowDialog();
                if (dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    string text = DXFCode.TranstateColorIndexToString(colorDialog.Color.ColorIndex);
                    if (!this._mColorList.Contains(text))
                    {
                        this._mColorList.Add(text);
                        this.cbValue.ItemsSource = this._mColorList;
                    }
                    this.cbValue.SelectedValue = text;
                    value = text;
                }
            }
            else
            {
                short colorIndex = DXFCode.TranslateColorString(selectedValue);
                value = DXFCode.TranstateColorIndexToString(colorIndex);
            }
            int index;

            if (this.QueryDataContainsRow(AfaStrings.Color, out index))
            {
                this.QueryData.Rows.RemoveAt(index);
            }
            if (!string.IsNullOrEmpty(value))
            {
                DataRow dataRow = this.QueryData.NewRow();
                dataRow["Value"] = value;
                dataRow["Type"]  = AfaStrings.Color;
                this.QueryData.Rows.Add(dataRow);
            }
        }
Beispiel #3
0
        private ResultBuffer BuildQueryResultBuffer()
        {
            ResultBuffer resultBuffer = new ResultBuffer();

            foreach (DataRow dataRow in this._QueryData.Rows)
            {
                DXFCode dXFCode = new DXFCode(dataRow["Type"].ToString());
                object  obj     = dataRow["Value"];
                if (dXFCode.Code == 62)
                {
                    obj = DXFCode.TranslateColorString(obj.ToString());
                }
                if (DXFCode.IsValidTypedValue(dXFCode.Code, obj.ToString()))
                {
                    TypedValue typedValue = DXFCode.CreateTypedValue(dXFCode.Code, obj.ToString());
                    resultBuffer.Add(typedValue);
                }
            }
            return(resultBuffer);
        }
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            BindingGroup  bindingGroup  = (BindingGroup)value;
            StringBuilder stringBuilder = null;

            foreach (object current in bindingGroup.Items)
            {
                DataRowView dataRowView = current as DataRowView;
                if (dataRowView != null)
                {
                    try
                    {
                        DataRow   row    = dataRowView.Row;
                        DataTable table  = row.Table;
                        string    value2 = "";
                        if (!DXFCode.IsValid(dataRowView.Row["Type"].ToString(), ref value2))
                        {
                            stringBuilder = new StringBuilder();
                            stringBuilder.Append(value2);
                            ValidationResult result = new ValidationResult(false, stringBuilder.ToString());
                            return(result);
                        }
                        string text = dataRowView.Row["Type"].ToString();
                        foreach (DataRow dataRow in table.Rows)
                        {
                            if (dataRow != row && dataRow["Type"].ToString() == text)
                            {
                                stringBuilder = new StringBuilder();
                                stringBuilder.Append(AfaStrings.DuplicateTypeCode);
                                ValidationResult result = new ValidationResult(false, stringBuilder.ToString());
                                return(result);
                            }
                        }
                        DXFCode dXFCode = new DXFCode(text);
                        object  obj     = dataRowView.Row["Value"];
                        if (dXFCode.Code == 62)
                        {
                            obj = DXFCode.TranslateColorString(obj.ToString());
                        }
                        if (!DXFCode.IsValidTypedValue(dXFCode.Code, obj.ToString()))
                        {
                            stringBuilder = new StringBuilder();
                            stringBuilder.Append(AfaStrings.CodeDoesNotMatchType);
                            ValidationResult result = new ValidationResult(false, stringBuilder.ToString());
                            return(result);
                        }
                    }
                    catch
                    {
                        stringBuilder = new StringBuilder();
                        stringBuilder.Append(AfaStrings.ErrorInDXFCode);
                        ValidationResult result = new ValidationResult(false, stringBuilder.ToString());
                        return(result);
                    }
                    if (!string.IsNullOrEmpty(dataRowView.Row.RowError))
                    {
                        if (stringBuilder == null)
                        {
                            stringBuilder = new StringBuilder();
                        }
                        stringBuilder.Append(((stringBuilder.Length != 0) ? ", " : "") + dataRowView.Row.RowError);
                    }
                }
            }
            if (stringBuilder != null)
            {
                return(new ValidationResult(false, stringBuilder.ToString()));
            }
            return(ValidationResult.ValidResult);
        }