Ejemplo n.º 1
1
        /// <summary>
        /// Constructs an instance that will expect messages using the given
        /// descriptor. Normally <paramref name="baseDescriptor"/> should be
        /// a descriptor for TestAllTypes. However, if extensionRegistry is non-null,
        /// then baseDescriptor should be for TestAllExtensions instead, and instead of
        /// reading and writing normal fields, the tester will read and write extensions.
        /// All of the TestAllExtensions extensions must be registered in the registry.
        /// </summary>
        private ReflectionTester(MessageDescriptor baseDescriptor,
                                 ExtensionRegistry extensionRegistry)
        {
            this.baseDescriptor = baseDescriptor;
            this.extensionRegistry = extensionRegistry;

            this.file = baseDescriptor.File;
            Assert.AreEqual(1, file.Dependencies.Count);
            this.importFile = file.Dependencies[0];

            MessageDescriptor testAllTypes;
            if (baseDescriptor.Name == "TestAllTypes")
            {
                testAllTypes = baseDescriptor;
            }
            else
            {
                testAllTypes = file.FindTypeByName<MessageDescriptor>("TestAllTypes");
                Assert.NotNull(testAllTypes);
            }

            if (extensionRegistry == null)
            {
                // Use testAllTypes, rather than baseDescriptor, to allow
                // initialization using TestPackedTypes descriptors. These objects
                // won't be used by the methods for packed fields.
                this.optionalGroup =
                    testAllTypes.FindDescriptor<MessageDescriptor>("OptionalGroup");
                this.repeatedGroup =
                    testAllTypes.FindDescriptor<MessageDescriptor>("RepeatedGroup");
            }
            else
            {
                this.optionalGroup =
                    file.FindTypeByName<MessageDescriptor>("OptionalGroup_extension");
                this.repeatedGroup =
                    file.FindTypeByName<MessageDescriptor>("RepeatedGroup_extension");
            }
            this.nestedMessage = testAllTypes.FindDescriptor<MessageDescriptor>("NestedMessage");
            this.foreignMessage = file.FindTypeByName<MessageDescriptor>("ForeignMessage");
            this.importMessage = importFile.FindTypeByName<MessageDescriptor>("ImportMessage");

            this.nestedEnum = testAllTypes.FindDescriptor<EnumDescriptor>("NestedEnum");
            this.foreignEnum = file.FindTypeByName<EnumDescriptor>("ForeignEnum");
            this.importEnum = importFile.FindTypeByName<EnumDescriptor>("ImportEnum");

            Assert.NotNull(optionalGroup);
            Assert.NotNull(repeatedGroup);
            Assert.NotNull(nestedMessage);
            Assert.NotNull(foreignMessage);
            Assert.NotNull(importMessage);
            Assert.NotNull(nestedEnum);
            Assert.NotNull(foreignEnum);
            Assert.NotNull(importEnum);

            this.nestedB = nestedMessage.FindDescriptor<FieldDescriptor>("bb");
            this.foreignC = foreignMessage.FindDescriptor<FieldDescriptor>("c");
            this.importD = importMessage.FindDescriptor<FieldDescriptor>("d");
            this.nestedFoo = nestedEnum.FindValueByName("FOO");
            this.nestedBar = nestedEnum.FindValueByName("BAR");
            this.nestedBaz = nestedEnum.FindValueByName("BAZ");
            this.foreignFoo = foreignEnum.FindValueByName("FOREIGN_FOO");
            this.foreignBar = foreignEnum.FindValueByName("FOREIGN_BAR");
            this.foreignBaz = foreignEnum.FindValueByName("FOREIGN_BAZ");
            this.importFoo = importEnum.FindValueByName("IMPORT_FOO");
            this.importBar = importEnum.FindValueByName("IMPORT_BAR");
            this.importBaz = importEnum.FindValueByName("IMPORT_BAZ");

            this.groupA = optionalGroup.FindDescriptor<FieldDescriptor>("a");
            this.repeatedGroupA = repeatedGroup.FindDescriptor<FieldDescriptor>("a");

            Assert.NotNull(groupA);
            Assert.NotNull(repeatedGroupA);
            Assert.NotNull(nestedB);
            Assert.NotNull(foreignC);
            Assert.NotNull(importD);
            Assert.NotNull(nestedFoo);
            Assert.NotNull(nestedBar);
            Assert.NotNull(nestedBaz);
            Assert.NotNull(foreignFoo);
            Assert.NotNull(foreignBar);
            Assert.NotNull(foreignBaz);
            Assert.NotNull(importFoo);
            Assert.NotNull(importBar);
            Assert.NotNull(importBaz);
        }
Ejemplo n.º 2
0
        public FlagsSelectorDialog(Gtk.Window parent, EnumDescriptor enumDesc, uint flags, string title)
        {
            this.flags = flags;
            this.parent = parent;

            Glade.XML xml = new Glade.XML (null, "stetic.glade", "FlagsSelectorDialog", null);
            xml.Autoconnect (this);

            store = new Gtk.ListStore (typeof(bool), typeof(string), typeof(uint));
            treeView.Model = store;

            Gtk.TreeViewColumn col = new Gtk.TreeViewColumn ();

            Gtk.CellRendererToggle tog = new Gtk.CellRendererToggle ();
            tog.Toggled += new Gtk.ToggledHandler (OnToggled);
            col.PackStart (tog, false);
            col.AddAttribute (tog, "active", 0);

            Gtk.CellRendererText crt = new Gtk.CellRendererText ();
            col.PackStart (crt, true);
            col.AddAttribute (crt, "text", 1);

            treeView.AppendColumn (col);

            foreach (Enum value in enumDesc.Values) {
                EnumValue eval = enumDesc[value];
                if (eval.Label == "")
                    continue;
                uint val = (uint) (int) eval.Value;
                store.AppendValues (((flags & val) != 0), eval.Label, val);
            }
        }
Ejemplo n.º 3
0
 static string GetLocalizeCaption(Enum value)
 {
     string capture = string.Empty;
     EnumDescriptor descriptor = new EnumDescriptor(typeof(DomainComponents.Common.Gender));
     capture = descriptor.GetCaption(value);
     return capture;
 }
Ejemplo n.º 4
0
 private void FillItemWithEnumValues(ChoiceActionItem parentItem, Type enumType) {
     foreach(object current in Enum.GetValues(enumType)) {
         EnumDescriptor ed = new EnumDescriptor(enumType);
         ChoiceActionItem item = new ChoiceActionItem(ed.GetCaption(current), current);
         item.ImageName = ImageLoader.Instance.GetEnumValueImageName(current);
         parentItem.Items.Add(item);
     }
 }
Ejemplo n.º 5
0
 internal EnumValueDescriptor(EnumValueDescriptorProto proto, FileDescriptor file,
                              EnumDescriptor parent, int index)
     : base(file, parent.FullName + "." + proto.Name, index)
 {
     this.proto = proto;
     enumDescriptor = parent;
     file.DescriptorPool.AddSymbol(this);
     file.DescriptorPool.AddEnumValueByNumber(this);
 }
Ejemplo n.º 6
0
 Image ErrorIcon(DisplayableValidationResultItem resultItem, EnumDescriptor enumDescriptor) {
     if (resultItem.Rule != null) {
         var ruleType =
             ((IModelRuleBaseRuleType)
              ((IModelApplicationValidation)Application.Model).Validation.Rules[resultItem.Rule.Id]);
         if (ruleType != null) {
             var errorType = (ErrorType)enumDescriptor.ParseCaption(ruleType.RuleType.ToString());
             return DXErrorProvider.GetErrorIconInternal(errorType);
         }
     }
     return null;
 }
Ejemplo n.º 7
0
		public void Initialize (PropertyDescriptor prop)
		{
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Flags editor does not support editing values of type " + prop.PropertyType);
				
			property = prop.Label;
			Spacing = 3;

			// For small enums, the editor is a list of checkboxes inside a frame
			// For large enums (>5), use a selector dialog.

			enm = Registry.LookupEnum (prop.PropertyType.FullName);
			
			if (enm.Values.Length < 6) 
			{
				Gtk.VBox vbox = new Gtk.VBox (true, 3);

				flags = new Hashtable ();

				foreach (Enum value in enm.Values) {
					EnumValue eval = enm[value];
					if (eval.Label == "")
						continue;

					Gtk.CheckButton check = new Gtk.CheckButton (eval.Label);
					check.TooltipText = eval.Description;
					uint uintVal = (uint) Convert.ToInt32 (eval.Value);
					flags[check] = uintVal;
					flags[uintVal] = check;
					
					check.Toggled += FlagToggled;
					vbox.PackStart (check, false, false, 0);
				}

				Gtk.Frame frame = new Gtk.Frame ();
				frame.Add (vbox);
				frame.ShowAll ();
				PackStart (frame, true, true, 0);
			} 
			else 
			{
				flagsLabel = new Gtk.Entry ();
				flagsLabel.IsEditable = false;
				flagsLabel.HasFrame = false;
				flagsLabel.ShowAll ();
				PackStart (flagsLabel, true, true, 0);
				
				Gtk.Button but = new Gtk.Button ("...");
				but.Clicked += OnSelectFlags;
				but.ShowAll ();
				PackStart (but, false, false, 0);
			}
		}
