Exemplo n.º 1
0
 public bool Push(RForm vAdd)
 {
     if (IsFull)
     {
         Maximum = RConvert.ToInt(RConvert.ToFloat(Maximum) * 1.20f);
     }
     if (!IsFull)
     {
         try {
             if (objectarr[iCount] == null)
             {
                 objectarr[iCount] = new RForm();
             }
             objectarr[iCount] = vAdd;                   //debug performance (change objectarr to refvarr (& rewrite call logic!)(?))
             iCount++;
             //sLogLine="debug_push{iCount:"+iCount.ToString()+"}";
             return(true);
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "RFormStack Push", "adding rform to stack {iCount:" + iCount.ToString() + "}");
         }
         return(false);
     }
     else
     {
         RReporting.ShowErr("RFormStack is full", "RFormStack Push", "adding rform to stack {vAdd:" + ((vAdd == null)?"null":"non-null") + "; iCount:" + iCount.ToString() + "; }");
         return(false);
     }
 }
Exemplo n.º 2
0
        public bool SetHsva(double h, double s, double v, double aTo1)
        {
            byte r, g, b, a;

            a = RConvert.ToByte(aTo1 * 255.0);
            RImage.HsvToRgb(out r, out g, out b, ref h, ref s, ref v);
            return(SetArgb(a, r, g, b));
        }
Exemplo n.º 3
0
        }        //end SetArgb (primary overload)

        public bool SetHsva(float h, float s, float v, float aTo1)
        {
            byte r, g, b, a;

            a = RConvert.ToByte(aTo1 * 255.0f);
            RImage.HsvToRgb(out r, out g, out b, ref h, ref s, ref v);
            return(SetArgb(a, r, g, b));
        }
Exemplo n.º 4
0
		public Rectangle ToRectangle() {
			Rectangle rectReturn=new Rectangle();
			rectReturn.X=RConvert.ToInt(X);
			rectReturn.Y=RConvert.ToInt(Y);
			rectReturn.Width=RConvert.ToInt(Width);
			rectReturn.Height=RConvert.ToInt(Height);
			return rectReturn;
		}
Exemplo n.º 5
0
 public bool SetBigEndian(uint dwPixel32_BigEndian_MostSignificantByteAsA)
 {
     return(this.SetArgb(
                RConvert.ToByte((dwPixel32_BigEndian_MostSignificantByteAsA >> 24) & 0xFF),
                RConvert.ToByte((dwPixel32_BigEndian_MostSignificantByteAsA >> 16) & 0xFF),
                RConvert.ToByte((dwPixel32_BigEndian_MostSignificantByteAsA >> 8) & 0xFF),
                RConvert.ToByte(dwPixel32_BigEndian_MostSignificantByteAsA & 0xFF)
                ));
 }
Exemplo n.º 6
0
 public bool Set(uint dwPixel32BGRA_LittleEndian_LeastSignificantByteAsA)
 {
     return(this.SetArgb(
                RConvert.ToByte(dwPixel32BGRA_LittleEndian_LeastSignificantByteAsA & 0xFF),
                RConvert.ToByte((dwPixel32BGRA_LittleEndian_LeastSignificantByteAsA >> 8) & 0xFF),
                RConvert.ToByte((dwPixel32BGRA_LittleEndian_LeastSignificantByteAsA >> 16) & 0xFF),
                RConvert.ToByte((dwPixel32BGRA_LittleEndian_LeastSignificantByteAsA >> 24) & 0xFF)
                ));
 }
