Ejemplo n.º 1
0
		public int Elements(string sNameNow) {
			int iFound=0;
			bool bFound=true;
			int iVarNow=IndexOf(sNameNow);
			try {
				if (iVarNow>=0) {
					varr[iVarNow].Elements();
				}
				else RReporting.ShowErr("Variable named \""+sNameNow+"\" does not exist.","Variables Elements");
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"Variables Elements","getting script array size");
			}
			return iFound;
		}//end Elements (formerly IndecesAtFirstDim or IndecesAtDim1)
Ejemplo n.º 2
0
        }        //end FromFixedHeightStaggered

        public bool FromImageValue(string sFile, int iCharWidth, int iCharHeight, int iRows, int iColumns)
        {
            bool  bGood = false;
            RAnim animNormal;

            RReporting.sLastFile = sFile;
            try {
                animNormal = new RAnim();
                bGood      = Init();
                if (bGood)
                {
                    Console.Error.WriteLine("FromImageValue...");
                    bGood = animNormal.SplitFromImage32(sFile, iCharWidth, iCharHeight, iRows, iColumns);
                    if (animNormal.Frame(0) == null)
                    {
                        Console.Error.WriteLine("SplitFromImage32...FAILED -- Null frame zero upon splitting image in " + String.Format("rfont FromImageValue(sFile={0},iCharWidth={1},iCharHeight={2},iRows={3},iColumns={4})", RReporting.StringMessage(sFile, true), iCharWidth, iCharHeight, iRows, iColumns));
                    }
                    else
                    {
                        Console.Error.WriteLine("SplitFromImage32...OK " + String.Format("rfont FromImageValue(sFile={0},iCharWidth={1},iCharHeight={2},iRows={3},iColumns={4})", RReporting.StringMessage(sFile, true), iCharWidth, iCharHeight, iRows, iColumns));
                    }
                    //animNormal.SaveSeq("etc/test/0.debug-glyph", "png");
                    //RImage.OverlayToBigNoClipRaw(ref riTarget, ref ipAt, ref animNormal.riFrame.byarrData, iCharWidth, iCharHeight, 4);
                    if (bGood)
                    {
                        Normal     = animNormal.CopyAsGray();
                        Bold       = Normal.Copy();
                        Italic     = Normal.Copy();
                        BoldItalic = Normal.Copy();
                        //TODO: finish modifying the Glyph Types -- italics using image manip
                    }
                    else
                    {
                        RReporting.ShowErr("Failed to split image", "splitting image from value", "rfont FromImageValue(" + RReporting.StringMessage(sFile, true) + ",...) {}");
                    }
                    //ShowAsciiTable();
                    //Console.Error.WriteLine("Normal.ToString(true):"+Normal.ToString(true));
                }
                else
                {
                    RReporting.ShowErr("Couldn't initialize font glyph graphics buffer", "initializing font graphics", "RFont FromImageValue");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "initializing font graphics", "RFont FromImageValue");
            }
            return(bGood);
        }        //end FromImageValue
Ejemplo n.º 3
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 InternalRowIndexOfFieldValue
		public string GetForcedString(int AtInternalRowIndex, int AtInternalColumnIndex) {
			string sReturn=null;
			try {
				if (AtInternalRowIndex<this.Rows) {
					if (AtInternalColumnIndex<tearr[AtInternalRowIndex].Columns) {
						sReturn=tearr[AtInternalRowIndex].Field(AtInternalColumnIndex);
						if (sReturn==null) RReporting.ShowErr("Getting row failed.","getting forced field string","GetForcedString(AtInternalRowIndex="+AtInternalRowIndex+",AtInternalColumnIndex="+AtInternalColumnIndex+")");
					}
					else RReporting.ShowErr("Column is beyond range","getting value at row,col location","GetForcedString("+AtInternalRowIndex.ToString()+","+AtInternalColumnIndex.ToString()+"){Columns:"+tearr[AtInternalRowIndex].Columns.ToString()+"}");
				}
				else RReporting.ShowErr("Row is beyond range","getting value at row,col location","GetForcedString("+AtInternalRowIndex.ToString()+","+AtInternalColumnIndex.ToString()+"){Rows:"+Rows.ToString()+"}");
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"getting value at row,col location","GetForcedString("+AtInternalRowIndex.ToString()+","+AtInternalColumnIndex.ToString()+")");
			}
			return sReturn;
		}