Ejemplo n.º 8
0
 void GridViewOnQueryErrorType(object sender, ErrorTypeEventArgs errorTypeEventArgs) {
     var enumDescriptor = new EnumDescriptor(typeof(ErrorType));
     var critical = (ErrorType)enumDescriptor.ParseCaption(RuleType.Critical.ToString());
     if (errorTypeEventArgs.Column != null && errorTypeEventArgs.ErrorType == critical) {
         if (View.ObjectTypeInfo.Type != typeof(DisplayableValidationResultItem)) {
             var xafGridColumn = ((XafGridColumn)errorTypeEventArgs.Column);
             var caption = GetRuleType(xafGridColumn.PropertyName).ToString();
             errorTypeEventArgs.ErrorType = (ErrorType)enumDescriptor.ParseCaption(caption);
         } else {
             var resultItem = (DisplayableValidationResultItem)((XafGridView)sender).GetRow(errorTypeEventArgs.RowHandle);
             var warning = ((IModelRuleBaseRuleType)((IModelApplicationValidation)Application.Model).Validation.Rules[resultItem.Rule.Id]);
             errorTypeEventArgs.ErrorType = (ErrorType)enumDescriptor.ParseCaption(warning.RuleType.ToString());
         }
     }
 }
Ejemplo n.º 9
0
 void GridViewOnCustomDrawCell(object sender, RowCellCustomDrawEventArgs e) {
     BaseEditViewInfo info = ((GridCellInfo)e.Cell).ViewInfo;
     var enumDescriptor = new EnumDescriptor(typeof(ErrorType));
     var row = ((GridView)sender).GetRow(e.RowHandle);
     var resultItem = row as DisplayableValidationResultItem;
     Image errorIcon = null;
     if (resultItem != null) {
         errorIcon = ErrorIcon(resultItem, enumDescriptor);
     } else if (Columns.Any()) {
         var caption = Columns.SelectMany(types => types).Last(pair => e.Column.PropertyName() == pair.Key.PropertyName).Value.ToString();
         errorIcon = DXErrorProvider.GetErrorIconInternal((ErrorType)enumDescriptor.ParseCaption(caption));
     }
     if (errorIcon != null) {
         info.ErrorIcon = errorIcon;
         info.CalcViewInfo(e.Graphics);
     }
 }
Ejemplo n.º 10
0
        public ResponseIdEditor()
        {
            combo = Gtk.ComboBoxEntry.NewText ();
            combo.Changed += combo_Changed;
            combo.Show ();
            PackStart (combo, true, true, 0);

            entry = combo.Child as Gtk.Entry;
            entry.Changed += entry_Changed;

            enm = Registry.LookupEnum ("Gtk.ResponseType");
            values = new ArrayList ();
            foreach (Enum value in enm.Values) {
                if (enm[value].Label != "") {
                    combo.AppendText (enm[value].Label);
                    values.Add ((int)enm[value].Value);
                }
            }
        }
Ejemplo n.º 11
0
 protected override void SetupRepositoryItem(RepositoryItem item) {
     base.SetupRepositoryItem(item);
     if (TypeHasFlagsAttribute()) {
         _enumDescriptor = new EnumDescriptor(GetUnderlyingType());
         var checkedItem = ((RepositoryItemCheckedComboBoxEdit)item);
         checkedItem.BeginUpdate();
         checkedItem.Items.Clear();
         _noneValue = GetNoneValue();
         //checkedItem.SelectAllItemVisible = false;
         //Dennis: this is required to show localized items in the editor.
         foreach (object value in _enumDescriptor.Values)
             if (!IsNoneValue(value))
                 checkedItem.Items.Add(value, _enumDescriptor.GetCaption(value), CheckState.Unchecked, true);
         //Dennis: use this method if you don't to show localized items in the editor.
         //checkedItem.SetFlags(GetUnderlyingType());
         checkedItem.EndUpdate();
         checkedItem.ParseEditValue += checkedEdit_ParseEditValue;
         checkedItem.CustomDisplayText += checkedItem_CustomDisplayText;
     }
 }
Ejemplo n.º 12
0
		public void Initialize (PropertyDescriptor prop)
		{
			if (!prop.PropertyType.IsEnum)
				throw new ApplicationException ("Enumeration editor does not support editing values of type " + prop.PropertyType);
				
			ebox = new Gtk.EventBox ();
			ebox.Show ();
			PackStart (ebox, true, true, 0);

			combo = Gtk.ComboBoxEntry.NewText ();
			combo.Changed += combo_Changed;
			combo.Entry.IsEditable = false;
			combo.Entry.HasFrame = false;
			combo.Entry.HeightRequest = combo.SizeRequest ().Height;	// The combo does not set the entry to the correct size when it does not have a frame
			combo.Show ();
			ebox.Add (combo);

			enm = Registry.LookupEnum (prop.PropertyType.FullName);
			foreach (Enum value in enm.Values)
				combo.AppendText (enm[value].Label);
		}
Ejemplo n.º 13
0
        public async Task Generate_With_Value()
        {
            // arrange
            var sb     = new StringBuilder();
            var writer = new CodeWriter(sb);

            var generator = new EnumGenerator();

            var descriptor = new EnumDescriptor(
                "Episode",
                new []
            {
                new EnumElementDescriptor("NewHope", "NEWHOPE", 1),
                new EnumElementDescriptor("Empire", "EMPIRE", 2),
            }
                );

            // act
            await generator.WriteAsync(writer, descriptor);

            // assert
            sb.ToString().MatchSnapshot();
        }
Ejemplo n.º 14
0
        public void CanHandle()
        {
            // arrange
            var sb     = new StringBuilder();
            var writer = new CodeWriter(sb);

            var generator = new EnumGenerator();

            var descriptor = new EnumDescriptor(
                "Episode",
                new []
            {
                new EnumElementDescriptor("NewHope", "NEWHOPE", 1),
                new EnumElementDescriptor("Empire", "EMPIRE", 2),
            }
                );

            // act
            bool result = generator.CanHandle(descriptor);

            // assert
            Assert.True(result);
        }
Ejemplo n.º 15
0
    public Descriptor(DescriptorPool pool, ProtoBase parent, DescriptorProto def)
    {
        Define = def;

        base.Init(pool, parent);

        // 字段
        for (int i = 0; i < def.field.Count; i++)
        {
            var fieldDef = def.field[i];

            var fieldD = new FieldDescriptor(this, fieldDef);

            _fieldByName.Add(fieldDef.name, fieldD);
            _fieldByFieldNumber.Add(fieldD.Number, fieldD);
        }

        // 内嵌消息
        for (int i = 0; i < def.nested_type.Count; i++)
        {
            var nestedDef = def.nested_type[i];

            var msgD = new Descriptor(pool, this, nestedDef);

            _nestedMsg.Add(nestedDef.name, msgD);
        }

        // 内嵌枚举
        for (int i = 0; i < def.enum_type.Count; i++)
        {
            var nestedDef = def.enum_type[i];

            var enumD = new EnumDescriptor(pool, this, nestedDef);

            _nestedEnum.Add(nestedDef.name, enumD);
        }
    }
Ejemplo n.º 16
0
        /// <summary>
        /// Parses a single field from the specified tokenizer and merges it into
        /// the builder.
        /// </summary>
        private static void MergeField(TextTokenizer tokenizer, ExtensionRegistry extensionRegistry,
                                       IBuilder builder)
        {
            FieldDescriptor   field;
            MessageDescriptor type      = builder.DescriptorForType;
            ExtensionInfo     extension = null;

            if (tokenizer.TryConsume("["))
            {
                // An extension.
                StringBuilder name = new StringBuilder(tokenizer.ConsumeIdentifier());
                while (tokenizer.TryConsume("."))
                {
                    name.Append(".");
                    name.Append(tokenizer.ConsumeIdentifier());
                }

                extension = extensionRegistry.FindByName(type, name.ToString());

                if (extension == null)
                {
                    throw tokenizer.CreateFormatExceptionPreviousToken("Extension \"" + name +
                                                                       "\" not found in the ExtensionRegistry.");
                }
                else if (extension.Descriptor.ContainingType != type)
                {
                    throw tokenizer.CreateFormatExceptionPreviousToken("Extension \"" + name +
                                                                       "\" does not extend message type \"" +
                                                                       type.FullName + "\".");
                }

                tokenizer.Consume("]");

                field = extension.Descriptor;
            }
            else
            {
                String name = tokenizer.ConsumeIdentifier();
                field = type.FindDescriptor <FieldDescriptor>(name);

                // Group names are expected to be capitalized as they appear in the
                // .proto file, which actually matches their type names, not their field
                // names.
                if (field == null)
                {
                    // Explicitly specify the invariant culture so that this code does not break when
                    // executing in Turkey.
#if PORTABLE_LIBRARY
                    String lowerName = name.ToLowerInvariant();
#else
                    String lowerName = name.ToLower(FrameworkPortability.InvariantCulture);
#endif
                    field = type.FindDescriptor <FieldDescriptor>(lowerName);
                    // If the case-insensitive match worked but the field is NOT a group,
                    // TODO(jonskeet): What? Java comment ends here!
                    if (field != null && field.FieldType != FieldType.Group)
                    {
                        field = null;
                    }
                }
                // Again, special-case group names as described above.
                if (field != null && field.FieldType == FieldType.Group && field.MessageType.Name != name)
                {
                    field = null;
                }

                if (field == null)
                {
                    throw tokenizer.CreateFormatExceptionPreviousToken(
                              "Message type \"" + type.FullName + "\" has no field named \"" + name + "\".");
                }
            }

            object value = null;

            if (field.MappedType == MappedType.Message)
            {
                tokenizer.TryConsume(":"); // optional

                String endToken;
                if (tokenizer.TryConsume("<"))
                {
                    endToken = ">";
                }
                else
                {
                    tokenizer.Consume("{");
                    endToken = "}";
                }

                IBuilder subBuilder;
                if (extension == null)
                {
                    subBuilder = builder.CreateBuilderForField(field);
                }
                else
                {
                    subBuilder = extension.DefaultInstance.WeakCreateBuilderForType() as IBuilder;
                    if (subBuilder == null)
                    {
                        throw new NotSupportedException("Lite messages are not supported.");
                    }
                }

                while (!tokenizer.TryConsume(endToken))
                {
                    if (tokenizer.AtEnd)
                    {
                        throw tokenizer.CreateFormatException("Expected \"" + endToken + "\".");
                    }
                    MergeField(tokenizer, extensionRegistry, subBuilder);
                }

                value = subBuilder.WeakBuild();
            }
            else
            {
                tokenizer.Consume(":");

                switch (field.FieldType)
                {
                case FieldType.Int32:
                case FieldType.SInt32:
                case FieldType.SFixed32:
                    value = tokenizer.ConsumeInt32();
                    break;

                case FieldType.Int64:
                case FieldType.SInt64:
                case FieldType.SFixed64:
                    value = tokenizer.ConsumeInt64();
                    break;

                case FieldType.UInt32:
                case FieldType.Fixed32:
                    value = tokenizer.ConsumeUInt32();
                    break;

                case FieldType.UInt64:
                case FieldType.Fixed64:
                    value = tokenizer.ConsumeUInt64();
                    break;

                case FieldType.Float:
                    value = tokenizer.ConsumeFloat();
                    break;

                case FieldType.Double:
                    value = tokenizer.ConsumeDouble();
                    break;

                case FieldType.Bool:
                    value = tokenizer.ConsumeBoolean();
                    break;

                case FieldType.String:
                    value = tokenizer.ConsumeString();
                    break;

                case FieldType.Bytes:
                    value = tokenizer.ConsumeByteString();
                    break;

                case FieldType.Enum:
                {
                    EnumDescriptor enumType = field.EnumType;

                    if (tokenizer.LookingAtInteger())
                    {
                        int number = tokenizer.ConsumeInt32();
                        value = enumType.FindValueByNumber(number);
                        if (value == null)
                        {
                            throw tokenizer.CreateFormatExceptionPreviousToken(
                                      "Enum type \"" + enumType.FullName +
                                      "\" has no value with number " + number + ".");
                        }
                    }
                    else
                    {
                        String id = tokenizer.ConsumeIdentifier();
                        value = enumType.FindValueByName(id);
                        if (value == null)
                        {
                            throw tokenizer.CreateFormatExceptionPreviousToken(
                                      "Enum type \"" + enumType.FullName +
                                      "\" has no value named \"" + id + "\".");
                        }
                    }

                    break;
                }

                case FieldType.Message:
                case FieldType.Group:
                    throw new InvalidOperationException("Can't get here.");
                }
            }

            if (field.IsRepeated)
            {
                builder.WeakAddRepeatedField(field, value);
            }
            else
            {
                builder.SetField(field, value);
            }
        }
