OSDN Git Service

メインウィンドウの閉じるボタンを押したときに本当に終了するか確認する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 16 Jun 2017 21:37:53 +0000 (06:37 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Tue, 20 Jun 2017 18:09:18 +0000 (03:09 +0900)
KancolleSniffer/ConfirmDialog.Designer.cs [new file with mode: 0644]
KancolleSniffer/ConfirmDialog.cs [new file with mode: 0644]
KancolleSniffer/ConfirmDialog.resx [new file with mode: 0644]
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/MainForm.cs

diff --git a/KancolleSniffer/ConfirmDialog.Designer.cs b/KancolleSniffer/ConfirmDialog.Designer.cs
new file mode 100644 (file)
index 0000000..a8c2e69
--- /dev/null
@@ -0,0 +1,107 @@
+// Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//    http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+namespace KancolleSniffer\r
+{\r
+    partial class ConfirmDialog\r
+    {\r
+        /// <summary>\r
+        /// Required designer variable.\r
+        /// </summary>\r
+        private System.ComponentModel.IContainer components = null;\r
+\r
+        /// <summary>\r
+        /// Clean up any resources being used.\r
+        /// </summary>\r
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>\r
+        protected override void Dispose(bool disposing)\r
+        {\r
+            if (disposing && (components != null))\r
+            {\r
+                components.Dispose();\r
+            }\r
+            base.Dispose(disposing);\r
+        }\r
+\r
+        #region Windows Form Designer generated code\r
+\r
+        /// <summary>\r
+        /// Required method for Designer support - do not modify\r
+        /// the contents of this method with the code editor.\r
+        /// </summary>\r
+        private void InitializeComponent()\r
+        {\r
+            this.label1 = new System.Windows.Forms.Label();\r
+            this.buttonYes = new System.Windows.Forms.Button();\r
+            this.buttonNo = new System.Windows.Forms.Button();\r
+            this.SuspendLayout();\r
+            // \r
+            // label1\r
+            // \r
+            this.label1.AutoSize = true;\r
+            this.label1.Font = new System.Drawing.Font("MS UI Gothic", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));\r
+            this.label1.Location = new System.Drawing.Point(12, 28);\r
+            this.label1.Name = "label1";\r
+            this.label1.Size = new System.Drawing.Size(183, 13);\r
+            this.label1.TabIndex = 0;\r
+            this.label1.Text = "KancolleSnifferを終了しますか?";\r
+            // \r
+            // buttonYes\r
+            // \r
+            this.buttonYes.DialogResult = System.Windows.Forms.DialogResult.Yes;\r
+            this.buttonYes.Location = new System.Drawing.Point(39, 68);\r
+            this.buttonYes.Name = "buttonYes";\r
+            this.buttonYes.Size = new System.Drawing.Size(75, 23);\r
+            this.buttonYes.TabIndex = 1;\r
+            this.buttonYes.Text = "はい";\r
+            this.buttonYes.UseVisualStyleBackColor = true;\r
+            // \r
+            // buttonNo\r
+            // \r
+            this.buttonNo.DialogResult = System.Windows.Forms.DialogResult.No;\r
+            this.buttonNo.Location = new System.Drawing.Point(120, 68);\r
+            this.buttonNo.Name = "buttonNo";\r
+            this.buttonNo.Size = new System.Drawing.Size(75, 23);\r
+            this.buttonNo.TabIndex = 2;\r
+            this.buttonNo.Text = "いいえ";\r
+            this.buttonNo.UseVisualStyleBackColor = true;\r
+            // \r
+            // ConfirmDialog\r
+            // \r
+            this.AcceptButton = this.buttonYes;\r
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
+            this.CancelButton = this.buttonNo;\r
+            this.ClientSize = new System.Drawing.Size(207, 103);\r
+            this.Controls.Add(this.buttonNo);\r
+            this.Controls.Add(this.buttonYes);\r
+            this.Controls.Add(this.label1);\r
+            this.MaximizeBox = false;\r
+            this.MinimizeBox = false;\r
+            this.Name = "ConfirmDialog";\r
+            this.ShowIcon = false;\r
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;\r
+            this.Text = "確認";\r
+            this.ResumeLayout(false);\r
+            this.PerformLayout();\r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        private System.Windows.Forms.Label label1;\r
+        private System.Windows.Forms.Button buttonYes;\r
+        private System.Windows.Forms.Button buttonNo;\r
+    }\r
+}
\ No newline at end of file
diff --git a/KancolleSniffer/ConfirmDialog.cs b/KancolleSniffer/ConfirmDialog.cs
new file mode 100644 (file)
index 0000000..d83c91a
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//    http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+using System.Windows.Forms;\r
+\r
+namespace KancolleSniffer\r
+{\r
+    public partial class ConfirmDialog : Form\r
+    {\r
+        public ConfirmDialog()\r
+        {\r
+            InitializeComponent();\r
+        }\r
+    }\r
+}\r
diff --git a/KancolleSniffer/ConfirmDialog.resx b/KancolleSniffer/ConfirmDialog.resx
new file mode 100644 (file)
index 0000000..29dcb1b
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<root>\r
+  <!-- \r
+    Microsoft ResX Schema \r
+    \r
+    Version 2.0\r
+    \r
+    The primary goals of this format is to allow a simple XML format \r
+    that is mostly human readable. The generation and parsing of the \r
+    various data types are done through the TypeConverter classes \r
+    associated with the data types.\r
+    \r
+    Example:\r
+    \r
+    ... ado.net/XML headers & schema ...\r
+    <resheader name="resmimetype">text/microsoft-resx</resheader>\r
+    <resheader name="version">2.0</resheader>\r
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\r
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\r
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>\r
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>\r
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">\r
+        <value>[base64 mime encoded serialized .NET Framework object]</value>\r
+    </data>\r
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">\r
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\r
+        <comment>This is a comment</comment>\r
+    </data>\r
+                \r
+    There are any number of "resheader" rows that contain simple \r
+    name/value pairs.\r
+    \r
+    Each data row contains a name, and value. The row also contains a \r
+    type or mimetype. Type corresponds to a .NET class that support \r
+    text/value conversion through the TypeConverter architecture. \r
+    Classes that don't support this are serialized and stored with the \r
+    mimetype set.\r
+    \r
+    The mimetype is used for serialized objects, and tells the \r
+    ResXResourceReader how to depersist the object. This is currently not \r
+    extensible. For a given mimetype the value must be set accordingly:\r
+    \r
+    Note - application/x-microsoft.net.object.binary.base64 is the format \r
+    that the ResXResourceWriter will generate, however the reader can \r
+    read any of the formats listed below.\r
+    \r
+    mimetype: application/x-microsoft.net.object.binary.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\r
+            : and then encoded with base64 encoding.\r
+    \r
+    mimetype: application/x-microsoft.net.object.soap.base64\r
+    value   : The object must be serialized with \r
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\r
+            : and then encoded with base64 encoding.\r
+\r
+    mimetype: application/x-microsoft.net.object.bytearray.base64\r
+    value   : The object must be serialized into a byte array \r
+            : using a System.ComponentModel.TypeConverter\r
+            : and then encoded with base64 encoding.\r
+    -->\r
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">\r
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />\r
+    <xsd:element name="root" msdata:IsDataSet="true">\r
+      <xsd:complexType>\r
+        <xsd:choice maxOccurs="unbounded">\r
+          <xsd:element name="metadata">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" use="required" type="xsd:string" />\r
+              <xsd:attribute name="type" type="xsd:string" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="assembly">\r
+            <xsd:complexType>\r
+              <xsd:attribute name="alias" type="xsd:string" />\r
+              <xsd:attribute name="name" type="xsd:string" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="data">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />\r
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />\r
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />\r
+              <xsd:attribute ref="xml:space" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+          <xsd:element name="resheader">\r
+            <xsd:complexType>\r
+              <xsd:sequence>\r
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />\r
+              </xsd:sequence>\r
+              <xsd:attribute name="name" type="xsd:string" use="required" />\r
+            </xsd:complexType>\r
+          </xsd:element>\r
+        </xsd:choice>\r
+      </xsd:complexType>\r
+    </xsd:element>\r
+  </xsd:schema>\r
+  <resheader name="resmimetype">\r
+    <value>text/microsoft-resx</value>\r
+  </resheader>\r
+  <resheader name="version">\r
+    <value>2.0</value>\r
+  </resheader>\r
+  <resheader name="reader">\r
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+  <resheader name="writer">\r
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
+  </resheader>\r
+</root>
\ No newline at end of file
index ee6c1dd..a6b8941 100644 (file)
     <Compile Include="ConfigDialog.Designer.cs">\r
       <DependentUpon>ConfigDialog.cs</DependentUpon>\r
     </Compile>\r
+    <Compile Include="ConfirmDialog.cs">\r
+      <SubType>Form</SubType>\r
+    </Compile>\r
+    <Compile Include="ConfirmDialog.Designer.cs">\r
+      <DependentUpon>ConfirmDialog.cs</DependentUpon>\r
+    </Compile>\r
     <Compile Include="CUDColor.cs" />\r
     <Compile Include="DockInfo.cs" />\r
     <Compile Include="FleetPanel.cs">\r
     <EmbeddedResource Include="ConfigDialog.resx">\r
       <DependentUpon>ConfigDialog.cs</DependentUpon>\r
     </EmbeddedResource>\r
+    <EmbeddedResource Include="ConfirmDialog.resx">\r
+      <DependentUpon>ConfirmDialog.cs</DependentUpon>\r
+    </EmbeddedResource>\r
     <EmbeddedResource Include="ErrorDialog.resx">\r
       <DependentUpon>ErrorDialog.cs</DependentUpon>\r
     </EmbeddedResource>\r
index ae4e3ca..608cd58 100644 (file)
@@ -197,6 +197,14 @@ namespace KancolleSniffer
 \r
         private void MainForm_FormClosing(object sender, FormClosingEventArgs e)\r
         {\r
+            using (var dialog = new ConfirmDialog())\r
+            {\r
+                if (dialog.ShowDialog(this) != DialogResult.Yes)\r
+                {\r
+                    e.Cancel = true;\r
+                    return;\r
+                }\r
+            }\r
             e.Cancel = false;\r
             _sniffer.FlashLog();\r
             _config.Location = (WindowState == FormWindowState.Normal ? Bounds : RestoreBounds).Location;\r