Ejemplo n.º 5
0
		public bool Enq(int add) { //Enqueue
			if (!IsFull) {
				try {
					arrobjects[NewIndex]=add;
					iCount++;
					return true;
				}
				catch (Exception exn) {
					RReporting.ShowExn(exn,"accessing intq array","intq Enq("+add.ToString()+") {enqueue-at:"+NewIndex.ToString()+"}");
				}
				return false;
			}
			else {
				RReporting.ShowErr("IntQ is full, can't enqueue","IntQ Enq("+add.ToString()+") {used:"+iCount.ToString()+"}");
				return false;
			}
		}
Ejemplo n.º 6
0
		}//end Deq
		public bool Enq(Packet packetX) { //debug performance make this a reference???
			bool bGood=false;
			try {
				//if (userarr[packetX.iTokenNum].sTo == packetX.sFrom) {
				if (accountant.NameOfNum(packetX.iTokenNum) == packetX.sFrom) {
					packetqIn.Enq(packetX); //packet will be processed later by Packeting
					bGood=true;
				}
				else {
					RReporting.ShowErr("security notice: name at token #"+packetX.iTokenNum.ToString()+" was "+accountant.NameOfNum(packetX.iTokenNum)+" not "+packetX.sFrom);
				}
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"Packeter Enq","checking matching name at token #"+packetX.iTokenNum.ToString()+" for authenticating a user packet" );
			}
			return bGood;
		}
Ejemplo n.º 7
0
		public void From(IRect rectFrom, bool bToInclusiveZone) {
			try {
				Left=rectFrom.X;
				Top=rectFrom.Y;
				Right=rectFrom.X+rectFrom.Width; //i.e. Width 1 makes exclusive rect of 1 width but inclusive rect of 2 width (fixed below)
				Bottom=rectFrom.Y+rectFrom.Height;
				if (bToInclusiveZone) {
					if (rectFrom.Height>0) Bottom-=1;
					else RReporting.ShowErr("Source rect height was "+rectFrom.Height.ToString()+" while setting IZone");
					if (rectFrom.Width>0) Right-=1;
					else RReporting.ShowErr("Source rect width was "+rectFrom.Width.ToString()+" while setting IZone");
				}
			}
			catch (Exception e) {
				RReporting.ShowExn(e,"IZone From(IRect)");
			}
		}
		}//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
Ejemplo n.º 9
0
 public RGradient(int iShades)
 {
     try {
         Init(iShades);
         Pixel32Struct pxUpper = new Pixel32Struct();
         Pixel32Struct pxLower = new Pixel32Struct();
         pxUpper.A = 255;
         pxLower.B = 255;
         pxLower.G = 255;
         pxLower.R = 255;
         if (!From(ref pxUpper, ref pxLower))
         {
             RReporting.ShowErr("Error calculating gradient values", "", "RImage(int) constructor");
         }
     }
     catch (Exception exn) {
         RReporting.ShowExn(exn, "creating gradient values", "RImage(int) constructor");
     }
 }
Ejemplo n.º 10
0
 public string GetForcedString(int index)
 {
     if (vsData != null)
     {
         try {
             return(vsData.GetForcedString(index));
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "packet GetForcedString", "trying to get string at index " + index.ToString());
             return("");
         }
     }
     else
     {
         RReporting.ShowErr("Tried to get string index " + index.ToString() + " from packet with null vsData", "packet GetForcedString");
         return("");
     }
     return("");
 }