Ejemplo n.º 17
0
 public Dictionary <OrganizationalLevel, string> GetOrganizationalLevels()
 {
     return(EnumDescriptor.GetEnumMembers <OrganizationalLevel>());
 }
Ejemplo n.º 18
0
        private void CreateRowForObject(XPBaseObject item, bool focusFirstControl, int rowindex)
        {
            _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)] = new List <TableRow>();
            var headerRowsForItem = new List <TableRow>();

            if (!HeadersOnTopOnly)
            {
                headerRowsForItem = CreateHeaderRows(item, rowindex);
                _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].AddRange(headerRowsForItem);
            }

            if (_btnAddFirst != null)
            {
                _btnAddFirst.Visible = false;
            }

            TableRow tr = null;

            var controlsOfRowPerColumn = new Dictionary <string, ASPxEdit>();

            int  i = 0;
            int  headerrowsadded     = 0;
            bool firstControlFocused = false;

            foreach (IModelColumn column in Model.Columns)
            {
                if (column.Index >= 0)
                {
                    if (i % ColumnsPerRow == 0)
                    {
                        if (headerRowsForItem.Count > headerrowsadded)
                        {
                            _table.Rows.Add(headerRowsForItem[headerrowsadded]);
                            headerrowsadded++;
                        }
                        tr = new TableRow {
                            CssClass = rowindex % 2 == 0 ? "evenrow" : "oddrow"
                        };
                        _table.Rows.Add(tr);
                        _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].Add(tr);
                    }
                    i++;

                    var tc = new TableCell();
                    if (tr != null)
                    {
                        tr.Cells.Add(tc);
                    }

                    if (!AllowEdit)
                    {
                        object itemGetMemberValue = item.GetMemberValue(column.PropertyName);
                        if (itemGetMemberValue == null)
                        {
                            tc.Text = "";
                        }
                        else if (itemGetMemberValue is XPBaseObject)
                        {
                            ITypeInfo typeInfo =
                                XafTypesInfo.Instance.FindTypeInfo(
                                    (itemGetMemberValue as XPBaseObject).ClassInfo.ClassType);
                            if (typeInfo.DefaultMember != null)
                            {
                                object defMembVal =
                                    (itemGetMemberValue as XPBaseObject).GetMemberValue(typeInfo.DefaultMember.Name);
                                tc.Text = defMembVal != null?defMembVal.ToString() : "";
                            }
                            else
                            {
                                tc.Text = itemGetMemberValue.ToString();
                            }
                        }
                        else if (itemGetMemberValue is Enum)
                        {
                            {
                                string caption =
                                    new EnumDescriptor(column.ModelMember.MemberInfo.MemberType).GetCaption(
                                        itemGetMemberValue);
                                tc.Text = string.IsNullOrEmpty(column.DisplayFormat)
                                    ? caption
                                    : string.Format(column.DisplayFormat, caption);
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(column.DisplayFormat))
                            {
                                tc.Text = string.Format(column.DisplayFormat, itemGetMemberValue);
                            }
                            else if (itemGetMemberValue is decimal)
                            {
                                tc.Text = string.Format("{0:C2}", itemGetMemberValue);
                            }
                            else
                            {
                                tc.Text = itemGetMemberValue.ToString();
                            }
                        }

                        tc.CssClass = "StaticText";
                    }
                    else
                    {
                        ASPxEdit cellControl = GetControlForColumn(column, item);
                        if (!column.AllowEdit)
                        {
                            cellControl.Enabled = false;
                        }

                        //handle control width
                        int tableColumns = Math.Max(Model.Columns.Count(c => c.Index >= 0), ColumnsPerRow);
                        if (cellControl is ASPxCheckBox)
                        {
                            tc.Width = new Unit(1, UnitType.Percentage);
                        }
                        else if (tableColumns > 0)
                        {
                            var value = 100 / tableColumns;
                            tc.Width = new Unit(value, UnitType.Percentage);
                        }

                        cellControl.ID = column.PropertyName + "_control_" +
                                         item.GetMemberValue(Model.ModelClass.KeyProperty)
                                         .ToString()
                                         .Replace("-", "_minus_");
                        cellControl.ValidationSettings.ErrorDisplayMode  = ErrorDisplayMode.ImageWithTooltip;
                        cellControl.ValidationSettings.Display           = Display.Dynamic;
                        cellControl.ValidationSettings.ErrorTextPosition = ErrorTextPosition.Left;
                        cellControl.ValidationSettings.ErrorImage.Url    =
                            ImageLoader.Instance.GetImageInfo("ximage").ImageUrl;

                        controlsOfRowPerColumn.Add(column.PropertyName, cellControl);
                        _baseObjectsHandledByControl[cellControl] = new Tuple <XPBaseObject, string>(item,
                                                                                                     column.PropertyName);

                        tc.Controls.Add(cellControl);

                        if (focusFirstControl && !firstControlFocused)
                        {
                            cellControl.Focus();
                            firstControlFocused = true;
                        }
                    }
                    OnCustomizeAppearance(new CustomizeAppearanceEventArgs(column.PropertyName,
                                                                           new WebControlAppearanceAdapter(tc, tc), item));
                }
            }

            if (tr == null)
            {
                tr = new TableRow {
                    CssClass = rowindex % 2 == 0 ? "evenrow" : "oddrow"
                };
                _table.Rows.Add(tr);
                _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].Add(tr);
            }

            var tcButtons = new TableCell {
                Wrap = false, Width = new Unit(1, UnitType.Percentage)
            };

            if (i % ColumnsPerRow != 0)
            {
                tcButtons.ColumnSpan = ColumnsPerRow - i % ColumnsPerRow;
            }
            else
            {
                tr = new TableRow {
                    CssClass = rowindex % 2 == 0 ? "evenrow" : "oddrow"
                };
                _table.Rows.Add(tr);
                _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].Add(tr);
                //a new row will be created and the whole row will be the buttons
                tcButtons.ColumnSpan = ColumnsPerRow;
            }

            tr.Cells.Add(tcButtons);

            var tblButtons = new Table();

            tcButtons.Controls.Add(tblButtons);
            var btnsrow = new TableRow();

            tblButtons.Rows.Add(btnsrow);

            if (AllowEdit && ShowButtons)
            {
                var btnRemove = new ASPxButton {
                    AutoPostBack = false, EnableClientSideAPI = true
                };

                btnRemove.SetClientSideEventHandler("Click",
                                                    "function(s, e) { " + "CallbackPanel" + Model.Id + ".PerformCallback(\"rem_" +
                                                    item.GetMemberValue(Model.ModelClass.KeyProperty) + "\"); }");
                btnRemove.Text = DeleteButtonCaption;
                btnRemove.ID   = "btnRemove_" + item.GetMemberValue(Model.ModelClass.KeyProperty);

                var t = new TableCell();
                btnsrow.Cells.Add(t);
                t.Controls.Add(btnRemove);
            }

            if (AllowEdit && ShowButtons)
            {
                var btnAdd = new ASPxButton {
                    AutoPostBack = false, EnableClientSideAPI = true
                };

                btnAdd.SetClientSideEventHandler("Click",
                                                 "function(s, e) { " + "CallbackPanel" + Model.Id + ".PerformCallback(\"add\"); }");
                btnAdd.Text = AddButtonCaption;
                btnAdd.ID   = "btnAdd_" + item.GetMemberValue(Model.ModelClass.KeyProperty);

                var t = new TableCell();
                btnsrow.Cells.Add(t);
                t.Controls.Add(btnAdd);
            }
            _controlsPerObjectInList[item.GetMemberValue(Model.ModelClass.KeyProperty)] = controlsOfRowPerColumn;
        }
