Esempio n. 1
0
 public string Peek(int iAt)
 {
     if (iAt >= 0)
     {
         if (!IsEmpty)
         {
             if (iAt < iCount)
             {
                 return(sarr[LastIndex]);
             }
             else
             {
                 RReporting.Warning("not enough strings to return so returned null", "", "StringStack Peek(" + iAt.ToString() + "){Count:" + Count.ToString() + "}");
             }
         }
         else
         {
             RReporting.Warning("no strings to return so returned null", "", "StringStack Peek(" + iAt.ToString() + "){Count:" + Count.ToString() + "}");
         }
     }
     else
     {
         RReporting.ShowErr("Tried to peek at negative index", "", "StringStack Peek(" + iAt.ToString() + "){Count:" + Count.ToString() + "}");
     }
     return(null);
 }
Esempio n. 2
0
        public Var Pop()
        {
            //RReporting.WriteLine("debug var pop iCount="+iCount.ToString()+" and "+(IsEmpty?"is":"is not")+" empty.");
            Var vReturn = null;

            if (iCount <= 0)
            {
                if (iCount == 0)
                {
                    return(null);
                }
                else                   //else <0
                {
                    RReporting.Warning("VarStack iCount was less than zero so setting to zero.", "{iCount:" + iCount.ToString() + "}");
                    iCount = 0;
                    return(null);
                }
            }
            else
            {
                iCount--;
                try {
                    vReturn = objectarr[iCount];                   //this is correct since decremented first
                }
                catch (Exception exn) {
                    RReporting.ShowExn(exn, "VarStack Pop", "accessing VarStack index {at:" + iCount.ToString() + "}");
                }
            }
            return(vReturn);
        }        //end Pop
		public string[] SelectFirst(string[] FieldNames, string WhereWhat, string EqualsValue) {
			string[] sarrReturn=null;
			if (FieldNames!=null&&FieldNames.Length>0) {
				int[] iarrFieldAbs=new int[FieldNames.Length];
				sarrReturn=new string[FieldNames.Length];
				for (int iFieldRel=0; iFieldRel<FieldNames.Length; iFieldRel++) {
					try {
						iarrFieldAbs[iFieldRel]=this.InternalColumnIndexOf(FieldNames[iFieldRel]);
					}
					catch (Exception exn) {
						RReporting.ShowExn(exn,"getting column index and finding row","rtable SelectFirst(...){FieldNames["+iFieldRel.ToString()+"]:\""+RReporting.SafeIndex(FieldNames,iFieldRel,"FieldNames")+"\"}");
					}
				}
				int iWhat=this.InternalColumnIndexOf(WhereWhat);
				int iRow=-1;
				if (iWhat>-1) {
					iRow=this.InternalRowIndexOfFieldValue(iWhat,EqualsValue);
					if (iRow>-1) {
						for (int iFieldRel=0; iFieldRel<FieldNames.Length; iFieldRel++) {
							sarrReturn[iFieldRel]=this.tearr[iRow].Field(iarrFieldAbs[iFieldRel]);
							if (sarrReturn[iFieldRel]==null) RReporting.ShowErr("Getting row "+iRow+" failed.","selecting database row","string array SelectFirst(...)");
						}
					}
					else RReporting.Warning("Nothing to Select","selecting fields from table by value","rtable SelectFirst(FieldNames,WhereWhat=\""+RReporting.StringMessage(WhereWhat,true)+"\",EqualsValue=\""+RReporting.StringMessage(EqualsValue,true)+"\")");
				}
				else RReporting.ShowErr("Cannot find column \""+RReporting.StringMessage(WhereWhat,true)+"\"","selecting fields from table by value","rtable SelectFirst");
			}
			else RReporting.ShowErr((FieldNames==null)?"null":"zero-length"+" FieldNames--can't select.","selecting fields from table","rtable Select(FieldNames,WhereWhat=\""+RReporting.StringMessage(WhereWhat,true)+"\",EqualsValue=\""+RReporting.StringMessage(EqualsValue,true)+"\")");
			return sarrReturn;
		}//end SelectFirst