Ejemplo n.º 11
0
		}//end iReturn
		public bool Update(int InternalRowIndex, int InternalColumnIndex, string val) {
			bool bGood=false;
			try {
				if (InternalRowIndex>=0&&InternalRowIndex<this.Rows) {
					if (InternalColumnIndex>=0&&InternalColumnIndex<this.Columns) {
						if (tearr!=null) {
							bGood=tearr[InternalRowIndex].SetField(InternalColumnIndex,val);
						}
						else RReporting.ShowErr("Tried to update column in null table","updating field by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+"){tearr:null}");
					}
					else RReporting.ShowErr("Tried to update column beyond range","updating field by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+")");
				}
				else RReporting.ShowErr("Tried to update row beyond range","updating field by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+")");
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"updating row by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+")");
			}
			return bGood;
		}
Ejemplo n.º 12
0
		}//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
Ejemplo n.º 13
0
		public string TitlesToCSVLine(bool bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty, bool bExtendedTitleColumns, int ColumnStart, int ColumnCount) {
			string sReturn="";
			RecheckIntegrity();
			if (this.teTitles!=null) {
				if (bExtendedTitleColumns) {
					string sField="";
					int ColAbs=ColumnStart;
					for (int ColRel=0; ColRel<ColumnCount; ColRel++) {
						sField="";
						if (bExtendedTitleColumns) {
							sField=RString.SafeString(GetForcedType(ColAbs),false);
							if (sField!="") sField+=" ";
						}//end if bExtendedTitleColumns
						string FieldDataNow=teTitles.Field(ColAbs);
						if (FieldDataNow==null) {
							RReporting.ShowErr("Can't access field","generating csv line","TitlesToCSVLine {NewLineInField:"+(bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty?"TAB":"BR with marker")+"; Row:title; Column:"+ColAbs+"}");
						}
						sField+=RString.SafeString(FieldDataNow,false);
						if (bExtendedTitleColumns) {
							string sMeta=GetForcedMeta(ColAbs);
							if (sMeta!=null) {
								sMeta=RString.SafeString(sMeta,false);
								sMeta=RString.RemoveEndsWhiteSpace(sMeta);
								if (!sMeta.StartsWith("{")) {
									sMeta=RString.Replace(sMeta,"{","");
									sMeta="{"+sMeta;
								}
								if (!sMeta.EndsWith("}")) {
									sMeta=RString.Replace(sMeta,"}","");
									sMeta+="}";
								}
								sField+=sMeta;
							}//end if metadata
						}//end if bExtendedTitleColumns
						sReturn+=((ColRel!=0)?",":"")+RTable.LiteralFieldToCSVField(sField,this.cFieldDelimiter,this.cTextDelimiter,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty);
						ColAbs++;
					}//end for field (column header)
				}
				else sReturn=teTitles.ToCSVLine(cFieldDelimiter, cTextDelimiter, bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty,ColumnStart,ColumnCount);
			}
			else RReporting.ShowErr("Cannot read nonexistant title row.","Converting table titles to text line","TitlesToCSVLine");
			return sReturn;
		}
Ejemplo n.º 14
0
		public bool Enq(Variables vsAdd) { //Enqueue
			if (!IsFull) {
				try {
					//if (vsarr[iNew]==null) vsarr[iNew]=new Variables();
					vsarr[iNew]=vsAdd;
					iCount++;
					//sLogLine="debug enq iCount="+iCount.ToString();
					return true;
				}
				catch (Exception exn) {
					RReporting.ShowExn(exn,"VariablesQ Enq("+((vsAdd==null)?"null interaction":"non-null")+")","setting iactionarr["+iNew.ToString()+"]");
				}
				return false;
			}
			else {
				RReporting.ShowErr("VariablesQ is full, with "+iCount.ToString()+" packets","VariablesQ Enq("+((vsAdd==null)?"null packet":"non-null")+")");
				return false;
			}
		}
Ejemplo n.º 15
0
		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