Ejemplo n.º 19
0
 private void AddEnum(EnumDescriptor enumDescriptor)
 {
     filesBySymbol[enumDescriptor.FullName] = enumDescriptor.File;
 }
        /// <summary>
        /// Заполнение списка перечислением
        /// </summary>
        /// <param name="type"></param>
        /// <param name="checkedListBox1"></param>
        private void enumToCheckedListBox(Type type, CheckedListBox checkedListBox1)
        {
            if (type == null) throw new ArgumentNullException("Type is null!");
            if (type.IsGenericType && type.GetGenericTypeDefinition().FullName == "System.Nullable`1" && type.GenericTypeArguments[0].IsEnum)
            {
                type = type.GenericTypeArguments[0];
            }
            if (!type.IsEnum) throw new ArgumentException("Type is not enum!");

            // Установка значений списка
            checkedListBox1.Items.Clear();

            // Значения из описания
            EnumDescriptor ed = new EnumDescriptor(type);
            foreach (var enumValue in Enum.GetValues(type))
            {
                checkedListBox1.Items.Add(ed.GetCaption(enumValue));
            }
            if (checkedListBox1.Items.Count > 0 && checkedListBox1.Items.Count < 3)
            {
                checkedListBox1.Height = 15 * checkedListBox1.Items.Count + 4;
                Height = checkedListBox1.Height;
            }

            Value.HandleEnumTypeChanged(type);
        }
Ejemplo n.º 21
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            GraphPane     myPane        = zedGraphControl1.GraphPane;
            PointPairList listPointsTwo = new PointPairList();
            string        selected      = comboBox1.Text;

            ACOK.SipRegisters sel = EnumDescriptor.ToEnum <ACOK.SipRegisters>(selected);
            if (selected == "Data1")
            {
                Dispdata(sel);
                //button6_Click(this, null);
            }
            if (selected != "Data1")
            {
                //if (axisflag == 1)
                //{
                //    myPane.YAxis.Max = 40;
                //    myPane.YAxis.Min = 0;
                //    myPane.XAxis.Min = 0;
                //    myPane.XAxis.Max = 50;
                //}

                if (i * yscalectrl > myPane.XAxis.Max - 5)
                {
                    myPane.XAxis.Max = (i + 10);
                    axisflag         = 0;
                }
                i++;


                Sipval[(i - 1)] = Data.GetVal(sel);


                zedGraphControl1.AxisChange();
                zedGraphControl1.Refresh();

                myPane.ScaledGap(1);

                Rangscale(sel);


                myPane.IsFontsScaled = true;


                PointPairList approx2 = new PointPairList();


                if (i > 1)
                {
                    a = (sumxy * (i - 1) - sumy * sumx) / (sumx2 * (i - 1) - Math.Pow(sumx, 2));
                    b = (sumy - a * sumx) / (i - 1);
                    for (double x = i - 1; x <= i; x += 0.5)
                    {
                        approx2.Add(x, a1 * x + b1);
                    }
                }
                sumx  += i;
                sumy  += Data.GetVal(sel);
                sumx2 += Math.Pow(i, 2);
                sumxy += i * Data.GetVal(sel);

                a = (sumxy * i - sumy * sumx) / (sumx2 * i - Math.Pow(sumx, 2));
                b = (sumy - a * sumx) / i;
                PointPairList approx1 = new PointPairList();
                approx1.Clear();
                for (double x = 1; x <= i; x += 0.5)
                {
                    approx1.Add(x, a * x + b);
                }

                /*
                 * LineItem f1_curve = myPane.AddCurve(null, approx1, Color.Black, SymbolType.None);
                 */
                myPane.CurveList.Clear();

                for (int u = 0; u < Sipval.Length; u++)
                {
                    listPointsTwo.Add(u + 1, Sipval[u]);
                }
                LineItem myCurveTwo = myPane.AddCurve("real T", listPointsTwo, Color.Black, SymbolType.None);
                if (i > 2)
                {
                    bezcurv(Sipval, i);
                }
                Array.Resize <double>(ref Sipval, Sipval.Length + 1);

                //byte[] temBuf = new byte[4];
                //int index = 0;

                //private void COM3_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
                //{

                //    ////byte[] tempval = new byte[3];
                //    //int[] tempval = new int[3];// tempval[3];
                //    //int j = 0;

                //        int count = COM3.BytesToRead;
                //        while (count > 0)
                //        {
                //            byte[] buf = new byte[count];
                //            COM3.Read(buf, 0, count);

                //            int wrCount = ((temBuf.Length - index) < count) ? count : count; //(temBuf.Length - index);
                //            Array.Copy(buf, 0, temBuf, index, wrCount);

                //            index += wrCount;
                //            if (index >= temBuf.Length)
                //            {
                //                index = 0;
                //                float temp = 0;
                //                try
                //                {
                //                    temp = BitConverter.ToSingle(temBuf, 0);
                //                }
                //                catch {}

                //                richTextBox1.Invoke(new Action(() =>
                //                {
                //                    richTextBox2.Text = string.Format("{0:F3}", temp); ;
                //                }));
                //            }

                //            //tempval[j]= COM3.Read(buf, 0, count);
                //            //richTextBox4.Text += tempval[j];
                //            //j++;
                //            //if (j > 2)
                //            //{
                //            //    j = 0;
                //            //};



                //            //string strB = "";
                //            //for (int i = 0; i < count; i++)
                //            //{
                //            //    strB += string.Format("{0:X2}", buf[i]);
                //            //    strB += "\t";
                //            //}

                //            //richTextBox1.Invoke(new Action(() =>
                //            //{
                //            //   richTextBox2.Text += strB;
                //            //}));

                //            count = COM3.BytesToRead;
                //        }
                //    }

                //private void COM3_ErrorReceived(object sender, System.IO.Ports.SerialErrorReceivedEventArgs e)
                //{

                //}
                //
                #endregion // Events
                //-------------------------------------------------------------------------



                //button1_Click_1(this, null);
            }
        }
Ejemplo n.º 22
0
 public void EnumDescription()
 {
     Assert.AreEqual(TESTENUM, EnumDescriptor.GetDescription(typeof(TestEnum)));
 }
Ejemplo n.º 23
0
 public void IsDefined(bool expected, object value)
 {
     Assert.AreEqual(expected, EnumDescriptor.IsDefined(typeof(TestEnum), value));
 }
Ejemplo n.º 24
0
 public void GetDescription(string expected, object value)
 {
     Assert.AreEqual(expected, EnumDescriptor.GetDescription(typeof(TestEnum), value));
 }
Ejemplo n.º 25
0
 public void Generic_GetDescription(string expected, object value)
 {
     Assert.AreEqual(expected, EnumDescriptor.GetDescription <TestEnum>(value));
 }
Ejemplo n.º 26
0
 public void Generic_EnumDescriptionNoDescription()
 {
     Assert.AreEqual(null, EnumDescriptor.GetDescription <NoDescriptionEnum>());
 }
Ejemplo n.º 27
0
 public void EnumDescriptionNoDescription()
 {
     Assert.AreEqual(null, EnumDescriptor.GetDescription(typeof(NoDescriptionEnum)));
 }
Ejemplo n.º 28
0
 public void Generic_IsDefined(bool expected, object value)
 {
     Assert.AreEqual(expected, EnumDescriptor.IsDefined <TestEnum>(value));
 }
Ejemplo n.º 29
0
 public override int AsEnum(EnumDescriptor es)
 {
     var ds = es.Find(AtString());
     if (ds == null) Expected("enum value");
     return ds.Id;
 }
