コード例 #1
0
        public ImageItemList Copy()
        {
            ImageItemList newList = new ImageItemList(Count);

            newList._imageItemCollection = new ArrayList(_imageItemCollection);

            return(newList);
        }
コード例 #2
0
 private void Init(string fileName, string name)
 {
     _imageItemCollection = new ImageItemList(13);
     SetPathAndFilename(fileName);
     _name   = name;
     _id     = Guid.NewGuid();
     _appLog = new AppLog();
 }
コード例 #3
0
        public ScriptFile(ScriptFile origSF, string newFileName)
        {
            // create a new filename
            string name = newFileName.Remove(newFileName.LastIndexOf("."), newFileName.Length - newFileName.LastIndexOf("."));

            string[] nameparts = name.Split("\\".ToCharArray());
            Init(newFileName, nameparts[nameparts.GetUpperBound(0)]);

            // copy the original members
            _imageItemCollection = origSF.ImageItemCollection.Copy();
        }
コード例 #4
0
        // todo: implement AND / OR logic and multiple keywords
        public ImageItemList SearchKeywords(List <string> keywords)
        {
            ImageItemList resultList = new ImageItemList();

            foreach (ImageItem ii in _imageItemCollection)
            {
                if (ii.KeywordList.Contains(keywords[0]))
                {
                    //resultList.AddImageItem(ii);
                    resultList._imageItemCollection.Add(ii);
                }
            }

            return(resultList);
        }
コード例 #5
0
        public bool Load(bool readKeywords, ProgressChangedEventHandler updateProgress)
        {
            FileStream fs = new FileStream(PathAndFileName, FileMode.Open, FileAccess.Read);

            try
            {
                using (fs)
                {
                    BinaryReader br = new BinaryReader(fs);

                    using (br)
                    {
                        string header = br.ReadString();
                        _name = br.ReadString();

                        _imageItemCollection = new ImageItemList();

                        while (br.BaseStream.Position < br.BaseStream.Length)
                        {
                            ImageItem ii = new ImageItem();
                            //_appLog.LogWarning("loading new image", null, "ScriptFile", "Load()");
                            ii.Deserialize(br, readKeywords);
                            _imageItemCollection.AddImageItem(ii);
                            if (updateProgress != null)
                            {
                                updateProgress((int)((float)br.BaseStream.Position / (float)br.BaseStream.Length * 100));
                            }
                        }

                        br.Close();
                    }

                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                _appLog.LogError("failed to load script file", ex, "ScriptFile", "Load");
                return(false);
            }

            return(true);
        }