Esempio n. 4
0
        public static bool Run(string sLine)
        {
            bool   bGood    = false;
            string sCommand = "";
            string sArgs    = "";
            int    iSpace   = -2;

            if (sLine != null && sLine.Length > 0)
            {
                bool bBlock = false;
                for (int iNow = 0; iNow < sarrBlockCommand.Length; iNow++)
                {
                    if (sLine.StartsWith(sarrBlockCommand[iNow] + " ") || sLine.Contains(" " + sarrBlockCommand[iNow] + " "))                 //||sLine.Contains("|rm ")||sLine.Contains("&rm ")  )
                    {
                        bBlock = true;
                    }
                }
                if (sLine[0] != '/' && !sLine.Contains("|") && !sLine.Contains(">") && !sLine.Contains("<") && !sLine.Contains("&") && !sLine.Contains("xargs") && !bBlock)
                {
                    try {
                        System.Diagnostics.Process proc = new System.Diagnostics.Process();
                        proc.EnableRaisingEvents = false;
                        iSpace = sLine.IndexOf(" ");
                        if (iSpace > -1)
                        {
                            sCommand = sLine.Substring(0, iSpace);
                            sArgs    = sLine.Substring(iSpace + 1);
                            proc.StartInfo.FileName  = sCommand;
                            proc.StartInfo.Arguments = sArgs;
                        }
                        else
                        {
                            proc.StartInfo.FileName = sLine;
                        }
                        proc.Start();
                        //proc.WaitForExit();
                        bGood = true;
                    }
                    catch (Exception exn) {
                        bGood = false;
                        RReporting.ShowExn(exn, "running system command",
                                           String.Format("Run{sLine:{0}; sCommand:{1}; sArgs:{2}}",
                                                         RReporting.StringMessage(sLine, true), RReporting.StringMessage(sCommand, true), RReporting.StringMessage(sArgs, true)
                                                         )
                                           );
                    }
                }
                else
                {
                    Console.Error.WriteLine("Warning: blocked a system command: " + sLine);
                }
            }
            else
            {
                RReporting.Warning("Sent a blank string to RPlatform Run(string sSystemCommand)");
            }
            return(bGood);
        }        //end Run
Esempio n. 5
0
 public void CalculateSpacing(int iGlyphType)
 {
     iPixelsSpace = (int)((double)WidthOf('|', iGlyphType) * 1.5);
     iPixelsTab   = iPixelsSpace * 5;
     iLineSpacing = (int)((double)Height * 1.5);
     if (iLineSpacing < 1)
     {
         iLineSpacing = 1;
         RReporting.Warning("Line spacing (calculated from height) was less than 1 so was set to 1", "calculating line spacing", "RFont_bgra32 CalculateSpacing");
     }
 }
Esempio n. 6
0
		public void Set(string val) {
			if (val!=null&&val.Length>0) {
				if (val!="%") {
					if (val[val.Length-1]=='%') Set(  double.Parse( val.Substring(0,val.Length-1) )  );
					else Set( double.Parse(val) );
				}
				else {
					iInternalValue=0;
					RReporting.Warning("Warning: Set Percent using the string \"%\" so setting to 0!");
				}
			}
			else {
				RReporting.Warning("Warning: Set Percent to "+(val==null?"null":(val.Length.ToString()+"-length"))+" string!");
			}
		}
Esempio n. 7
0
 public string Pop()
 {
     //sLogLine=("debug deq iCount="+iCount.ToString()+" and "+(IsEmpty?"is":"is not")+" empty.");
     if (!IsEmpty)
     {
         int iReturn = LastIndex;
         iCount--;
         return(sarr[iReturn]);
     }
     else
     {
         RReporting.Warning("no strings to return so returned null", "", "StringStack Pop");
     }
     return(null);
 }
		public int InternalRowIndexOfFieldValue(int AtInternalColumnIndex, string FieldValue) {
			int iReturn=-1;
			string FieldDataNow;
			if (FieldValue!=null&&FieldValue!="") {
				for (int iRow=0; iRow<iRows; iRow++) {
					FieldDataNow=tearr[iRow].Field(AtInternalColumnIndex);
					if (FieldDataNow==null) {
						RReporting.ShowErr("Can't access field","getting internal row index by value","InternalRowIndexOfFieldValue(AtInternalColumnIndex="+AtInternalColumnIndex+", FieldValue="+RReporting.StringMessage(FieldValue,true)+"){Row:"+iRow+"}");
					}
					else if (FieldDataNow==FieldValue) {
						iReturn=iRow;
						break;
					}
				}
			}
			else {
				RReporting.Warning((FieldValue==null?"null":"zero-length")+" FieldValue search was skipped--reporting as not found.","looking for value in column","InternalRowIndexOfFieldValue");
			}
			return iReturn;
		}//end InternalRowIndexOfFieldValue
Esempio n. 9
0
 private void Init(int iSetMax)           //always called by Constructor
 {
     if (iSetMax < 0)
     {
         RReporting.Warning("StringStack initialized with negative number so it will be set to a default.");
     }
     else if (iSetMax == 0)
     {
         RReporting.Warning("StringStack initialized with zero so it will be set to a default.");
     }
     if (iSetMax <= 0)
     {
         iSetMax = 1;
     }
     Maximum = iSetMax;
     iCount  = 0;
     if (sarr == null)
     {
         RReporting.ShowErr("Stack constructor couldn't initialize sarr");
     }
 }