Ejemplo n.º 30
0
 public void Generic_ParseIgnoreCase(object expected, string value)
 {
     Assert.AreEqual(expected, EnumDescriptor.Parse <TestEnum>(value, true));
 }
 internal SingleEnumAccessor(FieldDescriptor field, string name, string containingOneofName, bool supportFieldPresence)
     : base(field, name, containingOneofName, supportFieldPresence)
 {
     enumDescriptor = field.EnumType;
 }
        private static bool TryCoerceType(string text, FieldDescriptor field, out object value, IList <string> tmpReasons)
        {
            value = null;

            switch (field.FieldType)
            {
            case FieldType.Int32:
            case FieldType.SInt32:
            case FieldType.SFixed32:
                value = Int32.Parse(text);
                break;

            case FieldType.Int64:
            case FieldType.SInt64:
            case FieldType.SFixed64:
                value = Int64.Parse(text);
                break;

            case FieldType.UInt32:
            case FieldType.Fixed32:
                value = UInt32.Parse(text);
                break;

            case FieldType.UInt64:
            case FieldType.Fixed64:
                value = UInt64.Parse(text);
                break;

            case FieldType.Float:
                value = float.Parse(text);
                break;

            case FieldType.Double:
                value = Double.Parse(text);
                break;

            case FieldType.Bool:
                value = Boolean.Parse(text);
                break;

            case FieldType.String:
                value = text;
                break;

            case FieldType.Enum:
            {
                EnumDescriptor enumType = field.EnumType;

                int number;
                if (int.TryParse(text, out number))
                {
                    value = enumType.FindValueByNumber(number);
                    if (value == null)
                    {
                        tmpReasons.Add(
                            "Enum type \"" + enumType.FullName +
                            "\" has no value with number " + number + ".");
                        return(false);
                    }
                }
                else
                {
                    value = enumType.FindValueByName(text);
                    if (value == null)
                    {
                        tmpReasons.Add(
                            "Enum type \"" + enumType.FullName +
                            "\" has no value named \"" + text + "\".");
                        return(false);
                    }
                }

                break;
            }

            case FieldType.Bytes:
            case FieldType.Message:
            case FieldType.Group:
                tmpReasons.Add("Unhandled field type " + field.FieldType.ToString() + ".");
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Получение выражения запроса
        /// </summary>
        /// <param name="fieldRef"></param>
        /// <returns></returns>
        public override CriteriaOperator GetExpression()
        {
            var fieldRef = new OperandProperty(FilterColumn.Property);
            if (Value.BCheckBoxNull.HasValue)
            {
                if (!Value.BCheckBoxNull.Value)
                {
                    return new UnaryOperator(UnaryOperatorType.IsNull, new OperandProperty(FilterColumn.Property));
                }
                else
                {
                    return new UnaryOperator(UnaryOperatorType.Not, new UnaryOperator(UnaryOperatorType.IsNull, new OperandProperty(FilterColumn.Property)));
                }
            }
            else
            {
                if (Value.BCheckedListBox == null) return null;
                var type = Type;
                if (type.IsGenericType && type.GetGenericTypeDefinition().FullName == "System.Nullable`1" && type.GenericTypeArguments[0].IsEnum)
                {
                    type = type.GenericTypeArguments[0];
                }
                EnumDescriptor ed = new EnumDescriptor(type);
                List<string> items = new List<string>();
                for (int i = 0; i < Value.BCheckedListBox.Length; i++)
                {
                    if (Value.BCheckedListBox[i])
                    {
                        items.Add((string)checkedListBox1.Items[i]);
                    }
                }
                if (items.Count == 0) return null;

                int val = 0;
                bool flags = false;
                bool flag_none = false;

                // Определение на флаговый атрибут
                Type enumType = type.UnderlyingSystemType;
                Object[] attrs = enumType.GetCustomAttributes(typeof(FlagsAttribute), false);
                if (attrs.Length > 0)
                {
                    flags = true;
                }

                // Используется ли значение "никакой" в фильтре флага
                if (flags)
                {
                    foreach (var enumValue in Enum.GetValues(type))
                    {
                        if ((int)enumValue == 0)
                        {
                            flag_none = true;
                            break;
                        }
                    }
                }

                CriteriaOperator[] values = null;

                if (flag_none)
                {
                    // Для значения "никакой" используется обычное условие равенства фильтруемого поля нулю
                    values = new CriteriaOperator[1];
                    values[0] = new BinaryOperator(fieldRef, new OperandValue(0), BinaryOperatorType.Equal);
                }
                else
                {
                    if (!flags)
                    {
                        values = new CriteriaOperator[items.Count];
                    }
                    else
                    {
                        values = new CriteriaOperator[1];
                    }
                    for (int i = 0; i < items.Count; i++)
                    {
                        object enumVal = null;
                        foreach (var enumValue in Enum.GetValues(type))
                        {
                            if (ed.GetCaption(enumValue) == items[i])
                            {
                                enumVal = enumValue;
                                break;
                            }
                        }
                        if (flags)
                        {
                            val |= (int)enumVal;
                        }
                        else
                            values[i] = new BinaryOperator(fieldRef, new OperandValue(enumVal), BinaryOperatorType.Equal);
                    }
                    if (flags)
                    {
                        values[0] = new BinaryOperator(fieldRef, new OperandValue(val), BinaryOperatorType.Equal);
                    }
                }

                return GroupOperator.Or(values);
            }
        }
Ejemplo n.º 34
0
        public UrlBuilder WithValue(string key, object value)
        {
            switch (value)
            {
            case null:
                Parameters.Remove(key);
                break;

            case string v:
                Parameters[key] = v;
                break;

            case bool v:
                Parameters[key] = v ? "true" : "false";
                break;

            case int v:
                Parameters[key] = string.Format(CultureInfo.InvariantCulture, "{0}", v);
                break;

            case long v:
                Parameters[key] = string.Format(CultureInfo.InvariantCulture, "{0}", v);
                break;

            case DateTime v:
                Parameters[key] = v.ToString("o");
                break;

            case Enum v:
                Parameters[key] = FormatEnum(v);
                break;

            case PathWithNamespace v:
                Parameters[key] = v.FullPath;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(value));
            }

            return(this);

            string FormatEnum(Enum enumValue)
            {
                var descriptor = s_enumDescriptors.GetOrAdd(enumValue.GetType(), type => EnumDescriptor.Build(type));

                if (descriptor.IsFlags)
                {
                    return(string.Join(",", descriptor.Values.Where(ev => enumValue.HasFlag(ev.Key)).Select(ev => ev.Value)));
                }
                else
                {
                    return(descriptor.Values[enumValue]);
                }
            }
        }
Ejemplo n.º 35
0
 public EnumValueDescriptor(EnumDescriptor d, EnumValueDescriptorProto def)
 {
     Define = def;
     _d     = d;
 }
Ejemplo n.º 36
0
 internal SingleEnumAccessor(FieldDescriptor field, string name) : base(name)
 {
     enumDescriptor = field.EnumType;
 }
        private ASPxEdit GetControlForColumn(IModelColumn column, XPBaseObject item){
            object value = item.GetMemberValue(column.PropertyName);
            ASPxEdit c;
            if (typeof (XPBaseObject).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType)){
                c = RenderHelper.CreateASPxComboBox();
                var helper = new WebLookupEditorHelper(_application, _objectSpace,
                    column.ModelMember.MemberInfo.MemberTypeInfo, column);

                ((ASPxComboBox) c).ClientSideEvents.KeyUp =
                    "function(s, e) { if(e.htmlEvent.keyCode == 46){ s.SetSelectedIndex(-1); } }";
                ((ASPxComboBox) c).ValueType = column.ModelMember.MemberInfo.MemberTypeInfo.KeyMember.MemberType;
                ((ASPxComboBox) c).SelectedIndexChanged += DetailItemControlValueChanged;
                c.Style.Add("min-width", "120px");
                c.Width = new Unit(100, UnitType.Percentage);

                FillEditorValues(value, ((ASPxComboBox) c), helper, item, column.ModelMember);
                if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                    ((ASPxComboBox) c).ClientSideEvents.SelectedIndexChanged = "function(s, e) { " + "CallbackPanel" +
                                                                               Model.Id + ".PerformCallback(\"changed_" +
                                                                               column.PropertyName + "_" +
                                                                               item.GetMemberValue(
                                                                                   Model.ModelClass.KeyProperty) +
                                                                               "\"); }";
            }
            else if (typeof (Enum).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType)){
                c = RenderHelper.CreateASPxComboBox();
                ((ASPxComboBox) c).ClientSideEvents.KeyUp =
                    "function(s, e) { if(e.htmlEvent.keyCode == 46){ s.SetSelectedIndex(-1); } }";
                var descriptor = new EnumDescriptor(column.ModelMember.MemberInfo.MemberType);
                var source = (Enum.GetValues(column.ModelMember.MemberInfo.MemberType).Cast<object>()
                    .Select(v => new Tuple<object, string>(v, descriptor.GetCaption(v)))).ToList();
                c.DataSource = source;
                ((ASPxComboBox) c).ValueField = "Item1";
                ((ASPxComboBox) c).TextField = "Item2";
                ((ASPxComboBox) c).ValueType = column.ModelMember.MemberInfo.MemberType;
                ((ASPxComboBox) c).SelectedIndexChanged += DetailItemControlValueChanged;
                c.Style.Add("min-width", "120px");
                c.Width = new Unit(100, UnitType.Percentage);
                c.Load += c_Load;
                if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                    ((ASPxComboBox) c).ClientSideEvents.SelectedIndexChanged = "function(s, e) { " + "CallbackPanel" +
                                                                               Model.Id + ".PerformCallback(\"changed_" +
                                                                               column.PropertyName + "_" +
                                                                               item.GetMemberValue(
                                                                                   Model.ModelClass.KeyProperty) +
                                                                               "\"); }";
            }
            else{
                switch (column.ModelMember.MemberInfo.MemberType.ToString()){
                    case "System.Boolean":
                    case "System.bool":
                        c = RenderHelper.CreateASPxCheckBox();
                        ((ASPxCheckBox) c).CheckedChanged += DetailItemControlValueChanged;
                        c.Style.Add("max-width", "20px");
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxCheckBox) c).ClientSideEvents.CheckedChanged = "function(s, e) { " + "CallbackPanel" +
                                                                                 Model.Id +
                                                                                 ".PerformCallback(\"changed_" +
                                                                                 column.PropertyName + "_" +
                                                                                 item.GetMemberValue(
                                                                                     Model.ModelClass.KeyProperty) +
                                                                                 "\"); }";
                        break;
                    case "System.String":
                    case "System.string":
                        c = RenderHelper.CreateASPxTextBox();
                        ((ASPxTextBox) c).MaxLength = 100;
                        if (column.ModelMember.Size > 0)
                            ((ASPxTextBox) c).MaxLength = column.ModelMember.Size;
                        ((ASPxTextBox) c).TextChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxTextBox) c).ClientSideEvents.TextChanged = "function(s, e) { " + "CallbackPanel" +
                                                                             Model.Id + ".PerformCallback(\"changed_" +
                                                                             column.PropertyName + "_" +
                                                                             item.GetMemberValue(
                                                                                 Model.ModelClass.KeyProperty) +
                                                                             "\"); }";
                        c.Style.Add("min-width", "130px");
                        break;
                    case "System.Int32":
                    case "System.int":
                    case "System.Int64":
                    case "System.long":
                        c = RenderHelper.CreateASPxSpinEdit();
                        ((ASPxSpinEdit) c).NumberType = SpinEditNumberType.Integer;
                        ((ASPxSpinEdit) c).DecimalPlaces = 0;
                        c.ValueChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxSpinEdit) c).ClientSideEvents.NumberChanged = "function(s, e) { " + "CallbackPanel" +
                                                                                Model.Id + ".PerformCallback(\"changed_" +
                                                                                column.PropertyName + "_" +
                                                                                item.GetMemberValue(
                                                                                    Model.ModelClass.KeyProperty) +
                                                                                "\"); }";
                        c.Style.Add("min-width", "100px");
                        break;
                    case "System.Double":
                    case "System.double":
                    case "System.Decimal":
                    case "System.decimal":
                    case "System.Nullable`1[System.Decimal]":
                        c = RenderHelper.CreateASPxSpinEdit();
                        ((ASPxSpinEdit) c).NumberType = SpinEditNumberType.Float;
                        string format = column.ModelMember.DisplayFormat;
                        if (format == "{0:C}") format = null;
                        ((ASPxSpinEdit) c).DisplayFormatString = format;
                        if (string.IsNullOrEmpty(format))
                            ((ASPxSpinEdit) c).DecimalPlaces = 2;
                        c.ValueChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxSpinEdit) c).ClientSideEvents.NumberChanged = "function(s, e) { " + "CallbackPanel" +
                                                                                Model.Id + ".PerformCallback(\"changed_" +
                                                                                column.PropertyName + "_" +
                                                                                item.GetMemberValue(
                                                                                    Model.ModelClass.KeyProperty) +
                                                                                "\"); }";
                        c.Style.Add("min-width", "100px");
                        break;
                    case "System.DateTime":
                        c = RenderHelper.CreateASPxDateEdit();
                        ((ASPxDateEdit) c).DateChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxDateEdit) c).ClientSideEvents.DateChanged = "function(s, e) { " + "CallbackPanel" +
                                                                              Model.Id + ".PerformCallback(\"changed_" +
                                                                              column.PropertyName + "_" +
                                                                              item.GetMemberValue(
                                                                                  Model.ModelClass.KeyProperty) +
                                                                              "\"); }";
                        c.Style.Add("min-width", "90px");

                        break;
                    default:
                        c = RenderHelper.CreateASPxTextBox();
                        ((ASPxTextBox) c).MaxLength = 100;
                        ((ASPxTextBox) c).TextChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxTextBox) c).ClientSideEvents.TextChanged = "function(s, e) { " + "CallbackPanel" +
                                                                             Model.Id + ".PerformCallback(\"changed_" +
                                                                             column.PropertyName + "_" +
                                                                             item.GetMemberValue(
                                                                                 Model.ModelClass.KeyProperty) +
                                                                             "\"); }";
                        c.Style.Add("min-width", "130px");
                        break;
                }
                c.Width = new Unit(100, UnitType.Percentage);
            }

            SetValueToControl(value, c);
            _controls.Add(c);

            OnControlCreated(column.PropertyName, c, item);

            return c;
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Prepare a data contract.
        /// </summary>
        /// <param name="type">The type to prepare.</param>
        /// <returns>An alias-contract pair.</returns>
        /// <exception cref="InvalidDataContractException">Type does not conform to data contract rules.
        /// For example, the DataContractAttribute attribute has not been applied to the type.</exception>
        private static KeyValuePair<string, DataContractDescriptor> PrepareDataContract(Type type)
        {
            if (type == null) throw new ArgumentNullException("type");

            try
            {
                bool isDataContract;
                var amfxType = GetAmfxType(type, out isDataContract);
                var alias = isDataContract
                    ? DataContractHelper.GetContractAlias(type)
                    : type.FullName;

                DataContractDescriptor descriptor;

                if (type.IsEnum)
                {
                    descriptor = new EnumDescriptor
                                     {
                                         Values = DataContractHelper.GetEnumValues(type)
                                     };

                }
                else
                {
                    descriptor = new DataContractDescriptor();
                }

                descriptor.Alias = alias;
                descriptor.Type = type;
                descriptor.IsPrimitive = !isDataContract;
                descriptor.AmfxType = amfxType;

                if (isDataContract)
                {
                    descriptor.FieldMap = DataContractHelper.GetContractFields(type);
                    descriptor.PropertyMap = DataContractHelper.GetContractProperties(type);
                }

                return new KeyValuePair<string, DataContractDescriptor>(alias, descriptor);
            }
            catch (Exception e)
            {
                throw new InvalidDataContractException(string.Format("Type '{0}' is not a valid data contract.", type.FullName), e);
            }
        }