Ejemplo n.º 16
0
		/// <summary>
		/// Updates entire row to given array where column WhereFieldName has the exact value of EqualsFieldValue
		/// </summary>
		/// <param name="sarrLiteralFields">Row to replace an existing row if found (or to append to the table if bAppendIfFieldValueNotFound is true)</param>
		/// <param name="WhereFieldName">Update query field name (column)</param>
		/// <param name="EqualsFieldValue">Update at this field value (row)</param>
		/// <param name="bAppendIfFieldValueNotFound">Whether to append the row the table if the query finds no row to update.  If false, method returns false if no row is modified.</param>
		/// <param name="bCopyRowByRef">Keep the row--the values will change here if changed elsewhere.  If false, each of the field values are copied to a new row array.</param>
		/// <returns></returns>
		public bool UpdateAll(out bool bInsertedNewRow, string[] sarrLiteralFields, string WhereFieldName, string EqualsFieldValue, bool bAppendIfFieldValueNotFound, bool bCopyRowByRef) {
			bInsertedNewRow=false;
			bool bGood=false;
			int iInternalRowIndex=-1;
			try {
				int iInternalColumnIndex=InternalColumnIndexOf(WhereFieldName);
				if (iInternalColumnIndex>-1) {
					//ValueExistsInColumn(iInternalColumnIndex,EqualsFieldValue)
					iInternalRowIndex=InternalRowIndexOfFieldValue(iInternalColumnIndex,EqualsFieldValue);
					if (iInternalRowIndex<0) {
						if (bAppendIfFieldValueNotFound) {
							iInternalRowIndex=iRows;
							iRows++;
							bInsertedNewRow=true;
						}
					}
					if (iInternalRowIndex>-1) {
						int iMaxIndex=(iInternalRowIndex>iRows)?iInternalRowIndex:iRows;
						if (iMaxIndex>=this.Maximum) Maximum=iMaxIndex+iMaxIndex/2+1;
						tearr[iInternalRowIndex]=new TableEntry(sarrLiteralFields,bCopyRowByRef);
						bGood=true;
					}
				}//end if WHERE field is accessible
				else {
					bGood=false;
					bInsertedNewRow=false;
					RReporting.ShowErr("Column does not exist","Updating Row","UpdateAll(...,"+RReporting.StringMessage(WhereFieldName,true)+"){Titles:"+RReporting.StringMessage(teTitles.ToCSVLine(this.cFieldDelimiter,this.cTextDelimiter,true),true)+"}");
				}
			}
			catch (Exception exn) {
				bGood=false;
				RReporting.ShowExn(exn,bInsertedNewRow?"inserting row":"updating row","rtable UpdateAll");
				//NOTE: must show exception BEFORE changing bInsertedNewRow so that bInsertedNewRow's status can be recorded
				if (bInsertedNewRow) {
					iRows--;
					if (iRows<0) iRows=0;
					bInsertedNewRow=false;
				}
			}
			return bGood;
		}//end UpdateAll
Ejemplo n.º 17
0
 public bool Enq(string sAdd)           //Enqueue
 {
     if (!IsFull)
     {
         try {
             arrobjects[NewIndex] = sAdd;
             iCount_PlusFirstIsOneAfterLast++;
             //sLogLine="debug enq iCount_PlusFirstIsOneAfterLast="+iCount_PlusFirstIsOneAfterLast.ToString();
             return(true);
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "accessing stringq array", "stringq Enq(" + RReporting.StringMessage(sAdd, false) + ") {enqueue-at:" + NewIndex.ToString() + "}");
         }
         return(false);
     }
     else
     {
         RReporting.ShowErr("StringQ is full, can't enqueue", "StringQ Enq(" + ((sAdd == null)?"null string":"non-null") + ") {used:" + iCount_PlusFirstIsOneAfterLast.ToString() + "}");
         return(false);
     }
 }
Ejemplo n.º 18
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");
     }
 }
