public TableOptionCommonData(ushort objno,
                              string name,
                              string nameEn,
                              ItemType itype,
                              OptionBaseType obType,
                              uint start,
                              uint end,
                              OptionType otype,
                              float commonFloat,
                              int aBState,
                              int race,
                              bool isPlus,
                              string desc,
                              string descEn)
 {
     ObjNo         = objno;
     DName         = name;
     DNameEn       = nameEn;
     IType         = itype;
     ObType        = obType;
     Start         = start;
     End           = end;
     OpType        = otype;
     CommonFloat   = commonFloat;
     ABState       = aBState;
     Race          = race;
     IsPlus        = isPlus;
     Description   = desc;
     DescriptionEn = descEn;
 }
 public TableMaterialData(ushort objNo,
                          string displayName,
                          string displayNameEn,
                          MaterialType mtype,
                          float throwDexterity,
                          int strength,
                          OptionBaseType obType,
                          int optionAddStart,
                          float optionAddContinue,
                          float optionAddReduce,
                          int optionPowStart,
                          float optionPowContinue,
                          float optionPowReduce,
                          string description,
                          string descriptionEn)
 {
     ObjNo             = objNo;
     DisplayName       = displayName;
     DisplayNameEn     = displayNameEn;
     Mtype             = mtype;
     ThrowDexterity    = throwDexterity;
     Strength          = strength;
     OBType            = obType;
     OptionAddStart    = optionAddStart;
     OptionAddContinue = optionAddContinue;
     OptionAddReduce   = optionAddReduce;
     OptionPowStart    = optionPowStart;
     OptionPowContinue = optionPowContinue;
     OptionPowReduce   = optionPowReduce;
     Description       = description;
     DescriptionEn     = descriptionEn;
 }
    public static BaseOption GetValue(OptionBaseType type, uint rnd, int start, float prob, float con)
    {
        TableOptionCommonData data = Array.Find(Table, i => i.ObType == type &&
                                                i.Start <= rnd && rnd <= i.End);

        if (CommonFunction.IsNull(data) == true)
        {
            return(null);
        }
        BaseOption op = new BaseOption();

        AttachValue(op, data);
        if (data.IsPlus == true)
        {
            op.Plus = CommonFunction.ConvergenceRandom(start, prob, con, 5);
        }
        return(op);
    }
		private bool UpdateOptionIfChanged(OptionBaseType option, IOption vwOption)
        {
			if(option == null || vwOption == null)
			{
				return false;
			}

            // Compare for dirty option.
            bool bShouldUpdate;

			if (_bDeploymentIconOnly)
            {
				// Necessity to update is dependant on the deploying selection.
				bShouldUpdate = vwOption.Deploy;
			}
			else
			{
				// Necessity to update is dependant on whether the value has changed.
				bShouldUpdate = !string.Concat(option.Text).Equals(vwOption.StringValue, StringComparison.InvariantCultureIgnoreCase)
					|| vwOption.Deploy;
			}

			if (bShouldUpdate)
            {
				option.Text = new string[] { vwOption.StringValue };

				if (option is UIOptionType)
				{
					(option as UIOptionType).Deploy = vwOption.Deploy;
				}
            }

            if (option.IsOverrideAllowed != vwOption.CanOverride)
            {
                option.IsOverrideAllowed = vwOption.CanOverride;
				bShouldUpdate = true;
            }

			return bShouldUpdate;
        }