Exemplo n.º 7
0
        public bool CopyFrameToInternalBitmap()
        {
            bool   bGood    = true;
            string sVerbNow = "resetting internal bitmap using frame type";

            try {
                bGood = ResetBitmapUsingFrameNow();
                if (!bGood)
                {
                    RReporting.ShowErr("Failed to reset internal frame image", "CopyFrameToInternalBitmap");
                }
                sVerbNow = "getting bounds";
                gunit    = GraphicsUnit.Pixel;
                rectNowF = bmpLoaded.GetBounds(ref gunit);
                rectNow  = new Rectangle((int)rectNowF.X, (int)rectNowF.Y, (int)rectNowF.Width, (int)rectNowF.Height);
                int iNow = 0;
                for (int yNow = 0; yNow < rectNow.Height; yNow++)
                {
                    for (int xNow = 0; xNow < rectNow.Width; xNow++)
                    {
                        byte aNow, rNow, gNow, bNow;
                        if (gbFrame.rarrData != null)
                        {
                            aNow = RConvert.DecimalToByte(gbFrame.rarrData[iNow]);
                        }
                        else
                        {
                            aNow = 255;
                        }
                        if (gbFrame.pxarrData != null)
                        {
                            RConvert.HsvToRgb(out rNow, out gNow, out bNow, ref gbFrame.pxarrData[iNow].H, ref gbFrame.pxarrData[iNow].S, ref gbFrame.pxarrData[iNow].Y);                                                  //RConvert.YhsToRgb(out rNow, out gNow, out bNow, gbFrame.pxarrData[iNow].Y, gbFrame.pxarrData[iNow].H, gbFrame.pxarrData[iNow].S);
                        }
                        else
                        {
                            rNow = aNow; gNow = aNow; bNow = aNow;
                        }
                        bmpLoaded.SetPixel(xNow, yNow, Color.FromArgb(aNow, rNow, gNow, bNow));
                        iNow++;
                    }
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "CopyFrameToInternalBitmap", sVerbNow);
                bGood = false;
            }
            return(bGood);
        }
		}//end GetDeletionFlag
		public bool Delete_SetMarker(int iInternalRowIndex, bool bSet) {
			bool bGood=false;
			string sFuncNow="rtable Delete_SetMarker";
			RReporting.sParticiple="setting delete flag {bSet:"+RConvert.ToString(bSet)+"}";
			try {
				if (iInternalRowIndex>=0&&iInternalRowIndex<Rows) {
					tearr[iInternalRowIndex].bFlagForDelete=bSet;
					bGood=true;
				}
				else {
					RReporting.ShowErr("iInternalRowIndex out of range",RReporting.sParticiple+" {iInternalRowIndex:"+iInternalRowIndex.ToString()+"; Rows:"+Rows.ToString()+"}",sFuncNow);
					bGood=false;
				}
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,RReporting.sParticiple,sFuncNow);
			}
			return bGood;
		}//end Delete_SetMarker
Exemplo n.º 9
0
        /// <summary>
        /// Set by 6-character (rgb), 8-character (rgba), or 3-character (rgb) hex string (may start with # or 0x, x and hex chars are case-insensitive).
        /// </summary>
        /// <param name="sHexCode"></param>
        /// <returns></returns>
        public bool SetRgb(string sHexCode)
        {
            bool bGood = true;

            try {
                sHexCode = sHexCode.ToUpper();
                if (sHexCode.StartsWith("#"))
                {
                    sHexCode = sHexCode.Substring(1);
                }
                else if (sHexCode.StartsWith("0X"))
                {
                    sHexCode = sHexCode.Substring(2);
                }
                if (sHexCode.Length < 6)
                {
                    if (sHexCode.Length == 3)
                    {
                        if (!SetRgba(RConvert.ToByte(RConvert.HexNibbleToInt(sHexCode[0]) << 4),                      //*17
                                     RConvert.ToByte(RConvert.HexNibbleToInt(sHexCode[1]) << 4),                      //*17
                                     RConvert.ToByte(RConvert.HexNibbleToInt(sHexCode[2]) << 4),                      //*17
                                     255
                                     ))
                        {
                            bGood = false;
                        }
                    }
                    else
                    {
                        RReporting.ShowErr("This hex color code in the file is not complete", "", "RBrush SetRgb(" + sHexCode + ")");
                        bGood = false;
                    }
                }
                else
                {
                    if (sHexCode.Length >= 8)
                    {
                        if (!SetRgba(RConvert.HexToByte(sHexCode.Substring(0, 2)),
                                     RConvert.HexToByte(sHexCode.Substring(2, 2)),
                                     RConvert.HexToByte(sHexCode.Substring(4, 2)),
                                     RConvert.HexToByte(sHexCode.Substring(6, 2))
                                     ))
                        {
                            bGood = false;
                        }
                    }
                    else
                    {
                        if (!SetRgba(RConvert.HexToByte(sHexCode.Substring(0, 2)),
                                     RConvert.HexToByte(sHexCode.Substring(2, 2)),
                                     RConvert.HexToByte(sHexCode.Substring(4, 2)), 255))
                        {
                            bGood = false;
                        }
                    }
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "interpreting the specified hex color code", "RBrush SetRgb(" + sHexCode + ")");
                bGood = false;
            }
            return(bGood);
        }        //end SetRgb(Hex)
