Пример #1
0
		/// <summary>
		/// Copies the elements of the specified <see cref="EnumValue">EnumValue</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="EnumValue">EnumValue</see> containing the Components to add to the collection.</param>
		public void AddRange(EnumValue[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
Пример #2
0
 public GameRules(uint id, Client client) : base(id, client) {
     GameState = bindE<GameState>("DT_DOTAGamerules", "m_nGameState");
     GameTime = bind<float>("DT_DOTAGamerules", "m_fGameTime");
     HeroPickState = bind<uint>("DT_DOTAGamerules", "m_nHeroPickState");
     HeroPickStateTransitionTime = bind<float>("DT_DOTAGamerules", "m_flHeroPickStateTransitionTime");
     PreGameStartTime = bind<float>("DT_DOTAGamerules", "m_flPreGameStartTime");
 }
        public string GetCellValue(OpenXmlPartContainer wbPart, EnumValue<CellValues> dataType, string value)
        {
            if (dataType != null)
            {
                switch (dataType.Value)
                {
                    case CellValues.SharedString:
                        var stringTable = wbPart.GetPartsOfType<SharedStringTablePart>().FirstOrDefault();
                        if (stringTable != null)
                        {
                            value = stringTable.SharedStringTable.ElementAt(int.Parse(value)).InnerText;
                        }
                        break;

                    case CellValues.Boolean:
                        switch (value)
                        {
                            case "0":
                                value = "False";
                                break;
                            default:
                                value = "True";
                                break;
                        }
                        break;
                }

            }

            return value;
        }
		public void CanUseEnumConstructorTest()
		{
			// Arrange
			var enumValue = new EnumValue<TestEnum>((Enum) Enum.Parse(typeof(TestEnum), "Value4"));

			// Assert
			Assert.AreEqual(TestEnum.Value4, enumValue.Value);
		}
        private EnumValue GetValue(EnumValue value)
        {
            foreach (EnumValue myValue in PossibleValues.Where(myValue => myValue.Equals(value)))
            {
                return myValue;
            }

            throw new ArgumentException("EnumValue is not contained in this enum.");
        }
 public GeneralTransferCorrectionSeller()
 {
     ExecutedFunction = new EnumValue
     {
         Code = 4,
         Name = "InvoiceAndTransferCorrection",
         Description = "КСЧФДИС"
     };
 }
 internal EnumValueCollection(EnumValueCollection other)
 {
     m_possibleValues = new List<EnumValue>();
     foreach(EnumValue val in other.m_possibleValues)
     {
         EnumValue newVal = new EnumValue();
         newVal.Value = val.Value;
         m_possibleValues.Add(newVal);
     }
     m_currentValue = GetValue(other.m_currentValue);
     m_sourceEnum = other.m_sourceEnum;
 }
Пример #8
0
 public override MetaField CloneValue()
 {
     EnumData result = new EnumData(Name, Offset, FieldAddress, _type, _value, base.PluginLine);
     foreach (EnumValue option in Values)
     {
         EnumValue copiedValue = new EnumValue(option.Name, option.Value);
         result.Values.Add(copiedValue);
         if (_selectedValue != null && copiedValue.Value == _selectedValue.Value)
             result._selectedValue = copiedValue;
     }
     return result;
 }
Пример #9
0
        public bool Equals(EnumValue other)
        {
            if (other != null && Value != null)
            {
                return Value.Equals(other.Value);
            }
            else if (other != null && Value == null && other.Value == null)
            {
                return true;
            }

            return false;
        }
Пример #10
0
		/// <exception cref="ReservedNameException">
		/// The name is a reserved name.
		/// </exception>
		protected void AddValue(EnumValue newValue)
		{
			if (newValue != null) {
				foreach (EnumValue value in Values) {
					if (value.Name == newValue.Name)
						throw new ReservedNameException(newValue.Name);
				}

				values.Add(newValue);
				newValue.Modified += delegate { Changed(); };
				Changed();
			}
		}
 internal EnumValueCollection(Type enumType)
 {
     if (enumType.IsEnum)
     {
         m_possibleValues = new List<EnumValue>();
         foreach (string val in enumType.GetEnumNames())
         {
             EnumValue newVal = new EnumValue();
             newVal.Value = val;
             m_possibleValues.Add(newVal);
         }
         m_currentValue = m_possibleValues[0];
         m_sourceEnum = enumType.GetTraceLabQualifiedName();
     }
 }
Пример #12
0
        internal void Set(EnumValue enumValue)
        {
            ignore_changes = true;
            Items.Clear();

            if (enumValue.Items == null || enumValue.Items.Count == 0)
            {
                if (enumValue.EnumType != null)
                {
                    if (enumValue.Items == null)
                        enumValue.Items = new Dictionary<int,string>();
                    else
                        enumValue.Items.Clear();

                    foreach (Enum x in Enum.GetValues(enumValue.EnumType))
                    {
                        int value = (int)Convert.ChangeType(x, typeof(int));
                        if(!enumValue.Items.ContainsKey(value))
                            enumValue.Items.Add(value, x.ToString());
                    }
                }
            }

            if (enumValue.Items != null && enumValue.Items.Count > 0)
            {
                int idx = -1;
                foreach (KeyValuePair<int,string> pair in enumValue.Items)
                {
                    idx++;
                    ComboBoxEnumItem li = new ComboBoxEnumItem(pair.Value, pair.Key);
                    Items.Add(li);
                    if (enumValue.ValueInt == pair.Key)
                        SelectedIndex = idx;
                }
            }
            ignore_changes = false;
        }
Пример #13
0
		public EnumDescriptor (XmlElement elem)
		{
			string cls = elem.GetAttribute ("type");
			enumType = Registry.GetType (cls, true);
			this.name = enumType.FullName;
			
			values = new Hashtable ();

			// This gets the list of enum names and gets the value of each of them.
			// This is not done the other way (get the values, and then the names from them)
			// because it won't work if two different enum members have the same value
			ArrayList list = new ArrayList ();
			Hashtable evalues = new Hashtable ();
			foreach (string name in Enum.GetNames (enumType)) {
				object value = Enum.Parse (enumType, name);
				list.Add (value);
				evalues[name] = value;
			}

			foreach (XmlElement valueElem in elem.SelectNodes ("value")) {
				string name = valueElem.GetAttribute ("name");
				if (!evalues.Contains (name))
					throw new ArgumentException ("<enum> node for " + enumType.FullName + " contains extra element " + name);
				Enum value = (Enum)evalues[name];
				values[value] = new EnumValue (value,
							       valueElem.GetAttribute ("label"),
							       valueElem.GetAttribute ("description"));
				evalues.Remove (name);
			}
			
			// Remove from the array the values not declared in the xml file
			foreach (object val in evalues.Values)
				list.Remove (val);

			values_array = (Enum[]) list.ToArray (typeof(Enum));
		}
Пример #14
0
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(EnumValue[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
Пример #15
0
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="EnumValueCollection">EnumValueCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="EnumValueCollection">EnumValueCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(EnumValue value) 
		{
			return this.List.Contains(value);
		}
Пример #16
0
		public int Add(EnumValue value) 
		{
			return this.List.Add(value);
		}
Пример #17
0
        //public void SetEffectExtent(long topEdge, long bottomEdge, long leftEdge, long rightEdge)
        //{
        //    _effectExtent = new DW.EffectExtent() { TopEdge = topEdge, BottomEdge = bottomEdge, LeftEdge = leftEdge, RightEdge = rightEdge };
        //}

        public void SetRelativeWidth(EnumValue<DW2010.SizeRelativeHorizontallyValues> relativeFrom, int percentageWidth)
        {
            _relativeWidth = new DW2010.RelativeWidth();
            // <wp14:sizeRelH relativeFrom>
            _relativeWidth.ObjectId = relativeFrom;
            // PercentageWidth, child <wp14:pctWidth>
            _relativeWidth.PercentageWidth = new DW2010.PercentageWidth(percentageWidth.ToString());
        }
Пример #18
0
        public void SetHorizontalPosition(EnumValue<DW.HorizontalRelativePositionValues> relativeFrom, long? positionOffset, string horizontalAlignment = null, string percentagePositionHeightOffset = null)
        {
            // Horizontal Positioning
            // <wp:positionH relativeFrom="margin">
            //   <wp:posOffset>-38099</wp:posOffset>
            // </wp:positionH>
            // <wp:positionH relativeFrom="margin">
            //   <wp:align>left</wp:align>
            // </wp:positionH>
            // Horizontal Alignment (Ecma Office Open XML Part 1 - Fundamentals And Markup Language Reference.pdf - 20.4.3.1 page 3145)
            //   left, right, center, inside, outside

            _horizontalPosition = new DW.HorizontalPosition();
            // Horizontal Position Relative Base, <wp:positionH relativeFrom>
            // Margin - Page Margin ("margin"), Page - Page Edge ("page"), Column - Column ("column"), Character - Character ("character"), LeftMargin - Left Margin ("leftMargin"), RightMargin - Right Margin ("rightMargin")
            // InsideMargin - Inside Margin ("insideMargin"), OutsideMargin - Outside Margin ("outsideMargin")
            _horizontalPosition.RelativeFrom = relativeFrom;

            if (positionOffset != null)
                // Absolute Position Offset, <wp:posOffset>
                _horizontalPosition.PositionOffset = new DW.PositionOffset(positionOffset.ToString());

            if (horizontalAlignment != null)
                // Relative Horizontal Alignment, <wp:align>
                _horizontalPosition.HorizontalAlignment = new DW.HorizontalAlignment(horizontalAlignment);

            if (percentagePositionHeightOffset != null)
                // PercentagePositionHeightOffset, <wp14:pctPosHOffset>, available in Office2010 or above
                _horizontalPosition.PercentagePositionHeightOffset = new DW2010.PercentagePositionHeightOffset(percentagePositionHeightOffset);
        }
Пример #19
0
		private void DrawItem(IGraphics g, EnumValue value, Rectangle record, Style style)
		{
			Font font = GetFont(style);
			string memberString = value.ToString();
			itemBrush.Color = style.EnumItemColor;

			if (style.UseIcons)
			{
				Image icon = Properties.Resources.EnumItem;
				g.DrawImage(icon, record.X, record.Y);

				Rectangle textBounds = new Rectangle(
					record.X + IconSpacing, record.Y,
					record.Width - IconSpacing, record.Height);

				g.DrawString(memberString, font, itemBrush, textBounds, memberFormat);
			}
			else
			{
				g.DrawString(memberString, font, itemBrush, record, memberFormat);
			}
		}
Пример #20
0
		public void RemoveValue(EnumValue value)
		{
			if (values.Remove(value))
				Changed();
		}
Пример #21
0
        /// <summary>
        /// Banned heros
        /// </summary>
        //todo: public RangeValue<uint> BannedHeros; 

        /// <summary>
        /// Selected heros
        /// </summary>
        //todo: public RangeValue<uint> SelectedHeros; 

        #endregion


        public GameRules(uint id, DotaGameState state) : base(id, state)
        {
            const string t = "DT_DOTAGamerules";

            GameState = bindE<DOTA_GameState>(t, "m_nGameState");
            GameTime = bind<float>(t, "m_fGameTime");
            GameStartTime = bind<float>(t, "m_flGameStartTime");
            GameEndTime = bind<float>(t, "m_flGameEndTime");
            PreGameStartTime = bind<float>(t, "m_flPreGameStartTime");
            //MatchID = bind<ulong>(t, "m_unMatchID"); broken
            GameMode = bindE<DOTA_GameMode>(t, "m_nGameState");
            PauseTeam = bindE<DOTA_ServerTeam>(t, "m_iPauseTeam");
            GameWinner = bindE<DOTA_ServerTeam>(t, "m_nGameWinner");
            NetTimeOfDay = bind<ulong>(t, "m_iNetTimeOfDay");
            DraftStartingTeam = bindE<DOTA_ServerTeam>(t, "m_iStartingTeam");
            DraftActiveTeam = bindE<DOTA_ServerTeam>(t, "m_iActiveTeam");
            HeroPickState = bindE<DOTA_HeroPickState>(t, "m_nHeroPickState");
            //ExtraTimeRemaining = bind<float>(t, "m_fExtraTimeRemaining"); broken

            //todo: BannedHeros = range<uint>("m_BannedHeroes", )
            //todo: handle m_nGGTeam and m_flGGEndsAtTime
        }
Пример #22
0
		/// <exception cref="BadSyntaxException">
		/// The name does not fit to the syntax.
		/// </exception>
		/// <exception cref="ReservedNameException">
		/// The name is a reserved name.
		/// </exception>
		public abstract EnumValue ModifyValue(EnumValue value, string declaration);
        public DynamicReconfigureStringDropdown(DynamicReconfigureInterface dynamic, ParamDescription pd, object def, object max, object min, string edit_method)
        {
            this.def = def;
            this.max = max;
            this.min = min;
            this.edit_method = edit_method.Replace("'enum'", "'Enum'");
            Dictionary<string, string> parsed = EnumParser.Parse(this.edit_method);
            string[] vals = parsed["Enum"].Split(new[] {'}'}, StringSplitOptions.RemoveEmptyEntries);
            List<Dictionary<string, string>> descs = vals.Select(s => EnumParser.SubParse(s + "}")).ToList();
            descs = descs.Except(descs.Where(d => d.Count == 0)).ToList();
            enumdescription = new EnumDescription();
            enumdescription.Enum = new EnumValue[descs.Count];
            enumdescription.enum_description = parsed["enum_description"];
            Type tdesc = typeof (EnumValue);

            for (int i = 0; i < descs.Count; i++)
            {
                Dictionary<string, string> desc = descs[i];
                EnumValue newval = new EnumValue();
                foreach (string s in desc.Keys)
                {
                    FieldInfo fi = tdesc.GetField(s);
                    if (fi.FieldType == typeof (int))
                        fi.SetValue(newval, int.Parse(desc[s]));
                    else
                        fi.SetValue(newval, desc[s]);
                }
                enumdescription.Enum[i] = newval;
            }
            name = pd.name.data;
            this.dynamic = dynamic;
            InitializeComponent();
            for (int i = 0; i < enumdescription.Enum.Length; i++)
            {
                if (!types.ContainsKey(enumdescription.Enum[i].type))
                {
                    throw new Exception("HANDLE " + enumdescription.Enum[i].type);
                }
                switch (types[enumdescription.Enum[i].type])
                {
                    case DROPDOWN_TYPE.INT:
                    {
                        ComboBoxItem cbi = new ComboBoxItem {Tag = int.Parse(enumdescription.Enum[i].value), Content = enumdescription.Enum[i].name, ToolTip = new ToolTip {Content = enumdescription.Enum[i].description + " (" + enumdescription.Enum[i].value + ")"}};
                        @enum.Items.Add(cbi);
                        if (i == 0)
                        {
                            @enum.SelectedValue = this.def;
                            dynamic.Subscribe(name, (Action<int>) changed);
                        }
                        else if (enumdescription.Enum[i].type != enumdescription.Enum[i - 1].type)
                            throw new Exception("NO CHANGSIES MINDSIES");
                    }
                        break;
                    case DROPDOWN_TYPE.STR:
                    {
                        ComboBoxItem cbi = new ComboBoxItem {Tag = enumdescription.Enum[i].value, Content = enumdescription.Enum[i].name, ToolTip = new ToolTip {Content = enumdescription.Enum[i].description}};
                        @enum.Items.Add(cbi);
                        if (i == 0)
                        {
                            @enum.SelectedValue = this.def;
                            dynamic.Subscribe(name, (Action<string>) changed);
                        }
                        else if (enumdescription.Enum[i].type != enumdescription.Enum[i - 1].type)
                            throw new Exception("NO CHANGSIES MINDSIES");
                    }
                        break;
                }
            }
            description.Content = name + ":";
            JustTheTip.Content = pd.description.data;
            ignore = false;
        }
Пример #24
0
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="EnumValueCollection">EnumValueCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="EnumValueCollection">EnumValueCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(EnumValue value) 
		{
			return this.List.IndexOf(value);
		}
Пример #25
0
        public void SetVerticalPosition(EnumValue<DW.VerticalRelativePositionValues> relativeFrom, long? positionOffset, string verticalAlignment = null, string percentagePositionVerticalOffset = null)
        {
            // <wp:positionV relativeFrom="paragraph">
            //   <wp:posOffset>723900</wp:posOffset>
            // </wp:positionV>
            // <wp:positionV relativeFrom="line">
            //   <wp:align>top</wp:align>
            // </wp:positionV>
            // Vertical Alignment (Ecma Office Open XML Part 1 - Fundamentals And Markup Language Reference.pdf - 20.4.3.2 page 3146)
            //   top, bottom, center, inside, outside

            // Vertical Positioning
            _verticalPosition = new DW.VerticalPosition();
            // Vertical Position Relative Base, <wp:positionV relativeFrom>
            _verticalPosition.RelativeFrom = relativeFrom;

            if (positionOffset != null)
                // PositionOffset, <wp:posOffset>
                _verticalPosition.PositionOffset = new DW.PositionOffset(positionOffset.ToString());

            if (verticalAlignment != null)
                // Relative Vertical Alignment, <wp:align>
                _verticalPosition.VerticalAlignment = new DW.VerticalAlignment(verticalAlignment);

            if (percentagePositionVerticalOffset != null)
                // PercentagePositionVerticalOffset <wp14:pctPosVOffset>, available in Office2010 or above
                _verticalPosition.PercentagePositionVerticalOffset = new DW2010.PercentagePositionVerticalOffset(percentagePositionVerticalOffset);
        }
Пример #26
0
		public void Insert(int index, EnumValue value)	
		{
			List.Insert(index, value);
		}
Пример #27
0
 public void SetRelativeHeight(EnumValue<DW2010.SizeRelativeVerticallyValues> relativeFrom, int percentageHeight)
 {
     _relativeHeight = new DW2010.RelativeHeight();
     // <wp14:sizeRelV relativeFrom>
     _relativeHeight.RelativeFrom = relativeFrom;
     // PercentageHeight, child <wp14:pctHeight>
     _relativeHeight.PercentageHeight = new DW2010.PercentageHeight(percentageHeight.ToString());
 }
Пример #28
0
		public void Remove(EnumValue value) 
		{
			List.Remove(value);
		}
Пример #29
0
        public void VisitEnum(EnumData field)
        {
            SeekToOffset(field.Offset);
            switch (field.Type)
            {
                case EnumType.Enum8:
                    field.Value = (int)_reader.ReadSByte();
                    break;
                case EnumType.Enum16:
                    field.Value = (int)_reader.ReadInt16();
                    break;
                case EnumType.Enum32:
                    field.Value = _reader.ReadInt32();
                    break;
            }

            // Search for the corresponding option and select it
            EnumValue selected = null;
            foreach (EnumValue option in field.Values)
            {
                if (option.Value == field.Value)
                    selected = option;
            }
            if (selected == null)
            {
                // Nothing matched, so just add an option for it
                selected = new EnumValue(field.Value.ToString(), field.Value);
                field.Values.Add(selected);
            }
            field.SelectedValue = selected;
        }
Пример #30
0
		/// <summary>
		/// Initializes a new instance of the <see cref="EnumValueCollection">EnumValueCollection</see> class containing the specified array of <see cref="EnumValue">EnumValue</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="EnumValue">EnumValue</see> Components with which to initialize the collection. </param>
		public EnumValueCollection(EnumValue[] value)
		{
			this.AddRange(value);
		}