Beispiel #5
0
		private void ProcessOption(MainViewModel model, Dictionary<string, AreaOption> areas, Category shellCategory,
		                           Category shellSubCategory, OptionBaseType option)
		{
			if (option is UIOptionType)
			{
				var uiOption = option as UIOptionType;

				if (!ShouldOptionBeVisible(uiOption, model.AppModel.IsAdmin))
				{
					return;
				}

				var shellOption = CreateShellOption(shellSubCategory, uiOption);
				if (shellOption != null)
				{
					shellOption.IsEnabled = ShouldOptionBeEnabled(uiOption, model.AppModel.IsAdmin);
					shellOption.Category = shellCategory;
					shellOption.SubCategory = shellSubCategory;
					if (!string.IsNullOrEmpty(uiOption.Area))
					{
						if (!areas.ContainsKey(uiOption.Area))
						{
							var area = new AreaOption
							           	{
							           		Name = uiOption.Area,
							           		DisplayName = uiOption.DisplayText,
							           		Description = uiOption.DisplayText,
							           		Category = shellCategory,
							           		SubCategory = shellSubCategory
							           	};
							areas.Add(uiOption.Area, area);
						}
						areas[uiOption.Area].AddSubOption(shellOption, uiOption.PolicyScope);
					}
					else
					{
						model.AddOption(shellOption);
					}
				}
			}
			else if (option is UIOptionGroupType)
			{
				shellSubCategory.ContainsInstances = true;
				var optionGroup = option as UIOptionGroupType;
				foreach (var instance in optionGroup.OptionGroupInstances)
				{
					model.AddOption(CreateShellOptionGroupInstance(shellSubCategory, instance));
				}
			}
		}
		private void VisitOptionBaseType(OptionBaseType option, object context)
		{
			XmlNode optionNode = (XmlNode) context;

			option.Name = optionNode.Attributes["ID"].Value;
			option.DisplayText = optionNode.Attributes["DisplayText"].Value;

			XmlAttribute isOverrideAllowed = optionNode.Attributes["IsOverrideAllowed"];
			if (isOverrideAllowed != null)
			{
				option.IsOverrideAllowed = Boolean.Parse(isOverrideAllowed.Value);
			}			

			XmlAttribute isPrivate = optionNode.Attributes["Private"];
			if (isPrivate != null)
			{
				option.Private = Boolean.Parse(isPrivate.Value);
				option.PrivateSpecified = true;
			}

			XmlAttribute isVisible = optionNode.Attributes["Visible"];
			if (isVisible != null)
			{
				option.Visible = Boolean.Parse(isVisible.Value);
				option.VisibleSpecified = true;
			}
			else
			{
				// Not assigned therefore assume true.
				option.Visible = true;
			}

			XmlAttribute runtimeState = optionNode.Attributes["RuntimeState"];
			if (runtimeState != null)
			{
				option.RuntimeState = Boolean.Parse(runtimeState.Value);
				option.RuntimeStateSpecified = true;
			}

			XmlAttribute readLocalMachine = optionNode.Attributes["ReadLocalMachine"];
			if (readLocalMachine != null)
			{
				option.ReadLocalMachine = Boolean.Parse(readLocalMachine.Value);
				option.ReadLocalMachineSpecified = true;
			}
			else
			{
				option.ReadLocalMachine = true;
			}

			XmlAttribute readCurrentUser = optionNode.Attributes["ReadCurrentUser"];
			if (readCurrentUser != null)
			{
				option.ReadCurrentUser = Boolean.Parse(readCurrentUser.Value);
				option.ReadCurrentUserSpecified = true;
			}
			else
			{
				option.ReadCurrentUser = true;
			}

			XmlAttribute categoryRef = optionNode.Attributes["CategoryRef"];
			if (categoryRef != null)
			{
				option.CategoryRef = categoryRef.Value;
			}

			XmlAttribute subCategoryRef = optionNode.Attributes["SubCategoryRef"];
			if (subCategoryRef != null)
			{
				option.SubCategoryRef = subCategoryRef.Value;
			}

			XmlAttribute areaRef = optionNode.Attributes["Area"];
			if (areaRef != null)
			{
				option.Area = areaRef.Value;
			}
		}
