public bool GetForcedBool(int index1stDim, int index2ndDim) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index1stDim, index2ndDim); if (bGood) return Variable.ConvertToBool(RString.SafeSubstring(sVal,iStart,iLen)); else return false; }
void ProcessRes(PropertyInfo pi) { var obj = pi.GetValue(null, null); var type = obj.GetType(); if (type == typeof(string)) { var item = new RString(); item.name = pi.Name; item.value = obj as string; listString.Add(item); } else if (type == typeof(Texture2D)) { var item = new RTexture(); item.name = pi.Name; item.value = obj as Texture2D; listTexture.Add(item); } else { var item = new RUnknown(); item.name = pi.Name; item.type = type.Name; item.value = obj.ToString(); listUnknown.Add(item); } }
public REAL GetForcedReal(int index1stDim, int index2ndDim) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index1stDim, index2ndDim); if (bGood) return (REAL)Convert.ToDouble(RString.SafeSubstring(sVal,iStart,iLen)); else return r0; }
public decimal GetForcedDecimal(int index1stDim, int index2ndDim) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index1stDim, index2ndDim); if (bGood) return Convert.ToDecimal(RString.SafeSubstring(sVal,iStart,iLen)); else return 0.0M; }
public long GetForcedLong(int index1stDim, int index2ndDim) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index1stDim, index2ndDim); if (bGood) return (long)Convert.ToInt64(RString.SafeSubstring(sVal,iStart,iLen)); else return 0; }
public float GetForcedFloat(int index1stDim, int index2ndDim) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index1stDim, index2ndDim); if (bGood) return (float)Convert.ToDouble(RString.SafeSubstring(sVal,iStart,iLen)); else return 0.0f; }
public double GetForcedDouble(int index) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index); if (bGood) return Convert.ToDouble(RString.SafeSubstring(sVal,iStart,iLen)); else return 0.0; }
//============================================================ public override void DrawRenderable(FDxRegion region, FDxRenderable renderable, FDxEffect effect) { // 设置顶点缓冲 FDxGeometry geometry = renderable as FDxGeometry; effect.NativeEffect.GetVariableByName("_modelMatrix").AsMatrix().SetMatrix(renderable.Matrix.Native); effect.NativeEffect.GetVariableByName("_viewMatrix").AsMatrix().SetMatrix(region.Camera.Matrix.Native); effect.NativeEffect.GetVariableByName("_projectionMatrix").AsMatrix().SetMatrix(region.Camera.Viewport.Matrix); effect.NativeEffect.GetVariableByName("_cameraPosition").AsVector().Set(new Vector3(region.Camera.Position.X, region.Camera.Position.Y, region.Camera.Position.Z)); effect.NativeEffect.GetVariableByName("_lightPosition").AsVector().Set(new Vector3(region.LightDirectional.Position.X, region.LightDirectional.Position.Y, region.LightDirectional.Position.Z)); effect.NativeEffect.GetVariableByName("_lightDirection").AsVector().Set(new Vector3(region.LightDirectional.Camera.Direction.X, region.LightDirectional.Camera.Direction.Y, region.LightDirectional.Camera.Direction.Z)); _device.NativeDevice.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; _device.NativeDevice.InputAssembler.SetVertexBuffers(0, renderable.VertexBuffer.NativeBuffers); _device.NativeDevice.InputAssembler.SetIndexBuffer(renderable.FaceBuffer.NativeBuffer, Format.R32_UInt, 0); int textureCount = geometry.Material.Textures.Count; for (int i = 0; i < textureCount; i++) { FDxTexture texture = geometry.Material.Textures[i]; if (null != texture) { string textureName = "_texture" + RString.FirstUpper(texture.TypeName); effect.NativeEffect.GetVariableByName(textureName).AsResource().SetResource(texture.NativeResource); } } effect.NativePass.Apply(_device.NativeDevice); _device.NativeDevice.DrawIndexed(renderable.FaceBuffer.count, 0, 0); }
public bool Set(string val, int index1stDimension) { int iStart, iLen; int iElements=Elements(); bool bTest=true; if (index1stDimension<iElements) { bTest=Element(out iStart, out iLen, index1stDimension); sVal=RString.SafeSubstring(sVal,0,iStart)+val+RString.SafeSubstring(sVal,iStart+iLen); } else if (iElements>0) {//add an index if array bTest=Element(out iStart, out iLen, iElements-1);//get location of last element if (bTest) { int iAddIndeces=(index1stDimension+1)-iElements; int iAfterLastElement=iStart+iLen; for (int iNow=0; iNow<iAddIndeces; iNow++) { sVal=RString.SafeInsert(sVal,iAfterLastElement,","); iAfterLastElement++; } bTest=Element(out iStart, out iLen, index1stDimension);//do this test to make sure the operation worked if (bTest) sVal=RString.SafeSubstring(sVal,0,iStart)+val+RString.SafeSubstring(sVal,iStart+iLen); else { int iStatus=Elements(index1stDimension); RReporting.ShowErr( "Could not create index "+index1stDimension.ToString()+" in variable "+sName+(iStatus>0?"--program failed to detect it as a non-array and change it to one":("--there were only "+iStatus.ToString()+" elements.")) ); } } } else { //else non-array, so make into an array (TODO: change behavior to php-like and put value after "{}" area) sVal="{"+val; for (int iNow=0; iNow<index1stDimension; iNow++) { sVal+=","; } sVal+=val+"}"; } iType=TypeString; return bTest&&IsActive(); }//end Set(val,index1stDimension);
public int GetForcedInt(int index) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index); if (bGood) return Convert.ToInt32(RString.SafeSubstring(sVal,iStart,iLen)); else return 0; }
public override void LoadConfig(FXmlNode config) { _name = config[PTY_NAME]; RString.CheckEmpty(_name, "name"); _value = config[PTY_VALUE]; RString.CheckEmpty(_value, "value"); // Load formator if (config.Contains(PTY_FORMATOR)) { /*string formator = config[PTY_FORMATOR]; * _formator = (IFormator)RClass.CreateInstance(formator); * _formator.LoadConfig(config); * // Load formator value * FFormatorParameters parameters = new FFormatorParameters(); * parameters.RaiseException = true; * parameters.Value = Value; * if (_formator.Format(parameters)) { * _value = RString.Nvl(parameters.Value); * }*/ } // Dump if (_logger.DebugAble) { _logger.Debug(this, "LoadConfig", "Define {0}=[{1}]", _name, _value); } }
//============================================================ // <T>过滤数据。</T> //============================================================ public void DoFilter() { bool filterValue = !RString.IsBlank(_filterValue); // 加载子目录 lvResources.BeginUpdate(); lvResources.Items.Clear(); //foreach(INamePair<FRsResource> pair in _resources) { // FRsResource resource = pair.Value; // //SDsResourceTag tag = resource.Tag as SDsResourceTag; // //if(tag.item == null) { // // continue; // //} // //ListViewItem qItem = tag.item as ListViewItem; // //// 是否含有内容 // //if(filterValue) { // // if(!tag.key.Contains(_filterValue)) { // // continue; // // } // //} // // 增加内容 // lvResources.Items.Add(qItem); //} lvResources.EndUpdate(); }
public override bool DoCheck(FValidatorParameters parameters) { string mail = (string)parameters.Value; if (!RString.IsEmpty(mail)) { string[] lines = RString.TrimLines(mail.Split('\n'), false); if (_maxCount > 0) { if (lines.Length > _maxCount) { parameters.Description = _resource.FindDisplay(MSG_MAX_COUNT, _maxCount); return(false); } } foreach (string line in lines) { if (!CheckMail(parameters, line)) { return(false); } } } return(true); }
//============================================================ // <T>导出多个打包到目录。</T> // // @param fileName 文件名称 // @param widthCount 横向分割个数 // @param hightCount 纵向分割个数 //============================================================ public void ExportPath(string path, int tileWidth, int tileHight, int colorCount, int widthCount, int hightCount) { // 计算分割数量 int tileCx = _bitmap.Width / tileWidth; int tileCy = _bitmap.Height / tileHight; // 分割图片 for (int y = 0; y < tileCy; y++) { for (int x = 0; x < tileCx; x++) { // 绘制局部图形 FBitmap bitmap = new FBitmap(tileWidth, tileHight); bitmap.Fill(_bitmap, tileWidth * x, tileHight * y); // 存储索引图片 string fileName = path + "_" + RString.PadLeft(y.ToString(), 2, '0') + "_" + RString.PadLeft(x.ToString(), 2, '0') + "." + EXTEND_NAME; _logger.Debug(this, "ExportPath", "Export path file. (file_name={0}, color_count={1}, width_count={2}, hight_count={3})", fileName, colorCount, widthCount, hightCount); FLzmaFile file = new FLzmaFile(); file.EnsureSize(tileWidth * tileHight); StoreCompress(file, bitmap.Native, colorCount, widthCount, hightCount); file.Compress(fileName); file.Reset(); } } }
public string GetForcedString(int index1stDim, int index2ndDim) { int iStart, iLen; bool bGood; bGood=Element(out iStart, out iLen, index1stDim, index2ndDim); if (bGood) return RString.SafeSubstring(sVal,iStart,iLen); else return ""; }
public bool CheckMail(FValidatorParameters parameters, string mail) { if (!RString.IsEmpty(mail)) { mail = mail.Trim(); // Check @ int at = mail.IndexOf('@'); if (at == -1) { parameters.Result = false; parameters.Description = _resource.FindDisplay(MSG_NOT_FIND_AT, mail); return(false); } // Check . int dot = mail.IndexOf('.', at + 1); if (dot == -1) { parameters.Result = false; parameters.Description = _resource.FindDisplay(MSG_NOT_FIND_DOT, mail); return(false); } // Check space string[] items = mail.Split('@', '.'); foreach (string item in items) { if (RString.IsEmpty(item)) { parameters.Result = false; parameters.Description = _resource.FindDisplay(MSG_INVALID, mail); return(false); } } } return(true); }
public override void LoadConfig(FXmlNode config) { base.LoadConfig(config); // Load type string type = config[PTY_TYPE]; if (!RString.IsEmpty(type)) { _dataType = REnum.ToValue <EAopParameterType>(type); } // Load component if (config.HasNode()) { FXmlNode node = config.Nodes[0]; if (node.IsName(XAopComponent.TAG)) { _dataType = EAopParameterType.Component; } } // Load value if (_dataType == EAopParameterType.String) { _dataValue = config.Text; } }
public override void LoadConfig(FXmlNode config) { _name = config[PTY_NAME]; RString.CheckEmpty(_name, "name"); _type = config[PTY_TYPE]; _value = config.Text; }
} //end SplitFromImage32 /// <summary> /// Changes the frame order from top to bottom to left to right using /// the idea that the frames are currently wrapped to a square whose /// number of rows are specified by the number of output columns you /// specify. /// </summary> /// <param name="iResultCols"></param> /// <returns></returns> public bool TransposeFramesAsMatrix(int iResultRows, int iResultCols) { //TODO: exception handling bool bGood = false; GBuffer[] gbarrNew; string sDebug = "starting TranslateFrameOrder" + Environment.NewLine; RString.StringToFile("C:\\DOCUME~1\\OWNER\\MYDOCU~1\\DATABOX\\anim.TranslateFrameOrder debug.txt", sDebug); try { gbarrNew = new GBuffer[(int)lFrames]; int iFrames = (int)lFrames; for (int iFrame = 0; iFrame < iFrames; iFrame++) { int iNew = (int)(iFrame / iResultCols) + (int)(iFrame % iResultCols) * iResultRows; //switched (must be) sDebug += "old:" + iFrame.ToString() + "; new:" + iNew.ToString() + Environment.NewLine; gbarrNew[iFrame] = gbarrAnim[iNew]; } gbarrAnim = gbarrNew; RString.StringToFile("C:\\Documents and Settings\\Owner\\My Documents\\Databox\\anim.TranslateFrameOrder debug.txt", sDebug); gbFrame = gbarrAnim[this.lFrameNow]; bGood = true; } catch (Exception exn) { sDebug += "Exception!" + exn.ToString() + Environment.NewLine; //TODO: handle exception } sDebug += "Finished."; //TODO: in future don't set bGood according to StringToFile bGood = RString.StringToFile("C:\\Documents and Settings\\Owner\\My Documents\\Databox\\anim.TranslateFrameOrder debug.txt", sDebug); return(bGood); } //end TranslateFrameOrder
//============================================================ // <T>解析字符串内容。</T> // // @param value 字符串内容 //============================================================ public bool Parse(string value, bool alpha = true) { // 重置内容 Reset(); // 判断为空 if (RString.IsEmpty(value)) { return(false); } // 去除前置符号# if (value.StartsWith("#")) { value = value.Substring(1); } // 去除前置符号0x if (value.StartsWith("0x")) { value = value.Substring(2); } // 解析内容 int result = Convert.ToInt32(value, 16); Parse(result, alpha); return(true); }
} //end Glyph(cNow,iGlyphType) public bool TypeOnOneLine(ref RImage riDest, int xDest, int yDest, string sText, int iGlyphType) { //TODO: really, this should return a rect (e.g. html-style stretching of container) bool bGood = true; bool bSpacing; int xNow = xDest; try { int iCursor = 0; for (int iChar = 0; iChar < sText.Length; iChar++) { RImage riNow = Glyph(sText[iChar], iGlyphType); if (xNow + riNow.Width < riDest.Width) { if (!RString.IsWhiteSpace(sText[iChar])) { riDest.DrawFromSmallerWithoutCropElseCancel(xNow, yDest, riNow, RImage.DrawMode_AlphaHardEdgeColor_KeepDestAlpha); } } else { break; } xNow += WidthOf(sText[iChar], iGlyphType); } } catch (Exception exn) { RReporting.ShowExn(exn, "", "TypeOnOneLine(...,\"" + RString.ElipsisIfOver(sText, 10) + "\")"); bGood = false; } return(bGood); } //end TypeOnOneLine
void ProcessRes(PropertyInfo pi) { var obj = pi.GetValue(null, null); var type = obj.GetType(); if(type == typeof(string)) { var item = new RString(); item.name = pi.Name; item.value = obj as string; listString.Add(item); } else if (type == typeof(Texture2D)) { var item = new RTexture(); item.name = pi.Name; item.value = obj as Texture2D; listTexture.Add(item); } else { var item = new RUnknown(); item.name = pi.Name; item.type = type.Name; item.value = obj.ToString(); listUnknown.Add(item); } }
static void FilterProject(string projectName, string path) { // 获得项目文件集合 FDictionary <SFileInfo> infos = new FDictionary <SFileInfo>(); foreach (string fileName in RDirectory.ListFiles(path)) { if (fileName.EndsWith(".h") || fileName.EndsWith(".cpp")) { string formatName = fileName.Replace('\\', '/'); string name = RString.Right(formatName, "/"); SFileInfo info = new SFileInfo(); info.fileName = formatName; info.include = false; infos.Set(name, info); } } // 查找使用中的文件集合 string configFileName = path + "/vcproject/" + projectName + ".vcxproj"; FXmlDocument document = new FXmlDocument(configFileName); foreach (FXmlNode xnode in document.Root.Nodes) { if (xnode.IsName("ItemGroup")) { foreach (FXmlNode xfile in xnode.Nodes) { if (xfile.IsName("ClInclude") || xfile.IsName("ClCompile")) { string include = xfile.Get("Include"); string name = RString.Right(include, "\\"); SFileInfo info = infos.Find(name); if (info != null) { info.include = true; } } } } } // 查找删除集合 foreach (SFileInfo info in infos.Values) { if (!info.include) { RLogger.Find(typeof(SFileInfo)).Debug(null, "FilterProject", info.fileName); File.Delete(info.fileName); } } // 查找没用目录 RDirectory.Delete(path + "/build"); RDirectory.Delete(path + "/dist"); RDirectory.Delete(path + "/nbproject/private"); RDirectory.Delete(path + "/maproject/libs"); RDirectory.Delete(path + "/maproject/obj"); RDirectory.Delete(path + "/vcproject/Debug"); RDirectory.Delete(path + "/vcproject/Release"); RDirectory.Delete(path + "/vcproject/x64"); File.Delete(path + "/vcproject/" + projectName + ".vcxproj.user"); }
//============================================================ // <T>解析颜色字符串为数字。</T> // // @param source 字符串 // @return 整数 //============================================================ public static int ParseHex(string source) { // 解析内容 if (RString.IsEmpty(source)) { return(0); } if (!RInt.IsHex(source)) { return(0); } string value = source.Trim(); if (value.Length == 0) { return(0); } // 去除前缀 if (value.StartsWith("#")) { value = value.Substring(1); } if (value.StartsWith("0x")) { value = value.Substring(2); } // 转换为数字 int result = Convert.ToInt32(value, 16); if (value.Length <= 6) { result |= 0xFF << 24; } return(result); }
//============================================================ // <T>格式化数字为颜色字符串。</T> // // @param value 数字 // @param length 长度 // @return 字符串 //============================================================ public static string FormatHex(int value, int length = 8) { string source = String.Format("{0:X}", value); source = RString.PadLeft(source, length, '0'); return(source); }
//============================================================ // <T>序列化内容到输出流。</T> // // @param output 输出流 //============================================================ public override void OnSerialize(IOutput output) { base.OnSerialize(output); output.WriteUint8((byte)_textAlignCd); _font.Serialize(output); output.WriteWideString(RString.Nvl(_text, _label)); }
//============================================================ // <T>数据打包。</T> // // @return 设置内容的位置 //============================================================ public string Pack() { StringBuilder buffer = new StringBuilder(); for (int n = 0; n < _count; n++) { // value返回的值 string name = _names[n]; string value = _values[n]; if (RString.IsBlank(name)) { throw new Exception("Name is invalid."); } // 得到名称的长度及名称长度所占的位数 int nameLength = name.Length; int nameLLength = nameLength.ToString().Length; // 得到值的长度及值长度所占的位数 string valueString = "0"; if (!RString.IsBlank(value)) { int valueLength = value.Length; int valueLLength = valueLength.ToString().Length; valueString = valueLLength.ToString() + valueLength.ToString() + value; } // 接受返回的字符串 string itemPack = nameLLength.ToString() + nameLength.ToString() + name + valueString; // 使用StringBuilder进行字符串追加 buffer.Append(itemPack); } return(buffer.ToString()); }
public void RObjectTest() { RNumber rn = new RNumber(1); RLogical rl = new RLogical(false); RString rs = new RString("abc"); RVector <RString> rvs = new RVector <RString>(RMode.Character, 1); RVector <RNumber> rvn = new RVector <RNumber>(RMode.Numeric, 2); rs.IsString.Should().BeTrue(); rn.IsString.Should().BeFalse(); rl.IsString.Should().BeFalse(); rs.IsNumber.Should().BeFalse(); rn.IsNumber.Should().BeTrue(); rl.IsNumber.Should().BeFalse(); rs.IsScalar.Should().BeTrue(); rn.IsScalar.Should().BeTrue(); rl.IsScalar.Should().BeTrue(); rs.IsBoolean.Should().BeFalse(); rn.IsBoolean.Should().BeFalse(); rl.IsBoolean.Should().BeTrue(); rvs.IsScalar.Should().BeTrue(); rvn.IsScalar.Should().BeFalse(); rvs.IsString.Should().BeTrue(); rvn.IsNumber.Should().BeFalse(); }
public override void LoadConfig(FXmlNode config) { FXmlNodes nodes = config.Nodes; if (nodes != null) { foreach (FXmlNode node in nodes) { string flag = node[PTY_FLAG]; if (!RString.IsEmpty(flag)) { if ("0".EndsWith(flag)) { //_object0 = CreateObject(node); } else if ("1".EndsWith(flag)) { //_object1 = CreateObject(node); } else { throw new FFatalException("Unknown flag. {0}", config.Dump()); } } } } }
//============================================================ private void QDsTemplateEditorForm_Load(object sender, System.EventArgs e) { // 创建设备 _device = RDxCore.Adapter.CreateDevice(pnlViewport.Handle, pnlViewport.Width, pnlViewport.Height); // 创建舞台 FDxStage stage = new FDxStage(); RDxCore.StageConsole.ActiveStage = stage; // 创建场景 _scene = new FDxDesignScene(); _scene.Device = _device; _scene.Setup(); _scene.Region.BackgroundColor.Set(0, 0, 0, 1); _scene.Region.BackgroundColor.Set(0.5f, 0.5f, 0.5f, 1.0f); _scene.Region.Camera.Viewport.width = pnlSpace.Width; _scene.Region.Camera.Viewport.height = pnlSpace.Height; _scene.Region.Camera.Viewport.Update(); _scene.Region.Camera.Position.Set(0, 200, -500); _scene.Region.Camera.LookAt(0, 200, 0); _scene.Region.LightDirectional.Position.Set(1000, 1000, 0); _scene.Region.LightDirectional.Camera.Position.Set(1000, 1000, 0); _scene.Region.LightDirectional.Camera.LookAt(0, 200, 0); // 加载模型 if (!RString.IsEmpty(_templateName)) { LoadTemplate(_templateName); } // 加载场景 // qdsDeviceProperty.LoadDevice(_device); // qdsSceneTree.LoadScene(_scene); // 开始时钟 timRefresh.Enabled = true; CenterToScreen(); }
public override bool DoCheck(FValidatorParameters parameters) { string value = RString.Nvl(parameters.Value); if (!RString.IsEmpty(value)) { string[] items = value.Split('.'); if (items.Length != 4) { parameters.Description = _resource.FindDisplay(MSG_INVALID, _description); return(false); } foreach (string item in items) { int result = 0; if (!Int32.TryParse(item, out result)) { parameters.Description = _resource.FindDisplay(MSG_INVALID, _description); return(false); } if (result < 0 || result > 255) { parameters.Description = _resource.FindDisplay(MSG_INVALID, _description); return(false); } } } return(true); }
public RClass(string className) { this[new RString("class")] = new RString(className); }