///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Repository.GenericRepository`1.SetNewParamFromContextList(System.Data.Entity.DbContext,GenericRepositoryAndService.Repository.GenericRepository{`0}.CustomParam)"]/*'/> private CustomParam SetNewParamFromContextList(DbContext newContext, CustomParam customParam) { var newvalue = Convert.ChangeType( Activator.CreateInstance(typeof(List <>).MakeGenericType(customParam.TypeofElement)), typeof(List <>).MakeGenericType(customParam.TypeofElement) ); if (customParam.Value != null) { foreach (object item in customParam.Value as IList) { object newitem; if (item is BaseEntity entity) { newitem = newContext.Set(customParam.TypeofElement).Find(entity.Id); } else { object[] objs = GenericToolsTypeAnalysis.GetKeysValuesForType(item, customParam.TypeofElement); newitem = GenericToolsCRUD.FindByKeysInNewContextForType(customParam.TypeofElement, newContext, objs); } ((IList)newvalue).Add(newitem); } } return(new CustomParam( newvalue, customParam.TypeofElement, customParam.PropertyName, customParam.Prop, true )); }
public bool Parse(BinaryReader reader, long pngEnd) { try { long position = 0L; if (pngEnd > 0) { position = reader.BaseStream.Position; reader.Seek(0, SeekOrigin.Begin); PngData = reader.ReadBytes((int)pngEnd); reader.Seek(position, SeekOrigin.Begin); } this.CharaParameter = ReadCustomParameter(reader); return(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } return(false); }
private void ReadHair(BinaryReader reader, CustomParam chara) { int hairPartsCount = reader.ReadInt32(); chara.hairParts = new HairPart[hairPartsCount]; for (int i = 0; i < hairPartsCount; i++) { HairPart part = ReadHairPart(reader, chara.version); chara.hairParts[i] = part; } }
private CustomParam ReadCustomParameter(BinaryReader reader) { CustomParam chara = new CustomParam(); chara.version = reader.ReadInt32(); // 10 chara.sex = reader.ReadInt32(); ReadHair(reader, chara); ReadHead(reader, chara); ReadBody(reader, chara); ReadWear(reader, chara); ReadAccessory(reader, chara); return(chara); }
private void ReadAccessory(BinaryReader reader, CustomParam chara) { chara.accessories = new byte[10][]; for (int i = 0; i < 10; i++) { BinaryList list = new BinaryList(); // ACCESSORY_TYPE, id, nowAttach, addPos, addRot addScl list.AddRange(reader.ReadBytes(48)); list.AddRange(ReadColorPBR2(reader, chara.version)); // color chara.accessories[i] = list.ToArray(); } }
public PHCharaCard(string srcFileName, string marker, short sex) { this.SourceFileName = srcFileName; if (string.IsNullOrEmpty(marker)) { this.marker = sex == 0 ? "【PlayHome_Male】" : "【PlayHome_Female】"; } else { this.marker = marker; } this.Name = Path.GetFileNameWithoutExtension(srcFileName); this.Sex = sex; this.CharaParameter = new CustomParam(); }
private CustomParamValue CreateItem(CustomParam cp, decimal?parentCpvId) { var cpv = (CustomParamValue)Activator.CreateInstance(typeof(T)); cpv.CPVID = --_cpvid; cpv.CustomParamCode = cp.GetKey <string>(); cpv.CPV2Entity = CpEntity; cpv.CPVKey = CpKey; cpv.CPVValue = cp.CustomParamDefault; cpv.VCustomParamParent = cp.CustomParamParent; cpv.Cp = cp; cpv.FormattedValue = CpvHelper.GetFormattedValue(cpv); cpv.CPVParent = parentCpvId; cpv.VCustomParamCount = cp.CustomParamCount; cpv.VCustomParamDesc = cp.CustomParamDesc; return(cpv); }
private CustomParam GetRootCustomParam(IEnumerable <CustomParam> cps, CustomParam cp) { if (cps == null) { throw new ArgumentNullException("cps"); } if (cp == null) { throw new ArgumentNullException("cp"); } if (string.IsNullOrEmpty(cp.CustomParamParent)) { return(cp); } return(cps.Where(p => p.GetKey <string>() == cp.CustomParamParent).Select(p => GetRootCustomParam(cps, p)).FirstOrDefault()); }
private CustomParam GetParentCustomParam(IEnumerable <CustomParam> cps, CustomParam cp) { if (cps == null) { throw new ArgumentNullException("cps"); } if (cp == null) { throw new ArgumentNullException("cp"); } if (string.IsNullOrEmpty(cp.CustomParamParent)) { return(cp); } return (cps.SingleOrDefault( p => p.GetKey <string>() == cp.CustomParamParent)); }
private void ProductMessage(String message) { var parm = new CustomParam { DateTime = DateTime.Now, MessageText = message }; if (this.InvokeRequired) { this.Invoke(new Action(() => { SendMessage(this.Handle, WM_CUSTM_MSG, 0, ref parm); })); } else { SendMessage(this.Handle, WM_CUSTM_MSG, 0, ref parm); } }
private void ReadWear(BinaryReader reader, CustomParam chara) { chara.wear = new byte[11][]; for (int i = 0; i < 11; i++) { BinaryList list = new BinaryList(); // WEAR_TYPE, id list.AddRange(reader.ReadBytes(8)); // color list.AddRange(ReadColorPBR2(reader, chara.version)); chara.wear[i] = list.ToArray(); } if (chara.sex == 0) { chara.isSwimwear = reader.ReadBoolean(); // isSwimwear chara.swimOptTop = reader.ReadBoolean(); // swimOptTop chara.swimOptBtm = reader.ReadBoolean(); // swimOptBtm } }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Repository.GenericRepository`1.SetNewParamFromContextNotList(System.Data.Entity.DbContext,GenericRepositoryAndService.Repository.GenericRepository{`0}.CustomParam)"]/*'/> private CustomParam SetNewParamFromContextNotList(DbContext newContext, CustomParam customParam) { object newvalue = null; if (customParam.Value != null) { if (customParam.Value is BaseEntity entity) { newvalue = newContext.Set(customParam.TypeofElement).Find(entity.Id); } else { object[] objs = GenericToolsTypeAnalysis.GetKeysValuesForType(customParam.Value, customParam.TypeofElement); newvalue = GenericToolsCRUD.FindByKeysInNewContextForType(customParam.TypeofElement, newContext, objs); } } return(new CustomParam( newvalue, customParam.TypeofElement, customParam.PropertyName, customParam.Prop, false )); }
public SomeValue GetItems(CustomParam parameter) {
public void Add( CustomParam param ) { m_listParam.Add( param ); }
///<include file='docs.xml' path='doc/members/member[@name="M:GenericRepositoryAndService.Repository.GenericRepository`1.SetCustom(System.Object[])"]/*'/> private CustomParam[] SetCustom(params object[] objs) { CustomParam[] res = new CustomParam[_DynamicDBListTypes.Count() + _DynamicDBTypes.Count()]; int resindex = 0; List <string> lkeysforlisttypes = _DynamicDBListTypes.Keys.ToList(); List <Type> ltypesforlisttpes = _DynamicDBListTypes.Values.ToList(); List <Type> lTlisttype = _DynamicDBListTypes.Values.Select(typ => typeof(List <>).MakeGenericType(typ) ).ToList(); List <string> lkeysfortypes = _DynamicDBTypes.Keys.ToList(); List <Type> lTtypes = _DynamicDBTypes.Values.ToList(); foreach (object obj in objs.Where(o => o != null)) { bool isFound = false; int i = 0; if (obj is PropToNull proptonull) { isFound = true; Type typeofprop = typeof(T).GetProperty(proptonull.PropertyName).PropertyType; if (GenericToolsTypeAnalysis.TryListOfWhat(typeofprop, out Type innertype)) { res[resindex] = CreateDefaultListCustomParamFromKey(proptonull.PropertyName); lkeysforlisttypes.Remove(proptonull.PropertyName); ltypesforlisttpes.Remove(innertype); lTlisttype.Remove(typeof(List <>).MakeGenericType(innertype)); } else { res[resindex] = CreateDefaultCustomParamFromKey(proptonull.PropertyName); lkeysfortypes.Remove(proptonull.PropertyName); lTtypes.Remove(typeofprop); } resindex++; } else { foreach (Type typ in lTlisttype) { try { var test = Convert.ChangeType(obj, typ); isFound = true; res[resindex] = CreateListCustomParamFromKey(lkeysforlisttypes[i], obj); resindex++; lkeysforlisttypes.RemoveAt(i); ltypesforlisttpes.RemoveAt(i); lTlisttype.RemoveAt(i); break; } catch { } i++; } i = 0; if (!isFound) { foreach (Type typ in lTtypes) { try { var test = Convert.ChangeType(obj, typ); isFound = true; res[resindex] = CreateCustomParamFromKey(lkeysfortypes[i], obj); resindex++; lkeysfortypes.RemoveAt(i); lTtypes.RemoveAt(i); break; } catch { } i++; } } } if (!isFound) { throw new InvalidArgumentsForClassException(typeof(T)); } } foreach (string key in lkeysforlisttypes) { res[resindex] = CreateDefaultListCustomParamFromKey(key); resindex++; } foreach (string key in lkeysfortypes) { res[resindex] = CreateDefaultCustomParamFromKey(key); resindex++; } return(res); }
private static extern int SendMessage(IntPtr hWnd, int msg, uint wParam, ref CustomParam lParam);
private void btnAddParam_Click(object sender, EventArgs e) { if (lastLine != null) { CustomParam newParam = new CustomParam("", ""); ListViewItem newItem = new ListViewItem(new string[] { "", "" }) { Tag = newParam }; lvCustomParams.Items.Add(newItem); newItem.Selected = true; txtParamName.Focus(); SetModified(); } }
private void txtParamName_Leave(object sender, EventArgs e) { if (lastLine != null && lastParam != null && lastParamItem != null && lastParam.Name != txtParamName.Text) { Control activeControl = ActiveControl; // создание нового пользовательского параметра string newName = txtParamName.Text; CustomParam newParam = new CustomParam(newName, lastParam.Value); // удаление пользовательского параметра со старым наименованием lastLine.CustomParams.Remove(lastParam.Name); lvCustomParams.Items.RemoveAt(lastParamItem.Index); // удаление элемента списка, если новое наименование дублируется int newInd = lastLine.CustomParams.IndexOfKey(newName); if (newInd >= 0) lvCustomParams.Items.RemoveAt(newInd); // добавление нового пользовательского параметра lastLine.CustomParams[newName] = newParam.Value; newInd = lastLine.CustomParams.IndexOfKey(newName); ListViewItem newItem = new ListViewItem(new string[] { newName, newParam.Value }) { Tag = newParam }; lvCustomParams.Items.Insert(newInd, newItem); newItem.Selected = true; activeControl.Focus(); } }
private void lvCustomParams_SelectedIndexChanged(object sender, EventArgs e) { changing = true; if (lvCustomParams.SelectedItems.Count > 0) { lastParamItem = lvCustomParams.SelectedItems[0]; lastParam = lastParamItem.Tag as CustomParam; if (lastParam == null) { lastParamItem = null; } else { txtParamName.Text = lastParam.Name; txtParamValue.Text = lastParam.Value; gbSelectedParam.Enabled = true; } } else { lastParam = null; lastParamItem = null; txtParamName.Text = ""; txtParamValue.Text = ""; gbSelectedParam.Enabled = false; } // установка доступности кнопки удаления пользовательского параметра btnDelParam.Enabled = lastParamItem != null; changing = false; }
private bool fullLoad2; // загружать 2-й журнал полностью /// <summary> /// Конструктор /// </summary> public FrmMain() { Application.EnableVisualStyles(); InitializeComponent(); // установка формата времени опроса КП timeKpTime.CustomFormat = Localization.Culture.DateTimeFormat.LongTimePattern; // установка имён столбцов списков для перевода формы colParamName.Name = "colParamName"; colParamValue.Name = "colParamValue"; colKpOrder.Name = "colKpOrder"; colKpActive.Name = "colKpActive"; colKpBind.Name = "colKpBind"; colKpNumber.Name = "colKpNumber"; colKpName.Name = "colKpName"; colKpDll.Name = "colKpDll"; colKpAddress.Name = "colKpAddress"; colCallNum.Name = "colCallNum"; colKpTimeout.Name = "colKpTimeout"; colKpDelay.Name = "colKpDelay"; colKpTime.Name = "colKpTime"; colKpPeriod.Name = "colKpPeriod"; colKpCmdLine.Name = "colKpCmdLine"; // инициализация полей appDirs = new AppDirs(); errLog = new Log(Log.Formats.Simple); errLog.Encoding = Encoding.UTF8; mutex = null; icoStart = Icon.FromHandle((ilMain.Images["star_on.ico"] as Bitmap).GetHicon()); icoStop = Icon.FromHandle((ilMain.Images["star_off.ico"] as Bitmap).GetHicon()); svcContr = null; prevSvcStatus = ServiceControllerStatus.Stopped; nodeCommonParams = treeView.Nodes["nodeCommonParams"]; nodeKpDlls = treeView.Nodes["nodeKpDlls"]; nodeLines = treeView.Nodes["nodeLines"]; nodeStats = treeView.Nodes["nodeStats"]; origSettings = new Settings(); modSettings = null; lastNode = null; lastLine = null; lastParam = null; lastParamItem = null; lastKP = null; lastKpItem = null; copiedKP = null; changing = false; serverComm = null; baseTablesReceived = false; tblCommLine = new DataTable(); tblKP = new DataTable(); tblKPType = new DataTable(); kpDllInfoList = new SortedList<string, KpDllInfo>(); commCnlParamsBuf = new Dictionary<string, SortedList<string, string>>(); lbLog1 = null; lbLog2 = null; logFileName1 = ""; logFileName2 = ""; logFileAge1 = DateTime.MinValue; logFileAge2 = DateTime.MinValue; fullLoad1 = false; fullLoad2 = false; Application.ThreadException += Application_ThreadException; }
private void ReadHead(BinaryReader reader, CustomParam chara) { BinaryList list = new BinaryList(); // headID, faceTexID, detailID, detailWeight, eyeBrowID list.AddRange(reader.ReadBytes(20)); // eyeBrowColor list.AddRange(ReadColorPBR1(reader, chara.version)); if (chara.version < 4) { // eyeScleraColor byte[] eyeScleraColor = reader.ReadBytes(16); // eyeL list.Add(reader.ReadInt32()); // eyeID_L list.AddRange(eyeScleraColor); // eyeScleraColorL list.AddRange(reader.ReadBytes(16)); // eyeIrisColorL list.AddAll(0.0f, 0.5f); // eyePupilDilationL, eyeEmissiveL // eyeR list.Add(reader.ReadInt32()); // eyeID_R list.AddRange(eyeScleraColor); // eyeScleraColorR list.AddRange(reader.ReadBytes(16)); // eyeIrisColorR list.AddAll(0.0f, 0.5f); // eyePupilDilationR, eyeEmissiveR } else { // eyeID_L, eyeScleraColorL, eyeIrisColorL eyePupilDilationL list.AddRange(reader.ReadBytes(40)); if (chara.version >= 10) { list.Add(reader.ReadSingle()); // eyeEmissiveL } else { list.Add(0.5f); // eyeEmissiveL } // eyeID_R, eyeScleraColorR, eyeIrisColorR, eyePupilDilationR list.AddRange(reader.ReadBytes(40)); if (chara.version >= 10) { list.Add(reader.ReadSingle()); // eyeEmissiveR } else { list.Add(0.5f); // eyeEmissiveR } } // tattooID, tattooColor list.AddRange(reader.ReadBytes(20)); // shapeVals int shapeCount = reader.ReadInt32(); list.Add(shapeCount); list.AddRange(reader.ReadBytes(shapeCount * 4)); if (chara.sex == 0) { // eyeLash list.Add(reader.ReadInt32()); list.AddRange(ReadColorPBR1(reader, chara.version)); // eyeshadow list.AddRange(reader.ReadBytes(20)); // cheek list.AddRange(reader.ReadBytes(20)); // lip list.AddRange(reader.ReadBytes(20)); // mole list.AddRange(reader.ReadBytes(20)); // eyeHighlight list.Add(reader.ReadInt32()); list.AddRange(ReadColorEyeHighlight(reader, chara.version)); } else { // beard list.AddRange(reader.ReadBytes(20)); if (chara.version >= 2) { // eyeHighlightColor list.AddRange(ReadColorEyeHighlight(reader, chara.version)); } else { // eyeHighlightColor list.Add(7); // colorType list.AddAll(1f, 1f, 1f, 1f); // mainColor1 list.AddAll(1f, 1f, 1f, 1f); // specColor1 list.AddAll(0f, 0f); // specular1, smooth1 } } chara.head = list.ToArray(); }
private void ReadBody(BinaryReader reader, CustomParam chara) { BinaryList list = new BinaryList(); // bodyID list.Add(reader.ReadInt32()); // skinColor list.AddRange(ReadColorAlloyHSVOffset(reader, chara.version)); // detailID, detailWeight, underhairID list.AddRange(reader.ReadBytes(12)); // underhairColor list.AddRange(ReadColorAlloy(reader, chara.version)); // tattooID, tattooColor list.AddRange(reader.ReadBytes(20)); // shapeVals int shapeCount = reader.ReadInt32(); list.Add(shapeCount); list.AddRange(reader.ReadBytes(shapeCount * 4)); if (chara.sex == 0) { // nipID list.Add(reader.ReadInt32()); // nipColor list.AddRange(ReadColorAlloyHSVOffset(reader, chara.version)); // sunburnID, sunburnColor list.AddRange(reader.ReadBytes(20)); if (chara.version >= 3) { // nailColor list.AddRange(ReadColorAlloyHSVOffset(reader, chara.version)); if (chara.version >= 9) { // manicureColor list.AddRange(ReadColorPBR1(reader, chara.version)); } else { // manicureColor list.Add(2); // colorType list.AddAll(1f, 1f, 1f, 0f); // mainColor1 list.AddAll(1f, 1f, 1f, 1f); // specColor1 list.AddAll(0f, 0f); // specular1, smooth1 } // areolaSize, bustSoftness, bustWeight list.AddRange(reader.ReadBytes(12)); } else { // nailColor list.Add(5); // colorType list.AddAll(0f, 1f, 1f, 1f); // hsv offset + alpha list.AddAll(0f, 0.562f); // metallic, smooth // manicureColor list.Add(2); // colorType list.AddAll(1f, 1f, 1f, 0f); // mainColor1 list.AddAll(1f, 1f, 1f, 1f); // specColor1 list.AddAll(0f, 0f); // specular1, smooth1 // areolaSize, bustSoftness, bustWeight list.AddAll(0.5f, 0.5f, 0.5f); } } chara.body = list.ToArray(); }