Beispiel #7
0
		private void VisitOptionBaseType(OptionBaseType option, object context)
		{
			XmlNode optionNode = (XmlNode) context;

			XmlAttribute isOverrideAllowed = _xmlDoc.CreateAttribute("IsOverrideAllowed");
			isOverrideAllowed.Value = option.IsOverrideAllowed.ToString();
			optionNode.Attributes.Append(isOverrideAllowed);

			XmlAttribute displayText = _xmlDoc.CreateAttribute("DisplayText");
			displayText.Value = option.DisplayText;
			optionNode.Attributes.Append(displayText);
		}
		private static void DeleteOptionFromOptionsRoot(UIOptionRootType optionRoot, OptionBaseType option)
		{
			UIOptionCategoryType cat = optionRoot.Categories.Find(a => a.Name == option.CategoryRef);
			if (cat != null)
			{
				UIOptionSubCategoryType subcat = cat.SubCategories.Find(b => b.Name == option.SubCategoryRef);
				if (subcat != null)
				{
					int index = GetOptionIndexInSubCategory(subcat, option.Name);
					if (index != -1)
					{
						subcat.Options.RemoveAt(index);
					}
				}
			}
		}
		private static void LoadOption(IOption targetOpt, OptionBaseType opt)
		{
			targetOpt.CanOverride = opt.IsOverrideAllowed;			
			if (targetOpt is BoolOption)
			{
				(targetOpt as BoolOption).Value = Boolean.Parse(opt.Text[0]);
			}
			else if (targetOpt is StringOption)
			{
				(targetOpt as StringOption).Value = opt.Text[0];
			}
			else if (targetOpt is IntegerOption)
			{
				// If Int32.TryParse fails because the string value is null or not in the correct format the (uninitialized) result is zero which is also the default value for options of type integer.
				int result;
				Int32.TryParse(opt.Text[0], out result); 
				(targetOpt as IntegerOption).Value = result;
			}
			else if (targetOpt is EncryptionOption)
			{
				(targetOpt as EncryptionOption).Value = Workshare.Interop.Options.OptionApi.GetRawString(opt.Name, opt.Text[0], _entropy);
			}
			else if (targetOpt is EnumOption)
			{
				EnumOption eo = targetOpt as EnumOption;
				int index = Int32.Parse(opt.Text[0]);
				eo.Value = eo.GetValue(index);
			}
			else if (targetOpt is RangeOption)
			{
				(targetOpt as RangeOption).Value = Int32.Parse(opt.Text[0]);
			}
			else if (targetOpt is ColorOption)
			{
				(targetOpt as ColorOption).Value = OptionMapper.GetColor(opt.Text[0]);
			}
			else
			{
				Workshare.Interop.Logging.Logger.LogError("Option not loaded from WSO due to unknown type : " + targetOpt.Name + "  " + targetOpt.GetType().ToString());
			}

			if (opt is UIOptionType)
			{
				targetOpt.Deploy = (opt as UIOptionType).Deploy;
			}
		}
		private static void LoadGroup(MainViewModel viewModel, OptionBaseType opt)
		{

			Category cat = viewModel.GetSubCategory(opt.CategoryRef, opt.SubCategoryRef);
			if (cat == null)
				return;

			List<IOption> toRemove = new List<IOption>();
			foreach (IOption existingopt in cat.Options)
			{
				if (existingopt is OptionGroupInstance)
					toRemove.Add(existingopt);
			}

			foreach (IOption i in toRemove)
				cat.Options.Remove(i);


			UIOptionGroupType group = opt as UIOptionGroupType;
			foreach (var inst in group.OptionGroupInstances)
			{
				OptionGroupInstance newGroup = OptionMapper.CreateShellOptionGroupInstance(cat, inst);
				newGroup.IsDirty = true;
				newGroup.Deploy = inst.Deploy;
				newGroup.CanChangeDeploy = viewModel.AppModel.IsAdmin;

				foreach (IOption subOpt in newGroup.SubOptions)
				{
					subOpt.IsDirty = true;
					subOpt.Deploy = inst.Deploy;
					if (subOpt is EncryptionOption)
					{
						(subOpt as EncryptionOption).Value = Workshare.Interop.Options.OptionApi.GetRawString(group.Name, inst.Name, subOpt.Name, subOpt.StringValue, _entropy);
					}
				}
				cat.Options.Add(newGroup);
			}
		}