Ejemplo n.º 19
0
 public bool Enq(RForm objectAdd)           //Enqueue
 {
     if (!IsFull)
     {
         try {
             arrobjects[NewIndex] = objectAdd;
             iCount_PlusFirstIsOneAfterLast++;
             //sLogLine="debug enq iCount_PlusFirstIsOneAfterLast="+iCount_PlusFirstIsOneAfterLast.ToRForm();
             return(true);
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "accessing RFormq array", "RFormq Enq(" + RReporting.RFormMessage(objectAdd, false) + ") {enqueue-at:" + NewIndex.ToRForm() + "}");
         }
         return(false);
     }
     else
     {
         RReporting.ShowErr("RFormQ is full, can't enqueue", "RFormQ Enq(" + ((objectAdd == null)?"null RForm":"non-null") + ") {used:" + iCount_PlusFirstIsOneAfterLast.ToRForm() + "}");
         return(false);
     }
 }
Ejemplo n.º 20
0
        }        //end Init()

        /////////// Done Initialization /////////////

        public bool Enq(Packet packetNew)
        {
            bool bReturn = false;

            try {             //if didn't crash
                if (packeter != null)
                {
                    bReturn = packeter.Enq(packetNew);                                 //passes on the packet to the engine server
                }
                else
                {
                    RReporting.ShowErr("Port says: Server was not created so the data couldn't be processed.");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "port Enq");
                RReporting.ShowErr("Port says: Server thread not working!!! Please restart!");
                return(false);
            }
            return(bReturn);
        }
Ejemplo n.º 21
0
 //public RPaint (byte a, byte r, byte g, byte b) {
 // this constructor has been eliminated to avoid byte order confusion--use RPaint.From instead
 //	InitUninitializedNonNull();
 //	SetArgb(a,r,g,b);
 //}
 /// <summary>
 /// Assumes BGRA, BGR, or grayscale (255 will be used as alpha and gray value as color)
 /// </summary>
 /// <param name="byarrPixelData"></param>
 public RPaint(byte[] byarrPixelData, int iStart, int iChannels)
 {
     InitUninitializedNonNull();
     if (byarrPixelData != null)
     {
         if (iStart + iChannels <= byarrPixelData.Length &&
             iStart >= 0 &&
             iStart < byarrPixelData.Length &&
             iChannels >= 1)
         {
             if (iChannels == 1)
             {
                 SetArgb(255, byarrPixelData[iStart], byarrPixelData[iStart], byarrPixelData[iStart]);
             }
             else if (iChannels == 3)
             {
                 SetArgb(255, byarrPixelData[iStart + 2], byarrPixelData[iStart + 1], byarrPixelData[iStart]);
             }
             else if (iChannels == 4)
             {
                 SetArgb(byarrPixelData[iStart + 3], byarrPixelData[iStart + 2], byarrPixelData[iStart + 1], byarrPixelData[iStart]);
             }
             else
             {
                 RReporting.ShowErr("Error: unrecognized channel count was was ignored (must be 4 for BGRA, 3 for BGR, or 1 for grayscale) so new RPaint was set to Argb(0,0,0,0)", "creating RPaint object {byarrPixelData" + ((byarrPixelData != null)?(".Length:" + byarrPixelData.Length.ToString()):":null") + "; iStart=" + iStart.ToString() + "; iChannels=" + iChannels.ToString() + "}");
                 SetArgb(0, 0, 0, 0);
             }
         }
         else
         {
             RReporting.ShowErr("Error: out-of-range array access was was ignored so new RPaint was set to Argb(0,0,0,0)", "creating RPaint object {byarrPixelData" + ((byarrPixelData != null)?(".Length:" + byarrPixelData.Length.ToString()):":null") + "; iStart=" + iStart.ToString() + "; iChannels=" + iChannels.ToString() + "}");
             SetArgb(0, 0, 0, 0);
         }
     }
     else
     {
         RReporting.ShowErr("Error: null byte array was ignored so new RPaint was set to Argb(0,0,0,0)");
         SetArgb(0, 0, 0, 0);
     }
 }
