public ImageItem(String fileName) { Init(); SetPathAndFilename(fileName); try { tf = new ThumbnailFile(this.GetThumbnailPathAndFileName()); //_imageObj = Image.FromFile(fileName); } catch (Exception ex) { _appLog.LogError("failed to get thumbnail file or image file", ex, "ImageItem", "Constructor"); } }
protected ImageItem(SerializationInfo info, StreamingContext context) { _includeFlag = (IncludeFlags)info.GetInt32("IncludeFlag"); _fileName = info.GetString("FileName"); _filePath = info.GetString("FilePath"); _stretchType = (StretchTypes)info.GetInt32("StretchType"); _textDisplayFlag = (ThreeWayFlags)info.GetInt32("TextDisplayFlag"); _recursiveDirFlag = info.GetBoolean("RecursiveDirFlag"); _offset = (Point)info.GetValue("Offset", typeof(Point)); _scaleFactor = (float)info.GetDouble("ScaleFactor"); _keywordList = (ArrayList)info.GetValue("KeywordList", typeof(ArrayList)); // ?? _previewScaleFactor = (float) info.GetDouble("PreviewScaleFactor"); SetPathAndFilename(_filePath + _fileName); _appLog = new TSOP.AppLog(); try { tf = new ThumbnailFile(this.GetThumbnailPathAndFileName()); //_imageObj = Image.FromFile(PathAndFileName); } catch (Exception ex) { _appLog.LogError("failed to deserialize image item", ex, "ImageItem", "Constructor"); } }
private void _slideTimer_Tick(object sender, System.EventArgs e) { int i = DateTime.Now.Second % 4; try { if (_processor != null) { CleanupImageMemory(); _currentImage = _processor.GetNextImage(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); TSOP.AppLog appLog = new TSOP.AppLog(); appLog.LogError("failed to get next image", ex, "ScreenSaverForm", "_slideTimer_Tick"); } Refresh(); }
public bool Load() { StreamReader sr = null; if (!File.Exists(_fileName)) { return(false); } try { sr = new StreamReader(_fileName); using (sr) { BinaryReader br = new BinaryReader(sr.BaseStream); // read the file _type = br.ReadBytes(4); _blank = br.ReadBytes(131); byte[] keywordBytes = br.ReadBytes(127); byte flags = br.ReadByte(); short offX = br.ReadInt16(); if (Math.Abs(offX) < Utilities.MaxOffset) { _offsetX = offX; } else { _offsetX = 0; } short offY = br.ReadInt16(); if (Math.Abs(offY) < Utilities.MaxOffset) { _offsetY = offY; } else { _offsetY = 0; } float sf = br.ReadSingle(); // note: this may be read as 0.0 if (sf > 0.0f && sf <= Utilities.MaxScaleFactor) { _scaleFactor = sf; } else { _scaleFactor = 1.0f; } //_theRest = br.ReadBytes((int)(br.BaseStream.Length - (long) br.BaseStream.Position)); // convert the keyword string ASCIIEncoding ascii = new ASCIIEncoding(); _keywordString = ascii.GetString(keywordBytes); _keywordString = _keywordString.TrimEnd(new char[] { '\0' }); // set the flags if ((flags & (int)FlagConstants.Stretch) != 0) { _stretchFlag = true; } if ((flags & (int)FlagConstants.KAR) != 0) { _karFlag = true; } if ((flags & (int)FlagConstants.Text) != 0) { _textFlag = true; } if ((flags & (int)FlagConstants.NoStretch) != 0) { _noStretchFlag = true; } if ((flags & (int)FlagConstants.NoKAR) != 0) { _noKARFlag = true; } if ((flags & (int)FlagConstants.NoText) != 0) { _noTextFlag = true; } } } catch (Exception ex) { Debug.WriteLine(ex.Message); _appLog.LogError("failed to load thumbnail file", ex, "ThumbnailFile", "Load"); return(false); } finally { if (sr != null) { sr.Close(); } } return(true); }