Example #1
0
 public void CloseAll(SaveChangesCallback <TControl> callback, SaveAsCallback <TControl> saveAs)
 {
     while (this._documents.Count > 0)
     {
         //Get Confirmation to save/discard changes - allows application to cancel close
         Document <TControl> doc = this._documents[0];
         if (!this.Close(doc, callback, saveAs))
         {
             return;
         }
         this._documents.RemoveAt(0);
     }
 }
        /// <summary>
        /// Closes all documents
        /// </summary>
        /// <param name="saveChanges">Save Changes callback</param>
        /// <param name="saveAs">Save As callback</param>
        /// <returns>True if all documents are closed, false otherwise.  May be false if the application cancels one/more of the close operations</returns>
        public bool CloseAll(SaveChangesCallback <TControl> saveChanges, SaveAsCallback <TControl> saveAs)
        {
            int i = 0;

            while (i < this._documents.Count)
            {
                //Get Confirmation to save/discard changes - allows application to cancel close
                if (!this.Close(i, saveChanges, saveAs))
                {
                    //If the document was not closed increment the counter
                    //Otherwise we will be stuck trying to close the same document forever
                    i++;
                }
            }
            return(this._documents.Count == 0);
        }
Example #3
0
 public bool Close(SaveChangesCallback <TControl> callback, SaveAsCallback <TControl> saveAs)
 {
     if (this._documents.Count > 0)
     {
         if (!this.Close(this.ActiveDocument, callback, saveAs))
         {
             return(false);
         }
         this._documents.RemoveAt(this._current);
         this.CorrectIndex();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #4
0
 public void SaveAll(SaveAsCallback <TControl> saveAs)
 {
     foreach (Document <TControl> doc in this._documents)
     {
         if (doc.Filename != null && !doc.Filename.Equals(String.Empty))
         {
             doc.Save();
         }
         else
         {
             String filename = saveAs(doc);
             if (filename != null && !filename.Equals(String.Empty))
             {
                 doc.SaveAs(filename);
             }
         }
     }
 }
Example #5
0
 public bool Close(int index, SaveChangesCallback <TControl> callback, SaveAsCallback <TControl> saveAs)
 {
     if (index >= 0 && index < this._documents.Count)
     {
         Document <TControl> doc = this._documents[index];
         if (!this.Close(doc, callback, saveAs))
         {
             return(false);
         }
         this._documents.RemoveAt(index);
         this.CorrectIndex();
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #6
0
        private bool Close(Document <TControl> doc, SaveChangesCallback <TControl> callback, SaveAsCallback <TControl> saveAs)
        {
            //Get Confirmation to save/discard changes - allows application to cancel close
            if (doc.HasChanged)
            {
                switch (callback(doc))
                {
                case SaveChangesMode.Cancel:
                    return(false);

                case SaveChangesMode.Discard:
                    //Do nothing
                    return(true);

                case SaveChangesMode.Save:
                    if (doc.Filename != null && !doc.Filename.Equals(String.Empty))
                    {
                        doc.Save();
                    }
                    else
                    {
                        String filename = saveAs(doc);
                        if (filename != null && !filename.Equals(String.Empty))
                        {
                            doc.SaveAs(filename);
                        }
                    }
                    return(true);

                default:
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }