Example #1
0
        public void SaveMruList()
        {
            if (Loaded)
            {
                Settings.CurrentUser.SetInt32(PdnSettings.MruMax, MaxCount);
                MostRecentFile[] mrfArray = GetFileList();

                for (int i = 0; i < MaxCount; ++i)
                {
                    string mruName      = "MRU" + i.ToString();
                    string mruThumbName = mruName + "Thumb";

                    if (i >= mrfArray.Length)
                    {
                        Settings.CurrentUser.Delete(mruName);
                        Settings.CurrentUser.Delete(mruThumbName);
                    }
                    else
                    {
                        MostRecentFile mrf = mrfArray[i];
                        Settings.CurrentUser.SetString(mruName, mrf.FileName);
                        Settings.CurrentUser.SetImage(mruThumbName, mrf.Thumb);
                    }
                }
            }
        }
Example #2
0
        public MostRecentFile[] GetFileList()
        {
            if (!Loaded)
            {
                LoadMruList();
            }

            object[]         array    = files.ToArray();
            MostRecentFile[] mrfArray = new MostRecentFile[array.Length];
            array.CopyTo(mrfArray, 0);
            return(mrfArray);
        }
Example #3
0
        public MostRecentFile[] GetFileList()
        {
            if (!Loaded)
            {
                LoadMruList();
            }

            object[] array = files.ToArray();
            MostRecentFile[] mrfArray = new MostRecentFile[array.Length];
            array.CopyTo(mrfArray, 0);
            return mrfArray;
        }
Example #4
0
        public void Add(MostRecentFile mrf)
        {
            if (!Loaded)
            {
                LoadMruList();
            }

            if (!Contains(mrf.FileName))
            {
                files.Enqueue(mrf);

                while (files.Count > maxCount)
                {
                    files.Dequeue();
                }
            }
        }
Example #5
0
        public void LoadMruList()
        {
            try
            {
                this.loaded = true;
                Clear();

                for (int i = 0; i < MaxCount; ++i)
                {
                    try
                    {
                        string mruName  = "MRU" + i.ToString();
                        string fileName = (string)Settings.CurrentUser.GetString(mruName);

                        if (fileName != null)
                        {
                            Image thumb = Settings.CurrentUser.GetImage(mruName + "Thumb");

                            if (fileName != null && thumb != null)
                            {
                                MostRecentFile mrf = new MostRecentFile(fileName, thumb);
                                Add(mrf);
                            }
                        }
                    }

                    catch
                    {
                        break;
                    }
                }
            }

            catch (Exception ex)
            {
                Tracing.Ping("Exception when loading MRU list: " + ex.ToString());
                Clear();
            }
        }
Example #6
0
        /// <summary>
        /// Takes the current Document from this DocumentWorkspace instance and adds it to the MRU list.
        /// </summary>
        /// <param name="fileName"></param>
        public void AddToMruList()
        {
            using (new PushNullToolMode(this))
            {
                string fullFileName = Path.GetFullPath(this.FilePath);
                int edgeLength = AppWorkspace.MostRecentFiles.IconSize;
                Surface thumb1 = RenderThumbnail(edgeLength, true, true);

                // Put it inside a square bitmap
                Surface thumb = new Surface(4 + edgeLength, 4 + edgeLength);

                thumb.Clear(ColorBgra.Transparent);

                Rectangle dstRect = new Rectangle((thumb.Width - thumb1.Width) / 2,
                    (thumb.Height - thumb1.Height) / 2, thumb1.Width, thumb1.Height);

                thumb.CopySurface(thumb1, dstRect.Location);

                using (RenderArgs ra = new RenderArgs(thumb))
                {
                    // Draw black border
                    Rectangle borderRect = new Rectangle(dstRect.Left - 1, dstRect.Top - 1, dstRect.Width + 2, dstRect.Height + 2);
                    --borderRect.Width;
                    --borderRect.Height;
                    ra.Graphics.DrawRectangle(Pens.Black, borderRect);

                    Rectangle shadowRect = Rectangle.Inflate(borderRect, 1, 1);
                    ++shadowRect.Width;
                    ++shadowRect.Height;
                    Utility.DrawDropShadow1px(ra.Graphics, shadowRect);

                    thumb1.Dispose();
                    thumb1 = null;

                    MostRecentFile mrf = new MostRecentFile(fullFileName, Utility.FullCloneBitmap(ra.Bitmap));

                    if (AppWorkspace.MostRecentFiles.Contains(fullFileName))
                    {
                        AppWorkspace.MostRecentFiles.Remove(fullFileName);
                    }

                    AppWorkspace.MostRecentFiles.Add(mrf);
                    AppWorkspace.MostRecentFiles.SaveMruList();
                }
            }
        }
Example #7
0
        public void Add(MostRecentFile mrf)
        {
            if (!Loaded)
            {
                LoadMruList();
            }

            if (!Contains(mrf.FileName))
            {
                files.Enqueue(mrf);

                while (files.Count > maxCount)
                {
                    files.Dequeue();
                }
            }
        }
Example #8
0
        public void LoadMruList()
        {
            try
            {
                this.loaded = true;
                Clear();

                for (int i = 0; i < MaxCount; ++i)
                {
                    try
                    {
                        string mruName = "MRU" + i.ToString();
                        string fileName = (string)Settings.CurrentUser.GetString(mruName);

                        if (fileName != null)
                        {
                            Image thumb = Settings.CurrentUser.GetImage(mruName + "Thumb");

                            if (fileName != null && thumb != null)
                            {
                                MostRecentFile mrf = new MostRecentFile(fileName, thumb);
                                Add(mrf);
                            }
                        }
                    }

                    catch
                    {
                        break;
                    }
                }
            }

            catch (Exception ex)
            {
                Tracing.Ping("Exception when loading MRU list: " + ex.ToString());
                Clear();
            }
        }