Ejemplo n.º 22
0
		}//end GetLoginConfirmation
		public bool IsValidPacket(ref Packet packetX) {
			if (packetX==null) return false;
			//if (packetX.iTokenNum<0 && ) return true; //debug security, maybe use  &&packetX.sTo==sNameAdmin
			//else if (packetTokenNum==0) return false;
			bool bGood=false;
			//for (int i=0; i<iUsers; i++) {
			//	if (iarrIndexer[i]==packetX.iTokenNum) {
			//		bGood=true;
			//		break;
			//	}
			//}
			try {
				if (userarr[packetX.iTokenNum]!=null) {
					if (userarr[packetX.iTokenNum].iTokenBytes==packetX.iTokenBytes) {
						if ((packetX.iTokenBytes>0) && (packetX.iTokenBytes<=iMaxTokenBytes)) {
							GetLoginConfirmation(ref packetTemp, packetX.iTokenNum);
							if (packetTemp.iType==PacketType.LoginConfirmation) {
								bGood=true;
								for (int i=0; i<packetX.iTokenBytes; i++) {
									if (packetX.byarrToken[i]!=packetTemp.byarrToken[i]) {
										bGood=false;
										break;
									}
								}
							}
						}
					}
				}
				else {
					if (packetX.iTokenNum>0) RReporting.ShowErr("User #"+packetX.iTokenNum+" who is sending packet is not logged in");
					bGood=false;
				}
			}
			catch (Exception exn) {
				bGood=false;
				RReporting.ShowExn(exn,"IsValidPacket","accessing security variables");
				//Lockout();//debug security - mark user account for causing exception
			}
			return bGood;
		}//end IsValidPacket
Ejemplo n.º 23
0
        public bool SaveSeq(string sFileBaseName, string sFileExt, int iGlyphType)
        {
            bool bGood = false;

            try {
                bGood = animarrGlyphType[iGlyphType].SaveSeq(sFileBaseName, sFileExt);
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "GFont SaveSeq", "saving font to image sequence");
                bGood = false;
            }
            if (!bGood)
            {
                try {
                    RReporting.ShowErr("Failed to save " + sFileExt + " files named starting with " + sFileBaseName + " " + animarrGlyphType[iGlyphType].ToString(true), "GFont SaveSeq");
                }
                catch (Exception exn2) {
                    RReporting.ShowExn(exn2, "GFont SaveSeq", "accessing font glyphs (saving " + sFileExt + " files named starting with " + sFileBaseName + ")");
                }
            }
            return(bGood);
        }
Ejemplo n.º 24
0
        }        //end Shade

        public bool ShadeAlpha(ref byte[] byarrDest, int iDestByte, int iValue)
        {
            bool bGood = true;

            try {
                if (iBytesPP >= 4)
                {
                    if (by2dGrad[iValue][3] == 0)                    //transparent
                    {
                    }
                    else if (by2dGrad[iValue][3] == 255)
                    {
                        byarrDest[iDestByte] = by2dGrad[iValue][0];
                        iDestByte++;
                        byarrDest[iDestByte] = by2dGrad[iValue][1];
                        iDestByte++;
                        byarrDest[iDestByte] = by2dGrad[iValue][2];
                    }
                    else                      //else blend alpha
                    {
                        byarrDest[iDestByte] = RMath.Approach(byarrDest[iDestByte], by2dGrad[iValue][0], (float)by2dGrad[iValue][3] / 255.0f);
                        iDestByte++;
                        byarrDest[iDestByte] = RMath.Approach(byarrDest[iDestByte], by2dGrad[iValue][1], (float)by2dGrad[iValue][3] / 255.0f);
                        iDestByte++;
                        byarrDest[iDestByte] = RMath.Approach(byarrDest[iDestByte], by2dGrad[iValue][2], (float)by2dGrad[iValue][3] / 255.0f);
                    }
                }
                else
                {
                    RReporting.ShowErr("Incorrect gradient bit depth (need 4 for ShadeAlpha)", "", String.Format("RGradient ShadeAlpha(...){{GradientBitDepth:{0}}}", (iBytesPP * 8)));
                }
            }
            catch (Exception exn) {
                bGood = false;
                RReporting.ShowExn(exn, "shading", "RImage ShadeAlpha(byte array location) {iDestByte:" + iDestByte.ToString() + "; iValue:" + iValue.ToString() + "; by2dGrad.Length:" + by2dGrad.Length.ToString() + "}");
            }
            return(bGood);
        }        //end ShadeAlpha