Exemplo n.º 10
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sText">Time length formatted as [D]:[H]:[M]:[S.MS], [D]:[H]:[M]:[S]:[F], [H]:[M]:[S];[F], [S.MS], [F],
		/// numbers in arbitrary order but labeled as 0d0h0m0s0ms0f or where
		/// items in brackets are not in brackets but are instead numbers, and where [D] (days) and anything
		/// else to the left of [S] is optional.</param>
		/// <returns>Seconds, or if fails, returns decimal.MinValue instead.</returns>
		public static decimal SecondsFromDHMSF(string sText, decimal dFrameRate, uint FrameRate_override) {
			decimal dReturn=0.0M;
			bool bGood=false;
			RReporting.sParticiple="trimming DHMSF timecode string";
			try {
				darrToSecondMultiplier[TimeType_Frame]=1.0M/dFrameRate;
				darrFromSecondDivisor[TimeType_Frame]=dFrameRate;
				if (sText==null) sText="";
				if (sText.Length>0) {
					//int iMSTotal=0;
					//string[] sarrNum=new String[sText.Length];
					//string[] sarrType=new String[sText.Length];
					//for (int iNow=0; iNow<sText.Length; iNow++) {
					//	sarrNum[iNow]="";
					//	sarrType[iNow]="";
					//}
					int iFirst=0;
					int iLast=sText.Length-1;
					while (RString.IsWhiteSpace(sText[iFirst])) {
						iFirst++;
					}
					while (RString.IsWhiteSpace(sText[iLast])) {
						iLast--;
					}
					if (iFirst>0||(iLast!=(sText.Length-1))) {
						if (iLast>=iFirst) {
							sText=RString.SafeSubstringByInclusiveEnder(sText,iFirst,iLast);
						}
						else sText="";
					}
					int iNums=0;
					RReporting.sParticiple="checking DHMSF timecode string";
					int iDigits=0;
					int iLastDecimal=-1;
					int iLastColon=-1;
					for (int i=0; i<sText.Length; i++) {
						if (RString.IsDigit(sText[i])) iDigits++;
						else if (sText[i]=='.') iLastDecimal=i;
						else if (sText[i]==':') iLastColon=i;
					}
					bool bHasDecimalInLastSegment=iLastDecimal>iLastColon;
					int TimeType_Now=TimeType_Frame; //since SMTPE timecode is [hh]:[mm]:[ss]:[ff] (vegas is [hh]:[mm]:[ss];[ff])
					if (bHasDecimalInLastSegment) {
						TimeType_Now=TimeType_Second;//to account timecode with decimal seconds e.g. [hh]:[mm]:[ss].[_ms]
					}
					int iChar=sText.Length-1;
					bGood=true;
					int ParsingWhat=Parsing_Delimiter;
					int SegmentNow_EndBefore=iChar+1;
					if (RString.IsDigit(sText[iChar])) ParsingWhat=Parsing_Number; //ok to use iChar since this whole process only happens if sText.Length>0
					while (iChar>=-1) {
						if (ParsingWhat==Parsing_Space) {
							if (iChar==-1) {
								//do nothing
							}
							else if (!RString.IsWhiteSpace(sText[iChar])) {
								SegmentNow_EndBefore=iChar+1;//+1 since NOT whitespace
								if (RString.IsDigit(sText[iChar])||(sText[iChar]=='.')) {
									ParsingWhat=Parsing_Number;
									//sarrNum[iNums]+=sText.Substring(iChar,1);
								}
								else {
									ParsingWhat=Parsing_Delimiter;
								}
							}
						}
						else if (ParsingWhat==Parsing_Delimiter) {
							if (iChar<0) {
								RReporting.SourceErr("Warning: unknown text found at start of time string","",sText);
							}
							else if (RString.IsDigit(sText[iChar])||(sText[iChar]=='.')||(RString.IsWhiteSpace(sText[iChar]))) {
								int TimeType_Temp=-1;
								//if (sText[iChar]=='.') {
								//HANDLED BELOW (TimeType_Now decremented twice)
								//	TimeType_Temp=TimeType_Second 
								//}
								//else {
								if (SegmentNow_EndBefore-(iChar+1) == 1) TimeType_Temp=TimeDelimiterToTimeType(sText[iChar+1]); //+1 since [iChar] is NOT delimiter
								else TimeType_Temp=TimeDelimiterToTimeType(RString.SafeSubstringByExclusiveEnder(sText,iChar+1,SegmentNow_EndBefore)); //+1 since [iChar] is NOT delimiter
								//}
								if (TimeType_Temp<0) {//assume generic delimiter //if (sText[iChar]==":"||sText[iChar]==";") {
									if (carrTimeType[TimeType_Now]=='.') TimeType_Now--;//skip f if on ms
									TimeType_Now--;
								}
								else TimeType_Now=TimeType_Temp;
								
								SegmentNow_EndBefore=iChar+1;//+1 since sText[iChar] is NOT delimiter
								if (RString.IsWhiteSpace(sText[iChar])) {
									ParsingWhat=Parsing_Space;
								}
								else {//digit or '.'
									ParsingWhat=Parsing_Number;
								}
								//sarrNum[iNums]+=sText.Substring(iChar,1);
							}
						}
						else if (ParsingWhat==Parsing_Number) {
							if (  iChar<0  ||  ( !RString.IsDigit(sText[iChar]) && !(sText[iChar]=='.') )  ) {
								if (IsValidTimeType(TimeType_Now)) {
									//Each hour is 108000 non-drop frames (30 * 60 * 60) or 107892 drop frames (drop 108 frames). In real time,
									//each hour is 107892.108 frames.
									//Each "deci-minute" is 18000 non-drop frames (30 * 60 * 10) or 17982 drop frames (drop 18 frames, or 2 frames
									//for nine out of every ten minutes). In real time, 10 minutes is 17982.018 frames.
									//Each "single-minute" is 1800 non-drop frames (30 * 60) or 1798 drop frames (drop 2 frames for every minute, or
									//0 frames when multiplying by 0). In real time, a minute is 1798.202 frames.
									//Each second is 30 frames (both timebases), or 29.970 frames real-time.
									if (TimeType_Now==TimeType_Frame) {
										
									}
									else dReturn+=RConvert.ToDecimal( RString.SafeSubstringByExclusiveEnder(sText,iChar+1,SegmentNow_EndBefore) ) * darrToSecondMultiplier[TimeType_Now]; //+1 since [iChar] is NOT digit
								}
								if (!(iChar<0)) {
									SegmentNow_EndBefore=iChar+1;//+1 since [iChar] is NOT part of number
									if (RString.IsWhiteSpace(sText[iChar])) {
										ParsingWhat=Parsing_Space;
									}
									else {
										ParsingWhat=Parsing_Delimiter;
									}
								}//if not out of range
							}
							//else if (sText[iChar]=='.' && TimeType_Now==TimeType_Millisecond) TimeType_Now=TimeType_Second
						}
						else { //ParsingWhat does not have valid opcode
							bGood=false;
							RReporting.ShowErr("DHMSF Parsing Corruption");
						}
						iChar--;
					}//end while iChar>=-1
				}//end if sText.Length>0
				else {
					bGood=true; //good since it is ok to be blank
					dReturn=0.0M;
				}
			}
			catch (Exception e) {
				bGood=false;
				RReporting.ShowExn(e);
			}
			if (!bGood) dReturn=decimal.MinValue;
			return dReturn;
		}//end From(sDHMSF)