Ejemplo n.º 39
0
        private ASPxEdit GetControlForColumn(IModelColumn column, XPBaseObject item)
        {
            object   value = item.GetMemberValue(column.PropertyName);
            ASPxEdit c;

            if (typeof(XPBaseObject).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType))
            {
                c = RenderHelper.CreateASPxComboBox();
                var helper = new WebLookupEditorHelper(_application, _objectSpace,
                                                       column.ModelMember.MemberInfo.MemberTypeInfo, column);

                ((ASPxComboBox)c).ClientSideEvents.KeyUp =
                    "function(s, e) { if(e.htmlEvent.keyCode == 46){ s.SetSelectedIndex(-1); } }";
                ((ASPxComboBox)c).ValueType             = column.ModelMember.MemberInfo.MemberTypeInfo.KeyMember.MemberType;
                ((ASPxComboBox)c).SelectedIndexChanged += DetailItemControlValueChanged;
                c.Style.Add("min-width", "120px");
                c.Width = new Unit(100, UnitType.Percentage);

                FillEditorValues(value, ((ASPxComboBox)c), helper, item, column.ModelMember);
                if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                {
                    ((ASPxComboBox)c).ClientSideEvents.SelectedIndexChanged = "function(s, e) { " + "CallbackPanel" +
                                                                              Model.Id + ".PerformCallback(\"changed_" +
                                                                              column.PropertyName + "_" +
                                                                              item.GetMemberValue(
                        Model.ModelClass.KeyProperty) +
                                                                              "\"); }";
                }
            }
            else if (typeof(Enum).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType))
            {
                c = RenderHelper.CreateASPxComboBox();
                ((ASPxComboBox)c).ClientSideEvents.KeyUp =
                    "function(s, e) { if(e.htmlEvent.keyCode == 46){ s.SetSelectedIndex(-1); } }";
                var descriptor = new EnumDescriptor(column.ModelMember.MemberInfo.MemberType);
                var source     = (Enum.GetValues(column.ModelMember.MemberInfo.MemberType).Cast <object>()
                                  .Select(v => new Tuple <object, string>(v, descriptor.GetCaption(v)))).ToList();
                c.DataSource = source;
                ((ASPxComboBox)c).ValueField            = "Item1";
                ((ASPxComboBox)c).TextField             = "Item2";
                ((ASPxComboBox)c).ValueType             = column.ModelMember.MemberInfo.MemberType;
                ((ASPxComboBox)c).SelectedIndexChanged += DetailItemControlValueChanged;
                c.Style.Add("min-width", "120px");
                c.Width = new Unit(100, UnitType.Percentage);
                c.Load += c_Load;
                if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                {
                    ((ASPxComboBox)c).ClientSideEvents.SelectedIndexChanged = "function(s, e) { " + "CallbackPanel" +
                                                                              Model.Id + ".PerformCallback(\"changed_" +
                                                                              column.PropertyName + "_" +
                                                                              item.GetMemberValue(
                        Model.ModelClass.KeyProperty) +
                                                                              "\"); }";
                }
            }
            else
            {
                switch (column.ModelMember.MemberInfo.MemberType.ToString())
                {
                case "System.Boolean":
                case "System.bool":
                    c = RenderHelper.CreateASPxCheckBox();
                    ((ASPxCheckBox)c).CheckedChanged += DetailItemControlValueChanged;
                    c.Style.Add("max-width", "20px");
                    if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                    {
                        ((ASPxCheckBox)c).ClientSideEvents.CheckedChanged = "function(s, e) { " + "CallbackPanel" +
                                                                            Model.Id +
                                                                            ".PerformCallback(\"changed_" +
                                                                            column.PropertyName + "_" +
                                                                            item.GetMemberValue(
                            Model.ModelClass.KeyProperty) +
                                                                            "\"); }";
                    }
                    break;

                case "System.String":
                case "System.string":
                    c = RenderHelper.CreateASPxTextBox();
                    ((ASPxTextBox)c).MaxLength = 100;
                    if (column.ModelMember.Size > 0)
                    {
                        ((ASPxTextBox)c).MaxLength = column.ModelMember.Size;
                    }
                    ((ASPxTextBox)c).TextChanged += DetailItemControlValueChanged;
                    if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                    {
                        ((ASPxTextBox)c).ClientSideEvents.TextChanged = "function(s, e) { " + "CallbackPanel" +
                                                                        Model.Id + ".PerformCallback(\"changed_" +
                                                                        column.PropertyName + "_" +
                                                                        item.GetMemberValue(
                            Model.ModelClass.KeyProperty) +
                                                                        "\"); }";
                    }
                    c.Style.Add("min-width", "130px");
                    break;

                case "System.Int32":
                case "System.int":
                case "System.Int64":
                case "System.long":
                    c = RenderHelper.CreateASPxSpinEdit();
                    ((ASPxSpinEdit)c).NumberType    = SpinEditNumberType.Integer;
                    ((ASPxSpinEdit)c).DecimalPlaces = 0;
                    c.ValueChanged += DetailItemControlValueChanged;
                    if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                    {
                        ((ASPxSpinEdit)c).ClientSideEvents.NumberChanged = "function(s, e) { " + "CallbackPanel" +
                                                                           Model.Id + ".PerformCallback(\"changed_" +
                                                                           column.PropertyName + "_" +
                                                                           item.GetMemberValue(
                            Model.ModelClass.KeyProperty) +
                                                                           "\"); }";
                    }
                    c.Style.Add("min-width", "100px");
                    break;

                case "System.Double":
                case "System.double":
                case "System.Decimal":
                case "System.decimal":
                case "System.Nullable`1[System.Decimal]":
                    c = RenderHelper.CreateASPxSpinEdit();
                    ((ASPxSpinEdit)c).NumberType = SpinEditNumberType.Float;
                    string format = column.ModelMember.DisplayFormat;
                    if (format == "{0:C}")
                    {
                        format = null;
                    }
                    ((ASPxSpinEdit)c).DisplayFormatString = format;
                    if (string.IsNullOrEmpty(format))
                    {
                        ((ASPxSpinEdit)c).DecimalPlaces = 2;
                    }
                    c.ValueChanged += DetailItemControlValueChanged;
                    if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                    {
                        ((ASPxSpinEdit)c).ClientSideEvents.NumberChanged = "function(s, e) { " + "CallbackPanel" +
                                                                           Model.Id + ".PerformCallback(\"changed_" +
                                                                           column.PropertyName + "_" +
                                                                           item.GetMemberValue(
                            Model.ModelClass.KeyProperty) +
                                                                           "\"); }";
                    }
                    c.Style.Add("min-width", "100px");
                    break;

                case "System.DateTime":
                    c = RenderHelper.CreateASPxDateEdit();
                    ((ASPxDateEdit)c).DateChanged += DetailItemControlValueChanged;
                    if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                    {
                        ((ASPxDateEdit)c).ClientSideEvents.DateChanged = "function(s, e) { " + "CallbackPanel" +
                                                                         Model.Id + ".PerformCallback(\"changed_" +
                                                                         column.PropertyName + "_" +
                                                                         item.GetMemberValue(
                            Model.ModelClass.KeyProperty) +
                                                                         "\"); }";
                    }
                    c.Style.Add("min-width", "90px");

                    break;

                default:
                    c = RenderHelper.CreateASPxTextBox();
                    ((ASPxTextBox)c).MaxLength    = 100;
                    ((ASPxTextBox)c).TextChanged += DetailItemControlValueChanged;
                    if (column.ModelMember.MemberInfo.FindAttribute <ImmediatePostDataAttribute>() != null)
                    {
                        ((ASPxTextBox)c).ClientSideEvents.TextChanged = "function(s, e) { " + "CallbackPanel" +
                                                                        Model.Id + ".PerformCallback(\"changed_" +
                                                                        column.PropertyName + "_" +
                                                                        item.GetMemberValue(
                            Model.ModelClass.KeyProperty) +
                                                                        "\"); }";
                    }
                    c.Style.Add("min-width", "130px");
                    break;
                }
                c.Width = new Unit(100, UnitType.Percentage);
            }

            SetValueToControl(value, c);
            _controls.Add(c);

            OnControlCreated(column.PropertyName, c, item);

            return(c);
        }