Esempio n. 10
0
		public bool RenderIncrement(GBuffer gbDest, IRect rectDest) {
			bool bGood=true;
			try {
				gbFractal.SetPixelArgb(400,300, 255,255,0,0);//debug only
				if (!FinishedRenderingAll()) {
					iTickStartPrev=iTickStart;
					iTickStart=PlatformNow.TickCount;
					if (iTickStartPrev!=-1) {//&&iTickStart!=-1) {
						iTicksPerFrame=iTickStart-iTickStartPrev;
						//if (iTicksPerFrame>iMaxUsableTicksPerFrame_ElseIgnoreFrameRate) {
							//TODO: fix this: //FRACTALREAL rPerformanceScaler=(FRACTALREAL)iMaxUsableTicksPerFrame_ElseIgnoreFrameRate/(FRACTALREAL)iTicksPerFrame;
							//TODO: fix this: iMaxPPF=(int)((FRACTALREAL)iMaxPPF*rPerformanceScaler);
							if (iMaxPPF<1) iMaxPPF=1;
						//}
					}
					int iPixelRel=0;
					while (iPixelRel<iMaxPPF&&iPixelsRendered<gbFractal.iPixelsTotal) {
						//xSrc+=rPassUnitsPerChunk;
						if (xDest>=gbFractal.Width) {
							xDest=0;
							yDest+=iPassPixelsPerChunk;
							xSrc=xSrcStart;
							//ySrc+=rPassUnitsPerChunk;
						}
						xSrc=XPixelToUnitLocation(xDest);
						ySrc=YPixelToUnitLocation(yDest);
						
						if (yDest<gbFractal.Height) {
							//gbFractal.SetPixelRgb(xDest,yDest, 255,0,0);//debug only
	
							//float rFractalness=(float)(ResultMandelbrot((float)xSrc,(float)ySrc)%255)/255.0f;
							//TODO: finish this--use rSeed
							//double rFractalness=(double)(ResultMandelbrot((double)xSrc,(double)ySrc)%255)/255.0;
							
							//if (RMath.Dist(RMath.IRound(gbFractal.Width/2),RMath.IRound(gbFractal.Height/2),xDest,yDest)<iDetailRadius) {
							if (iPass==1||RMath.Dist((double)(gbFractal.Width/2.0),(double)(gbFractal.Height/2.0),(double)xDest,(double)yDest)<(double)iDetailRadius) {
								FRACTALREAL rFractalness=(FRACTALREAL)(ResultMandelbrot((FRACTALREAL)xSrc,(FRACTALREAL)ySrc)%255)/fr255;
								if (iPassPixelsPerChunk>1) {
									GBuffer.SetBrushHsva(rFractalness,1.0,rFractalness,1.0);
									gbFractal.DrawRectCroppedFilled(xDest,yDest,iPassPixelsPerChunk,iPassPixelsPerChunk);
								}
								else gbFractal.SetPixelHsva(xDest,yDest,rFractalness,1.0,rFractalness,1.0);
								//xSrc+=rPassUnitsPerChunk;
							}
							
							iPixelsRendered++;
							iPixelRel++;
						}//end if yDest<gbFractal.Height
						else break;//finished rendering frame
						xDest+=iPassPixelsPerChunk;
					}//end while iPixelRel<iMaxPPF
					
					//TODO: finish this
					if (FinishedRenderingFrame()) {
						iPass++;//must be incremented BEFORE ResetLocations (before OnSetPass)
						ResetLocations();//DOES OnStartPass
						iFramesRendered++;
					}
				}//end if !FinishedRenderingAll
				//gbFractal.SetPixelArgb(400,300, 255,0,255,0);//debug only
				if (!gbDest.Draw(rectDest,gbFractal)) {
					bGood=false;
					RReporting.Warning("Couldn't draw Fractal buffer to destination.","{gbFractal:"+GBuffer.VariableMessage(gbFractal)+"; gbDest:"+GBuffer.VariableMessage(gbDest)+"; rectDest:"+rectDest.Description()+"}");
				}
			}
			catch (Exception exn) {
				bGood=false;
				RReporting.ShowExn(exn,"Fractal RenderIncrement","rendering fractal increment");
			}
			return bGood;
		}//end RenderIncrement
Esempio n. 11
0
		public Fractal() {
			RReporting.Warning("Default fractal constructor should not be used.");
			Init(800,600);
		}