Exemplo n.º 11
0
		public FPoint ToFPoint() {
			FPoint pointReturn;
			pointReturn.X=RConvert.ToFloat(X);
			pointReturn.Y=RConvert.ToFloat(Y);
			return pointReturn;
		}
Exemplo n.º 12
0
		public System.Drawing.Point ToPoint() {
			System.Drawing.Point pointReturn=new System.Drawing.Point();
			pointReturn.X=RConvert.ToInt(X);
			pointReturn.Y=RConvert.ToInt(Y);
			return pointReturn;
		}
Exemplo n.º 13
0
        public static void TestMathInConsole()
        {
            float  fTest1;
            float  fTest2;
            double dTest1;
            double dTest2;
            int    iTest1;
            int    iTest2;
            ulong  ulTest1;
            ulong  ulTest2;
            string sTest1;

            byte[] byarrTest1 = new byte[] { 1, 2, 3, 4 };
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("RetroEngineTests.TestMathInConsole");
            Console.WriteLine();
            Console.WriteLine("FastString class:");
            FastString fstrTest1 = new FastString("be", 10);

            Console.WriteLine("fstrTest1=new FastString(\"be\",10):" + fstrTest1.ToString());
            Console.WriteLine("fstrTest1.Length:" + fstrTest1.Length.ToString());
            fstrTest1.Insert(1, "cfd");
            Console.WriteLine("fstrTest1.Insert(1,\"cfd\"):" + fstrTest1.ToString());
            fstrTest1.Remove(2, 1);
            Console.WriteLine("fstrTest1.Remove(2,1):" + fstrTest1.ToString());
            fstrTest1.Append('f');
            Console.WriteLine("fstrTest1.Append('f'):" + fstrTest1.ToString());
            fstrTest1.Append("gh");
            Console.WriteLine("fstrTest1.Append(\"gh\"):" + fstrTest1.ToString());
            Console.WriteLine("fstrTest1.Length:" + fstrTest1.Length.ToString());
            fstrTest1.Insert(fstrTest1.Length, "ij");
            Console.WriteLine("fstrTest1.Insert(fstrTest1.Length,\"ij\"):" + fstrTest1.ToString());
            fstrTest1.Insert(0, "ab");
            Console.WriteLine("fstrTest1.Insert(0,\"ab\"):" + fstrTest1.ToString());
            fstrTest1.Remove(1, 1);
            Console.WriteLine("fstrTest1.Remove(1,1):" + fstrTest1.ToString());
            fstrTest1.Insert(0, '-');
            Console.WriteLine("fstrTest1.Insert(0,'-'):" + fstrTest1.ToString());
            Console.WriteLine();
            Console.WriteLine("Percentage struct:");
            Console.WriteLine("Percentage.ToWholeDivisor:" + Percentage.ToWholeDivisor.ToString());
            Console.WriteLine("Percentage.Entire:" + Percentage.Entire.ToString());
            Percentage percTest1 = new Percentage();

            percTest1.Set_1As100Percent(.5d);
            Console.WriteLine("percTest1.Set_1As100Percent(val=.50):" + percTest1.ToString());
            percTest1.Set(50.0d);
            Console.WriteLine("percTest1.Set(val=50):" + percTest1.ToString());
            Console.WriteLine("percTest1.Multiply(val=800):" + percTest1.Multiply(800).ToString());
            Percentage percTest2 = new Percentage();

            percTest2.From(ref percTest1);
            Console.WriteLine("percTest2.From(val=percTest1):" + percTest2.ToString());
            Console.WriteLine("percTest2.ToString():" + percTest2.ToString());
            Console.WriteLine("percTest2.Equals(val=percTest1):" + ToString(percTest2.Equals(percTest1)));
            percTest2.Set_1As100Percent(1.0234);
            Console.WriteLine("percTest2.Set_1As100Percent(1.0234)" + percTest2.ToString());
            Console.WriteLine("percTest2.ToString():" + percTest2.ToString());
            Console.WriteLine("percTest2.ToString(iDecimalPlaces=-1):" + percTest2.ToString(-1));
            Console.WriteLine("percTest2.ToString(iDecimalPlaces=0):" + percTest2.ToString(0));
            Console.WriteLine("percTest2.ToString(iDecimalPlaces=1):" + percTest2.ToString(1));
            Console.WriteLine("percTest2.ToString(iDecimalPlaces=2):" + percTest2.ToString(2));
            Console.WriteLine("percTest2.ToString(iDecimalPlaces=3):" + percTest2.ToString(3));
            percTest1.Set("100.2");
            Console.WriteLine("percTest1.Set(string val=\"100.2\"):" + percTest1.ToString(2));
            percTest1.Set("10000");
            Console.WriteLine("percTest1.Set(string val=\"10000\"):" + percTest1.ToString(2));
            percTest1.Set(".1%");
            Console.WriteLine("percTest1.Set(string val=\".1%\"):" + percTest1.ToString(2));
            percTest1.Set("10.1%");
            Console.WriteLine("percTest1.Set(string val=\"10.1%\"):" + percTest1.ToString(2));
            percTest1.Set("101%");
            Console.WriteLine("percTest1.Set(string val=\"101%\"):" + percTest1.ToString(2));
            Console.WriteLine();
            Console.WriteLine("Base class static methods:");
            Console.WriteLine("SafeDivideRound(val=1,valDivisor=0,valMax=100):" + SafeDivideRound(1, 0, 100).ToString());
            Console.WriteLine("SafeDivideRound(val=2,valDivisor=0,valMax=100):" + SafeDivideRound(2, 0, 100).ToString());
            Console.WriteLine("SafeDivideRound(val=1,valDivisor=0,valMax=200):" + SafeDivideRound(1, 0, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=-2,valDivisor=0,valMax=100):" + SafeDivideRound(-2, 0, 100).ToString());
            Console.WriteLine("SafeDivideRound(val=-1,valDivisor=0,valMax=200):" + SafeDivideRound(-1, 0, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=100,valDivisor=2,valMax=200):" + SafeDivideRound(100, 2, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=2,valDivisor=3,valMax=200):" + SafeDivideRound(2, 3, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=1,valDivisor=3,valMax=200):" + SafeDivideRound(1, 3, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=100,valDivisor=3,valMax=200):" + SafeDivideRound(100, 3, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=200,valDivisor=300,valMax=200):" + SafeDivideRound(200, 300, 200).ToString());
            Console.WriteLine("SafeDivideRound(val=200,valDivisor=3,valMax=200):" + SafeDivideRound(200, 3, 200).ToString());
            Console.WriteLine();
            iTest1 = int.MinValue;
            Console.WriteLine("iTest1=int.MinValue:" + iTest1.ToString());
            CropAbsoluteValueToPosMax(ref iTest1);
            Console.WriteLine("CropAbsoluteValueToPosMax(ref val=iTest1):" + iTest1.ToString());
            dTest1 = double.MinValue;
            Console.WriteLine("dTest1=double.MinValue:" + dTest1.ToString());
            CropAbsoluteValueToPosMax(ref dTest1);
            Console.WriteLine("CropAbsoluteValueToPosMax(ref val=dTest1):" + dTest1.ToString());
            Console.WriteLine("SafeAdd(dTest,dTest):" + SafeAdd(dTest1, dTest1).ToString());
            Console.WriteLine("SafeAdd(-1*(dTest),-1*dTest):" + SafeAdd(-1 * dTest1, -1 * dTest1).ToString());
            Console.WriteLine("SafeAdd(1f,1f):" + SafeAdd(1F, 1F).ToString());
            Console.WriteLine("SafeAdd(-1f,-1f):" + SafeAdd(-1F, -1F).ToString());
            Console.WriteLine("SafeAdd(1f,-1f):" + SafeAdd(1F, -1F).ToString());
            Console.WriteLine("SafeAdd(-1f,1f):" + SafeAdd(-1F, 1F).ToString());
            Console.WriteLine("SafeAdd(1d,1d):" + SafeAdd(1D, 1D).ToString());
            Console.WriteLine("SafeAdd(-1d,-1d):" + SafeAdd(-1D, -1D).ToString());
            Console.WriteLine("SafeAdd(1d,-1d):" + SafeAdd(1D, -1D).ToString());
            Console.WriteLine("SafeAdd(-1d,1d):" + SafeAdd(-1D, 1D).ToString());
            Console.WriteLine("SafeAdd((int)1,(int)1):" + SafeAdd((int)1, (int)1).ToString());
            Console.WriteLine("SafeAdd((int)-1,(int)-1):" + SafeAdd((int)-1, (int)-1).ToString());
            Console.WriteLine("SafeAdd((int)1,(int)-1):" + SafeAdd((int)1, (int)-1).ToString());
            Console.WriteLine("SafeAdd((int)-1,(int)1):" + SafeAdd((int)-1, (int)1).ToString());
            Console.WriteLine();
            Console.WriteLine("SafeSubtract((ulong)1,(ulong)2):" + SafeSubtract((ulong)1, (ulong)2).ToString());
            Console.WriteLine("SafeSubtract((ulong)2,(ulong)1):" + SafeSubtract((ulong)2, (ulong)1).ToString());
            ulTest1 = ulong.MaxValue - 1;
            ulTest2 = 2;
            Console.WriteLine("ulong.MaxValue:" + ulong.MaxValue.ToString());
            Console.WriteLine("SafeAdd((ulong)" + ulTest1.ToString() + ",(ulong)" + ulTest2.ToString() + "):" + SafeAdd(ulTest1, ulTest2).ToString());
            ulTest2 = 1;
            Console.WriteLine("SafeAdd((ulong)" + ulTest1.ToString() + ",(ulong)" + ulTest2.ToString() + "):" + SafeAdd(ulTest1, ulTest2).ToString());
            Console.WriteLine();
            Console.WriteLine("SafeSubtract(1,1):" + SafeSubtract(1, 1).ToString());
            Console.WriteLine("SafeSubtract(-1,-1):" + SafeSubtract(-1, -1).ToString());
            Console.WriteLine("SafeSubtract(1,-1):" + SafeSubtract(1, -1).ToString());
            Console.WriteLine("SafeSubtract(-1,1):" + SafeSubtract(-1, 1).ToString());
            Console.WriteLine();
            Console.WriteLine("byte SafeAdd(253,2):" + SafeAdd((byte)253, (byte)2).ToString());
            Console.WriteLine("byte SafeAdd(254,2):" + SafeAdd((byte)254, (byte)2).ToString());
            Console.WriteLine("byte SafeSubtract(2,2):" + SafeSubtract((byte)2, (byte)2).ToString());
            Console.WriteLine("byte SafeSubtract(1,2):" + SafeSubtract((byte)1, (byte)2).ToString());
            Console.WriteLine();
            Console.WriteLine("byte SafeAddWrapped(253,2):" + SafeAddWrapped((byte)253, (byte)2).ToString());
            Console.WriteLine("byte SafeAddWrapped(254,2):" + SafeAddWrapped((byte)254, (byte)2).ToString());
            Console.WriteLine("byte SafeSubtractWrapped(2,2):" + SafeSubtractWrapped((byte)2, (byte)2).ToString());
            Console.WriteLine("byte SafeSubtractWrapped(1,2):" + SafeSubtractWrapped((byte)1, (byte)2).ToString());
            Console.WriteLine();
            Console.WriteLine("SafeSqrt(9):" + SafeSqrt(9).ToString());
            Console.WriteLine("SafeSqrt(13):" + SafeSqrt(13).ToString());
            Console.WriteLine("SafeSqrt(19):" + SafeSqrt(19).ToString());
            Console.WriteLine("SafeSqrt(-9):" + SafeSqrt(-9).ToString());
            Console.WriteLine("SafeSqrt(-13):" + SafeSqrt(-13).ToString());
            Console.WriteLine("SafeSqrt(-19):" + SafeSqrt(-19).ToString());
            Console.WriteLine();
            Console.WriteLine("FractionPartOf(2.22222f):" + FractionPartOf(2.22222f).ToString());
            Console.WriteLine("FractionPartOf(2.22222d):" + FractionPartOf(2.22222d).ToString());
            Console.WriteLine("FractionPartOf(1.23f):" + FractionPartOf(1.23f).ToString());
            Console.WriteLine("FractionPartOf(1.23d):" + FractionPartOf(1.23d).ToString());
            fTest1 = 1.23f;
            dTest1 = 1.23d;
            Floor(ref fTest1);
            Floor(ref dTest1);
            Console.WriteLine("Floor(1.93f):" + fTest1.ToString());
            Console.WriteLine("Floor(1.93d):" + dTest1.ToString());
            //Console.WriteLine("IFloor(1.93f):"+IFloor(1.93f).ToString());
            //Console.WriteLine("IFloor(1.93d):"+IFloor(1.93d).ToString());
            fTest1 = 1.23f;
            dTest1 = 1.23d;
            iTest1 = ICeiling(fTest1);
            iTest2 = ICeiling(dTest1);
            Console.WriteLine("ICeiling(1.23f):" + iTest1.ToString());
            Console.WriteLine("ICeiling(1.23d):" + iTest2.ToString());
            Console.WriteLine();
            Console.WriteLine("byarrTest1:" + ToString(byarrTest1));
            Console.WriteLine("SubArray(byarrTest1,0,-1):" + ToString(SubArray(byarrTest1, 0, -1)));
            Console.WriteLine("SubArray(byarrTest1,0,0):" + ToString(SubArray(byarrTest1, 0, 0)));
            Console.WriteLine("SubArray(byarrTest1,0,1):" + ToString(SubArray(byarrTest1, 0, 1)));
            Console.WriteLine("SubArray(byarrTest1,0,2):" + ToString(SubArray(byarrTest1, 0, 2)));
            Console.WriteLine("SubArray(byarrTest1,1,2):" + ToString(SubArray(byarrTest1, 1, 2)));
            Console.WriteLine("SubArray(byarrTest1,2,2):" + ToString(SubArray(byarrTest1, 2, 2)));
            Console.WriteLine("SubArray(byarrTest1,3,2):" + ToString(SubArray(byarrTest1, 3, 2)));
            Console.WriteLine("SubArray(byarrTest1,0,3):" + ToString(SubArray(byarrTest1, 0, 3)));
            Console.WriteLine("SubArray(byarrTest1,1,3):" + ToString(SubArray(byarrTest1, 1, 3)));
            Console.WriteLine("SubArray(byarrTest1,-1,4):" + ToString(SubArray(byarrTest1, -1, 4)));
            Console.WriteLine();
            Console.WriteLine("SubArrayReversed(byarrTest1,0,-1):" + ToString(SubArrayReversed(byarrTest1, 0, -1)));
            Console.WriteLine("SubArrayReversed(byarrTest1,0,0):" + ToString(SubArrayReversed(byarrTest1, 0, 0)));
            Console.WriteLine("SubArrayReversed(byarrTest1,0,1):" + ToString(SubArrayReversed(byarrTest1, 0, 1)));
            Console.WriteLine("SubArrayReversed(byarrTest1,0,2):" + ToString(SubArrayReversed(byarrTest1, 0, 2)));
            Console.WriteLine("SubArrayReversed(byarrTest1,1,2):" + ToString(SubArrayReversed(byarrTest1, 1, 2)));
            Console.WriteLine("SubArrayReversed(byarrTest1,2,2):" + ToString(SubArrayReversed(byarrTest1, 2, 2)));
            Console.WriteLine("SubArrayReversed(byarrTest1,3,2):" + ToString(SubArrayReversed(byarrTest1, 3, 2)));
            Console.WriteLine("SubArrayReversed(byarrTest1,0,3):" + ToString(SubArrayReversed(byarrTest1, 0, 3)));
            Console.WriteLine("SubArrayReversed(byarrTest1,1,3):" + ToString(SubArrayReversed(byarrTest1, 1, 3)));
            Console.WriteLine("SubArrayReversed(byarrTest1,0,4):" + ToString(SubArrayReversed(byarrTest1, 0, 4)));
            Console.WriteLine("SubArrayReversed(byarrTest1,-1,4):" + ToString(SubArrayReversed(byarrTest1, -1, 4)));
            Console.WriteLint("ToByte(257):" + RConvert.ToByte((int)257).ToString());
            Console.WriteLint("ToByte(-2):" + RConvert.ToByte((int)-1).ToString());
            Console.WriteLint("ToByte(257.0d):" + RConvert.ToByte(257.0d).ToString());
            Console.WriteLint("ToByte(-2.0d):" + RConvert.ToByte(-2.0d).ToString());
            Console.WriteLint("ToByte(2.4d):" + RConvert.ToByte(2.4d).ToString());
            Console.WriteLint("ToByte(2.5d):" + RConvert.ToByte(2.5d).ToString());
            Console.WriteLint("ToByte(2.4f):" + RConvert.ToByte(2.4f).ToString());
            Console.WriteLint("ToByte(2.5f):" + RConvert.ToByte(2.5f).ToString());
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            //SubArrayReversed(ref byarrTest1
        } //end TestMathInConsole
Exemplo n.º 14
0
		}//end GetForcedMeta

		public bool IsFlaggedForDeletion(int iInternalRowIndex) {
			bool bReturn=false;
			string sFuncNow="rtable IsFlaggedForDeletion";
			RReporting.sParticiple="getting delete flag";
			try {
				if (iInternalRowIndex>=0&&iInternalRowIndex<Rows) {
					bReturn=tearr[iInternalRowIndex].bFlagForDelete;
				}
				else {
					bReturn=false;
					RReporting.ShowErr("iInternalRowIndex out of range",RReporting.sParticiple+" {iInternalRowIndex:"+iInternalRowIndex.ToString()+"; Rows:"+Rows.ToString()+"; returning:"+RConvert.ToString(bReturn)+"}",sFuncNow);
				}
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,RReporting.sParticiple+" {iInternalRowIndex:"+iInternalRowIndex.ToString()+"; Rows:"+Rows.ToString()+"; returning:"+RConvert.ToString(bReturn)+"}",sFuncNow);
			}
			return bReturn;
		}//end GetDeletionFlag