Ejemplo n.º 40
0
 public void ParseIgnoreCase(object expected, string value)
 {
     Assert.AreEqual(expected, EnumDescriptor.Parse(typeof(TestEnum), value, true));
 }
Ejemplo n.º 41
0
 public ASPxRadioButtonEditor(Type objectType, IModelMemberViewItem info)
     : base(objectType, info)
 {
     this.enumDescriptor = new EnumDescriptor(MemberInfo.MemberType);
 }
        /// <summary>
        /// Метод получает необходимые данные пациента из БД
        /// </summary>
        private PatientData GetFromExamination(IExamination examination)
        {
            string examinationCode = examination.ObjectCode.TrimStart(new char[] { '0' });
            string patientCode = examination.Patient.ObjectCode.TrimStart(new char[] { '0' });
            string patientFullName = examination.Patient.FullName;

            string patientTitleName = String.Format("[{0} {1}] {2}", examinationCode, patientCode, patientFullName);

            EnumDescriptor descriptor = new EnumDescriptor(typeof(DomainComponents.Common.Gender));
            string gender = descriptor.GetCaption(examination.Patient.Gender);
            DateTime timeStart = examination.TimeStart;

            return new PatientData()
            {

                FullName = patientTitleName,//examination.Patient.FullName,
                Birthday = examination.Patient.Birthday,
                Gender = gender,//Enum.GetName(typeof(DomainComponents.Common.Gender), examination.Patient.Gender), //String.Format(@"Enums\DomainComponents.Common.Gender", examination.Patient.Gender),
                Address = examination.Patient.RegistrationAddress != null ?
                    examination.Patient.RegistrationAddress.Address : String.Empty,
                //Phone = examination.Patient.MainPhoneNumber,
                Document = String.Format("{0} {1}", examination.Patient.IdentityCardType != null ?
                        examination.Patient.IdentityCardType.DocumentName : String.Empty, examination.Patient.IdentifyCardInfo).Replace(Environment.NewLine, " "),
                //Document = String.Format("{0}" + "%" + "{1}", examination.Patient.Passport.IdentityCardType != null ?
                //    examination.Patient.Passport.IdentityCardType.DocumentName : String.Empty, examination.Patient.Passport.IdentifyCardInfo), // х.з зачем было через "%"

                TimeStart = examination.TimeStart
            };
        }
        private void CreateRowForObject(XPBaseObject item, bool focusFirstControl, int rowindex){
            _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)] = new List<TableRow>();
            var headerRowsForItem = new List<TableRow>();
            if (!HeadersOnTopOnly){
                headerRowsForItem = CreateHeaderRows(item, rowindex);
                _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].AddRange(headerRowsForItem);
            }

            if (_btnAddFirst != null)
                _btnAddFirst.Visible = false;

            TableRow tr = null;

            var controlsOfRowPerColumn = new Dictionary<string, ASPxEdit>();

            int i = 0;
            int headerrowsadded = 0;
            bool firstControlFocused = false;
            foreach (IModelColumn column in Model.Columns){
                if (column.Index >= 0){
                    if (i%ColumnsPerRow == 0){
                        if (headerRowsForItem.Count > headerrowsadded){
                            _table.Rows.Add(headerRowsForItem[headerrowsadded]);
                            headerrowsadded++;
                        }
                        tr = new TableRow{CssClass = rowindex%2 == 0 ? "evenrow" : "oddrow"};
                        _table.Rows.Add(tr);
                        _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].Add(tr);
                    }
                    i++;

                    var tc = new TableCell();
                    if (tr != null) tr.Cells.Add(tc);

                    if (!AllowEdit){
                        object itemGetMemberValue = item.GetMemberValue(column.PropertyName);
                        if (itemGetMemberValue == null)
                            tc.Text = "";
                        else if (itemGetMemberValue is XPBaseObject){
                            ITypeInfo typeInfo =
                                XafTypesInfo.Instance.FindTypeInfo(
                                    (itemGetMemberValue as XPBaseObject).ClassInfo.ClassType);
                            if (typeInfo.DefaultMember != null){
                                object defMembVal =
                                    (itemGetMemberValue as XPBaseObject).GetMemberValue(typeInfo.DefaultMember.Name);
                                tc.Text = defMembVal != null ? defMembVal.ToString() : "";
                            }
                            else
                                tc.Text = itemGetMemberValue.ToString();
                        }
                        else if (itemGetMemberValue is Enum){
                            {
                                string caption =
                                    new EnumDescriptor(column.ModelMember.MemberInfo.MemberType).GetCaption(
                                        itemGetMemberValue);
                                tc.Text = string.IsNullOrEmpty(column.DisplayFormat)
                                    ? caption
                                    : string.Format(column.DisplayFormat, caption);
                            }
                        }
                        else{
                            if (!string.IsNullOrEmpty(column.DisplayFormat)){
                                tc.Text = string.Format(column.DisplayFormat, itemGetMemberValue);
                            }
                            else if (itemGetMemberValue is decimal){
                                tc.Text = string.Format("{0:C2}", itemGetMemberValue);
                            }
                            else
                                tc.Text = itemGetMemberValue.ToString();
                        }

                        tc.CssClass = "StaticText";
                    }
                    else{
                        ASPxEdit cellControl = GetControlForColumn(column, item);
                        if (!column.AllowEdit)
                            cellControl.Enabled = false;

                        //handle control width
                        int tableColumns = Math.Max(Model.Columns.Count(c => c.Index >= 0), ColumnsPerRow);
                        if (cellControl is ASPxCheckBox){
                            tc.Width = new Unit(1, UnitType.Percentage);
                        }
                        else if (tableColumns>0){
                            var value = 100/tableColumns;
                            tc.Width = new Unit(value, UnitType.Percentage);
                        }

                        cellControl.ID = column.PropertyName + "_control_" +
                                         item.GetMemberValue(Model.ModelClass.KeyProperty)
                                             .ToString()
                                             .Replace("-", "_minus_");
                        cellControl.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithTooltip;
                        cellControl.ValidationSettings.Display = Display.Dynamic;
                        cellControl.ValidationSettings.ErrorTextPosition = ErrorTextPosition.Left;
                        cellControl.ValidationSettings.ErrorImage.Url =
                            ImageLoader.Instance.GetImageInfo("ximage").ImageUrl;

                        controlsOfRowPerColumn.Add(column.PropertyName, cellControl);
                        _baseObjectsHandledByControl[cellControl] = new Tuple<XPBaseObject, string>(item,
                            column.PropertyName);

                        tc.Controls.Add(cellControl);

                        if (focusFirstControl && !firstControlFocused){
                            cellControl.Focus();
                            firstControlFocused = true;
                        }
                    }
                    OnCustomizeAppearance(new CustomizeAppearanceEventArgs(column.PropertyName,
                        new WebControlAppearanceAdapter(tc, tc), item));
                }
            }

            if (tr == null){
                tr = new TableRow{CssClass = rowindex%2 == 0 ? "evenrow" : "oddrow"};
                _table.Rows.Add(tr);
                _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].Add(tr);
            }

            var tcButtons = new TableCell{Wrap = false, Width = new Unit(1, UnitType.Percentage)};

            if (i%ColumnsPerRow != 0){
                tcButtons.ColumnSpan = ColumnsPerRow - i%ColumnsPerRow;
            }
            else{
                tr = new TableRow{CssClass = rowindex%2 == 0 ? "evenrow" : "oddrow"};
                _table.Rows.Add(tr);
                _rowsPerObject[item.GetMemberValue(Model.ModelClass.KeyProperty)].Add(tr);
                //a new row will be created and the whole row will be the buttons
                tcButtons.ColumnSpan = ColumnsPerRow;
            }

            tr.Cells.Add(tcButtons);

            var tblButtons = new Table();
            tcButtons.Controls.Add(tblButtons);
            var btnsrow = new TableRow();
            tblButtons.Rows.Add(btnsrow);

            if (AllowEdit && ShowButtons){
                var btnRemove = new ASPxButton{AutoPostBack = false, EnableClientSideAPI = true};

                btnRemove.SetClientSideEventHandler("Click",
                    "function(s, e) { " + "CallbackPanel" + Model.Id + ".PerformCallback(\"rem_" +
                    item.GetMemberValue(Model.ModelClass.KeyProperty) + "\"); }");
                btnRemove.Text = DeleteButtonCaption;
                btnRemove.ID = "btnRemove_" + item.GetMemberValue(Model.ModelClass.KeyProperty);

                var t = new TableCell();
                btnsrow.Cells.Add(t);
                t.Controls.Add(btnRemove);
            }

            if (AllowEdit && ShowButtons){
                var btnAdd = new ASPxButton{AutoPostBack = false, EnableClientSideAPI = true};

                btnAdd.SetClientSideEventHandler("Click",
                    "function(s, e) { " + "CallbackPanel" + Model.Id + ".PerformCallback(\"add\"); }");
                btnAdd.Text = AddButtonCaption;
                btnAdd.ID = "btnAdd_" + item.GetMemberValue(Model.ModelClass.KeyProperty);

                var t = new TableCell();
                btnsrow.Cells.Add(t);
                t.Controls.Add(btnAdd);
            }
            _controlsPerObjectInList[item.GetMemberValue(Model.ModelClass.KeyProperty)] = controlsOfRowPerColumn;
        }
