次の方法で共有


Document.Saved プロパティ

更新 : 2007 年 11 月

オブジェクトが最後に保存または開かれてから変更されていない場合は、true を返します。

名前空間 :  EnvDTE
アセンブリ :  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Property Saved As Boolean
'使用
Dim instance As Document
Dim value As Boolean

value = instance.Saved

instance.Saved = value
bool Saved { get; set; }
property bool Saved {
    bool get ();
    void set (bool value);
}
function get Saved () : boolean
function set Saved (value : boolean)

プロパティ値

型 : System.Boolean

オブジェクトが最後に保存されたときまたは開かれたときから変更されていない場合は true (既定値) を示し、それ以外の場合は false を示すブール値。

解説

Saved プロパティは Visual Studio バージョン 6.0 の IsDirty に代わるプロパティですが、IsDirty とは反対の値を返します。

public void CodeExample(DTE2 dte, AddIn addin)
{   
    try
    {   // Before running, create two text files named "TextFile1.txt"
        // and "TextFile2.txt", include them in your solution,
        // and then open them. Notice changes when code executes.
        Document doc, doc2;
        string msg = "";
        string msg2 = "";
        if (dte.Documents.Count > 0)
        {
            doc = dte.Documents.Item("TextFile1.txt");
            // Find specified text.
            if (doc.MarkText("text to find", 0))
            {
                msg += "(1) The text was found!\n"; //MessageBox.Show("The text was found");
                // Delete the bookmark created by MarkText.
                doc.ClearBookmarks();
            }
            if (doc.ReplaceText("text to find", "was replaced by this", 0))
                msg += "(2) It [was replaced by this].\n";
            if (doc.Undo())
                msg += "(3) The ReplaceText method has been undone.\n";
            if (doc.Redo())
                msg += "(4) The ReplaceText method had been redone.\n";
            // This will bring the other document to the foreground.
            doc2 = doc.Collection.Item("TextFile2.txt");
            doc2.Activate();
            // Have these documents been saved?
            foreach (Document dc in dte.Documents)
            {
                if (dc.Saved) msg += dc.Name + " has been saved.\n";
            }
            MessageBox.Show(msg, "Example Output");
            // Access the application object.
            msg2 += doc2.DTE.Name + " is the application object.\n";
            // Show the Guid for the document.
            msg2 += doc2.Kind + " is the Guid for this document.\n";
            // Show the language used to author the code.
            msg2 += doc2.Language + " is the language used in this document.\n";
            // Show the document's name.
            msg2 += doc2.Name + " is the name of this document.\n";
            // Get the projectitem associated with this document.
            msg2 += doc2.ProjectItem.Name + " is the ProjectItem associated with this document.\n";
            // Show the document type.
            msg2 += doc2.Type + " is the type of document.\n";
            foreach (Window win in doc2.Windows)
            {
                msg2 += win.Caption + " is a window.\n";
            }
            MessageBox.Show(msg2, "Example Output");
        }
        else MessageBox.Show("Sample not setup properly.");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

Document インターフェイス

Document メンバ

EnvDTE 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する