Exemplo n.º 15
0
        }        //end ToByteArray

        public static string ToString(byte[] byarrData)
        {
            return(byarrData != null?RConvert.SubArrayToString(byarrData, 0, byarrData != null?byarrData.Length : 0) : "");
        }
Exemplo n.º 16
0
        public bool CopyFrameFromInternalBitmap()
        {
            bool bGood = true;

            try {
                if (bmpLoaded == null)
                {
                    RReporting.ShowErr("image not loaded!", "CopyFrameFromInternalBitmap");
                    bGood = false;
                }
                else if (gbFrame == null)
                {
                    bGood = false;
                    RReporting.ShowErr("No frame is selected, cannot continue with operation.", "CopyFrameFromInternalBitmap");
                }
                else
                {
                    gunit    = GraphicsUnit.Pixel;
                    rectNowF = bmpLoaded.GetBounds(ref gunit);
                    rectNow  = new Rectangle((int)rectNowF.X, (int)rectNowF.Y, (int)rectNowF.Width, (int)rectNowF.Height);
                    int iPixelsNew = rectNow.Width * rectNow.Height;
                    //gbFrame.iWidth!=rectNow.Width || gbFrameiHeight!=rectNow.Height
                    bool bNewSize = (iPixelsNew != gbFrame.iPixelsTotal);
                    gbFrame.iWidth  = rectNow.Width;                 //debug assumes these are the only vars that need to be changed
                    gbFrame.iHeight = rectNow.Height;                //debug assumes these are the only vars that need to be changed
                    if (gbFrame.pxarrData == null)
                    {
                        gbFrame.pxarrData = new PixelYhs[iPixelsNew];
                        if (gbFrame.rarrData == null || bNewSize)
                        {
                            gbFrame.rarrData = new REAL[iPixelsNew];
                        }
                    }
                    else if (gbFrame.rarrData == null)
                    {
                        gbFrame.rarrData = new REAL[iPixelsNew];
                        if (bNewSize)
                        {
                            gbFrame.pxarrData = new PixelYhs[iPixelsNew];
                        }
                    }
                    else if (bNewSize)
                    {
                        gbFrame.pxarrData = new PixelYhs[iPixelsNew];
                        gbFrame.rarrData  = new REAL[iPixelsNew];
                    }
                    int   iNow = 0;
                    Color pxNow;
                    for (int yNow = 0; yNow < rectNow.Height; yNow++)
                    {
                        for (int xNow = 0; xNow < rectNow.Width; xNow++)
                        {
                            pxNow = bmpLoaded.GetPixel(xNow, yNow);
                            gbFrame.pxarrData[iNow].FromRgb(pxNow.R, pxNow.G, pxNow.B);
                            gbFrame.rarrData[iNow] = RConvert.ByteToReal(pxNow.A);
                            iNow++;
                        }
                    }
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "CopyFrameFromInternalBitmap");
                bGood = false;
            }
            return(bGood);
        }        //end CopyFrameFromInternalBitmap