Ejemplo n.º 44
0
 public CheckboxEnumPropertyEditor(Type objectType, IModelMemberViewItem info)
     : base(objectType, info) {
     enumDescriptor = new EnumDescriptor(MemberInfo.MemberType);
 }
Ejemplo n.º 45
0
 public CheckboxEnumPropertyEditor(Type objectType, IModelMemberViewItem info)
     : base(objectType, info)
 {
     _enumDescriptor = new EnumDescriptor(MemberInfo.MemberType);
 }
 public override string ToString() {
     var enumDescriptor = new EnumDescriptor(typeof(ApplicationModelCombineModifier));
     return CaptionHelper.GetClassCaption(GetType().FullName) + " (" + enumDescriptor.GetCaption(Modifier) + "," + Difference + ")";
 }
Ejemplo n.º 47
0
        protected override string GetPermissionInfoCaption()
        {
            var enumDescriptor = new EnumDescriptor(typeof(ApplicationModelCombineModifier));

            return(CaptionHelper.GetClassCaption(GetType().FullName) + " (" + enumDescriptor.GetCaption(Modifier) + ")");
        }
Ejemplo n.º 48
0
        /// <summary>
        /// Получаем данные из БД для записи в шаблон
        /// </summary>
        public Dictionary<string, string> GetExaminationData(IExamination examination, IOrganization organization)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            AddText("DEVICE", "", dictionary);//DEVICE

            ExaminationSoftType softType = examination.ExaminationSoftType;
            if (softType != null)
            {
                AddText("EXAMINATION_SOFT_TYPE", softType.Name, dictionary);//ExaminationSoftType
            }

            FileSystemStoreObject examilationFile = examination.ExaminationFile;
            if (examilationFile != null)
            {
                AddText("FILE_NAME", examilationFile.FileName, dictionary);//FILE_NAME
            }

            IPatient patient = examination.Patient;
            if (patient != null)
            {
                //AddText("пациент_полное_имя", CommonData.RTFData.GetRTFString(patient.FullName), dictionary);//PATIENT_FULLNAME
                AddText("PATIENT_CODE", RTFData.GetRTFString(patient.RegCode), dictionary);//PATIENT_CODE
                AddText("PATIENT_FULLNAME", RTFData.GetRTFString(patient.FullName), dictionary);//PATIENT_FULLNAME
                AddText("DOB", RTFData.GetRTFString(patient.Birthday.ToString("dd/MM/yyyy")), dictionary);//DOB

                EnumDescriptor descriptor = new EnumDescriptor(typeof(DomainComponents.Common.Gender));
                string gender = descriptor.GetCaption(patient.Gender);
                AddText("GENDER", RTFData.GetRTFString(gender), dictionary);//GENDER

                AddText("ADDRESS", RTFData.GetRTFString(patient.RegistrationAddress.Address), dictionary);//ADDRESS

                AddText("PHONE", RTFData.GetRTFString(patient.MainPhone), dictionary);//PHONE
                AddText("JOB", RTFData.GetRTFString(patient.JobTitle), dictionary);//JOB

                AddText("DOCUMENT", RTFData.GetRTFString(patient.IdentifyCardInfo), dictionary);//DOCUMENT
                AddText("HISTORY", RTFData.GetRTFString(patient.DiseaseHistory), dictionary);//HISTORY

                AddText("AGE", RTFData.GetRTFString(patient.Age), dictionary);//AGE

                AddPicture("PHOTO_PICTURE", patient.Photo, dictionary); // PHOTO
            }

            AddText("REG_DATE", RTFData.GetRTFString(examination.RegDate.ToString("dd.MM.yyyy")), dictionary);//DATE
            AddText("REG_TIME", RTFData.GetRTFString(examination.RegDate.ToString("HH:mm")), dictionary);//TIME
            AddText("DIAGNOSIS", RTFData.GetRTFString(examination.Diagnosis), dictionary);//DIAGNOSIS
            AddText("EXAMINER_FULLNAME", RTFData.GetRTFString(examination.Examiner.UserName), dictionary);//EXAMINER

            if (organization != null)
            {
                AddPicture("LOGO_PICTURE", organization.Logo, dictionary); //LOGO
                AddText("ORGANIZATION_NAME", organization.OrganizationName, dictionary);//ORGANIZATION_NAME
            }

            Employee currentUser = SecuritySystem.CurrentUser as Employee;
            if (currentUser != null)
            {
                AddText("CURRENT_USER", RTFData.GetRTFString(currentUser.UserName), dictionary);// CURRENT_USER
            }

            AddText("DATETIME_NOW", RTFData.GetRTFString(DateTime.Now.ToString("dd.MM.yyyy HH:mm")), dictionary); //DATETIME_NOW

            return dictionary;
        }
        public override string ToString()
        {
            var enumDescriptor = new EnumDescriptor(typeof(ApplicationModelCombineModifier));

            return(CaptionHelper.GetClassCaption(GetType().FullName) + " (" + enumDescriptor.GetCaption(Modifier) + "," + Difference + ")");
        }
Ejemplo n.º 50
0
 public void Generic_EnumDescription()
 {
     Assert.AreEqual(TESTENUM, EnumDescriptor.GetDescription <TestEnum>());
 }
 public ICollection <LookUpModel> GetLookups <TEnum>(EnumDescriptor enumDescriptor) where TEnum : IConvertible
 {
     return(_lookUpModels.Where(s => s.SchemaName == enumDescriptor.SchemaName && s.TableName == enumDescriptor.TableName).ToList());
 }
 protected override string GetPermissionInfoCaption() {
     var enumDescriptor = new EnumDescriptor(typeof(ApplicationModelCombineModifier));
     return CaptionHelper.GetClassCaption(GetType().FullName) + " (" + enumDescriptor.GetCaption(Modifier) + ")";
 }
Ejemplo n.º 53
0
 public static Typ Of(EnumDescriptor desc) => desc.ContainingType == null?
 Manual(desc.File.CSharpNamespace(), desc.Name, isEnum : true) :
     Nested(Nested(Of(desc.ContainingType), "Types"), desc.Name, isEnum: true);
Ejemplo n.º 54
0
 public override int AsEnum(EnumDescriptor es)
 {
     var ev = (int)GetVarInt();
     // todo: should we check if it is valid enum value.
     return ev;
 }