Ejemplo n.º 25
0
		}//end ForceSet(...,...,string)
		public bool ForceSetByRef(int iInternalIndex, string sName, byte[] byarrToReference) {
			bool bGood=true;
			try {
				if (iInternalIndex>=MAXIMUM) {
					IncreaseMaxToFuzzy(iInternalIndex+1);
				}
				if (iInternalIndex>iCount) {//but CAN be created at iCount!!!!
					bGood=false;
					RReporting.ShowErr("variables.ForceSetByRef(...,"+sName+",...)","Index "+iInternalIndex.ToString()+" is beyond "+iCount.ToString()+" currently used slots and cannot be set or created.");
				}
				else if (iInternalIndex>=0) { //else if everything is okay, set it
					//if (sName.Length>0) {
						//DONT check//if (byarrToReference.Length>0) {
						if (varr[iInternalIndex]==null) varr[iInternalIndex]=new Variable(sName,byarrToReference);
						else varr[iInternalIndex].byarrVal=byarrToReference;
						varr[iInternalIndex].iType=Variable.TypeBinary;
						if (iInternalIndex==iCount) iCount++;
						//}
						//else {
						//	bGood=false;
						//	RReporting.ShowErr("variables.ForceCreate","Value is blank.");
						//}
					//}
					//else {
					//	bGood=false;
					//	RReporting.ShowErr("Name is blank.","variables ForceSet");
					//}
				}
				else {
					bGood=false;
					RReporting.ShowErr("variables ForceSetByRef","Index "+iInternalIndex.ToString()+" is not valid");
				}
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"ForceSetByRef("+((sName==null)?"null":"\"sName\","),((byarrToReference==null)?"null":"\"val\")"));
			}
			return bGood;
		}//end ForceSetByRef(...,...,byarrToReference)
Ejemplo n.º 26
0
        public bool SaveSeq(string sFileBaseName, string sFileExt, int iGlyphType)
        {
            RReporting.sLastFile = sFileBaseName + "*." + sFileExt;
            bool bGood = false;

            try {
                bGood = animarrGlyphType[iGlyphType].SaveSeq(sFileBaseName, sFileExt);
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "accessing font glyph type while saving", "RFont SaveSeq {sFileBaseName:" + sFileBaseName + "; sFileExt:" + sFileExt + "; GlyphType:" + GlyphTypeToString(iGlyphType) + "}");
                bGood = false;
            }
            if (!bGood)
            {
                try {
                    RReporting.ShowErr("Failed to save " + sFileExt + " files with names starting on " + sFileBaseName + " " + animarrGlyphType[iGlyphType].ToString(true), "", "SaveSeq");
                }
                catch (Exception exn2) {
                    RReporting.ShowExn(exn2, "accessing font glyph type while saving error data", "RFont SaveSeq(" + sFileBaseName + "," + sFileExt + "," + iGlyphType.ToString() + "){sFileBaseName:" + sFileBaseName + "; sFileExt:" + sFileExt + "; GlyphType:" + GlyphTypeToString(iGlyphType) + "}");
                }
            }
            return(bGood);
        }        //end SaveSeq
Ejemplo n.º 27
0
		public bool IsLoggedIn(int iTokenX) {
			//sFuncNow="IsLoggedIn("+iTokenX+")";
			string sErrNow="";
			bool bGood=false;
			try {
				if (userarr!=null) {
					if (userarr[iTokenX]!=null) {
						if ((userarr[iTokenX].bitsAttrib & UserAttrib.LoggedIn)!=0) { //call mysql and get logged-in bit of attribute integer
							bGood=true;
						}
					}
					else sErrNow="user array index "+iTokenX.ToString()+" is null"; //TODO:? allow null without error?
				}
				else sErrNow="user array is null";
			}
			catch (Exception exn) { 
				sErrNow="Exception error while accessing user attributes--"+exn.ToString();
			}
			if (sErrNow!="") {
				bGood=false;
				RReporting.ShowErr(sErrNow,"accountant NumOfIndex");
			}
			return bGood;
		}
Ejemplo n.º 28
0
        //public bool FromFrames(byte[][] by2dFrames, long lFrames, int iChannels, int iWidthNow, int iHeightNow) {
        //}
        public bool GotoFrame(long lFrameX)
        {
            //refers to a file if a file is used.\
            bool bGood = true;

            try {
                if (lFramesCached == lFrames)
                {
                    gbFrame   = gbarrAnim[lFrameX];
                    lFrameNow = lFrameX;
                }
                else                                                                                         //if ((sPathFile!=null) && (sPathFile.Length>0)) {
                {
                    RReporting.ShowErr("GotoFrame of non-cached sequence is not available in this version"); //debug NYI
                    //image.SelectActiveFrame(image.FrameDimensionsList[lFrameX], (int)lFrameX);
                    //debug NYI load from file
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "GotoFrame");
                bGood = false;
            }
            return(bGood);
        }        //end GotoFrame
Ejemplo n.º 29
0
        }        //end FromImageValue

        public bool FromImage(string sFile, int iCharWidth, int iCharHeight, int iRows, int iColumns)
        {
            bool  bGood = false;
            RAnim animNormal;

            RReporting.sLastFile = sFile;          //TODO: implement this EVERYWHERE
            try {
                animNormal = new RAnim();
                bGood      = Init();
                if (bGood)
                {
                    bGood = animNormal.SplitFromImage32(sFile, iCharWidth, iCharHeight, iRows, iColumns);
                    //animNormal.SaveSeq("etc/test/0.debug-glyph", "png");
                    //RImage.OverlayToBigNoClipRaw(ref riTarget, ref ipAt, ref animNormal.riFrame.byarrData, iCharWidth, iCharHeight, 4);
                    if (bGood)
                    {
                        Normal     = animNormal;
                        Bold       = Normal.Copy();
                        Italic     = Normal.Copy();
                        BoldItalic = Normal.Copy();
                        //TODO: finish modifying the Glyph Types -- italics using image manip
                    }
                    //else RReporting.ShowErr("RFont failed to split image","","RFont FromImage");//already shown by anim
                    //ShowAsciiTable();
                    //Console.Error.WriteLine("Normal.ToString(true):"+Normal.ToString(true));
                }
                else
                {
                    RReporting.ShowErr("Couldn't initialize font glyph graphics buffer", "initializing font graphics", "RFont FromImage");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "initializing font graphics", "RFont FromImage");
            }
            return(bGood);
        }        //end FromImage
Ejemplo n.º 30
0
        public bool NeedsToBreakBeforeWordBreaker(string sText, int iCursor, int xPixel, IRect rectDest, int iGlyphType)
        {
            bool bReturn = false;

            try {
                if (rectDest != null)
                {
                    if (sText != null && iCursor >= 0 && iCursor < sText.Length)
                    {
                        int zone_Right = rectDest.X + rectDest.Width;
                        while (!RString.IsWordBreaker(sText[iCursor]))                           //while (!RString.IsSpacing(sText[iCursor])) {
                        {
                            xPixel += WidthOf(sText[iCursor], iGlyphType);
                            if (xPixel >= zone_Right)
                            {
                                bReturn = true;
                                break;
                            }
                            iCursor++;
                        }
                    }
                }
                else
                {
                    RReporting.ShowErr("Cannot check line breaking using null rect.", "", "NeedsToBreakBeforeWordBreaker");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "checking for line break", String.Format("NeedsToBreakBeforeWordBreaker {{{0}{1}{2}rectDest:{3}}}",
                                                                                 RReporting.DebugStyle("sText", sText, false, true),
                                                                                 RReporting.DebugStyle("iCursor", iCursor, true),
                                                                                 RReporting.DebugStyle("xPixel", xPixel, true),
                                                                                 IRect.ToString(rectDest)));
            }
            return(bReturn);
        }